From af73513211dd696b59e27e454f78d96fffbc01ef Mon Sep 17 00:00:00 2001 From: CounterFire2023 <136581895+CounterFire2023@users.noreply.github.com> Date: Thu, 27 Jun 2024 20:02:18 +0800 Subject: [PATCH] bug fix --- src/abi/mint.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/abi/mint.js b/src/abi/mint.js index 335dd2a..6396742 100644 --- a/src/abi/mint.js +++ b/src/abi/mint.js @@ -2,6 +2,23 @@ import {Deferred} from '../utils/promise.util.js' const MINT_CONTRACT_ADDRESS=import.meta.env.VITE_CLAIMWL_ADDRESS const RPC='https://rpc.testnet.immutable.com/' +const chainCfgs = [{ + name: 'Immutable zkEVM', + type: 'Mainnet', + rpc: 'https://rpc.immutable.com', + id: 13371, + symbol: 'IMX', + explorerurl: 'https://explorer.immutable.com' +}, +{ + name: 'Immutable zkEVM Testnet', + type: 'Testnet', + rpc: 'https://rpc.testnet.immutable.com', + id: 13473, + symbol: 'tIMX', + explorerurl: 'https://explorer.testnet.immutable.com' +}] + const requestChain = async (rpc, method, params) => { const data = { id: Date.now(), @@ -122,7 +139,8 @@ export const switchEthereumChain = async (provider, targetChainId) => { console.log('error switch chain: ', e) if (e.code === 4902 || e.message.indexOf('Unrecognized chain ID') >= 0) { try { - const data = chainCfg + const chainIdNum = parseInt(hexChainId) + const data = chainCfgs.find(o => o.id === chainIdNum) await provider.request({ method: 'wallet_addEthereumChain', params: [