|
3 | 3 | * version used: 4.2.1 |
4 | 4 | */ |
5 | 5 |
|
6 | | -// import { type FC, type DetailedHTMLProps, type HTMLAttributes, type PropsWithChildren } from 'react' |
7 | | - |
8 | | -// import { createWeb3Modal, defaultWagmiConfig } from '@web3modal/wagmi' |
9 | | - |
10 | | -// import { env } from '@/src/env' |
11 | | - |
12 | | -// import { chains, transports } from '@/src/lib/networks.config' |
13 | | - |
14 | | -// export const WalletProvider: FC<PropsWithChildren> = ({ children }) => children |
15 | | - |
16 | | -// declare global { |
17 | | -// namespace JSX { |
18 | | -// interface IntrinsicElements { |
19 | | -// 'w3m-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> |
20 | | -// } |
21 | | -// } |
22 | | -// } |
23 | | -// export const ConnectWalletButton = ({ label = 'Connect' }: { label?: string }) => ( |
24 | | -// <w3m-button label={label} /> |
25 | | -// ) |
26 | | - |
27 | | -// // Required API Keys |
28 | | -// const projectId = env.PUBLIC_WALLETCONNECT_PROJECT_ID |
29 | | - |
30 | | -// export const config = defaultWagmiConfig({ |
31 | | -// chains, |
32 | | -// projectId, |
33 | | -// metadata: { |
34 | | -// // Required App Info |
35 | | -// name: env.PUBLIC_APP_NAME, |
36 | | -// description: env.PUBLIC_APP_DESCRIPTION ?? '', |
37 | | -// url: env.PUBLIC_APP_URL ?? '', |
38 | | -// icons: [env.PUBLIC_APP_LOGO ?? ''], |
39 | | -// }, |
40 | | -// transports, |
41 | | -// }) |
42 | | - |
43 | | -// createWeb3Modal({ |
44 | | -// wagmiConfig: config, |
45 | | -// projectId, |
46 | | -// }) |
| 6 | +import type { DetailedHTMLProps, FC, HTMLAttributes, PropsWithChildren } from 'react' |
| 7 | + |
| 8 | +import { WagmiAdapter } from '@reown/appkit-adapter-wagmi' |
| 9 | +import { createAppKit } from '@reown/appkit/react' |
| 10 | + |
| 11 | +import { env } from '@/src/env' |
| 12 | + |
| 13 | +import { chains } from '@/src/lib/networks.config' |
| 14 | +import type { Chain } from 'viem' |
| 15 | + |
| 16 | +export const WalletProvider: FC<PropsWithChildren> = ({ children }) => children |
| 17 | + |
| 18 | +declare global { |
| 19 | + namespace JSX { |
| 20 | + interface IntrinsicElements { |
| 21 | + 'w3m-button': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement> |
| 22 | + } |
| 23 | + } |
| 24 | +} |
| 25 | +export const ConnectWalletButton = ({ label = 'Connect' }: { label?: string }) => ( |
| 26 | + <appkit-button label={label} /> |
| 27 | +) |
| 28 | + |
| 29 | +// Required API Keys |
| 30 | +const projectId = env.PUBLIC_WALLETCONNECT_PROJECT_ID |
| 31 | + |
| 32 | +const metadata = { |
| 33 | + // Required App Info |
| 34 | + name: env.PUBLIC_APP_NAME, |
| 35 | + description: env.PUBLIC_APP_DESCRIPTION ?? '', |
| 36 | + url: env.PUBLIC_APP_URL ?? '', |
| 37 | + icons: [env.PUBLIC_APP_LOGO ?? ''], |
| 38 | +} |
| 39 | + |
| 40 | +// TODO avoid readonly types mismatch |
| 41 | +const wagmiAdapter = new WagmiAdapter({ |
| 42 | + networks: chains as unknown as Chain[], |
| 43 | + projectId, |
| 44 | +}) |
| 45 | + |
| 46 | +createAppKit({ |
| 47 | + adapters: [wagmiAdapter], |
| 48 | + networks: chains as unknown as [Chain, ...Chain[]], |
| 49 | + metadata: metadata, |
| 50 | + projectId, |
| 51 | + features: { |
| 52 | + analytics: true, |
| 53 | + }, |
| 54 | +}) |
| 55 | + |
| 56 | +export const config = wagmiAdapter.wagmiConfig |
0 commit comments