Skip to content

Commit

Permalink
Add exported return type for GetTotalMintPriceAndFeesReturnType (#305)
Browse files Browse the repository at this point in the history
* Add exported return type for GetTotalMintPriceAndFeesReturnType

* improve
  • Loading branch information
vigneshka committed Dec 28, 2023
1 parent 23e48a8 commit 6074901
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 20 deletions.
5 changes: 5 additions & 0 deletions .changeset/afraid-cameras-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@soundxyz/sdk': patch
---

Add exported return type for GetTotalMintPriceAndFeesReturnType
54 changes: 34 additions & 20 deletions packages/sdk/src/contract/edition-v2/read/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,47 @@ export type GetTotalMintPriceAndFeesParams = {
}

export type GetTotalMintPriceAndFeesReturnType = {
// The required Ether value.
// `subTotal + platformFlatFee`.
/** The required Ether value. */
total: bigint
// The total price before any additive fees.
/** The total price before any additive fees. */
subTotal: bigint
// The price per token.
/** The price per token. */
unitPrice: bigint
// The total platform fees.
// `platformFlatFee + platformMintBPSFee`.
platformFee: bigint
// The total platform flat fees.
// `platformTxFlatFee + platformMintFlatFee`.
platformFlatFee: bigint
// The platform per-transaction flat fees.
platformTxFlatFee: bigint
// The total platform per-token flat fees.
platformMintFlatFee: bigint
// The total platform per-token BPS fees.
platformMintBPSFee: bigint
// The total affiliate fees.
affiliateFee: bigint
}
} & (
| {
/** SuperMinterV1 */
version: '1'
/** The total platform fees.
`platformFlatFee + platformMintBPSFee`. */
platformFee: bigint
/** The total platform flat fees.
`platformTxFlatFee + platformMintFlatFee`. */
platformFlatFee: bigint
/** The platform per-transaction flat fees. */
platformTxFlatFee: bigint
/** The total platform per-token flat fees. */
platformMintFlatFee: bigint
/** The total platform per-token BPS fees. */
platformMintBPSFee: bigint
/** The total affiliate fees. */
affiliateFee: bigint
}
| {
/** SuperMinterV2 */
version: '2'
/** The total artist fees. */
finalArtistFee: bigint
/** The total platform fees. */
finalAffiliateFee: bigint
/** The total platform fees. */
finalPlatformFee: bigint
}
)

export async function getTotalMintPriceAndFees<Client extends Pick<PublicClient, 'readContract' | 'multicall'>>(
client: Client,
{ tier, scheduleNum, quantity, editionAddress }: GetTotalMintPriceAndFeesParams,
) {
): Promise<GetTotalMintPriceAndFeesReturnType> {
const superMinter = await getSuperMinterForEdition(client, { editionAddress })

switch (superMinter.version) {
Expand Down

0 comments on commit 6074901

Please sign in to comment.