Skip to content

Commit

Permalink
Merge pull request #508 from rabbitholegg/sam/boost-4428-update-quest…
Browse files Browse the repository at this point in the history
…dk-utils-to-support-numerical-operators-in-mint

feat(utils): upgrade mint action params to support more numerical types, and operators
  • Loading branch information
sammccord authored Aug 12, 2024
2 parents fbacef3 + 665ea02 commit 0017121
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 0017121

Please sign in to comment.