@@ -28,9 +28,10 @@ import { setupMintbaseWallet } from "@near-wallet-selector/mintbase-wallet";
28
28
import { setupBitteWallet } from "@near-wallet-selector/bitte-wallet" ;
29
29
import { setupOKXWallet } from "@near-wallet-selector/okx-wallet" ;
30
30
import { setupEthereumWallets } from "@near-wallet-selector/ethereum-wallets" ;
31
- import { createWeb3Modal } from "@web3modal/wagmi" ;
32
- import { reconnect , http , createConfig , type Config } from "@wagmi/core" ;
33
- import { type Chain } from "@wagmi/core/chains" ;
31
+ import { WagmiAdapter } from "@reown/appkit-adapter-wagmi" ;
32
+ import { createAppKit } from "@reown/appkit/react" ;
33
+ import { defineChain } from "@reown/appkit/networks" ;
34
+ import type { CreateConnectorFn } from "@wagmi/core" ;
34
35
import { injected , walletConnect } from "@wagmi/connectors" ;
35
36
import { CONTRACT_ID } from "../../../constants" ;
36
37
@@ -41,11 +42,13 @@ declare global {
41
42
}
42
43
}
43
44
44
- // Get a project ID at https://cloud.walletconnect .com
45
+ // Get a project ID at https://cloud.reown .com
45
46
const projectId = "30147604c5f01d0bc4482ab0665b5697" ;
46
47
47
- const near : Chain = {
48
+ const near = defineChain ( {
48
49
id : 398 ,
50
+ caipNetworkId : "eip155:398" ,
51
+ chainNamespace : "eip155" ,
49
52
name : "NEAR Protocol Testnet" ,
50
53
nativeCurrency : {
51
54
decimals : 18 ,
@@ -63,33 +66,42 @@ const near: Chain = {
63
66
} ,
64
67
} ,
65
68
testnet : true ,
66
- } ;
69
+ } ) ;
67
70
68
- const wagmiConfig : Config = createConfig ( {
69
- chains : [ near ] ,
70
- transports : {
71
- [ near . id ] : http ( ) ,
72
- } ,
73
- connectors : [
74
- walletConnect ( {
75
- projectId ,
76
- metadata : {
77
- name : "NEAR Guest Book" ,
78
- description : "A guest book with comments stored on the NEAR blockchain" ,
79
- url : "https://near.github.io/wallet-selector" ,
80
- icons : [ "https://near.github.io/wallet-selector/favicon.ico" ] ,
81
- } ,
82
- showQrModal : false ,
83
- } ) ,
84
- injected ( { shimDisconnect : true } ) ,
85
- ] ,
71
+ const connectors : Array < CreateConnectorFn > = [
72
+ walletConnect ( {
73
+ projectId ,
74
+ metadata : {
75
+ name : "NEAR Guest Book" ,
76
+ description : "A guest book with comments stored on the NEAR blockchain" ,
77
+ url : "https://near.github.io/wallet-selector" ,
78
+ icons : [ "https://near.github.io/wallet-selector/favicon.ico" ] ,
79
+ } ,
80
+ showQrModal : false , // showQrModal must be false
81
+ } ) ,
82
+ injected ( { shimDisconnect : true } ) ,
83
+ ] ;
84
+
85
+ const wagmiAdapter = new WagmiAdapter ( {
86
+ projectId ,
87
+ connectors ,
88
+ networks : [ near ] ,
86
89
} ) ;
87
- reconnect ( wagmiConfig ) ;
88
90
89
- const web3Modal = createWeb3Modal ( {
90
- wagmiConfig : wagmiConfig ,
91
+ const web3Modal = createAppKit ( {
92
+ adapters : [ wagmiAdapter ] ,
91
93
projectId,
92
- enableOnramp : false ,
94
+ networks : [ near ] ,
95
+ defaultNetwork : near ,
96
+ enableWalletConnect : true ,
97
+ features : {
98
+ analytics : true ,
99
+ swaps : false ,
100
+ onramp : false ,
101
+ email : false , // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
102
+ socials : false , // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
103
+ } ,
104
+ coinbasePreference : "eoaOnly" , // Smart accounts (Safe contract) not available on NEAR Protocol, only EOA.
93
105
allWallets : "SHOW" ,
94
106
} ) ;
95
107
@@ -158,7 +170,10 @@ export class WalletSelectorComponent implements OnInit {
158
170
setupNearMobileWallet ( ) ,
159
171
setupMintbaseWallet ( { contractId : CONTRACT_ID } ) ,
160
172
setupBitteWallet ( { contractId : CONTRACT_ID } ) ,
161
- setupEthereumWallets ( { wagmiConfig, web3Modal } ) ,
173
+ setupEthereumWallets ( {
174
+ wagmiConfig : wagmiAdapter . wagmiConfig ,
175
+ web3Modal,
176
+ } ) ,
162
177
] ,
163
178
} ) ;
164
179
0 commit comments