aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/transactions/nonce-tracker.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2018-05-29 05:29:31 +0800
committerkumavis <aaron@kumavis.me>2018-05-29 05:29:31 +0800
commit5be154ea2035810462ff0e7051e537870bfc1afb (patch)
tree438d5c4cf20001645adff24151d9f0222bbf5782 /app/scripts/controllers/transactions/nonce-tracker.js
parent9f8d5f05470d68a7a9a5474a5b1f4587398e94a3 (diff)
downloadtangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.tar
tangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.tar.gz
tangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.tar.bz2
tangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.tar.lz
tangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.tar.xz
tangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.tar.zst
tangerine-wallet-browser-5be154ea2035810462ff0e7051e537870bfc1afb.zip
controllers - transactions - merge @frankiebee's work with mine
Diffstat (limited to 'app/scripts/controllers/transactions/nonce-tracker.js')
-rw-r--r--app/scripts/controllers/transactions/nonce-tracker.js16
1 files changed, 4 insertions, 12 deletions
diff --git a/app/scripts/controllers/transactions/nonce-tracker.js b/app/scripts/controllers/transactions/nonce-tracker.js
index 490118c89..fe2d25fca 100644
--- a/app/scripts/controllers/transactions/nonce-tracker.js
+++ b/app/scripts/controllers/transactions/nonce-tracker.js
@@ -35,7 +35,7 @@ class NonceTracker {
* @typedef NonceDetails
* @property {number} highestLocallyConfirmed - A hex string of the highest nonce on a confirmed transaction.
* @property {number} nextNetworkNonce - The next nonce suggested by the eth_getTransactionCount method.
- * @property {number} highetSuggested - The maximum between the other two, the number returned.
+ * @property {number} highestSuggested - The maximum between the other two, the number returned.
*/
/**
@@ -75,14 +75,6 @@ class NonceTracker {
return { nextNonce, nonceDetails, releaseLock }
}
- async _getCurrentBlock () {
- const currentBlock = this.blockTracker.getCurrentBlock()
- if (currentBlock) return currentBlock
- return await new Promise((reject, resolve) => {
- this.blockTracker.once('latest', resolve)
- })
- }
-
async _globalMutexFree () {
const globalMutex = this._lookupMutex('global')
const release = await globalMutex.acquire()
@@ -108,9 +100,8 @@ class NonceTracker {
// calculate next nonce
// we need to make sure our base count
// and pending count are from the same block
- const currentBlock = await this._getCurrentBlock()
- const blockNumber = currentBlock.blockNumber
- const baseCountBN = await this.ethQuery.getTransactionCount(address, blockNumber || 'latest')
+ const blockNumber = await this.blockTracker.getLatestBlock()
+ const baseCountBN = await this.ethQuery.getTransactionCount(address, blockNumber)
const baseCount = baseCountBN.toNumber()
assert(Number.isInteger(baseCount), `nonce-tracker - baseCount is not an integer - got: (${typeof baseCount}) "${baseCount}"`)
const nonceDetails = { blockNumber, baseCount }
@@ -171,6 +162,7 @@ class NonceTracker {
return { name: 'local', nonce: highest, details: { startPoint, highest } }
}
+
}
module.exports = NonceTracker