diff options
author | Dan Finlay <dan@danfinlay.com> | 2019-07-19 10:23:03 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2019-07-19 10:23:03 +0800 |
commit | a6deccd81096ad4bbef0f1fa6e816c41ecb57ba5 (patch) | |
tree | 196c85de6819dae95a70c26482cee06453071f33 /app/scripts/controllers | |
parent | ac8f3cb310338d92db057fcfbdd8cd6282e6d3de (diff) | |
download | tangerine-wallet-browser-a6deccd81096ad4bbef0f1fa6e816c41ecb57ba5.tar.gz tangerine-wallet-browser-a6deccd81096ad4bbef0f1fa6e816c41ecb57ba5.tar.zst tangerine-wallet-browser-a6deccd81096ad4bbef0f1fa6e816c41ecb57ba5.zip |
Fix resubmit bug
Diffstat (limited to 'app/scripts/controllers')
-rw-r--r-- | app/scripts/controllers/transactions/index.js | 12 |
1 files changed, 12 insertions, 0 deletions
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) } } /** |