mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
Address resubmit bug (#6886)
* Add some notes * Add explanatory comment and TODO * Typo * Improve verbage * Remove contextual comment
This commit is contained in:
parent
2a7278eb7e
commit
aea54d1b86
@ -68,6 +68,7 @@ class TransactionController extends EventEmitter {
|
|||||||
this.blockTracker = opts.blockTracker
|
this.blockTracker = opts.blockTracker
|
||||||
this.signEthTx = opts.signTransaction
|
this.signEthTx = opts.signTransaction
|
||||||
this.getGasPrice = opts.getGasPrice
|
this.getGasPrice = opts.getGasPrice
|
||||||
|
this.inProcessOfSigning = new Set()
|
||||||
|
|
||||||
this.memStore = new ObservableStore({})
|
this.memStore = new ObservableStore({})
|
||||||
this.query = new EthQuery(this.provider)
|
this.query = new EthQuery(this.provider)
|
||||||
@ -354,6 +355,15 @@ class TransactionController extends EventEmitter {
|
|||||||
@param txId {number} - the tx's Id
|
@param txId {number} - the tx's Id
|
||||||
*/
|
*/
|
||||||
async approveTransaction (txId) {
|
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
|
let nonceLock
|
||||||
try {
|
try {
|
||||||
// approve
|
// approve
|
||||||
@ -387,6 +397,8 @@ class TransactionController extends EventEmitter {
|
|||||||
if (nonceLock) nonceLock.releaseLock()
|
if (nonceLock) nonceLock.releaseLock()
|
||||||
// continue with error chain
|
// continue with error chain
|
||||||
throw err
|
throw err
|
||||||
|
} finally {
|
||||||
|
this.inProcessOfSigning.delete(txId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user