@@ -6,13 +6,24 @@ import { sampleCredential, samplePresentationRequest } from "./sample-data";
6
6
7
7
const store = createStore ( ) ;
8
8
9
+ const sampleSignFieldsWithPassphrase = {
10
+ fields : [
11
+ "15194438335254979123992673494772742932886141479807135737958843785282001151979" ,
12
+ "13058445919007356413345300070030973942059862825965583483176167800381508277987" ,
13
+ "26067489438851605530938171293652363087823200555042082718868551789908955769071" ,
14
+ ] ,
15
+ passphrase : "1234" ,
16
+ } ;
17
+
9
18
export const TestZkApp = ( ) => {
10
19
const [ currentProvider , setCurrentProvider ] = useLocalStorage (
11
20
"minajs:provider" ,
12
21
"" ,
13
22
) ;
14
23
const [ message , setMessage ] = useState ( "A message to sign" ) ;
15
24
const [ fields , setFields ] = useState ( '["1", "2", "3"]' ) ;
25
+ const [ signFieldsWithPassphraseInput , setSignFieldsWithPassphraseInput ] =
26
+ useState ( JSON . stringify ( sampleSignFieldsWithPassphrase , null , 2 ) ) ;
16
27
const [ credentialInput , setCredentialInput ] = useState (
17
28
JSON . stringify ( sampleCredential , null , 2 ) ,
18
29
) ;
@@ -32,6 +43,7 @@ export const TestZkApp = () => {
32
43
mina_getBalance : "" ,
33
44
mina_sign : "" ,
34
45
mina_signFields : "" ,
46
+ mina_signFieldsWithPassphrase : "" ,
35
47
mina_signTransaction : "" ,
36
48
mina_switchChain : "" ,
37
49
mina_storePrivateCredential : "" ,
@@ -125,6 +137,23 @@ export const TestZkApp = () => {
125
137
mina_signFields : JSON . stringify ( result , undefined , "\t" ) ,
126
138
} ) ) ;
127
139
} ;
140
+ const signFieldsWithPassphrase = async ( ) => {
141
+ if ( ! provider ) return ;
142
+ try {
143
+ const parsedInput = JSON . parse ( signFieldsWithPassphraseInput ) ;
144
+ const { result } = await provider . request ( {
145
+ method : "mina_signFieldsWithPassphrase" ,
146
+ params : [ parsedInput ] ,
147
+ } ) ;
148
+ setResults ( ( ) => ( {
149
+ mina_signFieldsWithPassphrase : JSON . stringify ( result , null , 2 ) ,
150
+ } ) ) ;
151
+ } catch ( error ) {
152
+ setResults ( ( ) => ( {
153
+ mina_signFieldsWithPassphrase : `Error: ${ error . message } ` ,
154
+ } ) ) ;
155
+ }
156
+ } ;
128
157
const createNullifier = async ( ) => {
129
158
if ( ! provider ) return ;
130
159
const parsedFields = JSON . parse ( fields ) ;
@@ -501,6 +530,37 @@ export const TestZkApp = () => {
501
530
</ div >
502
531
</ div >
503
532
</ section >
533
+ < section className = "card bg-neutral" >
534
+ < div className = "card-body gap-4" >
535
+ < h2 className = "card-title" > Sign Fields With Passphrase</ h2 >
536
+ < p > mina_signFieldsWithPassphrase</ p >
537
+ < div className = "flex flex-col gap-2" >
538
+ < div className = "flex flex-col gap-4" >
539
+ < textarea
540
+ value = { signFieldsWithPassphraseInput }
541
+ onChange = { ( event ) =>
542
+ setSignFieldsWithPassphraseInput ( event . target . value )
543
+ }
544
+ className = "textarea textarea-bordered h-48 font-mono text-sm"
545
+ placeholder = "Enter fields and passphrase JSON..."
546
+ />
547
+ < button
548
+ type = "button"
549
+ className = "btn btn-primary"
550
+ onClick = { signFieldsWithPassphrase }
551
+ >
552
+ Sign Fields With Passphrase
553
+ </ button >
554
+ </ div >
555
+ < label > Result</ label >
556
+ < textarea
557
+ value = { results . mina_signFieldsWithPassphrase }
558
+ readOnly
559
+ className = "textarea textarea-bordered h-24 resize-none font-mono"
560
+ />
561
+ </ div >
562
+ </ div >
563
+ </ section >
504
564
</ main >
505
565
) ;
506
566
} ;
0 commit comments