From 974ab98bfe2d9f1f5e495c58ce81ba304ecfbf24 Mon Sep 17 00:00:00 2001 From: Canh Trinh Date: Wed, 20 Dec 2023 12:56:32 -0500 Subject: [PATCH] chore: fix zod schema validation to account for 0x string salt --- apps/maestro/src/lib/utils/validation.ts | 2 ++ .../routers/interchainToken/getInterchainTokenDetails.ts | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/maestro/src/lib/utils/validation.ts b/apps/maestro/src/lib/utils/validation.ts index 4e25ea96c..d62c0e4c4 100644 --- a/apps/maestro/src/lib/utils/validation.ts +++ b/apps/maestro/src/lib/utils/validation.ts @@ -86,6 +86,8 @@ export const hex64 = () => */ export const hex0x = () => z.string().startsWith("0x").max(2); +export const hex0xLiteral = () => hex0x().transform(asHexLiteral); + export const hex40Literal = () => hex40().transform(asHexLiteral); export const hex64Literal = () => hex64().transform(asHexLiteral); diff --git a/apps/maestro/src/server/routers/interchainToken/getInterchainTokenDetails.ts b/apps/maestro/src/server/routers/interchainToken/getInterchainTokenDetails.ts index c1f3446f3..86093fc7f 100644 --- a/apps/maestro/src/server/routers/interchainToken/getInterchainTokenDetails.ts +++ b/apps/maestro/src/server/routers/interchainToken/getInterchainTokenDetails.ts @@ -1,7 +1,11 @@ import { TRPCError } from "@trpc/server"; import { z } from "zod"; -import { hex0x, hex40Literal, hex64Literal } from "~/lib/utils/validation"; +import { + hex0xLiteral, + hex40Literal, + hex64Literal, +} from "~/lib/utils/validation"; import { publicProcedure } from "~/server/trpc"; const remoteTokenSchema = z.object({ @@ -30,7 +34,7 @@ const outputSchema = z.object({ kind: z.string(), createdAt: z.date().nullable(), updatedAt: z.date().nullable(), - salt: hex64Literal().or(hex0x()), + salt: hex64Literal().or(hex0xLiteral()), remoteTokens: z.array(remoteTokenSchema), });