mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
pending-tx - move incrementing of the retryCount on the txMeta outside pending-tx-tracker
This commit is contained in:
parent
b05a6f89cb
commit
0a94ec41d3
@ -75,6 +75,11 @@ module.exports = class TransactionController extends EventEmitter {
|
|||||||
this.pendingTxTracker.on('tx:warning', this.txStateManager.updateTx.bind(this.txStateManager))
|
this.pendingTxTracker.on('tx:warning', this.txStateManager.updateTx.bind(this.txStateManager))
|
||||||
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', this.txStateManager.setTxStatusConfirmed.bind(this.txStateManager))
|
this.pendingTxTracker.on('tx:confirmed', this.txStateManager.setTxStatusConfirmed.bind(this.txStateManager))
|
||||||
|
this.pendingTxTracker.on('tx:retry', (txMeta) => {
|
||||||
|
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
|
||||||
|
txMeta.retryCount++
|
||||||
|
this.txStateManager.updateTx(txMeta)
|
||||||
|
})
|
||||||
|
|
||||||
this.blockTracker.on('rawBlock', this.pendingTxTracker.checkForTxInBlock.bind(this.pendingTxTracker))
|
this.blockTracker.on('rawBlock', this.pendingTxTracker.checkForTxInBlock.bind(this.pendingTxTracker))
|
||||||
// this is a little messy but until ethstore has been either
|
// this is a little messy but until ethstore has been either
|
||||||
|
@ -102,7 +102,6 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
|||||||
const address = txMeta.txParams.from
|
const address = txMeta.txParams.from
|
||||||
const balance = this.getBalance(address)
|
const balance = this.getBalance(address)
|
||||||
if (balance === undefined) return
|
if (balance === undefined) return
|
||||||
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
|
|
||||||
|
|
||||||
if (txMeta.retryCount > this.retryLimit) {
|
if (txMeta.retryCount > this.retryLimit) {
|
||||||
const err = new Error(`Gave up submitting after ${this.retryLimit} blocks un-mined.`)
|
const err = new Error(`Gave up submitting after ${this.retryLimit} blocks un-mined.`)
|
||||||
@ -124,7 +123,7 @@ module.exports = class PendingTransactionTracker extends EventEmitter {
|
|||||||
const txHash = await this.publishTransaction(rawTx)
|
const txHash = await this.publishTransaction(rawTx)
|
||||||
|
|
||||||
// Increment successful tries:
|
// Increment successful tries:
|
||||||
txMeta.retryCount++
|
this.emit('tx:retry', txMeta)
|
||||||
return txHash
|
return txHash
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ describe('Transaction Controller', function () {
|
|||||||
networkStore: new ObservableStore(currentNetworkId),
|
networkStore: new ObservableStore(currentNetworkId),
|
||||||
txHistoryLimit: 10,
|
txHistoryLimit: 10,
|
||||||
blockTracker: { getCurrentBlock: noop, on: noop, once: noop },
|
blockTracker: { getCurrentBlock: noop, on: noop, once: noop },
|
||||||
accountTracker: { store: {getState: noop} },
|
accountTracker: { store: { getState: noop } },
|
||||||
signTransaction: (ethTx) => new Promise((resolve) => {
|
signTransaction: (ethTx) => new Promise((resolve) => {
|
||||||
ethTx.sign(privKey)
|
ethTx.sign(privKey)
|
||||||
resolve()
|
resolve()
|
||||||
|
Loading…
Reference in New Issue
Block a user