|
1 | 1 | import { ConnectButton, Connector } from '@ant-design/web3';
|
2 | 2 | import {
|
3 | 3 | CoinbaseWallet,
|
| 4 | + MetaMask, |
4 | 5 | TokenPocket,
|
5 | 6 | WagmiWeb3ConfigProvider,
|
6 | 7 | WalletConnect,
|
7 | 8 | } from '@ant-design/web3-wagmi';
|
8 |
| -import { configureChains, createConfig } from 'wagmi'; |
| 9 | +import { createConfig, http } from 'wagmi'; |
9 | 10 | import { mainnet, polygon } from 'wagmi/chains';
|
10 |
| -import { CoinbaseWalletConnector } from 'wagmi/connectors/coinbaseWallet'; |
11 |
| -import { InjectedConnector } from 'wagmi/connectors/injected'; |
12 |
| -import { MetaMaskConnector } from 'wagmi/connectors/metaMask'; |
13 |
| -import { WalletConnectConnector } from 'wagmi/connectors/walletConnect'; |
14 |
| -import { publicProvider } from 'wagmi/providers/public'; |
15 |
| - |
16 |
| -const { publicClient, chains } = configureChains([mainnet, polygon], [publicProvider()]); |
| 11 | +import { coinbaseWallet, injected, walletConnect } from 'wagmi/connectors'; |
17 | 12 |
|
18 | 13 | const config = createConfig({
|
19 |
| - autoConnect: true, |
20 |
| - publicClient, |
| 14 | + chains: [mainnet, polygon], |
| 15 | + transports: { |
| 16 | + [mainnet.id]: http(), |
| 17 | + [polygon.id]: http(), |
| 18 | + }, |
21 | 19 | connectors: [
|
22 |
| - new MetaMaskConnector({ |
23 |
| - chains, |
| 20 | + injected({ |
| 21 | + target: 'metaMask', |
24 | 22 | }),
|
25 |
| - new WalletConnectConnector({ |
26 |
| - chains, |
27 |
| - options: { |
28 |
| - showQrModal: false, |
29 |
| - projectId: YOUR_WALLET_CONNET_PROJECT_ID, |
30 |
| - }, |
| 23 | + walletConnect({ |
| 24 | + showQrModal: false, |
| 25 | + projectId: YOUR_WALLET_CONNET_PROJECT_ID, |
31 | 26 | }),
|
32 |
| - new CoinbaseWalletConnector({ |
33 |
| - chains, |
34 |
| - options: { |
35 |
| - appName: 'ant.design.web3', |
36 |
| - jsonRpcUrl: `https://api.zan.top/node/v1/eth/mainnet/${YOUR_ZAN_API_KEY}`, |
37 |
| - }, |
| 27 | + coinbaseWallet({ |
| 28 | + appName: 'ant.design.web3', |
| 29 | + jsonRpcUrl: `https://api.zan.top/node/v1/eth/mainnet/${YOUR_ZAN_API_KEY}`, |
38 | 30 | }),
|
39 |
| - new InjectedConnector({ |
40 |
| - chains, |
41 |
| - options: { |
42 |
| - name: 'TokenPocket', |
43 |
| - getProvider: () => { |
44 |
| - return (window as any).tokenpocket?.ethereum; |
45 |
| - }, |
46 |
| - }, |
| 31 | + injected({ |
| 32 | + target: 'tokenPocket', |
47 | 33 | }),
|
48 | 34 | ],
|
49 | 35 | });
|
50 | 36 |
|
51 | 37 | const App: React.FC = () => {
|
52 | 38 | return (
|
53 |
| - <WagmiWeb3ConfigProvider config={config} assets={[WalletConnect, TokenPocket, CoinbaseWallet]}> |
| 39 | + <WagmiWeb3ConfigProvider |
| 40 | + config={config} |
| 41 | + wallets={[MetaMask(), WalletConnect(), TokenPocket(), CoinbaseWallet()]} |
| 42 | + > |
54 | 43 | <Connector>
|
55 | 44 | <ConnectButton />
|
56 | 45 | </Connector>
|
|
0 commit comments