diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index f84fd95ff..6266fea16 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -57,7 +57,6 @@ class TransactionController extends EventEmitter { initState: opts.initState, txHistoryLimit: opts.txHistoryLimit, getNetwork: this.getNetwork.bind(this), - confirmTransaction: this.confirmTransaction.bind(this), }) this._onBootCleanUp() @@ -389,6 +388,7 @@ class TransactionController extends EventEmitter { this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:warning') }) this.pendingTxTracker.on('tx:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager)) + this.pendingTxTracker.on('tx:confirmed', (txId) => this.confirmTransaction(txId)) this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => { if (!txMeta.firstRetryBlockNumber) { txMeta.firstRetryBlockNumber = latestBlockNumber diff --git a/app/scripts/controllers/transactions/pending-tx-tracker.js b/app/scripts/controllers/transactions/pending-tx-tracker.js index 68f016d79..9a764b962 100644 --- a/app/scripts/controllers/transactions/pending-tx-tracker.js +++ b/app/scripts/controllers/transactions/pending-tx-tracker.js @@ -28,7 +28,6 @@ class PendingTransactionTracker extends EventEmitter { this.getCompletedTransactions = config.getCompletedTransactions this.publishTransaction = config.publishTransaction this.confirmTransaction = config.confirmTransaction - this.updatePendingTxs() } /** @@ -37,6 +36,7 @@ class PendingTransactionTracker extends EventEmitter { async updatePendingTxs () { const pendingTxs = this.getPendingTransactions() // in order to keep the nonceTracker accurate we block it while updating pending transactions + console.log('updating pending txs....', pendingTxs) const nonceGlobalLock = await this.nonceTracker.getGlobalLock() try { await Promise.all(pendingTxs.map((txMeta) => this._checkPendingTx(txMeta))) @@ -152,7 +152,7 @@ class PendingTransactionTracker extends EventEmitter { const txParams = await this.query.getTransactionByHash(txHash) if (!txParams) return if (txParams.blockNumber) { - this.confirmTransaction(txId) + this.emit('tx:confirmed', txId) } } catch (err) { txMeta.warning = {