From db90b70005b9010e85759be200e19b34b783d9f8 Mon Sep 17 00:00:00 2001 From: Sam McCord Date: Fri, 9 Aug 2024 18:11:58 -0600 Subject: [PATCH 1/2] feat(utils): upgrade mint action params to support more numerical types, and operators --- .changeset/ninety-stingrays-destroy.md | 5 +++++ packages/utils/src/types/actions.ts | 23 +++++++++++++++++++++-- packages/utils/src/types/filters.ts | 8 ++++---- 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 .changeset/ninety-stingrays-destroy.md diff --git a/.changeset/ninety-stingrays-destroy.md b/.changeset/ninety-stingrays-destroy.md new file mode 100644 index 000000000..b7e311c7c --- /dev/null +++ b/.changeset/ninety-stingrays-destroy.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-utils": minor +--- + +Upgrade Mint action schema to support numeric operator types diff --git a/packages/utils/src/types/actions.ts b/packages/utils/src/types/actions.ts index 6e8a0a8cc..a23641308 100644 --- a/packages/utils/src/types/actions.ts +++ b/packages/utils/src/types/actions.ts @@ -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 } @@ -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(), }) diff --git a/packages/utils/src/types/filters.ts b/packages/utils/src/types/filters.ts index defcce7d0..b9fcf5709 100644 --- a/packages/utils/src/types/filters.ts +++ b/packages/utils/src/types/filters.ts @@ -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 = { From 665ea02476f3b28f4ce5810ed5e1aa4c40dcba58 Mon Sep 17 00:00:00 2001 From: sammccord Date: Sat, 10 Aug 2024 00:36:34 +0000 Subject: [PATCH 2/2] chore: format --- packages/utils/src/types/filters.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/utils/src/types/filters.ts b/packages/utils/src/types/filters.ts index b9fcf5709..ed483f49f 100644 --- a/packages/utils/src/types/filters.ts +++ b/packages/utils/src/types/filters.ts @@ -27,16 +27,16 @@ export type NumericOperator = | number | string | { - $gt?: bigint | string | number; + $gt?: bigint | string | number } | { - $gte?: bigint | string | number; + $gte?: bigint | string | number } | { - $lt?: bigint | string | number; + $lt?: bigint | string | number } | { - $lte?: bigint | string | number; + $lte?: bigint | string | number } export type StringOperator = {