diff options
author | Dan Finlay <dan@danfinlay.com> | 2017-08-24 12:50:28 +0800 |
---|---|---|
committer | Dan Finlay <dan@danfinlay.com> | 2017-08-24 12:50:28 +0800 |
commit | c620123fab9e1eac8d3038204c9cfb04ca85afb1 (patch) | |
tree | 997d8ac63c2ca30b499ee359cb3766e976436987 | |
parent | a122ec1f8ba0935d26a45ce0b26be991d222aaad (diff) | |
download | tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.tar tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.tar.gz tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.tar.bz2 tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.tar.lz tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.tar.xz tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.tar.zst tangerine-wallet-browser-c620123fab9e1eac8d3038204c9cfb04ca85afb1.zip |
Enforce nonces as type string
-rw-r--r-- | app/scripts/lib/nonce-tracker.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/app/scripts/lib/nonce-tracker.js b/app/scripts/lib/nonce-tracker.js index e0e065d82..08f1e1e86 100644 --- a/app/scripts/lib/nonce-tracker.js +++ b/app/scripts/lib/nonce-tracker.js @@ -115,13 +115,21 @@ class NonceTracker { } _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) return highestNonce } _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 while (nonces.includes(highest)) { |