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

the zodSchema field to construct other types #214

Open
keyp-dev opened this issue Jul 15, 2024 · 0 comments
Open

the zodSchema field to construct other types #214

keyp-dev opened this issue Jul 15, 2024 · 0 comments

Comments

@keyp-dev
Copy link

Lost all types

export const TransferTokenEVMSchema = z.object({
  tokenContract: AddressSchema,
  tokenId: z.string(),
  to: AddressSchema,
  deadline: z.string(),
  v: z.string(),
  r: AddressSchema,
  s: AddressSchema,
  type: z.enum(['ERC721', 'ERC1155']),
  amount: z.string().nullish(),
});

export type TransferTokenEVM = z.infer<typeof TransferTokenEVMSchema>;

export const TransferTokenSUISchema = z.object({
  tokenContract: AddressSchema,
  tokenId: z.string(),
  from: AddressSchema,
  to: AddressSchema,
  bcs: z.number().array(),
  customSign: z.string(),
  typeArguments: z.string().array(),
});

export type TransferTokenSUI = z.infer<typeof TransferTokenSUISchema>;

export const TransferTokenSchema = z.union([
  TransferTokenEVMSchema,
  TransferTokenSUISchema,
]);

class TransferTokenRequest extends createZodDto(TransferTokenSchema) {}

Lost artwork type

export const CreateGiftBoxParamsSchema = z
  .object({
    task_id: z.string().uuid().optional(),
    owner: z.string().email(),
    first_name: z.string(),
    last_name: z.string(),
    note_subject: z.string(),
    signature: z.string(),
    message: z.string(),
    message_bless: z.string().optional(),
    wrapping: z.string(),
    artwork: CreateArtworkSchema,
  })
  .merge(ParamsForEventTransactionSchema)
  .merge(LoginAndChainSchema);

export type CreateGiftBoxParams = z.infer<typeof CreateGiftBoxParamsSchema>;


class CreateGiftBoxRequest extends createZodDto(
  CreateGiftBoxParamsSchema.omit({
    chainName: true,
    login: true,
    event: true,
  }).merge(
    z.object({
      event: z.object({
        transaction_hash: z.string(),
      }),
    }),
  ),
) {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant