Skip to content

Commit

Permalink
add optional hasValidAffiliate param to getTotalMintPriceAndFees to s…
Browse files Browse the repository at this point in the history
…how accurate affiliateFee
  • Loading branch information
vigneshka committed Dec 28, 2023
1 parent a8eb762 commit 620d9e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/strange-toes-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soundxyz/sdk': patch
---

add optional hasValidAffiliate param to getTotalMintPriceAndFees to show accurate affiliateFee
14 changes: 9 additions & 5 deletions packages/sdk/src/contract/edition-v2/read/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export type GetTotalMintPriceAndFeesParams = {
tier: number
scheduleNum: number
quantity: number

editionAddress: Address
hasValidAffiliate?: boolean
}

export type GetTotalMintPriceAndFeesReturnType = {
Expand Down Expand Up @@ -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 extends Pick<PublicClient, 'readContract' | 'multicall'>>(
client: Client,
{ tier, scheduleNum, quantity, editionAddress }: GetTotalMintPriceAndFeesParams,
{ tier, scheduleNum, quantity, editionAddress, hasValidAffiliate }: GetTotalMintPriceAndFeesParams,
): Promise<GetTotalMintPriceAndFeesReturnType> {
const superMinter = await getSuperMinterForEdition(client, { editionAddress })

Expand All @@ -69,7 +69,11 @@ export async function getTotalMintPriceAndFees<Client extends Pick<PublicClient,
functionName: 'totalPriceAndFees',
args: [editionAddress, tier, scheduleNum, quantity],
})
.then((res) => ({ ...res, version: superMinter.version }))
.then((res) => ({
...res,
affiliateFee: !!hasValidAffiliate ? res.affiliateFee : 0n,
version: superMinter.version,
}))
}

case '2': {
Expand All @@ -79,7 +83,7 @@ export async function getTotalMintPriceAndFees<Client extends Pick<PublicClient,
abi,
address,
functionName: 'totalPriceAndFees',
args: [editionAddress, tier, scheduleNum, quantity, false],
args: [editionAddress, tier, scheduleNum, quantity, !!hasValidAffiliate],
})
.then((res) => ({ ...res, version: superMinter.version }))
}
Expand Down

0 comments on commit 620d9e1

Please sign in to comment.