Skip to content

Commit 19d6b92

Browse files
authored
add optional hasValidAffiliate param to getTotalMintPriceAndFees to s… (#307)
add optional hasValidAffiliate param to getTotalMintPriceAndFees to show accurate affiliateFee
1 parent a8eb762 commit 19d6b92

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

.changeset/strange-toes-collect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@soundxyz/sdk': patch
3+
---
4+
5+
add optional hasValidAffiliate param to getTotalMintPriceAndFees to show accurate affiliateFee

packages/sdk/src/contract/edition-v2/read/mint.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export type GetTotalMintPriceAndFeesParams = {
1111
tier: number
1212
scheduleNum: number
1313
quantity: number
14-
1514
editionAddress: Address
15+
hasValidAffiliate?: boolean
1616
}
1717

1818
export type GetTotalMintPriceAndFeesReturnType = {
@@ -48,14 +48,14 @@ export type GetTotalMintPriceAndFeesReturnType = {
4848
finalArtistFee: bigint
4949
/** The total platform fees. */
5050
finalAffiliateFee: bigint
51-
/** The total platform fees. */
51+
/** The total affiliate fees. */
5252
finalPlatformFee: bigint
5353
}
5454
)
5555

5656
export async function getTotalMintPriceAndFees<Client extends Pick<PublicClient, 'readContract' | 'multicall'>>(
5757
client: Client,
58-
{ tier, scheduleNum, quantity, editionAddress }: GetTotalMintPriceAndFeesParams,
58+
{ tier, scheduleNum, quantity, editionAddress, hasValidAffiliate }: GetTotalMintPriceAndFeesParams,
5959
): Promise<GetTotalMintPriceAndFeesReturnType> {
6060
const superMinter = await getSuperMinterForEdition(client, { editionAddress })
6161

@@ -69,7 +69,11 @@ export async function getTotalMintPriceAndFees<Client extends Pick<PublicClient,
6969
functionName: 'totalPriceAndFees',
7070
args: [editionAddress, tier, scheduleNum, quantity],
7171
})
72-
.then((res) => ({ ...res, version: superMinter.version }))
72+
.then((res) => ({
73+
...res,
74+
affiliateFee: !!hasValidAffiliate ? res.affiliateFee : 0n,
75+
version: superMinter.version,
76+
}))
7377
}
7478

7579
case '2': {
@@ -79,7 +83,7 @@ export async function getTotalMintPriceAndFees<Client extends Pick<PublicClient,
7983
abi,
8084
address,
8185
functionName: 'totalPriceAndFees',
82-
args: [editionAddress, tier, scheduleNum, quantity, false],
86+
args: [editionAddress, tier, scheduleNum, quantity, !!hasValidAffiliate],
8387
})
8488
.then((res) => ({ ...res, version: superMinter.version }))
8589
}

0 commit comments

Comments
 (0)