Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(frontend): Use Zod for Network type #3251

Merged
Merged
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
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(),
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR but, should we be a bit more expressive on the type of the icons?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, define the type of string for icons, I will have a look

Copy link
Collaborator

Choose a reason for hiding this comment

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

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