diff options
author | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-15 04:55:41 +0800 |
---|---|---|
committer | Frances Pangilinan <frankie.diamond@gmail.com> | 2016-12-15 04:55:41 +0800 |
commit | 090935f90aa3c2589fee7bc038c8f4fcf77da03c (patch) | |
tree | 82a21bd7d0df26d6de637892cbd9322d52b7785b /app/scripts/metamask-controller.js | |
parent | 9e3fa3cfba20299413df87d18158180c7798d2ac (diff) | |
download | tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.tar tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.tar.gz tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.tar.bz2 tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.tar.lz tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.tar.xz tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.tar.zst tangerine-wallet-browser-090935f90aa3c2589fee7bc038c8f4fcf77da03c.zip |
Create a TxManager
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r-- | app/scripts/metamask-controller.js | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index ae761c753..3b70f63db 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3,6 +3,7 @@ const EthStore = require('eth-store') const MetaMaskProvider = require('web3-provider-engine/zero.js') const KeyringController = require('./keyring-controller') const messageManager = require('./lib/message-manager') +const TxManager = require('./transaction-manager') const HostStore = require('./lib/remote-store.js').HostStore const Web3 = require('web3') const ConfigManager = require('./lib/config-manager') @@ -18,13 +19,21 @@ 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, getNetwork: this.getStateNetwork.bind(this), }) 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.publicConfigStore = this.initPublicConfigStore() @@ -49,7 +58,7 @@ module.exports = class MetamaskController { getApi () { const keyringController = this.keyringController - + const txManager = this.txManager return { getState: (cb) => { cb(null, this.getState()) }, setRpcTarget: this.setRpcTarget.bind(this), @@ -81,6 +90,9 @@ module.exports = class MetamaskController { signMessage: keyringController.signMessage.bind(keyringController), cancelMessage: keyringController.cancelMessage.bind(keyringController), + // forward directly to txManager + getUnapprovedTxList: txManager.getTxList.bind(txManager), + getFilterdTxList: txManager.getFilterdTxList.bind(txManager), // coinbase buyEth: this.buyEth.bind(this), // shapeshift @@ -154,7 +166,7 @@ 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)) |