diff options
author | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-17 02:33:36 +0800 |
---|---|---|
committer | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-22 05:41:32 +0800 |
commit | 6e78494846c9032fbf1264a0225c0df4df0867cb (patch) | |
tree | 0d3b2cdc463d5c8380f4af92ed9ec94fc15d1164 /app/scripts/metamask-controller.js | |
parent | da9349fe63de70d29a13b6c7d94eb40dc5fcb127 (diff) | |
download | tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.tar tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.tar.gz tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.tar.bz2 tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.tar.lz tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.tar.xz tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.tar.zst tangerine-wallet-browser-6e78494846c9032fbf1264a0225c0df4df0867cb.zip |
First pass at revision requests
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 3b70f63db..d5b70c647 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -11,7 +11,6 @@ const extension = require('./lib/extension') const autoFaucet = require('./lib/auto-faucet') const nodeify = require('./lib/nodeify') - module.exports = class MetamaskController { constructor (opts) { @@ -19,12 +18,6 @@ module.exports = class MetamaskController { this.opts = opts this.listeners = [] this.configManager = new ConfigManager(opts) - this.txManager = new TxManager({ - TxListFromStore: this.configManager.getTxList(), - txLimit: this.configManager.txLimit, - setTxList: this.configManager.setTxList.bind(this.configManager), - }) - this.keyringController = new KeyringController({ configManager: this.configManager, txManager: this.txManager, @@ -33,9 +26,17 @@ module.exports = class MetamaskController { this.provider = this.initializeProvider(opts) this.ethStore = new EthStore(this.provider) this.keyringController.setStore(this.ethStore) - this.txManager.setProvider(this.provider) this.getNetwork() this.messageManager = messageManager + this.txManager = new TxManager({ + txList: this.configManager.getTxList(), + txHistoryLimit: 40, + setTxList: this.configManager.setTxList.bind(this.configManager), + getGasMultiplier: this.configManager.getGasMultiplier.bind(this.configManager), + getNetwork: this.getStateNetwork.bind(this), + provider: this.provider, + blockTracker: this.provider, + }) this.publicConfigStore = this.initPublicConfigStore() var currentFiat = this.configManager.getCurrentFiat() || 'USD' @@ -52,7 +53,8 @@ module.exports = class MetamaskController { this.state, this.ethStore.getState(), this.configManager.getConfig(), - this.keyringController.getState() + this.keyringController.getState(), + this.txManager.getState() ) } @@ -85,14 +87,14 @@ module.exports = class MetamaskController { exportAccount: nodeify(keyringController.exportAccount).bind(keyringController), // signing methods - approveTransaction: keyringController.approveTransaction.bind(keyringController), - cancelTransaction: keyringController.cancelTransaction.bind(keyringController), + approveTransaction: txManager.approveTransaction.bind(txManager), + cancelTransaction: txManager.cancelTransaction.bind(txManager), signMessage: keyringController.signMessage.bind(keyringController), cancelMessage: keyringController.cancelMessage.bind(keyringController), // forward directly to txManager - getUnapprovedTxList: txManager.getTxList.bind(txManager), - getFilterdTxList: txManager.getFilterdTxList.bind(txManager), + getUnapprovedTxList: txManager.getUnapprovedTxList.bind(txManager), + getFilteredTxList: txManager.getFilteredTxList.bind(txManager), // coinbase buyEth: this.buyEth.bind(this), // shapeshift @@ -150,7 +152,8 @@ module.exports = class MetamaskController { // tx signing approveTransaction: this.newUnsignedTransaction.bind(this), signTransaction: (...args) => { - keyringController.signTransaction(...args) + var signedTxPromise = keyringController.signTransaction(...args) + this.txManager.resolveSignedTransaction(signedTxPromise) this.sendUpdate() }, @@ -166,7 +169,6 @@ module.exports = class MetamaskController { var web3 = new Web3(provider) this.web3 = web3 keyringController.web3 = web3 - this.txManager.web3 = web3 provider.on('block', this.processBlock.bind(this)) provider.on('error', this.getNetwork.bind(this)) @@ -220,13 +222,13 @@ module.exports = class MetamaskController { } newUnsignedTransaction (txParams, onTxDoneCb) { - const keyringController = this.keyringController + const txManager = this.txManager const err = this.enforceTxValidations(txParams) if (err) return onTxDoneCb(err) - keyringController.addUnconfirmedTransaction(txParams, onTxDoneCb, (err, txData) => { + txManager.addUnapprovedTransaction(txParams, onTxDoneCb, (err, txData) => { if (err) return onTxDoneCb(err) this.sendUpdate() - this.opts.showUnconfirmedTx(txParams, txData, onTxDoneCb) + this.opts.showUnapprovedTx(txParams, txData, onTxDoneCb) }) } |