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 {