From aaec480e3298ae9bc56aabd1671787f528b544ee Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Tue, 23 Feb 2021 12:33:33 -0600 Subject: [PATCH] fix misuse of getCurrentNetwork (#10504) --- .../rpc-method-middleware/handlers/add-ethereum-chain.js | 6 +++--- app/scripts/metamask-controller.js | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js b/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js index cb7b69f7c..b347f681c 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js @@ -22,7 +22,7 @@ async function addEthereumChainHandler( end, { addCustomRpc, - getCurrentNetwork, + getCurrentChainId, findCustomRpcBy, updateRpcTarget, requestUserApproval, @@ -122,8 +122,8 @@ async function addEthereumChainHandler( const existingNetwork = findCustomRpcBy({ chainId: _chainId }); if (existingNetwork !== null) { - const currentNetwork = getCurrentNetwork(); - if (currentNetwork.chainId === _chainId) { + const currentChainId = getCurrentChainId(); + if (currentChainId === _chainId) { res.result = null; return end(); } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index eea666f3c..a9ebc71f7 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2111,7 +2111,9 @@ export default class MetamaskController extends EventEmitter { this.alertController, ), findCustomRpcBy: this.findCustomRpcBy.bind(this), - getCurrentNetwork: this.getCurrentNetwork.bind(this), + getCurrentChainId: this.networkController.getCurrentChainId.bind( + this.networkController, + ), requestUserApproval: this.approvalController.addAndShowApprovalRequest.bind( this.approvalController, ),