Enforce nonces as type string

feature/default_network_editable
Dan Finlay 7 years ago
parent a122ec1f8b
commit c620123fab
  1. 12
      app/scripts/lib/nonce-tracker.js

@ -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)) {

Loading…
Cancel
Save