Skip to content

Commit

Permalink
feat(utils): upgrade mint action params to support more numerical typ…
Browse files Browse the repository at this point in the history
…es, and operators
  • Loading branch information
sammccord committed Aug 10, 2024
1 parent fbacef3 commit db90b70
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/ninety-stingrays-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rabbitholegg/questdk-plugin-utils": minor
---

Upgrade Mint action schema to support numeric operator types
23 changes: 21 additions & 2 deletions packages/utils/src/types/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export type MintActionParams = {
chainId: number
contractAddress: Address
tokenId?: number
amount?: number | FilterOperator
amount?: number | string | bigint | FilterOperator
recipient?: Address
referral?: Address
}
Expand Down Expand Up @@ -215,11 +215,30 @@ export const MintActionFormSchema = z.object({
amountOperator: QuestInputActionParamsAmountOperatorEnum.optional(),
})

export const NumericSchema = z.union([z.bigint(), z.string(), z.number()])
export const AmountSchema = z.union([
z.bigint(),
z.number(),
z.string(),
z.object({
$gt: NumericSchema.optional(),
}),
z.object({
$gte: NumericSchema.optional(),
}),
z.object({
$lt: NumericSchema.optional(),
}),
z.object({
$lte: NumericSchema.optional(),
}),
])

export const MintActionDetailSchema = z.object({
chainId: z.number(),
contractAddress: EthAddressSchema,
tokenId: z.number().optional(),
amount: z.string().optional(),
amount: AmountSchema,
amountOperator: QuestInputActionParamsAmountOperatorEnum.optional(),
})

Expand Down
8 changes: 4 additions & 4 deletions packages/utils/src/types/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ export type NumericOperator =
| number
| string
| {
$gt?: bigint
$gt?: bigint | string | number;
}
| {
$gte?: bigint
$gte?: bigint | string | number;
}
| {
$lt?: bigint
$lt?: bigint | string | number;
}
| {
$lte?: bigint
$lte?: bigint | string | number;
}

export type StringOperator = {
Expand Down

0 comments on commit db90b70

Please sign in to comment.