aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Miller <danjm.com@gmail.com>2018-09-22 01:34:21 +0800
committerDan Miller <danjm.com@gmail.com>2018-09-22 01:59:42 +0800
commit19d72c9b0b4539f55624f6e9d41ded46c31d38d5 (patch)
treedc943e0a87f1626f186efc2970f0aaa5f0786703
parentd493ec6dc44ce53265c757a1a57dc23baca1efca (diff)
downloadtangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.tar
tangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.tar.gz
tangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.tar.bz2
tangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.tar.lz
tangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.tar.xz
tangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.tar.zst
tangerine-wallet-browser-19d72c9b0b4539f55624f6e9d41ded46c31d38d5.zip
Adds getPendingNonce method to provider initialization options in metamask-controller.
-rw-r--r--app/scripts/controllers/network/createMetamaskMiddleware.js2
-rw-r--r--app/scripts/metamask-controller.js14
2 files changed, 15 insertions, 1 deletions
diff --git a/app/scripts/controllers/network/createMetamaskMiddleware.js b/app/scripts/controllers/network/createMetamaskMiddleware.js
index 8b17829b7..9e6a45888 100644
--- a/app/scripts/controllers/network/createMetamaskMiddleware.js
+++ b/app/scripts/controllers/network/createMetamaskMiddleware.js
@@ -38,6 +38,6 @@ function createPendingNonceMiddleware ({ getPendingNonce }) {
const address = req.params[0]
const blockRef = req.params[1]
if (blockRef !== 'pending') return next()
- req.result = await getPendingNonce(address)
+ res.result = await getPendingNonce(address)
})
}
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 431a49dde..f11626c78 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -268,6 +268,7 @@ module.exports = class MetamaskController extends EventEmitter {
// msg signing
processEthSignMessage: this.newUnsignedMessage.bind(this),
processPersonalMessage: this.newUnsignedPersonalMessage.bind(this),
+ getPendingNonce: this.getPendingNonce.bind(this),
}
const providerProxy = this.networkController.initializeProvider(providerOpts)
return providerProxy
@@ -1362,6 +1363,19 @@ module.exports = class MetamaskController extends EventEmitter {
return '0x' + percentileNumBn.mul(GWEI_BN).toString(16)
}
+ /**
+ * Returns the nonce that will be associated with a transaction once approved
+ * @param address {string} - The hex string address for the transaction
+ * @returns Promise<number>
+ */
+ async getPendingNonce (address) {
+ const { nonceDetails, releaseLock} = await this.txController.nonceTracker.getNonceLock(address)
+ const pendingNonce = nonceDetails.params.highestSuggested
+
+ releaseLock()
+ return pendingNonce
+ }
+
//=============================================================================
// CONFIG
//=============================================================================