Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 src/schema/contracts/common/airdrop.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { z } from "zod";
import { AddressSchema, PriceSchema } from "../../shared";
import { AddressSchema, AirdropQuantitySchema } from "../../shared";

/**
* @internal
*/
export const AirdropAddressInput = z.object({
address: AddressSchema,
quantity: PriceSchema.default(1),
quantity: AirdropQuantitySchema.default(1),
});

/**
Expand Down
7 changes: 7 additions & 0 deletions src/schema/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ export const RawDateSchema = z.date().transform((i) => {
return BigNumber.from(Math.floor(i.getTime() / 1000));
});

export const AirdropQuantitySchema = z
Copy link
Member

Choose a reason for hiding this comment

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

I think we already have an alias for Price that is "Amount" - can you use that instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not sure what you mean here, I added this because I realized the error message for airdrop when invalid quantity was wrong

Copy link
Member

Choose a reason for hiding this comment

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

lets just call this AmountSchema and use it for the Amount type

.union([
z.string().regex(/^([0-9]+\.?[0-9]*|\.[0-9]+)$/, "Invalid quantity"),
z.number().min(0, "Quantity cannot be negative"),
])
.transform((arg) => (typeof arg === "number" ? arg.toString() : arg));

/**
* Default to now
*/
Expand Down