pending-tx - move incrementing of the retryCount on the txMeta outside pending-tx-tracker

feature/default_network_editable
frankiebee 7 years ago
parent b05a6f89cb
commit 0a94ec41d3
  1. 5
      app/scripts/controllers/transactions.js
  2. 3
      app/scripts/lib/pending-tx-tracker.js
  3. 2
      test/unit/tx-controller-test.js

@ -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:failed', this.txStateManager.setTxStatusFailed.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 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 balance = this.getBalance(address)
if (balance === undefined) return
if (!('retryCount' in txMeta)) txMeta.retryCount = 0
if (txMeta.retryCount > this.retryLimit) {
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)
// Increment successful tries:
txMeta.retryCount++
this.emit('tx:retry', txMeta)
return txHash
}

@ -25,7 +25,7 @@ describe('Transaction Controller', function () {
networkStore: new ObservableStore(currentNetworkId),
txHistoryLimit: 10,
blockTracker: { getCurrentBlock: noop, on: noop, once: noop },
accountTracker: { store: {getState: noop} },
accountTracker: { store: { getState: noop } },
signTransaction: (ethTx) => new Promise((resolve) => {
ethTx.sign(privKey)
resolve()

Loading…
Cancel
Save