11import { createConfig , http } from "wagmi" ;
22import { injected , walletConnect } from "wagmi/connectors" ;
33
4- import {
5- arbitrum ,
6- base ,
7- gnosis ,
8- goerli ,
9- mainnet ,
10- optimism ,
11- polygon ,
12- polygonZkEvm ,
13- sepolia ,
14- } from "wagmi/chains" ;
4+ import * as _chains from "wagmi/chains" ;
5+ import type { Chain , Transport } from "viem" ;
156
167import { safe } from "./overrides/safe" ;
178
@@ -20,55 +11,42 @@ const ALCHEMY_API_KEY = import.meta.env.VITE_ALCHEMY_API_KEY;
2011
2112const isIframe = window . self !== window . top ;
2213
23- export const transports = ALCHEMY_API_KEY
24- ? {
25- [ mainnet . id ] : http (
26- `https://eth-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
27- ) ,
28- [ sepolia . id ] : http (
29- `https://eth-sepolia.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
30- ) ,
31- [ goerli . id ] : http ( ) ,
32- [ gnosis . id ] : http ( ) ,
33- [ polygon . id ] : http (
34- `https://polygon-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
35- ) ,
36- [ polygonZkEvm . id ] : http (
37- `https://polygonzkevm-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
38- ) ,
39- [ optimism . id ] : http (
40- `https://opt-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
41- ) ,
42- [ arbitrum . id ] : http (
43- `https://arb-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
44- ) ,
45- [ base . id ] : http (
46- `https://base-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
47- ) ,
48- }
49- : {
50- [ mainnet . id ] : http ( ) ,
51- [ sepolia . id ] : http ( ) ,
52- [ goerli . id ] : http ( ) ,
53- [ gnosis . id ] : http ( ) ,
54- [ polygon . id ] : http ( ) ,
55- [ polygonZkEvm . id ] : http ( ) ,
56- [ optimism . id ] : http ( ) ,
57- [ arbitrum . id ] : http ( ) ,
58- [ base . id ] : http ( ) ,
59- } ;
14+ const alchemyTransports = ALCHEMY_API_KEY && {
15+ [ _chains . mainnet . id ] :
16+ `https://eth-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
17+ [ _chains . sepolia . id ] :
18+ `https://eth-sepolia.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
19+ [ _chains . polygon . id ] :
20+ `https://polygon-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
21+ [ _chains . polygonAmoy . id ] :
22+ `https://polygon-amoy.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
23+ [ _chains . polygonZkEvm . id ] :
24+ `https://polygonzkevm-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
25+ [ _chains . polygonZkEvmCardona . id ] :
26+ `https://polygonzkevm-cardona.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
27+ [ _chains . optimism . id ] :
28+ `https://opt-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
29+ [ _chains . optimismSepolia . id ] :
30+ `https://opt-sepolia.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
31+ [ _chains . arbitrum . id ] :
32+ `https://arb-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
33+ [ _chains . arbitrumSepolia . id ] :
34+ `https://arb-sepolia.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
35+ [ _chains . base . id ] : `https://base-mainnet.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
36+ [ _chains . baseSepolia . id ] :
37+ `https://base-sepolia.g.alchemy.com/v2/${ ALCHEMY_API_KEY } ` ,
38+ } ;
39+ const chains = Object . values ( _chains ) as unknown as [ Chain , ...Chain [ ] ] ;
40+ export const transports = chains . reduce (
41+ ( acc , { id } ) => {
42+ acc [ id ] = alchemyTransports ?. [ id ] ? http ( alchemyTransports [ id ] ) : http ( ) ;
43+ return acc ;
44+ } ,
45+ { } as Record < number , Transport > ,
46+ ) ;
6047
6148export const config = createConfig ( {
62- chains : [
63- mainnet ,
64- sepolia ,
65- goerli ,
66- gnosis ,
67- polygon ,
68- polygonZkEvm ,
69- optimism ,
70- arbitrum ,
71- ] ,
49+ chains,
7250 connectors : [
7351 ! isIframe && injected ( ) ,
7452 ! isIframe &&
0 commit comments