Skip to content

Commit

Permalink
chore: fix zod schema validation to account for 0x string salt
Browse files Browse the repository at this point in the history
  • Loading branch information
canhtrinh committed Dec 20, 2023
1 parent bdb7221 commit 2cca85b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions apps/maestro/src/lib/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ export const hex40 = () =>
export const hex64 = () =>
z.string().regex(/^0x[0-9a-fA-F]{64}$/, "Invalid hash");

/**
* Zod schema to validate a 0x hex entry
*/
export const hex0x = () => z.string().startsWith("0x").max(2);

export const hex40Literal = () => hex40().transform(asHexLiteral);

export const hex64Literal = () => hex64().transform(asHexLiteral);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TRPCError } from "@trpc/server";
import { z } from "zod";

import { hex40Literal, hex64Literal } from "~/lib/utils/validation";
import { hex0x, hex40Literal, hex64Literal } from "~/lib/utils/validation";
import { publicProcedure } from "~/server/trpc";

const remoteTokenSchema = z.object({
Expand Down Expand Up @@ -30,7 +30,7 @@ const outputSchema = z.object({
kind: z.string(),
createdAt: z.date().nullable(),
updatedAt: z.date().nullable(),
salt: hex64Literal(),
salt: hex64Literal().or(hex0x()),
remoteTokens: z.array(remoteTokenSchema),
});

Expand Down

2 comments on commit 2cca85b

@vercel
Copy link

@vercel vercel bot commented on 2cca85b Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

axelar-ui – ./packages/ui

axelar-ui-git-main-axelar-network.vercel.app
axelar-ui-axelar-network.vercel.app
axelar-ui.vercel.app
ui.axelar.dev

@vercel
Copy link

@vercel vercel bot commented on 2cca85b Dec 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

axelar-registry – ./apps/registry

axelar-registry-git-main-axelar-network.vercel.app
axelar-registry-axelar-network.vercel.app

Please sign in to comment.