1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

controllers - transactions - fix tx confirmation

This commit is contained in:
kumavis 2018-05-29 00:41:28 -07:00
parent 7d449e974d
commit 16d0db15e0
2 changed files with 3 additions and 3 deletions

View File

@ -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

View File

@ -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 = {