Skip to content

Commit

Permalink
chore(providers): remove presentation
Browse files Browse the repository at this point in the history
  • Loading branch information
martonmoro committed Nov 11, 2024
1 parent 67ad8e8 commit 0b7f905
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 257 deletions.
6 changes: 0 additions & 6 deletions packages/providers/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
JsonSchema,
NetworkId,
NullifierSchema,
// PresentationRequestSchema,
PublicKeySchema,
SignedFieldsSchema,
SignedMessageSchema,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -223,7 +218,6 @@ export const ProviderRequestParamsUnion = z.discriminatedUnion("method", [
SetStateRequestParamsSchema,
GetStateRequestParamsSchema,
StorePrivateCredentialRequestParamsSchema,
// PresentationRequestParamsSchema
]);
export type RpcReturnTypesUnionType = z.infer<typeof RpcReturnTypesUnion>;
export type ResultType<M extends string> = {
Expand Down
251 changes: 0 additions & 251 deletions packages/utils/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof SerializedValueSchema> }
| { type: "root" }
| { type: "property"; key: string; inner: Node }
| { type: "record"; data: Record<string, Node> }
| { 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<Node> = 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
Expand Down

0 comments on commit 0b7f905

Please sign in to comment.