diff --git a/.changeset/rare-cats-change.md b/.changeset/rare-cats-change.md new file mode 100644 index 000000000..6ef4c243c --- /dev/null +++ b/.changeset/rare-cats-change.md @@ -0,0 +1,10 @@ +--- +"@rabbitholegg/questdk-plugin-foundation": patch +"@rabbitholegg/questdk-plugin-soundxyz": patch +"@rabbitholegg/questdk-plugin-thirdweb": patch +"@rabbitholegg/questdk-plugin-utils": patch +"@rabbitholegg/questdk-plugin-pods": patch +"@rabbitholegg/questdk-plugin-zora": patch +--- + +change name of amount utils to be more descriptive diff --git a/packages/foundation/src/Foundation.ts b/packages/foundation/src/Foundation.ts index 43f1515eb..94c22ebf7 100644 --- a/packages/foundation/src/Foundation.ts +++ b/packages/foundation/src/Foundation.ts @@ -24,8 +24,8 @@ import { import { Chains, DEFAULT_ACCOUNT, - formatAmount, - getMintAmount, + formatAmountToFilterOperator, + formatAmountToInteger, type MintIntentParams, chainIdToViemChain, } from '@rabbitholegg/questdk-plugin-utils' @@ -70,7 +70,7 @@ export const mint = async ( { // 721 $abi: [...FIXED_PRICE_FRAGMENTS, DUTCH_AUCTION_FRAGMENT], - count: formatAmount(amount), + count: formatAmountToFilterOperator(amount), nftContract: contractAddress, nftRecipient: recipient, buyReferrer: referral, @@ -81,7 +81,7 @@ export const mint = async ( multiTokenCollection: contractAddress, tokenRecipient: recipient, tokenQuantities: { - $some: { tokenId, quantity: formatAmount(amount) }, + $some: { tokenId, quantity: formatAmountToFilterOperator(amount) }, }, referrer: referral, }, @@ -108,7 +108,7 @@ export const getFees = async ( }) as PublicClient const contractType = await getContractType(client, contractAddress) - const quantityToMint = getMintAmount(amount) + const quantityToMint = formatAmountToInteger(amount) if (contractType === '721') { const dropFactoryAddress = CHAIN_TO_CONTRACT_ADDRESS[chainId] @@ -178,7 +178,7 @@ export const getMintIntent = async ( }) as PublicClient const contractType = await getContractType(client, contractAddress) - const mintAmount = getMintAmount(amount) + const mintAmount = formatAmountToInteger(amount) if (contractType === '721') { const dropFactoryAddress = CHAIN_TO_CONTRACT_ADDRESS[chainId] @@ -286,7 +286,7 @@ export const simulateMint = async ( const contractType = await getContractType(_client, contractAddress) - const mintAmount = getMintAmount(amount) + const mintAmount = formatAmountToInteger(amount) if (contractType === '721') { if (tokenId) { diff --git a/packages/pods/src/Pods.ts b/packages/pods/src/Pods.ts index 5073cf963..ae1ff9471 100644 --- a/packages/pods/src/Pods.ts +++ b/packages/pods/src/Pods.ts @@ -14,8 +14,8 @@ import { type MintIntentParams, chainIdToViemChain, getExitAddresses, - formatAmount, - getMintAmount, + formatAmountToFilterOperator, + formatAmountToInteger, } from '@rabbitholegg/questdk-plugin-utils' import { http, @@ -38,7 +38,7 @@ export const mint = async ( const andArray1155: AndArrayItem[] = [ { - quantity: formatAmount(amount), + quantity: formatAmountToFilterOperator(amount), }, ] if (referral) { @@ -161,7 +161,7 @@ export const getFees = async ( mint: MintActionParams, ): Promise<{ actionFee: bigint; projectFee: bigint }> => { const { chainId, contractAddress, tokenId, amount } = mint - const quantityToMint = getMintAmount(amount) + const quantityToMint = formatAmountToInteger(amount) try { const client = createPublicClient({ chain: chainIdToViemChain(chainId), diff --git a/packages/soundxyz/src/Soundxyz.ts b/packages/soundxyz/src/Soundxyz.ts index 303027412..42509f019 100644 --- a/packages/soundxyz/src/Soundxyz.ts +++ b/packages/soundxyz/src/Soundxyz.ts @@ -25,8 +25,8 @@ import { type MintIntentParams, chainIdToViemChain, getExitAddresses, - formatAmount, - getMintAmount, + formatAmountToFilterOperator, + formatAmountToInteger, } from '@rabbitholegg/questdk-plugin-utils' import { type Address, @@ -53,7 +53,7 @@ export const mint = async ( $abiAbstract: SUPERMINTER_V2_ABI, p: { edition: contractAddress, - quantity: formatAmount(amount), + quantity: formatAmountToFilterOperator(amount), tier: tokenId, to: recipient, // Can be given as gift, so recipient will not always match sender affiliate: referral, @@ -67,7 +67,7 @@ export const getMintIntent = async ( ): Promise => { const { contractAddress, recipient, tokenId, amount } = mint const tier = await getDefaultMintTier(mint.chainId, contractAddress, tokenId) - const quantity = getMintAmount(amount) + const quantity = formatAmountToInteger(amount) const mintTo = { edition: contractAddress, @@ -119,7 +119,7 @@ export const simulateMint = async ( tokenId, _client, ) - const quantity = getMintAmount(amount) + const quantity = formatAmountToInteger(amount) const mintTo = { edition: contractAddress, @@ -186,7 +186,7 @@ export const getFees = async ( tokenId, client, ) - const quantity = getMintAmount(amount) + const quantity = formatAmountToInteger(amount) try { const totalPriceAndFees = (await client.readContract({ diff --git a/packages/thirdweb/src/ThirdWeb.ts b/packages/thirdweb/src/ThirdWeb.ts index 9101f2403..d218e46f0 100644 --- a/packages/thirdweb/src/ThirdWeb.ts +++ b/packages/thirdweb/src/ThirdWeb.ts @@ -18,8 +18,8 @@ import { DEFAULT_ACCOUNT, type MintActionParams, type MintIntentParams, - formatAmount, - getMintAmount, + formatAmountToFilterOperator, + formatAmountToInteger, } from '@rabbitholegg/questdk-plugin-utils' import { type Address, @@ -38,13 +38,13 @@ export const mint = async ( const Erc721Filter = { $abi: [CLAIM_721_FRAGMENT], _receiver: recipient, - _quantity: formatAmount(amount), + _quantity: formatAmountToFilterOperator(amount), } const Erc1155Filter = { $abi: [CLAIM_1155_FRAGMENT], _receiver: recipient, - _quantity: formatAmount(amount), + _quantity: formatAmountToFilterOperator(amount), _tokenId: tokenId, } @@ -66,7 +66,7 @@ export const getFees = async ( mint: MintActionParams, ): Promise<{ actionFee: bigint; projectFee: bigint }> => { const { chainId, contractAddress, amount, tokenId } = mint - const quantityToMint = getMintAmount(amount) + const quantityToMint = formatAmountToInteger(amount) const client = getClient(chainId) try { @@ -138,7 +138,7 @@ export const simulateMint = async ( const mintArgs = [ recipient, tokenId ?? 0n, - getMintAmount(amount), + formatAmountToInteger(amount), claimCondition.currency, value, [ @@ -174,7 +174,7 @@ export const simulateMint = async ( const mintArgs = [ recipient, - getMintAmount(amount), + formatAmountToInteger(amount), claimCondition.currency, value, [ diff --git a/packages/utils/src/helpers/index.ts b/packages/utils/src/helpers/index.ts index 683509400..e9a35069a 100644 --- a/packages/utils/src/helpers/index.ts +++ b/packages/utils/src/helpers/index.ts @@ -2,4 +2,7 @@ export { createTestCase } from './test-helpers' export type { TestCase, TestParams } from './test-helpers' export { chainIdToViemChain } from './chain-id-to-viem-chain' export { getExitAddresses } from './get-exit-addresses' -export { formatAmount, getMintAmount } from './mint-amount' +export { + formatAmountToFilterOperator, + formatAmountToInteger, +} from './mint-amount' diff --git a/packages/utils/src/helpers/mint-amount.ts b/packages/utils/src/helpers/mint-amount.ts index 81901231d..1996bd4e1 100644 --- a/packages/utils/src/helpers/mint-amount.ts +++ b/packages/utils/src/helpers/mint-amount.ts @@ -1,6 +1,6 @@ import { FilterOperator } from '../types' -export function formatAmount( +export function formatAmountToFilterOperator( amount: FilterOperator | undefined, ): FilterOperator { if (!amount || (typeof amount === 'string' && isNaN(Number(amount)))) { @@ -17,8 +17,8 @@ export function formatAmount( return amount } -export function getMintAmount(amount: FilterOperator | undefined) { - if (!amount) { +export function formatAmountToInteger(amount: FilterOperator | undefined) { + if (!amount || amount === '0') { return 1n } // If the amount is a primitive, pass that value through diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 9d85f4f5d..ff9c6ca80 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -12,8 +12,8 @@ export { chainIdToViemChain, createTestCase, getExitAddresses, - formatAmount, - getMintAmount, + formatAmountToFilterOperator, + formatAmountToInteger, } from './helpers' export type { IntentParams, diff --git a/packages/zora/src/Zora.ts b/packages/zora/src/Zora.ts index 5ba576c4c..ce775b4d2 100644 --- a/packages/zora/src/Zora.ts +++ b/packages/zora/src/Zora.ts @@ -19,7 +19,7 @@ import { type TransactionFilter, compressJson, } from '@rabbitholegg/questdk' -import { formatAmount } from '@rabbitholegg/questdk-plugin-utils' +import { formatAmountToFilterOperator } from '@rabbitholegg/questdk-plugin-utils' import { ActionType, Chains, @@ -110,7 +110,7 @@ export const mint = async ( : contractAddress const quantityCheck = { - quantity: formatAmount(amount), + quantity: formatAmountToFilterOperator(amount), } const andArray721: AndArrayItem[] = [quantityCheck] const andArray1155: AndArrayItem[] = [quantityCheck]