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

Fix network nonce parsing

This commit is contained in:
Dan Finlay 2017-08-23 21:14:46 -07:00
parent e057c37b33
commit 55c1a259b1

View File

@ -37,8 +37,14 @@ class NonceTracker {
const pendingTxs = this.getPendingTransactions(address)
const localNonceResult = this._getHighestContinuousFrom(pendingTxs, highestSuggested) || 0
nonceDetails.local = localNonceResult.details
nonceDetails.network = networkNonceResult.details
nonceDetails.params = {
highestLocalNonce,
highestSuggested,
nextNetworkNonce,
}
nonceDetails.local = localNonceResult
nonceDetails.network = networkNonceResult
const nextNonce = Math.max(networkNonceResult.nonce, localNonceResult.nonce)
assert(Number.isInteger(nextNonce), `nonce-tracker - nextNonce is not an integer - got: (${typeof nextNonce}) "${nextNonce}"`)
@ -82,8 +88,9 @@ class NonceTracker {
// and pending count are from the same block
const currentBlock = await this._getCurrentBlock()
const blockNumber = currentBlock.blockNumber
const baseCountHex = await this.ethQuery.getTransactionCount(address, blockNumber)
const baseCount = parseInt(baseCountHex, 16)
const baseCountBN = await this.ethQuery.getTransactionCount(address, blockNumber)
const baseString = baseCountBN.toString()
const baseCount = parseInt(baseString)
assert(Number.isInteger(baseCount), `nonce-tracker - baseCount is not an integer - got: (${typeof baseCount}) "${baseCount}"`)
const nonceDetails = { blockNumber, baseCount }
return { name: 'network', nonce: baseCount, details: nonceDetails }