Merge pull request #3454 from ethereum/trust_wallet_provider
add trustwallet providerpull/3535/head
commit
ee31bc06b6
@ -1,18 +0,0 @@ |
||||
import * as packageJson from '../../../../../package.json' |
||||
import { InjectedProvider } from './injected-provider' |
||||
|
||||
const profile = { |
||||
name: 'injected', |
||||
displayName: 'Injected Provider', |
||||
kind: 'provider', |
||||
description: 'injected Provider', |
||||
methods: ['sendAsync', 'init'], |
||||
version: packageJson.version |
||||
} |
||||
|
||||
export class BasicInjectedProvider extends InjectedProvider {
|
||||
|
||||
constructor () { |
||||
super(profile) |
||||
} |
||||
} |
@ -0,0 +1,40 @@ |
||||
/* global ethereum */ |
||||
import * as packageJson from '../../../../../package.json' |
||||
import { InjectedProvider } from './injected-provider' |
||||
|
||||
export class InjectedProviderDefaultBase extends InjectedProvider {
|
||||
constructor (profile) { |
||||
super(profile) |
||||
} |
||||
|
||||
async init () {
|
||||
const injectedProvider = this.getInjectedProvider() |
||||
if (injectedProvider && injectedProvider._metamask && injectedProvider._metamask.isUnlocked) { |
||||
if (!await injectedProvider._metamask.isUnlocked()) this.call('notification', 'toast', 'Please make sure the injected provider is unlocked (e.g Metamask).') |
||||
} |
||||
return super.init() |
||||
} |
||||
|
||||
getInjectedProvider () { |
||||
return (window as any).ethereum |
||||
} |
||||
|
||||
notFound () { |
||||
return 'No injected provider found. Make sure your provider (e.g. MetaMask, ...) is active and running (when recently activated you may have to reload the page).' |
||||
} |
||||
} |
||||
|
||||
const profile = { |
||||
name: 'injected', |
||||
displayName: 'Injected Provider', |
||||
kind: 'provider', |
||||
description: 'injected Provider', |
||||
methods: ['sendAsync', 'init'], |
||||
version: packageJson.version |
||||
} |
||||
|
||||
export class InjectedProviderDefault extends InjectedProviderDefaultBase { |
||||
constructor () { |
||||
super(profile) |
||||
} |
||||
} |
@ -0,0 +1,26 @@ |
||||
/* global ethereum */ |
||||
import * as packageJson from '../../../../../package.json' |
||||
import { InjectedProvider } from './injected-provider' |
||||
|
||||
const profile = { |
||||
name: 'injected-trustwallet', |
||||
displayName: 'Trust wallet', |
||||
kind: 'provider', |
||||
description: 'Trust wallet', |
||||
methods: ['sendAsync', 'init'], |
||||
version: packageJson.version |
||||
} |
||||
|
||||
export class InjectedProviderTrustWallet extends InjectedProvider {
|
||||
constructor () { |
||||
super(profile) |
||||
} |
||||
|
||||
getInjectedProvider () { |
||||
return (window as any).trustwallet |
||||
} |
||||
|
||||
notFound () { |
||||
return 'Could not find Trust Wallet provider. Please make sure the Trust Wallet extension is active. Download the latest version from https://trustwallet.com/browser-extension' |
||||
} |
||||
} |
Loading…
Reference in new issue