Skip to content

Commit

Permalink
feat(frontend): Use Zod for Network type (#3251)
Browse files Browse the repository at this point in the history
# Motivation

We change `Network` type to use Zod directly.
  • Loading branch information
AntonioVentilii-DFINITY authored Oct 31, 2024
1 parent 56547d0 commit 58b9d12
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/frontend/src/lib/types/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ const NetworkAppMetadataSchema = z.object({
explorerUrl: UrlSchema
});

const NetworkSchema = z.object({
id: NetworkIdSchema,
env: NetworkEnvironmentSchema,
name: z.string(),
icon: z.string().optional(),
iconBW: z.string().optional(),
buy: z.custom<AtLeastOne<NetworkBuy>>().optional()
});

export type NetworkId = z.infer<typeof NetworkIdSchema>;

export type NetworkEnvironment = z.infer<typeof NetworkEnvironmentSchema>;

export interface Network {
id: NetworkId;
env: NetworkEnvironment;
name: string;
icon?: string;
iconBW?: string;
buy?: AtLeastOne<NetworkBuy>;
}
export type Network = z.infer<typeof NetworkSchema>;

export type NetworkBuy = z.infer<typeof NetworkBuySchema>;

Expand Down

0 comments on commit 58b9d12

Please sign in to comment.