1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #6888 from MetaMask/ResubmitFix

Resubmit fix
This commit is contained in:
Thomas Huang 2019-07-18 20:25:35 -07:00 committed by GitHub
commit 787079d8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
}
}
/**