diff options
author | Frankie <frankie.diamond@gmail.com> | 2016-07-22 04:41:10 +0800 |
---|---|---|
committer | Dan Finlay <somniac@me.com> | 2016-07-22 04:41:10 +0800 |
commit | fcd523abe4c5e8c4da7f176b2fc15578903384b7 (patch) | |
tree | 9118133325c282d01f49bc717dacabfd824aa762 /app | |
parent | 6658bea8d444281491718f8eee7bc3ae42f91b69 (diff) | |
download | tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.tar tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.tar.gz tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.tar.bz2 tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.tar.lz tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.tar.xz tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.tar.zst tangerine-wallet-browser-fcd523abe4c5e8c4da7f176b2fc15578903384b7.zip |
Buy button (#474)
* WIP: Buy button link
* Add buy eth and the buy eth warning message
* Add css
* Move the opening of coinbase page to background
and send to faucet if on test net
* Create a Warning about storeing eth
* Finish Buy button and Eth store warning screen
* Add to CHANGELOG
* fix frankies deletion and change chrome to extension
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/lib/config-manager.js | 10 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 3 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 28 |
3 files changed, 40 insertions, 1 deletions
diff --git a/app/scripts/lib/config-manager.js b/app/scripts/lib/config-manager.js index caaae8a75..d7df5343b 100644 --- a/app/scripts/lib/config-manager.js +++ b/app/scripts/lib/config-manager.js @@ -270,3 +270,13 @@ ConfigManager.prototype.getConfirmed = function () { return ('isConfirmed' in data) && data.isConfirmed } +ConfigManager.prototype.setShouldntShowWarning = function (confirmed) { + var data = this.getData() + data.isEthConfirmed = confirmed + this.setData(data) +} + +ConfigManager.prototype.getShouldntShowWarning = function () { + var data = this.getData() + return ('isEthConfirmed' in data) && data.isEthConfirmed +} diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index 2c8e9108b..c6ac55a03 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -94,6 +94,7 @@ IdentityStore.prototype.getState = function () { isUnlocked: this._isUnlocked(), seedWords: seedWords, isConfirmed: configManager.getConfirmed(), + isEthConfirmed: configManager.getShouldntShowWarning(), unconfTxs: configManager.unconfirmedTxs(), transactions: configManager.getTxList(), unconfMsgs: messageManager.unconfirmedMsgs(), @@ -199,7 +200,7 @@ IdentityStore.prototype.addUnconfirmedTransaction = function (txParams, onTxDone time: time, status: 'unconfirmed', } - + console.log('addUnconfirmedTransaction:', txData) // keep the onTxDoneCb around for after approval/denial (requires user interaction) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 17af4cc29..4f03ace8f 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -40,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), @@ -56,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), } } @@ -237,6 +240,15 @@ 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) @@ -254,6 +266,22 @@ module.exports = class MetamaskController { this.configManager.useEtherscanProvider() 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 () {} |