diff --git a/apps/docs/src/components/test-zkapp.tsx b/apps/docs/src/components/test-zkapp.tsx index b63f117..1b45e20 100644 --- a/apps/docs/src/components/test-zkapp.tsx +++ b/apps/docs/src/components/test-zkapp.tsx @@ -2,7 +2,7 @@ import { createStore } from "@mina-js/connect"; import { useLocalStorage, useObjectState } from "@uidotdev/usehooks"; import { clsx } from "clsx"; import { useState, useSyncExternalStore } from "react"; -import { sampleCredential1, samplePresentationRequest } from "./sample-data"; +import { sampleCredential, samplePresentationRequest } from "./sample-data"; const store = createStore(); @@ -14,7 +14,7 @@ export const TestZkApp = () => { const [message, setMessage] = useState("A message to sign"); const [fields, setFields] = useState('["1", "2", "3"]'); const [credentialInput, setCredentialInput] = useState( - JSON.stringify(sampleCredential1, null, 2), + JSON.stringify(sampleCredential, null, 2), ); const [presentationRequest, setPresentationRequest] = useState( JSON.stringify(samplePresentationRequest, null, 2), diff --git a/packages/providers/src/validation.ts b/packages/providers/src/validation.ts index 7525f22..d8a0c4b 100644 --- a/packages/providers/src/validation.ts +++ b/packages/providers/src/validation.ts @@ -1,5 +1,6 @@ import { FieldSchema, + FieldsAndPassphraseSchema, JsonSchema, NetworkId, NullifierSchema, @@ -59,6 +60,10 @@ export const SignFieldsRequestParamsSchema = RequestWithContext.extend({ method: z.literal("mina_signFields"), params: z.array(z.array(FieldSchema)), }).strict(); +export const signFieldsWithPassphraseParamsSchema = RequestWithContext.extend({ + method: z.literal("mina_signFieldsWithPassphrase"), + params: z.array(FieldsAndPassphraseSchema), +}); export const SignTransactionRequestParamsSchema = RequestWithContext.extend({ method: z.literal("mina_signTransaction"), params: z.array(z.union([TransactionPayloadSchema, ZkAppCommandPayload])), @@ -140,6 +145,10 @@ export const SignFieldsRequestReturnSchema = z result: SignedFieldsSchema, }) .strict(); +export const signFieldsWithPassphraseRequestReturnSchema = z.object({ + method: z.literal("mina_signFieldsWithPassphrase"), + result: SignedFieldsSchema, +}); export const SignTransactionRequestReturnSchema = z .object({ method: z.literal("mina_signTransaction"), @@ -212,6 +221,7 @@ export const RpcReturnTypesUnion = z.discriminatedUnion("method", [ GetStateRequestReturnSchema, StorePrivateCredentialReturnSchema, PresentationRequestReturnSchema, + signFieldsWithPassphraseRequestReturnSchema, ]); export const ProviderRequestParamsUnion = z.discriminatedUnion("method", [ @@ -231,6 +241,7 @@ export const ProviderRequestParamsUnion = z.discriminatedUnion("method", [ GetStateRequestParamsSchema, StorePrivateCredentialRequestParamsSchema, PresentationRequestParamsSchema, + signFieldsWithPassphraseParamsSchema, ]); export type RpcReturnTypesUnionType = z.infer; export type ResultType = { diff --git a/packages/utils/src/validation.ts b/packages/utils/src/validation.ts index 883fa45..fc3a02e 100644 --- a/packages/utils/src/validation.ts +++ b/packages/utils/src/validation.ts @@ -79,6 +79,13 @@ export const ZkAppCommandPayload = z }) .strict(); +export const FieldsAndPassphraseSchema = z + .object({ + fields: z.array(FieldSchema), + passphrase: z.string(), + }) + .strict(); + /** * Return type schemas */