From aea54d1b86e8b3d23afe145428335bffdbfe906c Mon Sep 17 00:00:00 2001 From: Dan Finlay <542863+danfinlay@users.noreply.github.com> Date: Thu, 18 Jul 2019 20:37:51 -0700 Subject: Address resubmit bug (#6886) * Add some notes * Add explanatory comment and TODO * Typo * Improve verbage * Remove contextual comment --- app/scripts/controllers/transactions/index.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/scripts/controllers/transactions/index.js') diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 1ae925835..c4371c25b 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -68,6 +68,7 @@ class TransactionController extends EventEmitter { this.blockTracker = opts.blockTracker this.signEthTx = opts.signTransaction this.getGasPrice = opts.getGasPrice + this.inProcessOfSigning = new Set() this.memStore = new ObservableStore({}) this.query = new EthQuery(this.provider) @@ -354,6 +355,15 @@ class TransactionController extends EventEmitter { @param txId {number} - the tx's Id */ async approveTransaction (txId) { + // TODO: Move this safety out of this function. + // Since this transaction is async, + // we need to keep track of what is currently being signed, + // So that we do not increment nonce + resubmit something + // that is already being incrmented & signed. + if (this.inProcessOfSigning.has(txId)) { + return + } + this.inProcessOfSigning.add(txId) let nonceLock try { // approve @@ -387,6 +397,8 @@ class TransactionController extends EventEmitter { if (nonceLock) nonceLock.releaseLock() // continue with error chain throw err + } finally { + this.inProcessOfSigning.delete(txId) } } /** -- cgit v1.2.3 From 4d88e1cf862c3ae174780cd888d7703685db23e7 Mon Sep 17 00:00:00 2001 From: Whymarrh Whitby Date: Wed, 31 Jul 2019 17:47:11 -0230 Subject: Enable indent linting via ESLint (#6936) * Enable indent linting via ESLint * yarn run lint:fix --- app/scripts/controllers/transactions/index.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'app/scripts/controllers/transactions/index.js') diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index c4371c25b..a33b46851 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -129,7 +129,7 @@ class TransactionController extends EventEmitter { } } -/** + /** Adds a tx to the txlist @emits ${txMeta.id}:unapproved */ @@ -220,7 +220,7 @@ class TransactionController extends EventEmitter { return txMeta } -/** + /** adds the tx gas defaults: gas && gasPrice @param txMeta {Object} - the txMeta object @returns {Promise} resolves with txMeta @@ -495,9 +495,9 @@ class TransactionController extends EventEmitter { this.txStateManager.updateTx(txMeta, 'transactions#setTxHash') } -// -// PRIVATE METHODS -// + // + // PRIVATE METHODS + // /** maps methods for convenience*/ _mapMethods () { /** @returns the state in transaction controller */ @@ -537,14 +537,14 @@ class TransactionController extends EventEmitter { loadingDefaults: true, }).forEach((tx) => { this.addTxGasDefaults(tx) - .then((txMeta) => { - txMeta.loadingDefaults = false - this.txStateManager.updateTx(txMeta, 'transactions: gas estimation for tx on boot') - }).catch((error) => { - tx.loadingDefaults = false - this.txStateManager.updateTx(tx, 'failed to estimate gas during boot cleanup.') - this.txStateManager.setTxStatusFailed(tx.id, error) - }) + .then((txMeta) => { + txMeta.loadingDefaults = false + this.txStateManager.updateTx(txMeta, 'transactions: gas estimation for tx on boot') + }).catch((error) => { + tx.loadingDefaults = false + this.txStateManager.updateTx(tx, 'failed to estimate gas during boot cleanup.') + this.txStateManager.setTxStatusFailed(tx.id, error) + }) }) this.txStateManager.getFilteredTxList({ -- cgit v1.2.3