From 620d9e1a9a6178a8019d060e04e7c66c0c3cc233 Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Thu, 28 Dec 2023 15:31:33 -0500 Subject: [PATCH] add optional hasValidAffiliate param to getTotalMintPriceAndFees to show accurate affiliateFee --- .changeset/strange-toes-collect.md | 5 +++++ packages/sdk/src/contract/edition-v2/read/mint.ts | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .changeset/strange-toes-collect.md diff --git a/.changeset/strange-toes-collect.md b/.changeset/strange-toes-collect.md new file mode 100644 index 00000000..d2731cf2 --- /dev/null +++ b/.changeset/strange-toes-collect.md @@ -0,0 +1,5 @@ +--- +'@soundxyz/sdk': patch +--- + +add optional hasValidAffiliate param to getTotalMintPriceAndFees to show accurate affiliateFee diff --git a/packages/sdk/src/contract/edition-v2/read/mint.ts b/packages/sdk/src/contract/edition-v2/read/mint.ts index 55e51e07..8f892f39 100644 --- a/packages/sdk/src/contract/edition-v2/read/mint.ts +++ b/packages/sdk/src/contract/edition-v2/read/mint.ts @@ -11,8 +11,8 @@ export type GetTotalMintPriceAndFeesParams = { tier: number scheduleNum: number quantity: number - editionAddress: Address + hasValidAffiliate?: boolean } export type GetTotalMintPriceAndFeesReturnType = { @@ -48,14 +48,14 @@ export type GetTotalMintPriceAndFeesReturnType = { finalArtistFee: bigint /** The total platform fees. */ finalAffiliateFee: bigint - /** The total platform fees. */ + /** The total affiliate fees. */ finalPlatformFee: bigint } ) export async function getTotalMintPriceAndFees>( client: Client, - { tier, scheduleNum, quantity, editionAddress }: GetTotalMintPriceAndFeesParams, + { tier, scheduleNum, quantity, editionAddress, hasValidAffiliate }: GetTotalMintPriceAndFeesParams, ): Promise { const superMinter = await getSuperMinterForEdition(client, { editionAddress }) @@ -69,7 +69,11 @@ export async function getTotalMintPriceAndFees ({ ...res, version: superMinter.version })) + .then((res) => ({ + ...res, + affiliateFee: !!hasValidAffiliate ? res.affiliateFee : 0n, + version: superMinter.version, + })) } case '2': { @@ -79,7 +83,7 @@ export async function getTotalMintPriceAndFees ({ ...res, version: superMinter.version })) }