Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/sdk/src/schema/contracts/custom.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { toSemver } from "../../common/index";
import { AddressSchema, BigNumberishSchema } from "../shared";
import { AddressSchema, BigNumberishSchema, JsonSchema } from "../shared";
import {
CommonContractOutputSchema,
CommonContractSchema,
Expand All @@ -10,7 +10,7 @@ import {
CommonTrustedForwarderSchema,
MerkleSchema,
} from "./common";
import { FileOrBufferOrStringSchema, JsonSchema } from "@thirdweb-dev/storage";
import { FileOrBufferOrStringSchema } from "@thirdweb-dev/storage";
import { BigNumberish } from "ethers";
import { z } from "zod";

Expand Down
12 changes: 12 additions & 0 deletions packages/sdk/src/schema/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ export const PercentSchema = z
.max(100, "Cannot exeed 100%")
.min(0, "Cannot be below 0%");

export const JsonLiteral = z.union([
z.string(),
z.number(),
z.boolean(),
z.null(),
]);

export const JsonSchema: z.ZodSchema<Json> = z.lazy(() =>
z.union([JsonLiteral, z.array(JsonSchema), z.record(JsonSchema)]),
);
export const JsonObjectSchema = z.record(JsonSchema);

export const HexColor = z.union([
z
.string()
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/schema/tokens/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumberSchema, HexColor } from "../../shared";
import { BigNumberSchema, HexColor, JsonSchema } from "../../shared";
import { OptionalPropertiesInput } from "./properties";
import { FileOrBufferOrStringSchema, JsonSchema } from "@thirdweb-dev/storage";
import { FileOrBufferOrStringSchema } from "@thirdweb-dev/storage";
import { z } from "zod";

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/schema/tokens/common/properties.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { JsonObjectSchema } from "@thirdweb-dev/storage";
import { JsonObjectSchema } from "../../shared";
import { z } from "zod";

/**
Expand Down
1 change: 1 addition & 0 deletions packages/storage/src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const JsonSchema: z.ZodType<Json> = z.lazy(() =>
JsonObjectSchema,
FileOrBufferSchema,
z.array(JsonSchema),
z.record(JsonSchema),
]),
);

Expand Down