File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed
apps/api-reference/src/components/EvmProvider Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change 1- import { defineChain } from "viem" ;
21import type { Chain } from "viem" ;
2+ import { defineChain } from "viem" ;
33
44/**
55 * Chain overrides for chains that are not available in viem's built-in chain list.
@@ -10,10 +10,10 @@ import type { Chain } from "viem";
1010 * 2. Add a new defineChain entry with the following required fields:
1111 * - id: chainId. id in EvmChains.json is the name
1212 * - name: Chain display name
13- * - nativeCurrency: { name, symbol, decimals }
14- * - rpcUrls: { default: { http: ['...'] } }
13+ * - nativeCurrency: \ { name, symbol, decimals \ }
14+ * - rpcUrls: \ { default: \ { http: ['...'] \} \ }
1515 * - testnet: true/false (optional, defaults to false for mainnet)
16- * - blockExplorers: { default: { name, url } } (optional)
16+ * - blockExplorers: \ { default: \ { name, url \} \ } (optional)
1717 */
1818export const chainOverrides : readonly Chain [ ] = [
1919 // Example chain override (remove or replace with actual chains):
@@ -75,4 +75,3 @@ export const chainOverrides: readonly Chain[] = [
7575 } ,
7676 } ) ,
7777] ;
78-
Original file line number Diff line number Diff line change @@ -11,10 +11,18 @@ import type { ReactNode } from "react";
1111import * as chains from "viem/chains" ;
1212import { WagmiProvider , createConfig , http , useChainId } from "wagmi" ;
1313
14+ import { chainOverrides } from "./chain-overrides" ;
1415import { metadata } from "../../metadata" ;
1516
1617const CHAINS = allEvmChainIds
17- . map ( ( id ) => Object . values ( chains ) . find ( ( chain ) => chain . id === id ) )
18+ . map ( ( id ) => {
19+ // First, check if we have an override for this chain
20+ const overrideChain = chainOverrides . find ( ( chain ) => chain . id === id ) ;
21+ if ( overrideChain ) return overrideChain ;
22+
23+ // Fall back to viem's built-in chains
24+ return Object . values ( chains ) . find ( ( chain ) => chain . id === id ) ;
25+ } )
1826 . filter ( ( chain ) => chain !== undefined ) as unknown as readonly [
1927 chains . Chain ,
2028 ...chains . Chain [ ] ,
You can’t perform that action at this time.
0 commit comments