From 50dae27b5a354b50f09b1174b0c6fed23f26e9bf Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Thu, 28 Dec 2023 12:29:28 -0500 Subject: [PATCH 1/2] Add exported return type for GetTotalMintPriceAndFeesReturnType --- .changeset/afraid-cameras-crash.md | 5 ++ .../sdk/src/contract/edition-v2/read/mint.ts | 66 ++++++++++++------- 2 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 .changeset/afraid-cameras-crash.md diff --git a/.changeset/afraid-cameras-crash.md b/.changeset/afraid-cameras-crash.md new file mode 100644 index 00000000..8a9d19fb --- /dev/null +++ b/.changeset/afraid-cameras-crash.md @@ -0,0 +1,5 @@ +--- +'@soundxyz/sdk': patch +--- + +Add exported return type for GetTotalMintPriceAndFeesReturnType diff --git a/packages/sdk/src/contract/edition-v2/read/mint.ts b/packages/sdk/src/contract/edition-v2/read/mint.ts index dce4f9f0..6ad5ce35 100644 --- a/packages/sdk/src/contract/edition-v2/read/mint.ts +++ b/packages/sdk/src/contract/edition-v2/read/mint.ts @@ -15,34 +15,52 @@ export type GetTotalMintPriceAndFeesParams = { editionAddress: Address } -export type GetTotalMintPriceAndFeesReturnType = { - // The required Ether value. - // `subTotal + platformFlatFee`. - total: bigint - // The total price before any additive fees. - subTotal: bigint - // 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 -} +export type GetTotalMintPriceAndFeesReturnType = + | { + // SuperMinterV1 + version: '1' + // The required Ether value. + total: bigint + // The total price before any additive fees. + subTotal: bigint + // 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 + } + | { + // SuperMinterV2 + version: '2' + // The required Ether value. + total: bigint + // The total price before any additive fees. + subTotal: bigint + // The price per token. + unitPrice: bigint + // The total artist fees. + finalArtistFee: bigint + // The total platform fees. + finalAffiliateFee: bigint + // The total platform fees. + finalPlatformFee: bigint + } export async function getTotalMintPriceAndFees>( client: Client, { tier, scheduleNum, quantity, editionAddress }: GetTotalMintPriceAndFeesParams, -) { +): Promise { const superMinter = await getSuperMinterForEdition(client, { editionAddress }) switch (superMinter.version) { From 3205545d09b11863eaf22b94632971b132bd33ac Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Thu, 28 Dec 2023 12:37:33 -0500 Subject: [PATCH 2/2] improve --- .../sdk/src/contract/edition-v2/read/mint.ts | 48 +++++++++---------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/packages/sdk/src/contract/edition-v2/read/mint.ts b/packages/sdk/src/contract/edition-v2/read/mint.ts index 6ad5ce35..55e51e07 100644 --- a/packages/sdk/src/contract/edition-v2/read/mint.ts +++ b/packages/sdk/src/contract/edition-v2/read/mint.ts @@ -15,47 +15,43 @@ export type GetTotalMintPriceAndFeesParams = { editionAddress: Address } -export type GetTotalMintPriceAndFeesReturnType = +export type GetTotalMintPriceAndFeesReturnType = { + /** The required Ether value. */ + total: bigint + /** The total price before any additive fees. */ + subTotal: bigint + /** The price per token. */ + unitPrice: bigint +} & ( | { - // SuperMinterV1 + /** SuperMinterV1 */ version: '1' - // The required Ether value. - total: bigint - // The total price before any additive fees. - subTotal: bigint - // The price per token. - unitPrice: bigint - // The total platform fees. - // `platformFlatFee + platformMintBPSFee`. + /** The total platform fees. + `platformFlatFee + platformMintBPSFee`. */ platformFee: bigint - // The total platform flat fees. - // `platformTxFlatFee + platformMintFlatFee`. + /** The total platform flat fees. + `platformTxFlatFee + platformMintFlatFee`. */ platformFlatFee: bigint - // The platform per-transaction flat fees. + /** The platform per-transaction flat fees. */ platformTxFlatFee: bigint - // The total platform per-token flat fees. + /** The total platform per-token flat fees. */ platformMintFlatFee: bigint - // The total platform per-token BPS fees. + /** The total platform per-token BPS fees. */ platformMintBPSFee: bigint - // The total affiliate fees. + /** The total affiliate fees. */ affiliateFee: bigint } | { - // SuperMinterV2 + /** SuperMinterV2 */ version: '2' - // The required Ether value. - total: bigint - // The total price before any additive fees. - subTotal: bigint - // The price per token. - unitPrice: bigint - // The total artist fees. + /** The total artist fees. */ finalArtistFee: bigint - // The total platform fees. + /** The total platform fees. */ finalAffiliateFee: bigint - // The total platform fees. + /** The total platform fees. */ finalPlatformFee: bigint } +) export async function getTotalMintPriceAndFees>( client: Client,