From b758165c1b0fc6ccc5de93979b6f485ab43aa92e Mon Sep 17 00:00:00 2001 From: Victorien Gauch <85494462+VGau@users.noreply.github.com> Date: Fri, 28 Apr 2023 14:34:10 +0200 Subject: [PATCH] =?UTF-8?q?fix(18709):=20fix=20error=20when=20switching=20?= =?UTF-8?q?to=20linea=20testnet=20using=20wallet=5Fsw=E2=80=A6=20(#18710)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(18709): fix error when switching to linea testnet using wallet_switchEthereumChain * fix: update condition to get network config --- .../handlers/switch-ethereum-chain.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js b/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js index faeded072..4755a2c3d 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/switch-ethereum-chain.js @@ -6,7 +6,7 @@ import { NETWORK_TO_NAME_MAP, CHAIN_ID_TO_RPC_URL_MAP, CURRENCY_SYMBOLS, - NETWORK_TYPES, + BUILT_IN_INFURA_NETWORKS, } from '../../../../../shared/constants/network'; import { isPrefixedFormattedHexString, @@ -27,7 +27,11 @@ const switchEthereumChain = { export default switchEthereumChain; function findExistingNetwork(chainId, findNetworkConfigurationBy) { - if (chainId in CHAIN_ID_TO_TYPE_MAP) { + if ( + Object.values(BUILT_IN_INFURA_NETWORKS) + .map(({ chainId: id }) => id) + .includes(chainId) + ) { return { chainId, ticker: CURRENCY_SYMBOLS.ETH, @@ -109,9 +113,9 @@ async function switchEthereumChainHandler( requestData, }); if ( - chainId in CHAIN_ID_TO_TYPE_MAP && - approvedRequestData.type !== NETWORK_TYPES.LOCALHOST && - approvedRequestData.type !== NETWORK_TYPES.LINEA_TESTNET + Object.values(BUILT_IN_INFURA_NETWORKS) + .map(({ chainId: id }) => id) + .includes(chainId) ) { await setProviderType(approvedRequestData.type); } else {