diff --git a/apps/klesia/src/methods/mina.ts b/apps/klesia/src/methods/mina.ts index 136e930..9c82c9b 100644 --- a/apps/klesia/src/methods/mina.ts +++ b/apps/klesia/src/methods/mina.ts @@ -1,11 +1,6 @@ import { gql } from "@urql/core"; -import { calculateQuantile } from "bigint-quantile"; import { match } from "ts-pattern"; -import { - SendDelegationBodySchema, - SendTransactionBodySchema, - SendZkAppBodySchema, -} from "../schema"; +import { SendTransactionBodySchema, SendZkAppBodySchema } from "../schema"; import { getNodeClient } from "../utils/node"; export const PRIORITY = { @@ -113,7 +108,7 @@ const sendTransaction = async ({ }) .with("delegation", async () => { const { signature, input } = - SendDelegationBodySchema.parse(signedTransaction); + SendTransactionBodySchema.parse(signedTransaction); const { data } = await client.mutation( gql` mutation { diff --git a/apps/klesia/src/schema.ts b/apps/klesia/src/schema.ts index 1483f2a..6988aa0 100644 --- a/apps/klesia/src/schema.ts +++ b/apps/klesia/src/schema.ts @@ -1,8 +1,4 @@ -import { - PublicKeySchema, - TransportableDelegationPayload, - TransportableTransactionPayload, -} from "@mina-js/utils"; +import { PublicKeySchema, TransactionPayload } from "@mina-js/utils"; import { z } from "zod"; import { SendZkappInput } from "./zkapp"; @@ -16,11 +12,7 @@ export const SignatureSchema = z.union([ z.object({ field: z.string(), scalar: z.string() }), ]); export const SendTransactionBodySchema = z.object({ - input: TransportableTransactionPayload, - signature: SignatureSchema, -}); -export const SendDelegationBodySchema = z.object({ - input: TransportableDelegationPayload, + input: TransactionPayload, signature: SignatureSchema, }); export const SendZkAppBodySchema = z.object({ @@ -28,7 +20,6 @@ export const SendZkAppBodySchema = z.object({ }); export const SendableSchema = z.union([ SendTransactionBodySchema, - SendDelegationBodySchema, SendZkAppBodySchema, ]); export const SendTransactionSchema = z.tuple([ diff --git a/packages/accounts/src/validation.ts b/packages/accounts/src/validation.ts index 3a77296..b65d432 100644 --- a/packages/accounts/src/validation.ts +++ b/packages/accounts/src/validation.ts @@ -1,4 +1,4 @@ -import { FieldSchema, TransactionPayload } from "@mina-js/utils"; +import { FieldSchema, TransactionBody } from "@mina-js/utils"; import { z } from "zod"; export const SignFieldsParamsSchema = z @@ -21,6 +21,6 @@ export const CreateNullifierParamsSchema = z export const SignTransactionParamsSchema = z .object({ - transaction: TransactionPayload, + transaction: TransactionBody, }) .strict(); diff --git a/packages/utils/src/validation.ts b/packages/utils/src/validation.ts index 2cfab85..acea7a7 100644 --- a/packages/utils/src/validation.ts +++ b/packages/utils/src/validation.ts @@ -37,7 +37,7 @@ export const FeePayerSchema = z }) .strict(); -export const DelegationPayload = z +export const TransactionBody = z .object({ from: PublicKeySchema, to: PublicKeySchema, @@ -45,29 +45,16 @@ export const DelegationPayload = z fee: z.coerce.string(), nonce: z.coerce.string(), validUntil: z.coerce.string().optional(), + amount: z.coerce.string().optional(), }) .strict(); -export const TransportableDelegationPayload = z +export const TransactionPayload = z .object({ - from: PublicKeySchema, - to: PublicKeySchema, - memo: z.string().optional(), - fee: z.coerce.string(), - nonce: z.coerce.string(), - validUntil: z.coerce.string().optional(), + transaction: TransactionBody, }) .strict(); -export const TransactionPayload = DelegationPayload.extend({ - amount: z.coerce.string(), -}).strict(); - -export const TransportableTransactionPayload = - TransportableDelegationPayload.extend({ - amount: z.coerce.string(), - }).strict(); - export const PartiallyFormedTransactionPayload = TransactionPayload.extend({ fee: z.coerce.string().optional(), nonce: z.coerce.string().optional(), @@ -125,7 +112,7 @@ export const SignedTransactionSchema = z .object({ signature: SignatureSchema, publicKey: PublicKeySchema, - data: TransactionPayload, + data: TransactionBody, }) .strict();