11import React from "react" ;
22
3- import { createWeb3Modal } from "@web3modal/wagmi/react" ;
4- import { type Chain } from "viem" ;
5- import { createConfig , fallback , http , WagmiProvider , webSocket } from "wagmi" ;
6- import { mainnet , arbitrumSepolia , arbitrum , sepolia } from "wagmi/chains" ;
7- import { walletConnect } from "wagmi/connectors" ;
8-
3+ import { fallback , http , WagmiProvider , webSocket } from "wagmi" ;
4+ import { mainnet , arbitrumSepolia , arbitrum , sepolia , type AppKitNetwork } from "@reown/appkit/networks" ;
5+ import { createAppKit } from "@reown/appkit/react" ;
6+ import { WagmiAdapter } from "@reown/appkit-adapter-wagmi" ;
97import { ALL_CHAINS , DEFAULT_CHAIN } from "consts/chains" ;
108import { isProductionDeployment } from "consts/index" ;
119
@@ -25,10 +23,10 @@ const alchemyToViemChain = {
2523type AlchemyProtocol = "https" | "wss" ;
2624
2725// https://github.com/alchemyplatform/alchemy-sdk-js/blob/96b3f62/src/util/const.ts#L16-L18
28- const alchemyURL = ( protocol : AlchemyProtocol , chainId : number ) =>
26+ const alchemyURL = ( protocol : AlchemyProtocol , chainId : number | string ) =>
2927 `${ protocol } ://${ alchemyToViemChain [ chainId ] } .g.alchemy.com/v2/${ alchemyApiKey } ` ;
3028
31- export const getChainRpcUrl = ( protocol : AlchemyProtocol , chainId : number ) => {
29+ export const getChainRpcUrl = ( protocol : AlchemyProtocol , chainId : number | string ) => {
3230 return alchemyURL ( protocol , chainId ) ;
3331} ;
3432
@@ -37,7 +35,7 @@ export const getDefaultChainRpcUrl = (protocol: AlchemyProtocol) => {
3735} ;
3836
3937export const getTransports = ( ) => {
40- const alchemyTransport = ( chain : Chain ) =>
38+ const alchemyTransport = ( chain : AppKitNetwork ) =>
4139 fallback ( [ http ( alchemyURL ( "https" , chain . id ) ) , webSocket ( alchemyURL ( "wss" , chain . id ) ) ] ) ;
4240
4341 return {
@@ -48,28 +46,29 @@ export const getTransports = () => {
4846 } ;
4947} ;
5048
51- const chains = ALL_CHAINS as [ Chain , ...Chain [ ] ] ;
49+ const chains = ALL_CHAINS as [ AppKitNetwork , ...AppKitNetwork [ ] ] ;
5250const transports = getTransports ( ) ;
5351const projectId = import . meta. env . WALLETCONNECT_PROJECT_ID ?? "" ;
54-
55- const wagmiConfig = createConfig ( {
56- chains ,
52+ const wagmiAdapter = new WagmiAdapter ( {
53+ networks : chains ,
54+ projectId ,
5755 transports,
58- connectors : [ walletConnect ( { projectId, showQrModal : false } ) ] ,
5956} ) ;
6057
61- createWeb3Modal ( {
62- wagmiConfig,
58+ createAppKit ( {
59+ adapters : [ wagmiAdapter ] ,
60+ networks : chains ,
61+ defaultNetwork : isProduction ? arbitrum : arbitrumSepolia ,
6362 projectId,
64- defaultChain : isProductionDeployment ( ) ? arbitrum : arbitrumSepolia ,
6563 themeVariables : {
6664 "--w3m-color-mix" : lightTheme . primaryPurple ,
6765 "--w3m-color-mix-strength" : 20 ,
66+ // overlay portal is at 9999
67+ "--w3m-z-index" : 10000 ,
6868 } ,
6969} ) ;
70-
7170const Web3Provider : React . FC < { children : React . ReactNode } > = ( { children } ) => {
72- return < WagmiProvider config = { wagmiConfig } > { children } </ WagmiProvider > ;
71+ return < WagmiProvider config = { wagmiAdapter . wagmiConfig } > { children } </ WagmiProvider > ;
7372} ;
7473
7574export default Web3Provider ;
0 commit comments