1
1
import { createConfig , http } from "wagmi" ;
2
2
import { injected , walletConnect } from "wagmi/connectors" ;
3
3
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" ;
15
6
16
7
import { safe } from "./overrides/safe" ;
17
8
@@ -20,55 +11,42 @@ const ALCHEMY_API_KEY = import.meta.env.VITE_ALCHEMY_API_KEY;
20
11
21
12
const isIframe = window . self !== window . top ;
22
13
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
+ ) ;
60
47
61
48
export const config = createConfig ( {
62
- chains : [
63
- mainnet ,
64
- sepolia ,
65
- goerli ,
66
- gnosis ,
67
- polygon ,
68
- polygonZkEvm ,
69
- optimism ,
70
- arbitrum ,
71
- ] ,
49
+ chains,
72
50
connectors : [
73
51
! isIframe && injected ( ) ,
74
52
! isIframe &&
0 commit comments