1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

fix(18709): fix error when switching to linea testnet using wallet_sw… (#18710)

* fix(18709): fix error when switching to linea testnet using wallet_switchEthereumChain

* fix: update condition to get network config
This commit is contained in:
Victorien Gauch 2023-04-28 14:34:10 +02:00 committed by Dan Miller
parent ca0a4bec3b
commit b758165c1b

View File

@ -6,7 +6,7 @@ import {
NETWORK_TO_NAME_MAP, NETWORK_TO_NAME_MAP,
CHAIN_ID_TO_RPC_URL_MAP, CHAIN_ID_TO_RPC_URL_MAP,
CURRENCY_SYMBOLS, CURRENCY_SYMBOLS,
NETWORK_TYPES, BUILT_IN_INFURA_NETWORKS,
} from '../../../../../shared/constants/network'; } from '../../../../../shared/constants/network';
import { import {
isPrefixedFormattedHexString, isPrefixedFormattedHexString,
@ -27,7 +27,11 @@ const switchEthereumChain = {
export default switchEthereumChain; export default switchEthereumChain;
function findExistingNetwork(chainId, findNetworkConfigurationBy) { 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 { return {
chainId, chainId,
ticker: CURRENCY_SYMBOLS.ETH, ticker: CURRENCY_SYMBOLS.ETH,
@ -109,9 +113,9 @@ async function switchEthereumChainHandler(
requestData, requestData,
}); });
if ( if (
chainId in CHAIN_ID_TO_TYPE_MAP && Object.values(BUILT_IN_INFURA_NETWORKS)
approvedRequestData.type !== NETWORK_TYPES.LOCALHOST && .map(({ chainId: id }) => id)
approvedRequestData.type !== NETWORK_TYPES.LINEA_TESTNET .includes(chainId)
) { ) {
await setProviderType(approvedRequestData.type); await setProviderType(approvedRequestData.type);
} else { } else {