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

Enforce nonces as type string

This commit is contained in:
Dan Finlay 2017-08-23 21:50:28 -07:00
parent a122ec1f8b
commit c620123fab

View File

@ -115,13 +115,21 @@ class NonceTracker {
} }
_getHighestNonce (txList) { _getHighestNonce (txList) {
const nonces = txList.map((txMeta) => parseInt(txMeta.txParams.nonce, 16)) const nonces = txList.map((txMeta) => {
const nonce = txMeta.txParams.nonce
assert(typeof nonce, 'string', 'nonces should be hex strings')
return parseInt(nonce, 16)
})
const highestNonce = Math.max.apply(null, nonces) const highestNonce = Math.max.apply(null, nonces)
return highestNonce return highestNonce
} }
_getHighestContinuousFrom (txList, startPoint) { _getHighestContinuousFrom (txList, startPoint) {
const nonces = txList.map((txMeta) => parseInt(txMeta.txParams.nonce, 16)) const nonces = txList.map((txMeta) => {
const nonce = txMeta.txParams.nonce
assert(typeof nonce, 'string', 'nonces should be hex strings')
return parseInt(nonce, 16)
})
let highest = startPoint let highest = startPoint
while (nonces.includes(highest)) { while (nonces.includes(highest)) {