|
|
|
@ -4,7 +4,7 @@ const clone = require('clone') |
|
|
|
|
const ObservableStore = require('obs-store') |
|
|
|
|
const ethUtil = require('ethereumjs-util') |
|
|
|
|
const EthQuery = require('ethjs-query') |
|
|
|
|
const TxProviderUtil = require('../lib/tx-utils') |
|
|
|
|
const TxProviderUtils = require('../lib/tx-utils') |
|
|
|
|
const PendingTransactionWatchers = require('../lib/pending-tx-watchers') |
|
|
|
|
const createId = require('../lib/random-id') |
|
|
|
|
const NonceTracker = require('../lib/nonce-tracker') |
|
|
|
@ -35,9 +35,9 @@ module.exports = class TransactionController extends EventEmitter { |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
this.query = new EthQuery(this.provider) |
|
|
|
|
this.txProviderUtils = new TxProviderUtil(this.provider) |
|
|
|
|
this.txProviderUtils = new TxProviderUtils(this.provider) |
|
|
|
|
|
|
|
|
|
this.pendingTxWatcher = new PendingTransactionWatchers({ |
|
|
|
|
this.pendingTxWatchers = new PendingTransactionWatchers({ |
|
|
|
|
provider: this.provider, |
|
|
|
|
nonceTracker: this.nonceTracker, |
|
|
|
|
getBalance: (address) => this.ethStore.getState().accounts[address].balance, |
|
|
|
@ -50,16 +50,16 @@ module.exports = class TransactionController extends EventEmitter { |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.pendingTxWatcher.on('txWarning', this.updateTx.bind(this)) |
|
|
|
|
this.pendingTxWatcher.on('txFailed', this.setTxStatusFailed.bind(this)) |
|
|
|
|
this.pendingTxWatcher.on('txConfirmed', this.setTxStatusConfirmed.bind(this)) |
|
|
|
|
this.pendingTxWatchers.on('txWarning', this.updateTx.bind(this)) |
|
|
|
|
this.pendingTxWatchers.on('txFailed', this.setTxStatusFailed.bind(this)) |
|
|
|
|
this.pendingTxWatchers.on('txConfirmed', this.setTxStatusConfirmed.bind(this)) |
|
|
|
|
|
|
|
|
|
this.blockTracker.on('rawBlock', this.pendingTxWatcher.checkForTxInBlock.bind(this)) |
|
|
|
|
this.blockTracker.on('rawBlock', this.pendingTxWatchers.checkForTxInBlock.bind(this)) |
|
|
|
|
// this is a little messy but until ethstore has been either
|
|
|
|
|
// removed or redone this is to guard against the race condition
|
|
|
|
|
// where ethStore hasent been populated by the results yet
|
|
|
|
|
this.blockTracker.once('latest', () => this.blockTracker.on('latest', this.pendingTxWatcher.resubmitPendingTxs.bind(this))) |
|
|
|
|
this.blockTracker.on('sync', this.pendingTxWatcher.queryPendingTxs.bind(this)) |
|
|
|
|
this.blockTracker.once('latest', () => this.blockTracker.on('latest', this.pendingTxWatchers.resubmitPendingTxs.bind(this))) |
|
|
|
|
this.blockTracker.on('sync', this.pendingTxWatchers.queryPendingTxs.bind(this)) |
|
|
|
|
// memstore is computed from a few different stores
|
|
|
|
|
this._updateMemstore() |
|
|
|
|
this.store.subscribe(() => this._updateMemstore()) |
|
|
|
|