diff --git a/frontend-dapp/src/config/networks.ts b/frontend-dapp/src/config/networks.ts index b017e67..35560f9 100644 --- a/frontend-dapp/src/config/networks.ts +++ b/frontend-dapp/src/config/networks.ts @@ -17,6 +17,38 @@ const rpcUrl138 = import.meta.env.VITE_RPC_URL_138 || 'https://rpc-http-pub.d-bi const rpcUrl651940 = import.meta.env.VITE_RPC_URL_651940 || 'https://mainnet-rpc.alltra.global' const rpcUrl42793 = import.meta.env.VITE_RPC_URL_42793 || 'https://node.mainnet.etherlink.com' +/** When true, testnet 2138 is included in Wagmi chains, RPC map, and supportedChainIds. */ +export const chain2138TestnetEnabled = + import.meta.env.VITE_ENABLE_CHAIN2138 === 'true' || + import.meta.env.VITE_ENABLE_CHAIN2138 === '1' + +const rpcUrl2138 = + import.meta.env.VITE_RPC_URL_2138 || 'https://rpc.public-2138.defi-oracle.io' +const explorerUrl2138 = + import.meta.env.VITE_EXPLORER_URL_2138 || 'https://public-2138.defi-oracle.io' + +/** Chain 2138 - Defi Oracle Meta Testnet (optional; enable with VITE_ENABLE_CHAIN2138) */ +export const chain2138Testnet = defineChain({ + id: 2138, + name: 'Defi Oracle Meta Testnet', + network: 'chain2138-testnet', + nativeCurrency: { + decimals: 18, + name: 'testEther', + symbol: 'tETH', + }, + rpcUrls: { + default: { http: [rpcUrl2138] }, + public: { http: [rpcUrl2138] }, + }, + blockExplorers: { + default: { + name: 'Defi Oracle Meta Testnet Explorer', + url: explorerUrl2138, + }, + }, +}) + /** Chain 138 - DeFi Oracle Meta Mainnet */ export const chain138 = defineChain({ id: 138, @@ -128,8 +160,31 @@ export const gnosis = defineChain({ blockExplorers: { default: { name: 'GnosisScan', url: 'https://gnosisscan.io' } }, }) +const customChainsWithout2138 = [ + chain138, + allMainnet, + etherlink, + bsc, + avalanche, + cronos, + gnosis, +] as const + +const customChainsWith2138 = [ + chain138, + chain2138Testnet, + allMainnet, + etherlink, + bsc, + avalanche, + cronos, + gnosis, +] as const + /** All custom chains (Viem Chain type) - for use with Wagmi/Viem */ -export const customChains = [chain138, allMainnet, etherlink, bsc, avalanche, cronos, gnosis] as const +export const customChains = chain2138TestnetEnabled + ? customChainsWith2138 + : customChainsWithout2138 /** Standard L2s from wagmi/chains (Ethereum, Base, Arbitrum, Polygon, Optimism) */ export const standardChains = [mainnet, base, arbitrum, polygon, optimism] as const @@ -140,6 +195,7 @@ export const allNetworks = [...customChains, ...standardChains] as const /** Chain IDs we support (for CowSwap, Jumper, UI filters) - all deployed contract networks */ export const supportedChainIds = [ chain138.id, + ...(chain2138TestnetEnabled ? [chain2138Testnet.id] : []), allMainnet.id, etherlink.id, mainnet.id, @@ -156,6 +212,7 @@ export const supportedChainIds = [ /** Map chainId -> RPC URL for transports */ export const chainRpcUrls: Record = { [chain138.id]: rpcUrl138, + ...(chain2138TestnetEnabled ? { [chain2138Testnet.id]: rpcUrl2138 } : {}), [allMainnet.id]: rpcUrl651940, [etherlink.id]: rpcUrl42793, [bsc.id]: rpcUrlBsc,