diff options
author | Frankie <frankie.pangilinan@consensys.net> | 2016-08-11 04:43:01 +0800 |
---|---|---|
committer | Frankie <frankie.pangilinan@consensys.net> | 2016-08-11 04:43:01 +0800 |
commit | 9c6dd9ef4953f6e421feb6e6684ef43da26f6b75 (patch) | |
tree | 309366cc31236440709705e0a9a9e7eb183801a3 /app | |
parent | 667483ac2037bef5b412ce33f0d9bb0605d6c13b (diff) | |
download | tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.tar tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.tar.gz tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.tar.bz2 tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.tar.lz tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.tar.xz tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.tar.zst tangerine-wallet-browser-9c6dd9ef4953f6e421feb6e6684ef43da26f6b75.zip |
Create "buy form" add shape shift
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/metamask-controller.js | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 63970799d..dd43ac2fc 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -6,6 +6,7 @@ const messageManager = require('./lib/message-manager') const HostStore = require('./lib/remote-store.js').HostStore const Web3 = require('web3') const ConfigManager = require('./lib/config-manager') +const extension = require('./lib/extension') module.exports = class MetamaskController { @@ -39,6 +40,7 @@ module.exports = class MetamaskController { setProviderType: this.setProviderType.bind(this), useEtherscanProvider: this.useEtherscanProvider.bind(this), agreeToDisclaimer: this.agreeToDisclaimer.bind(this), + agreeToEthWarning: this.agreeToEthWarning.bind(this), // forward directly to idStore createNewVault: idStore.createNewVault.bind(idStore), recoverFromSeed: idStore.recoverFromSeed.bind(idStore), @@ -55,6 +57,8 @@ module.exports = class MetamaskController { saveAccountLabel: idStore.saveAccountLabel.bind(idStore), tryPassword: idStore.tryPassword.bind(idStore), recoverSeed: idStore.recoverSeed.bind(idStore), + // coinbase + buyEth: this.buyEth.bind(this), } } @@ -161,6 +165,7 @@ module.exports = class MetamaskController { function configToPublic (state) { return { provider: state.provider, + selectedAddress: state.selectedAccount, } } // dump obj into store @@ -236,23 +241,48 @@ module.exports = class MetamaskController { } } + agreeToEthWarning (cb) { + try { + this.configManager.setShouldntShowWarning(true) + cb() + } catch (e) { + cb(e) + } + } + // called from popup setRpcTarget (rpcTarget) { this.configManager.setRpcTarget(rpcTarget) - chrome.runtime.reload() + extension.runtime.reload() this.idStore.getNetwork() } setProviderType (type) { this.configManager.setProviderType(type) - chrome.runtime.reload() + extension.runtime.reload() this.idStore.getNetwork() } useEtherscanProvider () { this.configManager.useEtherscanProvider() - chrome.runtime.reload() + extension.runtime.reload() } + + buyEth (address, amount) { + if (!amount) amount = '5' + + var network = this.idStore._currentState.network + var url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH` + + if (network === '2') { + url = 'https://testfaucet.metamask.io/' + } + + extension.tabs.create({ + url, + }) + } + } function noop () {} |