@@ -8,6 +8,12 @@ import {
8
8
} from "./sample-data" ;
9
9
import bs58 from 'bs58' ;
10
10
11
+ enum TransactionType {
12
+ PAYMENT = "payment" ,
13
+ DELEGATION = "delegation" ,
14
+ ZKAPP = "zkapp"
15
+ }
16
+
11
17
function bytesToHex ( bytes : Uint8Array ) : string {
12
18
return Array . from ( bytes )
13
19
. map ( ( byte ) => byte . toString ( 16 ) . padStart ( 2 , '0' ) )
@@ -61,6 +67,7 @@ export const TestZkApp = () => {
61
67
const [ presentationRequest , setPresentationRequest ] = useState (
62
68
JSON . stringify ( samplePresentationRequestHttpsFromExampleUpdated , null , 2 ) ,
63
69
) ;
70
+ const [ transactionType , setTransactionType ] = useState ( TransactionType . PAYMENT )
64
71
const [ transactionBody , setTransactionBody ] = useObjectState ( {
65
72
to : "B62qnVUL6A53E4ZaGd3qbTr6RCtEZYTu3kTijVrrquNpPo4d3MuJ3nb" ,
66
73
amount : "3000000000" ,
@@ -213,6 +220,7 @@ export const TestZkApp = () => {
213
220
setResults ( ( ) => ( {
214
221
mina_signTransaction : JSON . stringify ( result , undefined , "\t" ) ,
215
222
} ) ) ;
223
+ setTransactionType ( TransactionType . PAYMENT ) ;
216
224
} ;
217
225
const signZkAppCommand = async ( ) => {
218
226
if ( ! provider ) return ;
@@ -247,22 +255,24 @@ export const TestZkApp = () => {
247
255
setResults ( ( ) => ( {
248
256
mina_signTransaction : JSON . stringify ( result , undefined , "\t" ) ,
249
257
} ) ) ;
258
+ setTransactionType ( TransactionType . ZKAPP ) ;
250
259
} ;
251
260
const sendTransaction = async ( ) => {
252
261
if ( ! provider ) return ;
253
262
if ( ! results . mina_signTransaction ) return ;
254
263
const signedTransaction = JSON . parse ( results . mina_signTransaction )
255
- const { result } = await provider . request ( {
256
- method : "mina_sendTransaction" ,
257
- params : [ {
258
- ...signedTransaction ,
259
- signature : typeof signedTransaction . signature === "string" ?
260
- convertSignature ( signedTransaction . signature ) : signedTransaction . signature
261
- } ] ,
262
- } ) ;
263
- setResults ( ( ) => ( {
264
- mina_sendTransaction : JSON . stringify ( result , undefined , "\t" ) ,
265
- } ) ) ;
264
+ if ( transactionType === TransactionType . PAYMENT ) {
265
+ const { result } = await provider . request ( {
266
+ method : "mina_sendTransaction" ,
267
+ params : [ {
268
+ input : signedTransaction . data ,
269
+ signature : signedTransaction . signature
270
+ } , "payment" ] ,
271
+ } ) ;
272
+ setResults ( ( ) => ( {
273
+ mina_sendTransaction : JSON . stringify ( result , undefined , "\t" ) ,
274
+ } ) ) ;
275
+ }
266
276
} ;
267
277
const switchChain = async ( networkId : string ) => {
268
278
if ( ! provider ) return ;
0 commit comments