1
1
import { useEffect , useState } from "react" ;
2
- import { Web3AuthNoModal as Web3Auth } from "@web3auth/no-modal" ;
2
+ import { Web3AuthNoModal as Web3Auth , Web3AuthNoModal } from "@web3auth/no-modal" ;
3
3
import { CHAIN_NAMESPACES , IProvider , UX_MODE , WALLET_ADAPTERS , WEB3AUTH_NETWORK } from "@web3auth/base" ;
4
4
import { CommonPrivateKeyProvider } from "@web3auth/base-provider" ;
5
5
import { AuthAdapter } from "@web3auth/auth-adapter" ;
@@ -11,7 +11,7 @@ import TonRPC from "./tonRpc";
11
11
const testnetRpc = await getHttpEndpoint ( {
12
12
network : "testnet" ,
13
13
protocol : "json-rpc" ,
14
- } ) ;
14
+ } ) ;
15
15
16
16
const clientId = "BPi5PB_UiIZ-cPz1GtV5i1I2iOSOHuimiXBI0e-Oe_u6X3oVAbCiAZOTEBtTXw4tsluTITPqA8zMsfxIKMjiqNQ" ; // get from https://dashboard.web3auth.io
17
17
@@ -35,17 +35,25 @@ function App() {
35
35
36
36
const privateKeyProvider = new CommonPrivateKeyProvider ( { config : { chainConfig } } ) ;
37
37
38
- const web3auth = new Web3Auth ( {
38
+ const web3auth = new Web3AuthNoModal ( {
39
39
clientId,
40
40
privateKeyProvider,
41
41
web3AuthNetwork : WEB3AUTH_NETWORK . SAPPHIRE_MAINNET ,
42
+ useCoreKitKey : true ,
42
43
} ) ;
43
44
44
45
setWeb3auth ( web3auth ) ;
45
46
46
47
const authAdapter = new AuthAdapter ( {
47
48
adapterSettings : {
48
49
uxMode : UX_MODE . REDIRECT ,
50
+ loginConfig : {
51
+ google : {
52
+ verifier : "w3a-google-demo" ,
53
+ typeOfLogin : "google" ,
54
+ clientId : "519228911939-cri01h55lsjbsia1k7ll6qpalrus75ps.apps.googleusercontent.com" , //use your app client id you got from google
55
+ } ,
56
+ } ,
49
57
} ,
50
58
} ) ;
51
59
web3auth . configureAdapter ( authAdapter ) ;
@@ -113,6 +121,16 @@ function App() {
113
121
uiConsole ( address ) ;
114
122
} ;
115
123
124
+ const getPreGenAccounts = async ( ) => {
125
+ if ( ! provider ) {
126
+ uiConsole ( "provider not initialized yet" ) ;
127
+ return ;
128
+ }
129
+ const rpc = new TonRPC ( provider ) ;
130
+ const address = await rpc . getPreGenAccounts ( ) ;
131
+ uiConsole ( address ) ;
132
+ } ;
133
+
116
134
const getBalance = async ( ) => {
117
135
if ( ! provider ) {
118
136
uiConsole ( "provider not initialized yet" ) ;
@@ -175,7 +193,12 @@ function App() {
175
193
</ div >
176
194
< div >
177
195
< button onClick = { getAccounts } className = "card" >
178
- Get Accounts
196
+ Get Account
197
+ </ button >
198
+ </ div >
199
+ < div >
200
+ < button onClick = { getPreGenAccounts } className = "card" >
201
+ Get PreGen Account
179
202
</ button >
180
203
</ div >
181
204
< div >
@@ -208,18 +231,32 @@ function App() {
208
231
< p style = { { whiteSpace : "pre-line" } } > Logged in Successfully!</ p >
209
232
</ div >
210
233
< div className = "faucet-message" >
211
- < p > Need test TON? Click < a href = "https://faucet.tonxapi.com/" target = "_blank" rel = "noopener noreferrer" >
234
+ < p >
235
+ Need test TON? Click{ " " }
236
+ < a href = "https://faucet.tonxapi.com/" target = "_blank" rel = "noopener noreferrer" >
212
237
here
213
- </ a > to visit the faucet and receive free testnet tokens.</ p >
238
+ </ a > { " " }
239
+ to visit the faucet and receive free testnet tokens.
240
+ </ p >
214
241
< p > Remember to use your TON testnet address when requesting tokens from the faucet.</ p >
215
242
</ div >
216
243
</ >
217
244
) ;
218
245
219
246
const unloggedInView = (
220
- < button onClick = { login } className = "card" >
221
- Login
222
- </ button >
247
+ < >
248
+ < button onClick = { login } className = "card" >
249
+ Login
250
+ </ button >
251
+ < div >
252
+ < button onClick = { getPreGenAccounts } className = "card" >
253
+ Get PreGen Account
254
+ </ button >
255
+ </ div >
256
+ < div id = "console" style = { { whiteSpace : "pre-line" } } >
257
+ < p style = { { whiteSpace : "pre-line" } } > </ p >
258
+ </ div >
259
+ </ >
223
260
) ;
224
261
225
262
return (
@@ -241,4 +278,4 @@ function App() {
241
278
) ;
242
279
}
243
280
244
- export default App ;
281
+ export default App ;
0 commit comments