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:
parent
7d449e974d
commit
16d0db15e0
@ -57,7 +57,6 @@ class TransactionController extends EventEmitter {
|
|||||||
initState: opts.initState,
|
initState: opts.initState,
|
||||||
txHistoryLimit: opts.txHistoryLimit,
|
txHistoryLimit: opts.txHistoryLimit,
|
||||||
getNetwork: this.getNetwork.bind(this),
|
getNetwork: this.getNetwork.bind(this),
|
||||||
confirmTransaction: this.confirmTransaction.bind(this),
|
|
||||||
})
|
})
|
||||||
this._onBootCleanUp()
|
this._onBootCleanUp()
|
||||||
|
|
||||||
@ -389,6 +388,7 @@ class TransactionController extends EventEmitter {
|
|||||||
this.txStateManager.updateTx(txMeta, 'transactions/pending-tx-tracker#event: tx:warning')
|
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:failed', this.txStateManager.setTxStatusFailed.bind(this.txStateManager))
|
||||||
|
this.pendingTxTracker.on('tx:confirmed', (txId) => this.confirmTransaction(txId))
|
||||||
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
|
this.pendingTxTracker.on('tx:block-update', (txMeta, latestBlockNumber) => {
|
||||||
if (!txMeta.firstRetryBlockNumber) {
|
if (!txMeta.firstRetryBlockNumber) {
|
||||||
txMeta.firstRetryBlockNumber = latestBlockNumber
|
txMeta.firstRetryBlockNumber = latestBlockNumber
|
||||||
|
@ -28,7 +28,6 @@ class PendingTransactionTracker extends EventEmitter {
|
|||||||
this.getCompletedTransactions = config.getCompletedTransactions
|
this.getCompletedTransactions = config.getCompletedTransactions
|
||||||
this.publishTransaction = config.publishTransaction
|
this.publishTransaction = config.publishTransaction
|
||||||
this.confirmTransaction = config.confirmTransaction
|
this.confirmTransaction = config.confirmTransaction
|
||||||
this.updatePendingTxs()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,6 +36,7 @@ class PendingTransactionTracker extends EventEmitter {
|
|||||||
async updatePendingTxs () {
|
async updatePendingTxs () {
|
||||||
const pendingTxs = this.getPendingTransactions()
|
const pendingTxs = this.getPendingTransactions()
|
||||||
// in order to keep the nonceTracker accurate we block it while updating pending transactions
|
// 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()
|
const nonceGlobalLock = await this.nonceTracker.getGlobalLock()
|
||||||
try {
|
try {
|
||||||
await Promise.all(pendingTxs.map((txMeta) => this._checkPendingTx(txMeta)))
|
await Promise.all(pendingTxs.map((txMeta) => this._checkPendingTx(txMeta)))
|
||||||
@ -152,7 +152,7 @@ class PendingTransactionTracker extends EventEmitter {
|
|||||||
const txParams = await this.query.getTransactionByHash(txHash)
|
const txParams = await this.query.getTransactionByHash(txHash)
|
||||||
if (!txParams) return
|
if (!txParams) return
|
||||||
if (txParams.blockNumber) {
|
if (txParams.blockNumber) {
|
||||||
this.confirmTransaction(txId)
|
this.emit('tx:confirmed', txId)
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
txMeta.warning = {
|
txMeta.warning = {
|
||||||
|
Loading…
Reference in New Issue
Block a user