Skip to content

Commit

Permalink
Fix resubmit bug
Browse files Browse the repository at this point in the history
  • Loading branch information
danfinlay committed Jul 19, 2019
1 parent ac8f3cb commit a6deccd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -387,6 +397,8 @@ class TransactionController extends EventEmitter {
if (nonceLock) nonceLock.releaseLock()
// continue with error chain
throw err
} finally {
this.inProcessOfSigning.delete(txId)
}
}
/**
Expand Down

0 comments on commit a6deccd

Please sign in to comment.