@@ -26,6 +26,7 @@ export const TestZkApp = () => {
26
26
mina_sign : "" ,
27
27
mina_signFields : "" ,
28
28
mina_signTransaction : "" ,
29
+ mina_switchChain : "" ,
29
30
} ) ;
30
31
const providers = useSyncExternalStore ( store . subscribe , store . getProviders ) ;
31
32
const provider = providers . find (
@@ -140,6 +141,14 @@ export const TestZkApp = () => {
140
141
mina_signTransaction : JSON . stringify ( result , undefined , "\t" ) ,
141
142
} ) ) ;
142
143
} ;
144
+ const switchChain = async ( networkId : string ) => {
145
+ if ( ! provider ) return ;
146
+ const { result } = await provider . request ( {
147
+ method : "mina_switchChain" ,
148
+ params : [ networkId ] ,
149
+ } ) ;
150
+ setResults ( ( ) => ( { mina_switchChain : result } ) ) ;
151
+ } ;
143
152
return (
144
153
< main className = "flex flex-col gap-8" >
145
154
< h1 className = "text-3xl font-bold" > Test zkApp</ h1 >
@@ -201,32 +210,56 @@ export const TestZkApp = () => {
201
210
Request Accounts
202
211
</ button >
203
212
</ div >
204
- < label > mina_networkId </ label >
213
+ < label > mina_getBalance </ label >
205
214
< div className = "flex justify-between items-center gap-4" >
206
215
< input
207
- value = { results . mina_networkId }
216
+ value = { results . mina_getBalance }
208
217
className = "input input-bordered flex-1"
209
218
/>
210
219
< button
211
220
type = "button"
212
221
className = "btn btn-primary"
213
- onClick = { fetchNetworkId }
222
+ onClick = { fetchBalance }
214
223
>
215
- Get Network ID
224
+ Get Balance
216
225
</ button >
217
226
</ div >
218
- < label > mina_getBalance</ label >
227
+ </ div >
228
+ </ div >
229
+ </ section >
230
+ < section className = "card bg-neutral" >
231
+ < div className = "card-body gap-4" >
232
+ < h2 className = "card-title" > Network</ h2 >
233
+ < div className = "flex flex-col gap-2" >
234
+ < label > mina_networkId</ label >
219
235
< div className = "flex justify-between items-center gap-4" >
220
236
< input
221
- value = { results . mina_getBalance }
237
+ value = { results . mina_networkId }
222
238
className = "input input-bordered flex-1"
223
239
/>
224
240
< button
225
241
type = "button"
226
242
className = "btn btn-primary"
227
- onClick = { fetchBalance }
243
+ onClick = { fetchNetworkId }
228
244
>
229
- Get Balance
245
+ Get Network ID
246
+ </ button >
247
+ </ div >
248
+ < label > mina_switchChain</ label >
249
+ < div className = "flex items-center gap-4" >
250
+ < button
251
+ type = "button"
252
+ className = "btn btn-primary"
253
+ onClick = { ( ) => switchChain ( "mina:devnet" ) }
254
+ >
255
+ Switch to Devnet
256
+ </ button >
257
+ < button
258
+ type = "button"
259
+ className = "btn btn-primary"
260
+ onClick = { ( ) => switchChain ( "mina:mainnet" ) }
261
+ >
262
+ Switch to Mainnet
230
263
</ button >
231
264
</ div >
232
265
</ div >
0 commit comments