diff options
author | frankiebee <frankie.diamond@gmail.com> | 2017-05-23 13:56:10 +0800 |
---|---|---|
committer | frankiebee <frankie.diamond@gmail.com> | 2017-05-23 13:56:10 +0800 |
commit | 529304c005318852b60bb93846a58d6eb3da2066 (patch) | |
tree | 2e3b5f29e8fd0b8151d178361dba7aef9c87cabd /app/scripts/controllers/transactions.js | |
parent | e08c1541e5a91d7958b15753982d22066c1a0a7d (diff) | |
download | tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.tar tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.tar.gz tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.tar.bz2 tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.tar.lz tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.tar.xz tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.tar.zst tangerine-wallet-browser-529304c005318852b60bb93846a58d6eb3da2066.zip |
Wrap the provider in a proxy
Diffstat (limited to 'app/scripts/controllers/transactions.js')
-rw-r--r-- | app/scripts/controllers/transactions.js | 27 |
1 files changed, 7 insertions, 20 deletions
diff --git a/app/scripts/controllers/transactions.js b/app/scripts/controllers/transactions.js index cfeeab6e6..b9bea2f1c 100644 --- a/app/scripts/controllers/transactions.js +++ b/app/scripts/controllers/transactions.js @@ -4,7 +4,6 @@ const extend = require('xtend') const Semaphore = require('semaphore') const ObservableStore = require('obs-store') const ethUtil = require('ethereumjs-util') -const EthQuery = require('eth-query') const TxProviderUtil = require('../lib/tx-utils') const createId = require('../lib/random-id') @@ -18,11 +17,13 @@ module.exports = class TransactionManager extends EventEmitter { this.networkStore = opts.networkStore || new ObservableStore({}) this.preferencesStore = opts.preferencesStore || new ObservableStore({}) this.txHistoryLimit = opts.txHistoryLimit - this.setupProviderAndEthQuery({ - provider: opts.provider, - blockTracker: opts.blockTracker, - ethQuery: opts.ethQuery, - }) + this.provider = opts.provider + this.blockTracker = opts.blockTracker + this.query = opts.ethQuery + this.txProviderUtils = new TxProviderUtil(this.query) + this.networkStore.subscribe((_) => this.blockTracker.on('block', this.checkForTxInBlock.bind(this))) + this.blockTracker.on('block', this.checkForTxInBlock.bind(this)) + this.signEthTx = opts.signTransaction this.nonceLock = Semaphore(1) @@ -41,20 +42,6 @@ module.exports = class TransactionManager extends EventEmitter { return this.networkStore.getState().network } - setupProviderAndEthQuery ({provider, blockTracker, ethQuery}) { - if (this.provider) { - delete this.provider - delete this.blockTracker - delete this.query - delete this.txProviderUtils - } - this.provider = provider - this.query = ethQuery - this.txProviderUtils = new TxProviderUtil(ethQuery) - blockTracker ? this.blockTracker = blockTracker : this.blockTracker = provider - this.blockTracker.on('block', this.checkForTxInBlock.bind(this)) - } - getSelectedAddress () { return this.preferencesStore.getState().selectedAddress } |