diff options
author | Thomas Huang <tmashuang@users.noreply.github.com> | 2018-09-24 21:45:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-24 21:45:25 +0800 |
commit | 82ec86d953cb22d36f9b67d35e3d994d7d2d245d (patch) | |
tree | 1d6377a17d2ff0f756c12af3407808def127e1c8 | |
parent | 04988eca5e98f0dcead3d85f6806bcf48ab09cfc (diff) | |
parent | 19d72c9b0b4539f55624f6e9d41ded46c31d38d5 (diff) | |
download | tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.tar tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.tar.gz tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.tar.bz2 tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.tar.lz tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.tar.xz tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.tar.zst tangerine-wallet-browser-82ec86d953cb22d36f9b67d35e3d994d7d2d245d.zip |
Merge pull request #5310 from MetaMask/getPendingNonce-hotfix
Adds getPendingNonce method to provider initialization in metamask-controller.
-rw-r--r-- | app/scripts/controllers/network/createMetamaskMiddleware.js | 2 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 14 |
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 //============================================================================= |