From 0b7f905f71b29325bb04a8d7b23c5dd16318b38e Mon Sep 17 00:00:00 2001 From: Marton Moro Date: Mon, 11 Nov 2024 12:58:54 +0100 Subject: [PATCH] chore(providers): remove presentation --- packages/providers/src/validation.ts | 6 - packages/utils/src/validation.ts | 251 --------------------------- 2 files changed, 257 deletions(-) diff --git a/packages/providers/src/validation.ts b/packages/providers/src/validation.ts index 79ab0d8..f7ce318 100644 --- a/packages/providers/src/validation.ts +++ b/packages/providers/src/validation.ts @@ -3,7 +3,6 @@ import { JsonSchema, NetworkId, NullifierSchema, - // PresentationRequestSchema, PublicKeySchema, SignedFieldsSchema, SignedMessageSchema, @@ -92,10 +91,6 @@ export const StorePrivateCredentialRequestParamsSchema = method: z.literal("mina_storePrivateCredential"), params: z.array(StoredCredentialSchema), }).strict(); -// export const PresentationRequestParamsSchema = RequestWithContext.extend({ -// method: z.literal("mina_requestPresentation"), -// params: z.array(PresentationRequestSchema), -// }).strict(); // Returns export const AccountsRequestReturnSchema = z @@ -223,7 +218,6 @@ export const ProviderRequestParamsUnion = z.discriminatedUnion("method", [ SetStateRequestParamsSchema, GetStateRequestParamsSchema, StorePrivateCredentialRequestParamsSchema, - // PresentationRequestParamsSchema ]); export type RpcReturnTypesUnionType = z.infer; export type ResultType = { diff --git a/packages/utils/src/validation.ts b/packages/utils/src/validation.ts index b2f08e6..b3cf68a 100644 --- a/packages/utils/src/validation.ts +++ b/packages/utils/src/validation.ts @@ -356,257 +356,6 @@ const SerializedSignatureSchema = z }) .strict(); -// Private Credentials: Node schemas - -type Node = - | { type: "owner" } - | { type: "issuer"; credentialKey: string } - | { type: "constant"; data: z.infer } - | { type: "root" } - | { type: "property"; key: string; inner: Node } - | { type: "record"; data: Record } - | { type: "equals"; left: Node; right: Node } - | { type: "equalsOneOf"; input: Node; options: Node[] | Node } - | { type: "lessThan"; left: Node; right: Node } - | { type: "lessThanEq"; left: Node; right: Node } - | { type: "add"; left: Node; right: Node } - | { type: "sub"; left: Node; right: Node } - | { type: "mul"; left: Node; right: Node } - | { type: "div"; left: Node; right: Node } - | { type: "and"; inputs: Node[] } - | { type: "or"; left: Node; right: Node } - | { type: "not"; inner: Node } - | { type: "hash"; inputs: Node[]; prefix?: string | null } - | { type: "ifThenElse"; condition: Node; thenNode: Node; elseNode: Node }; - -const NodeSchema: z.ZodType = z.lazy(() => - z.discriminatedUnion("type", [ - z - .object({ - type: z.literal("owner"), - }) - .strict(), - - z - .object({ - type: z.literal("issuer"), - credentialKey: z.string(), - }) - .strict(), - - z - .object({ - type: z.literal("constant"), - data: SerializedValueSchema, - }) - .strict(), - - z - .object({ - type: z.literal("root"), - }) - .strict(), - - z - .object({ - type: z.literal("property"), - key: z.string(), - inner: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("record"), - data: z.record(NodeSchema), - }) - .strict(), - - z - .object({ - type: z.literal("equals"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("equalsOneOf"), - input: NodeSchema, - options: z.union([ - z.array(NodeSchema), // For array of nodes case - NodeSchema, - ]), - }) - .strict(), - - z - .object({ - type: z.literal("lessThan"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("lessThanEq"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("add"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("sub"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("mul"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("div"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("and"), - inputs: z.array(NodeSchema), - }) - .strict(), - - z - .object({ - type: z.literal("or"), - left: NodeSchema, - right: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("not"), - inner: NodeSchema, - }) - .strict(), - - z - .object({ - type: z.literal("hash"), - inputs: z.array(NodeSchema), - prefix: z.union([z.string(), z.null()]).optional(), - }) - .strict(), - - z - .object({ - type: z.literal("ifThenElse"), - condition: NodeSchema, - thenNode: NodeSchema, - elseNode: NodeSchema, - }) - .strict(), - ]), -); - -// Private Credentials: Input Schema - -const InputSchema = z.discriminatedUnion("type", [ - z - .object({ - type: z.literal("credential"), - credentialType: z.union([ - z.literal("simple"), - z.literal("unsigned"), - z.literal("recursive"), - ]), - witness: z.union([z.record(SerializedTypeSchema), SerializedTypeSchema]), - data: z.union([z.record(SerializedTypeSchema), SerializedTypeSchema]), - }) - .strict(), - - z - .object({ - type: z.literal("constant"), - data: SerializedTypeSchema, - value: z.union([z.string(), z.record(z.string())]), - }) - .strict(), - - z - .object({ - type: z.literal("claim"), - data: z.union([z.record(SerializedTypeSchema), SerializedTypeSchema]), - }) - .strict(), -]); - -// Private Credentials: Context schemas - -const HttpsContextSchema = z - .object({ - type: z.literal("https"), - action: z.string(), - serverNonce: SerializedFieldSchema, - }) - .strict(); - -const ZkAppContextSchema = z - .object({ - type: z.literal("zk-app"), - action: SerializedFieldSchema, - serverNonce: SerializedFieldSchema, - }) - .strict(); - -const ContextSchema = z.union([HttpsContextSchema, ZkAppContextSchema]); - -// Private Credentials: PresentationRequestSchema - -export const PresentationRequestSchema = z - .object({ - type: z.union([ - z.literal("no-context"), - z.literal("zk-app"), - z.literal("https"), - ]), - spec: z - .object({ - inputs: z.record(InputSchema), - logic: z - .object({ - assert: NodeSchema, - outputClaim: NodeSchema, - }) - .strict(), - }) - .strict(), - claims: z.record(SerializedValueSchema), - inputContext: z.union([ContextSchema, z.null()]), - }) - .strict(); - // Private Credentials: Witness Schemas const SimpleWitnessSchema = z