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

Account for a custom nonce of zero (#8883)

* Account for a custom nonce of zero
* Remove default value for customNonceValue
This commit is contained in:
Thomas Huang 2020-07-02 12:58:12 -07:00 committed by GitHub
parent dd209c8fd2
commit 259d19850f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -443,14 +443,14 @@ export default class TransactionController extends EventEmitter {
const txMeta = this.txStateManager.getTx(txId) const txMeta = this.txStateManager.getTx(txId)
const fromAddress = txMeta.txParams.from const fromAddress = txMeta.txParams.from
// wait for a nonce // wait for a nonce
let { customNonceValue = null } = txMeta let { customNonceValue } = txMeta
customNonceValue = Number(customNonceValue) customNonceValue = Number(customNonceValue)
nonceLock = await this.nonceTracker.getNonceLock(fromAddress) nonceLock = await this.nonceTracker.getNonceLock(fromAddress)
// add nonce to txParams // add nonce to txParams
// if txMeta has lastGasPrice then it is a retry at same nonce with higher // if txMeta has lastGasPrice then it is a retry at same nonce with higher
// gas price transaction and their for the nonce should not be calculated // gas price transaction and their for the nonce should not be calculated
const nonce = txMeta.lastGasPrice ? txMeta.txParams.nonce : nonceLock.nextNonce const nonce = txMeta.lastGasPrice ? txMeta.txParams.nonce : nonceLock.nextNonce
const customOrNonce = customNonceValue || nonce const customOrNonce = (customNonceValue === 0) ? customNonceValue : customNonceValue || nonce
txMeta.txParams.nonce = ethUtil.addHexPrefix(customOrNonce.toString(16)) txMeta.txParams.nonce = ethUtil.addHexPrefix(customOrNonce.toString(16))
// add nonce debugging information to txMeta // add nonce debugging information to txMeta