Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exported return type for GetTotalMintPriceAndFeesReturnType #305

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading