From ec1946e589af81f792f361234fbe095cab7a8a16 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 9 Jul 2024 21:38:24 -0700 Subject: [PATCH 1/3] feat(utils): update formatAmount function to use a 1 mint default --- packages/utils/src/helpers/mint-amount.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/utils/src/helpers/mint-amount.ts b/packages/utils/src/helpers/mint-amount.ts index ead380700..172c8c654 100644 --- a/packages/utils/src/helpers/mint-amount.ts +++ b/packages/utils/src/helpers/mint-amount.ts @@ -1,11 +1,17 @@ import { FilterOperator } from '../types' -export function formatAmount(amount: FilterOperator | undefined) { - if (amount === undefined) { - return undefined +export function formatAmount( + amount: FilterOperator | undefined, +): FilterOperator { + if (!amount) { + return { $gte: 1n } } - if (amount && ['string', 'number', 'bigint'].includes(typeof amount)) { - return { $gte: amount } + if ( + typeof amount === 'string' || + typeof amount === 'number' || + typeof amount === 'bigint' + ) { + return { $gte: BigInt(amount) } } return amount From 0f1bcea608e9ecc9de9f6f1920e7962264a2ebf7 Mon Sep 17 00:00:00 2001 From: mmackz Date: Tue, 9 Jul 2024 21:40:06 -0700 Subject: [PATCH 2/3] chore: generate changeset --- .changeset/stale-horses-argue.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stale-horses-argue.md diff --git a/.changeset/stale-horses-argue.md b/.changeset/stale-horses-argue.md new file mode 100644 index 000000000..9a58ee5b4 --- /dev/null +++ b/.changeset/stale-horses-argue.md @@ -0,0 +1,5 @@ +--- +"@rabbitholegg/questdk-plugin-utils": minor +--- + +update for token zero fix From 80dd152d7b1abdfd8991f57a22fbb82119074791 Mon Sep 17 00:00:00 2001 From: mmackz Date: Wed, 10 Jul 2024 11:19:02 -0700 Subject: [PATCH 3/3] feat(utils): improve formatAmount function to handle invalid input --- packages/utils/src/helpers/mint-amount.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/utils/src/helpers/mint-amount.ts b/packages/utils/src/helpers/mint-amount.ts index 172c8c654..81901231d 100644 --- a/packages/utils/src/helpers/mint-amount.ts +++ b/packages/utils/src/helpers/mint-amount.ts @@ -3,7 +3,7 @@ import { FilterOperator } from '../types' export function formatAmount( amount: FilterOperator | undefined, ): FilterOperator { - if (!amount) { + if (!amount || (typeof amount === 'string' && isNaN(Number(amount)))) { return { $gte: 1n } } if (