@@ -2,12 +2,12 @@ import React, { useRef, type FC, type PropsWithChildren } from "react";
2
2
3
3
import { useSyncWagmiConfig } from "@lifi/wallet-management" ;
4
4
import { useAvailableChains } from "@lifi/widget" ;
5
+ import { mainnet , arbitrumSepolia , arbitrum } from "@reown/appkit/networks" ;
6
+ import { createAppKit } from "@reown/appkit/react" ;
7
+ import { WagmiAdapter } from "@reown/appkit-adapter-wagmi" ;
5
8
import { injected , walletConnect } from "@wagmi/connectors" ;
6
- import { createWeb3Modal } from "@web3modal/wagmi" ;
7
9
import { createClient , http } from "viem" ;
8
- import { arbitrum , arbitrumSepolia , mainnet } from "viem/chains" ;
9
- import type { Config } from "wagmi" ;
10
- import { createConfig , WagmiProvider } from "wagmi" ;
10
+ import { WagmiProvider } from "wagmi" ;
11
11
12
12
import { isProductionDeployment } from "consts/index" ;
13
13
@@ -19,32 +19,36 @@ const connectors = [injected(), walletConnect({ projectId })];
19
19
20
20
export const WalletProvider : FC < PropsWithChildren > = ( { children } ) => {
21
21
const { chains } = useAvailableChains ( ) ;
22
- const wagmi = useRef < Config > ( ) ;
22
+ const adapter = useRef < WagmiAdapter > ( ) ;
23
23
24
- if ( ! wagmi . current ) {
25
- wagmi . current = createConfig ( {
26
- chains : [ mainnet ] ,
24
+ if ( ! adapter . current ) {
25
+ adapter . current = new WagmiAdapter ( {
26
+ networks : [ mainnet ] ,
27
+ projectId,
27
28
client ( { chain } ) {
28
29
return createClient ( { chain, transport : http ( ) } ) ;
29
30
} ,
30
- ssr : true ,
31
31
} ) ;
32
32
}
33
33
34
- useSyncWagmiConfig ( wagmi . current , connectors , chains ) ;
34
+ useSyncWagmiConfig ( adapter . current . wagmiConfig , connectors , chains ) ;
35
35
36
- createWeb3Modal ( {
37
- wagmiConfig : wagmi . current ,
38
- projectId ,
39
- defaultChain : isProductionDeployment ( ) ? arbitrum : arbitrumSepolia ,
36
+ createAppKit ( {
37
+ adapters : [ adapter . current ] ,
38
+ networks : [ mainnet ] ,
39
+ defaultNetwork : isProductionDeployment ( ) ? arbitrum : arbitrumSepolia ,
40
40
allowUnsupportedChain : true ,
41
+ projectId,
41
42
themeVariables : {
42
43
"--w3m-color-mix" : lightTheme . primaryPurple ,
43
44
"--w3m-color-mix-strength" : 20 ,
45
+ // overlay portal is at 9999
46
+ "--w3m-z-index" : 10000 ,
44
47
} ,
45
48
} ) ;
49
+
46
50
return (
47
- < WagmiProvider config = { wagmi . current } reconnectOnMount = { false } >
51
+ < WagmiProvider config = { adapter . current . wagmiConfig } reconnectOnMount = { false } >
48
52
{ children }
49
53
</ WagmiProvider >
50
54
) ;
0 commit comments