From 28d4d2af56de63646d0d83a062f50c47a923cd6b Mon Sep 17 00:00:00 2001 From: Vignesh Hirudayakanth Date: Thu, 14 Dec 2023 11:14:00 -0800 Subject: [PATCH] support SuperMinterV1_1 --- .changeset/four-weeks-fetch.md | 5 + .../{super-minter.ts => super-minter-v1.ts} | 9 +- .../edition-v2/abi/super-minter-v1_1.ts | 1061 +++++++++++++++++ .../src/contract/edition-v2/read/create.ts | 28 +- .../src/contract/edition-v2/read/helpers.ts | 51 + .../sdk/src/contract/edition-v2/read/info.ts | 20 +- .../src/contract/edition-v2/read/interface.ts | 17 - .../sdk/src/contract/edition-v2/read/mint.ts | 72 +- .../src/contract/edition-v2/write/create.ts | 2 +- .../sdk/src/contract/edition-v2/write/mint.ts | 6 +- packages/sdk/src/utils/cache-utils.ts | 12 + 11 files changed, 1185 insertions(+), 98 deletions(-) create mode 100644 .changeset/four-weeks-fetch.md rename packages/sdk/src/contract/edition-v2/abi/{super-minter.ts => super-minter-v1.ts} (99%) create mode 100644 packages/sdk/src/contract/edition-v2/abi/super-minter-v1_1.ts create mode 100644 packages/sdk/src/utils/cache-utils.ts diff --git a/.changeset/four-weeks-fetch.md b/.changeset/four-weeks-fetch.md new file mode 100644 index 00000000..0f065a0d --- /dev/null +++ b/.changeset/four-weeks-fetch.md @@ -0,0 +1,5 @@ +--- +'@soundxyz/sdk': minor +--- + +support SuperMinterV1_1 diff --git a/packages/sdk/src/contract/edition-v2/abi/super-minter.ts b/packages/sdk/src/contract/edition-v2/abi/super-minter-v1.ts similarity index 99% rename from packages/sdk/src/contract/edition-v2/abi/super-minter.ts rename to packages/sdk/src/contract/edition-v2/abi/super-minter-v1.ts index 3501299e..6f9e7571 100644 --- a/packages/sdk/src/contract/edition-v2/abi/super-minter.ts +++ b/packages/sdk/src/contract/edition-v2/abi/super-minter-v1.ts @@ -1,6 +1,6 @@ -export const SUPER_MINTER_ADDRESS = '0x0000000000CF4558c36229ac0026ee16D3aE35Cd' +export const SUPER_MINTER_V1_ADDRESS = '0x0000000000CF4558c36229ac0026ee16D3aE35Cd' -export const SUPER_MINTER_ABI = [ +export const SUPER_MINTER_V1_ABI = [ { inputs: [], name: 'CallerNotDelegated', type: 'error' }, { inputs: [], name: 'ExceedsMaxPerAccount', type: 'error' }, { inputs: [], name: 'ExceedsMintSupply', type: 'error' }, @@ -981,3 +981,8 @@ export const SUPER_MINTER_ABI = [ }, { stateMutability: 'payable', type: 'receive' }, ] as const + +export const SUPER_MINTER_V1 = { + address: SUPER_MINTER_V1_ADDRESS, + abi: SUPER_MINTER_V1_ABI, +} as const diff --git a/packages/sdk/src/contract/edition-v2/abi/super-minter-v1_1.ts b/packages/sdk/src/contract/edition-v2/abi/super-minter-v1_1.ts new file mode 100644 index 00000000..a815b922 --- /dev/null +++ b/packages/sdk/src/contract/edition-v2/abi/super-minter-v1_1.ts @@ -0,0 +1,1061 @@ +export const SUPER_MINTER_V1_1_ADDRESS = '0x4b6fdcbb545bb1737eba144625b66d491c65dc38' + +export const SUPER_MINTER_V1_1_ABI = [ + { inputs: [], name: 'CallerNotDelegated', type: 'error' }, + { inputs: [], name: 'ExceedsMaxPerAccount', type: 'error' }, + { inputs: [], name: 'ExceedsMintSupply', type: 'error' }, + { inputs: [], name: 'ExceedsSignedQuantity', type: 'error' }, + { inputs: [], name: 'InvalidAffiliate', type: 'error' }, + { inputs: [], name: 'InvalidAffiliateFeeBPS', type: 'error' }, + { inputs: [], name: 'InvalidMaxMintableRange', type: 'error' }, + { inputs: [], name: 'InvalidMerkleProof', type: 'error' }, + { inputs: [], name: 'InvalidMode', type: 'error' }, + { inputs: [], name: 'InvalidPlatformFeeBPS', type: 'error' }, + { inputs: [], name: 'InvalidPlatformFeeConfig', type: 'error' }, + { inputs: [], name: 'InvalidPlatformFlatFee', type: 'error' }, + { inputs: [], name: 'InvalidSignature', type: 'error' }, + { inputs: [], name: 'InvalidTimeRange', type: 'error' }, + { inputs: [], name: 'MaxMintableIsZero', type: 'error' }, + { inputs: [], name: 'MaxMintablePerAccountIsZero', type: 'error' }, + { inputs: [], name: 'MerkleRootIsEmpty', type: 'error' }, + { inputs: [], name: 'MintDoesNotExist', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'blockTimestamp', type: 'uint256' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { internalType: 'uint32', name: 'endTime', type: 'uint32' }, + ], + name: 'MintNotOpen', + type: 'error', + }, + { inputs: [], name: 'MintPaused', type: 'error' }, + { inputs: [], name: 'MintsAlreadyExist', type: 'error' }, + { inputs: [], name: 'NotConfigurable', type: 'error' }, + { inputs: [], name: 'PlatformFeeAddressIsZero', type: 'error' }, + { inputs: [], name: 'SignatureAlreadyUsed', type: 'error' }, + { inputs: [], name: 'SignatureExpired', type: 'error' }, + { inputs: [], name: 'SignedPriceTooLow', type: 'error' }, + { + inputs: [ + { internalType: 'uint256', name: 'paid', type: 'uint256' }, + { internalType: 'uint256', name: 'required', type: 'uint256' }, + ], + name: 'WrongPayment', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'uint16', name: 'bps', type: 'uint16' }, + ], + name: 'AffiliateFeeSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'affiliate', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'accrued', type: 'uint256' }, + ], + name: 'AffiliateFeesWithdrawn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'bytes32', name: 'root', type: 'bytes32' }, + ], + name: 'AffiliateMerkleRootSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'platform', type: 'address' }, + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + indexed: false, + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: 'config', + type: 'tuple', + }, + ], + name: 'DefaultPlatformFeeConfigSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'platform', type: 'address' }, + { indexed: false, internalType: 'uint96', name: 'price', type: 'uint96' }, + ], + name: 'GAPriceSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'uint32', name: 'value', type: 'uint32' }, + ], + name: 'MaxMintablePerAccountSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'uint32', name: 'value', type: 'uint32' }, + ], + name: 'MaxMintableSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'bytes32', name: 'merkleRoot', type: 'bytes32' }, + ], + name: 'MerkleRootSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint96', name: 'price', type: 'uint96' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { internalType: 'uint32', name: 'endTime', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintablePerAccount', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintable', type: 'uint32' }, + { internalType: 'uint16', name: 'affiliateFeeBPS', type: 'uint16' }, + { internalType: 'bytes32', name: 'affiliateMerkleRoot', type: 'bytes32' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'address', name: 'platform', type: 'address' }, + { internalType: 'uint8', name: 'mode', type: 'uint8' }, + { internalType: 'bytes32', name: 'merkleRoot', type: 'bytes32' }, + ], + indexed: false, + internalType: 'struct ISuperMinterV1_1.MintCreation', + name: 'creation', + type: 'tuple', + }, + ], + name: 'MintCreated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: true, internalType: 'address', name: 'to', type: 'address' }, + { + components: [ + { internalType: 'uint32', name: 'quantity', type: 'uint32' }, + { internalType: 'uint256', name: 'fromTokenId', type: 'uint256' }, + { internalType: 'address', name: 'allowlisted', type: 'address' }, + { internalType: 'uint32', name: 'allowlistedQuantity', type: 'uint32' }, + { internalType: 'uint32', name: 'signedQuantity', type: 'uint32' }, + { internalType: 'uint32', name: 'signedClaimTicket', type: 'uint32' }, + { internalType: 'address', name: 'affiliate', type: 'address' }, + { internalType: 'bool', name: 'affiliated', type: 'bool' }, + { internalType: 'uint256', name: 'requiredEtherValue', type: 'uint256' }, + { internalType: 'uint256', name: 'unitPrice', type: 'uint256' }, + { internalType: 'uint256', name: 'finalArtistFee', type: 'uint256' }, + { internalType: 'uint256', name: 'finalPlatformFee', type: 'uint256' }, + { internalType: 'uint256', name: 'finalAffiliateFee', type: 'uint256' }, + { internalType: 'uint256', name: 'finalAffiliateIncentive', type: 'uint256' }, + { internalType: 'uint256', name: 'finalCheapMintIncentive', type: 'uint256' }, + ], + indexed: false, + internalType: 'struct ISuperMinterV1_1.MintedLogData', + name: 'data', + type: 'tuple', + }, + { indexed: true, internalType: 'uint256', name: 'attributionId', type: 'uint256' }, + ], + name: 'Minted', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'bool', name: 'paused', type: 'bool' }, + ], + name: 'PausedSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'address[]', name: 'to', type: 'address[]' }, + { indexed: false, internalType: 'uint32', name: 'signedQuantity', type: 'uint32' }, + ], + name: 'PlatformAirdropped', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'platform', type: 'address' }, + { indexed: false, internalType: 'address', name: 'recipient', type: 'address' }, + ], + name: 'PlatformFeeAddressSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'platform', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + indexed: false, + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: 'config', + type: 'tuple', + }, + ], + name: 'PlatformFeeConfigSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'platform', type: 'address' }, + { indexed: false, internalType: 'uint256', name: 'accrued', type: 'uint256' }, + ], + name: 'PlatformFeesWithdrawn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'platform', type: 'address' }, + { indexed: false, internalType: 'address', name: 'signer', type: 'address' }, + ], + name: 'PlatformSignerSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'uint96', name: 'price', type: 'uint96' }, + ], + name: 'PriceSet', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: 'address', name: 'edition', type: 'address' }, + { indexed: false, internalType: 'uint8', name: 'tier', type: 'uint8' }, + { indexed: false, internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { indexed: false, internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { indexed: false, internalType: 'uint32', name: 'endTime', type: 'uint32' }, + ], + name: 'TimeRangeSet', + type: 'event', + }, + { stateMutability: 'payable', type: 'fallback' }, + { + inputs: [], + name: 'BPS_DENOMINATOR', + outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DEFAULT', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'DOMAIN_TYPEHASH', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'GA_TIER', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_AFFILIATE_FEE_BPS', + outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_PLATFORM_PER_MINT_FEE_BPS', + outputs: [{ internalType: 'uint16', name: '', type: 'uint16' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_PLATFORM_PER_MINT_FLAT_FEE', + outputs: [{ internalType: 'uint96', name: '', type: 'uint96' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MAX_PLATFORM_PER_TX_FLAT_FEE', + outputs: [{ internalType: 'uint96', name: '', type: 'uint96' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'MINT_TO_TYPEHASH', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PLATFORM_AIRDROP', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'PLATFORM_AIRDROP_TYPEHASH', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'VERIFY_MERKLE', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'VERIFY_SIGNATURE', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'affiliateFeesAccrued', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32[]', name: 'claimTickets', type: 'uint32[]' }, + ], + name: 'checkClaimTickets', + outputs: [{ internalType: 'bool[]', name: 'claimed', type: 'bool[]' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint32', name: 'quantity', type: 'uint32' }, + { internalType: 'address', name: 'allowlisted', type: 'address' }, + { internalType: 'uint32', name: 'allowlistedQuantity', type: 'uint32' }, + { internalType: 'bytes32[]', name: 'allowlistProof', type: 'bytes32[]' }, + { internalType: 'uint96', name: 'signedPrice', type: 'uint96' }, + { internalType: 'uint32', name: 'signedQuantity', type: 'uint32' }, + { internalType: 'uint32', name: 'signedClaimTicket', type: 'uint32' }, + { internalType: 'uint32', name: 'signedDeadline', type: 'uint32' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'address', name: 'affiliate', type: 'address' }, + { internalType: 'bytes32[]', name: 'affiliateProof', type: 'bytes32[]' }, + { internalType: 'uint256', name: 'attributionId', type: 'uint256' }, + ], + internalType: 'struct ISuperMinterV1_1.MintTo', + name: 'p', + type: 'tuple', + }, + ], + name: 'computeMintToDigest', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address[]', name: 'to', type: 'address[]' }, + { internalType: 'uint32', name: 'signedQuantity', type: 'uint32' }, + { internalType: 'uint32', name: 'signedClaimTicket', type: 'uint32' }, + { internalType: 'uint32', name: 'signedDeadline', type: 'uint32' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformAirdrop', + name: 'p', + type: 'tuple', + }, + ], + name: 'computePlatformAirdropDigest', + outputs: [{ internalType: 'bytes32', name: '', type: 'bytes32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint96', name: 'price', type: 'uint96' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { internalType: 'uint32', name: 'endTime', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintablePerAccount', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintable', type: 'uint32' }, + { internalType: 'uint16', name: 'affiliateFeeBPS', type: 'uint16' }, + { internalType: 'bytes32', name: 'affiliateMerkleRoot', type: 'bytes32' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'address', name: 'platform', type: 'address' }, + { internalType: 'uint8', name: 'mode', type: 'uint8' }, + { internalType: 'bytes32', name: 'merkleRoot', type: 'bytes32' }, + ], + internalType: 'struct ISuperMinterV1_1.MintCreation', + name: 'c', + type: 'tuple', + }, + ], + name: 'createEditionMint', + outputs: [{ internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'platform', type: 'address' }], + name: 'defaultPlatformFeeConfig', + outputs: [ + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'platform', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + ], + name: 'effectivePlatformFeeConfig', + outputs: [ + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'eip712Domain', + outputs: [ + { internalType: 'bytes1', name: 'fields', type: 'bytes1' }, + { internalType: 'string', name: 'name', type: 'string' }, + { internalType: 'string', name: 'version', type: 'string' }, + { internalType: 'uint256', name: 'chainId', type: 'uint256' }, + { internalType: 'address', name: 'verifyingContract', type: 'address' }, + { internalType: 'bytes32', name: 'salt', type: 'bytes32' }, + { internalType: 'uint256[]', name: 'extensions', type: 'uint256[]' }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'gaPrice', + outputs: [{ internalType: 'uint96', name: '', type: 'uint96' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'affiliate', type: 'address' }, + ], + name: 'isAffiliated', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'affiliate', type: 'address' }, + { internalType: 'bytes32[]', name: 'affiliateProof', type: 'bytes32[]' }, + ], + name: 'isAffiliatedWithProof', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + ], + name: 'mintInfo', + outputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'platform', type: 'address' }, + { internalType: 'uint96', name: 'price', type: 'uint96' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { internalType: 'uint32', name: 'endTime', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintablePerAccount', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintable', type: 'uint32' }, + { internalType: 'uint32', name: 'minted', type: 'uint32' }, + { internalType: 'uint16', name: 'affiliateFeeBPS', type: 'uint16' }, + { internalType: 'uint8', name: 'mode', type: 'uint8' }, + { internalType: 'bool', name: 'paused', type: 'bool' }, + { internalType: 'bool', name: 'hasMints', type: 'bool' }, + { internalType: 'bytes32', name: 'affiliateMerkleRoot', type: 'bytes32' }, + { internalType: 'bytes32', name: 'merkleRoot', type: 'bytes32' }, + { internalType: 'address', name: 'signer', type: 'address' }, + ], + internalType: 'struct ISuperMinterV1_1.MintInfo', + name: 'info', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'edition', type: 'address' }], + name: 'mintInfoList', + outputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'platform', type: 'address' }, + { internalType: 'uint96', name: 'price', type: 'uint96' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { internalType: 'uint32', name: 'endTime', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintablePerAccount', type: 'uint32' }, + { internalType: 'uint32', name: 'maxMintable', type: 'uint32' }, + { internalType: 'uint32', name: 'minted', type: 'uint32' }, + { internalType: 'uint16', name: 'affiliateFeeBPS', type: 'uint16' }, + { internalType: 'uint8', name: 'mode', type: 'uint8' }, + { internalType: 'bool', name: 'paused', type: 'bool' }, + { internalType: 'bool', name: 'hasMints', type: 'bool' }, + { internalType: 'bytes32', name: 'affiliateMerkleRoot', type: 'bytes32' }, + { internalType: 'bytes32', name: 'merkleRoot', type: 'bytes32' }, + { internalType: 'address', name: 'signer', type: 'address' }, + ], + internalType: 'struct ISuperMinterV1_1.MintInfo[]', + name: 'a', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'to', type: 'address' }, + { internalType: 'uint32', name: 'quantity', type: 'uint32' }, + { internalType: 'address', name: 'allowlisted', type: 'address' }, + { internalType: 'uint32', name: 'allowlistedQuantity', type: 'uint32' }, + { internalType: 'bytes32[]', name: 'allowlistProof', type: 'bytes32[]' }, + { internalType: 'uint96', name: 'signedPrice', type: 'uint96' }, + { internalType: 'uint32', name: 'signedQuantity', type: 'uint32' }, + { internalType: 'uint32', name: 'signedClaimTicket', type: 'uint32' }, + { internalType: 'uint32', name: 'signedDeadline', type: 'uint32' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + { internalType: 'address', name: 'affiliate', type: 'address' }, + { internalType: 'bytes32[]', name: 'affiliateProof', type: 'bytes32[]' }, + { internalType: 'uint256', name: 'attributionId', type: 'uint256' }, + ], + internalType: 'struct ISuperMinterV1_1.MintTo', + name: 'p', + type: 'tuple', + }, + ], + name: 'mintTo', + outputs: [], + stateMutability: 'payable', + type: 'function', + }, + { + inputs: [], + name: 'name', + outputs: [{ internalType: 'string', name: 'name_', type: 'string' }], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + ], + name: 'nextScheduleNum', + outputs: [{ internalType: 'uint8', name: '', type: 'uint8' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address', name: 'collector', type: 'address' }, + ], + name: 'numberMinted', + outputs: [{ internalType: 'uint32', name: '', type: 'uint32' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'address[]', name: 'to', type: 'address[]' }, + { internalType: 'uint32', name: 'signedQuantity', type: 'uint32' }, + { internalType: 'uint32', name: 'signedClaimTicket', type: 'uint32' }, + { internalType: 'uint32', name: 'signedDeadline', type: 'uint32' }, + { internalType: 'bytes', name: 'signature', type: 'bytes' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformAirdrop', + name: 'p', + type: 'tuple', + }, + ], + name: 'platformAirdrop', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'platformFeeAddress', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'platform', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + ], + name: 'platformFeeConfig', + outputs: [ + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'platformFeesAccrued', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: '', type: 'address' }], + name: 'platformSigner', + outputs: [{ internalType: 'address', name: '', type: 'address' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint16', name: 'bps', type: 'uint16' }, + ], + name: 'setAffiliateFee', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'bytes32', name: 'root', type: 'bytes32' }, + ], + name: 'setAffiliateMerkleRoot', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: 'c', + type: 'tuple', + }, + ], + name: 'setDefaultPlatformFeeConfig', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'uint96', name: 'price', type: 'uint96' }], + name: 'setGAPrice', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32', name: 'value', type: 'uint32' }, + ], + name: 'setMaxMintable', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32', name: 'value', type: 'uint32' }, + ], + name: 'setMaxMintablePerAccount', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'bytes32', name: 'merkleRoot', type: 'bytes32' }, + ], + name: 'setMerkleRoot', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'bool', name: 'paused', type: 'bool' }, + ], + name: 'setPaused', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'recipient', type: 'address' }], + name: 'setPlatformFeeAddress', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { + components: [ + { internalType: 'uint96', name: 'affiliateIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentive', type: 'uint96' }, + { internalType: 'uint96', name: 'cheapMintIncentiveThreshold', type: 'uint96' }, + { internalType: 'uint96', name: 'perTxFlat', type: 'uint96' }, + { internalType: 'uint96', name: 'perMintFlat', type: 'uint96' }, + { internalType: 'uint16', name: 'perMintBPS', type: 'uint16' }, + { internalType: 'bool', name: 'active', type: 'bool' }, + ], + internalType: 'struct ISuperMinterV1_1.PlatformFeeConfig', + name: 'c', + type: 'tuple', + }, + ], + name: 'setPlatformFeeConfig', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'signer', type: 'address' }], + name: 'setPlatformSigner', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint96', name: 'price', type: 'uint96' }, + ], + name: 'setPrice', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + ], + name: 'setStartTime', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32', name: 'startTime', type: 'uint32' }, + { internalType: 'uint32', name: 'endTime', type: 'uint32' }, + ], + name: 'setTimeRange', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'bytes4', name: 'interfaceId', type: 'bytes4' }], + name: 'supportsInterface', + outputs: [{ internalType: 'bool', name: '', type: 'bool' }], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32', name: 'quantity', type: 'uint32' }, + ], + name: 'totalPriceAndFees', + outputs: [ + { + components: [ + { internalType: 'uint256', name: 'total', type: 'uint256' }, + { internalType: 'uint256', name: 'subTotal', type: 'uint256' }, + { internalType: 'uint256', name: 'unitPrice', type: 'uint256' }, + { internalType: 'uint256', name: 'platformFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformFlatFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformTxFlatFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformMintFlatFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformMintBPSFee', type: 'uint256' }, + { internalType: 'uint256', name: 'affiliateFee', type: 'uint256' }, + { internalType: 'uint256', name: 'affiliateIncentive', type: 'uint256' }, + { internalType: 'uint256', name: 'cheapMintIncentive', type: 'uint256' }, + { internalType: 'uint256', name: 'cheapMintIncentiveThreshold', type: 'uint256' }, + ], + internalType: 'struct ISuperMinterV1_1.TotalPriceAndFees', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { internalType: 'address', name: 'edition', type: 'address' }, + { internalType: 'uint8', name: 'tier', type: 'uint8' }, + { internalType: 'uint8', name: 'scheduleNum', type: 'uint8' }, + { internalType: 'uint32', name: 'quantity', type: 'uint32' }, + { internalType: 'uint96', name: 'signedPrice', type: 'uint96' }, + ], + name: 'totalPriceAndFeesWithSignedPrice', + outputs: [ + { + components: [ + { internalType: 'uint256', name: 'total', type: 'uint256' }, + { internalType: 'uint256', name: 'subTotal', type: 'uint256' }, + { internalType: 'uint256', name: 'unitPrice', type: 'uint256' }, + { internalType: 'uint256', name: 'platformFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformFlatFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformTxFlatFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformMintFlatFee', type: 'uint256' }, + { internalType: 'uint256', name: 'platformMintBPSFee', type: 'uint256' }, + { internalType: 'uint256', name: 'affiliateFee', type: 'uint256' }, + { internalType: 'uint256', name: 'affiliateIncentive', type: 'uint256' }, + { internalType: 'uint256', name: 'cheapMintIncentive', type: 'uint256' }, + { internalType: 'uint256', name: 'cheapMintIncentiveThreshold', type: 'uint256' }, + ], + internalType: 'struct ISuperMinterV1_1.TotalPriceAndFees', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'version', + outputs: [{ internalType: 'string', name: 'version_', type: 'string' }], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'affiliate', type: 'address' }], + name: 'withdrawForAffiliate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [{ internalType: 'address', name: 'platform', type: 'address' }], + name: 'withdrawForPlatform', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { stateMutability: 'payable', type: 'receive' }, +] as const + +export const SUPER_MINTER_V1_1 = { + address: SUPER_MINTER_V1_1_ADDRESS, + abi: SUPER_MINTER_V1_1_ABI, +} as const diff --git a/packages/sdk/src/contract/edition-v2/read/create.ts b/packages/sdk/src/contract/edition-v2/read/create.ts index 23be2c7b..058824f6 100644 --- a/packages/sdk/src/contract/edition-v2/read/create.ts +++ b/packages/sdk/src/contract/edition-v2/read/create.ts @@ -1,26 +1,25 @@ import { encodeFunctionData, + keccak256, + type Account, type Address, + type Chain, type EncodeFunctionDataParameters, type Hex, type PublicClient, - type Account, - type Chain, - keccak256, } from 'viem' +import { MINT_GAS_LIMIT_MULTIPLIER, UINT32_MAX } from '../../../utils/constants' +import { InvalidUint32 } from '../../../utils/errors' +import { curry, scaleAmount } from '../../../utils/helpers' +import type { Prettify, TransactionGasOptions } from '../../../utils/types' +import type { ContractCall } from '../../types' import { SPLIT_MAIN_ABI, SPLIT_MAIN_ADDRESS } from '../abi/external/split-main' import { SOUND_CREATOR_V2_ABI, SOUND_CREATOR_V2_ADDRESS } from '../abi/sound-creator-v2' import { SOUND_EDITION_V2_ABI, SOUND_EDITION_V2_IMPLEMENTATION_ADDRESS } from '../abi/sound-edition-v2' import { SOUND_METADATA_ABI, SOUND_METADATA_ADDRESS } from '../abi/sound-metadata' -import { SUPER_MINTER_ABI, SUPER_MINTER_ADDRESS } from '../abi/super-minter' -import type { MinterScheduleConfig, TierConfig, TieredEditionConfig } from './info' -import type { ContractCall } from '../../types' +import { SUPER_MINTER_V1_1_ABI, SUPER_MINTER_V1_1_ADDRESS } from '../abi/super-minter-v1_1' import { MINTER_ROLE } from './helpers' -import { scaleAmount } from '../../../utils/helpers' -import type { Prettify, TransactionGasOptions } from '../../../utils/types' -import { curry } from '../../../utils/helpers' -import { InvalidUint32 } from '../../../utils/errors' -import { MINT_GAS_LIMIT_MULTIPLIER, NULL_ADDRESS, UINT32_MAX } from '../../../utils/constants' +import type { MinterScheduleConfig, TierConfig, TieredEditionConfig } from './info' interface EditionV2EncodeArguments { readonly owner: Address | Readonly @@ -64,7 +63,7 @@ function createTieredEditionArgs({ calldata: encodeFunctionData({ abi: SOUND_EDITION_V2_ABI, functionName: 'grantRoles', - args: [SUPER_MINTER_ADDRESS, MINTER_ROLE], + args: [SUPER_MINTER_V1_1_ADDRESS, MINTER_ROLE], }), }) @@ -99,9 +98,9 @@ function createTieredEditionArgs({ } contractCalls.push({ - contractAddress: SUPER_MINTER_ADDRESS, + contractAddress: SUPER_MINTER_V1_1_ADDRESS, calldata: encodeFunctionData({ - abi: SUPER_MINTER_ABI, + abi: SUPER_MINTER_V1_1_ABI, functionName: 'createEditionMint', args: [ { @@ -118,7 +117,6 @@ function createTieredEditionArgs({ // TODO: add better typesafety here mode: mintConfig.mode === 'DEFAULT' ? 0 : mintConfig.mode === 'VERIFY_MERKLE' ? 1 : 2, merkleRoot: mintConfig.mode === 'VERIFY_MERKLE' ? mintConfig.merkleRoot : EMPTY_MERKLE_ROOT, - signer: mintConfig.mode === 'VERIFY_SIGNATURE' ? mintConfig.signer : NULL_ADDRESS, }, ], }), diff --git a/packages/sdk/src/contract/edition-v2/read/helpers.ts b/packages/sdk/src/contract/edition-v2/read/helpers.ts index 2a761651..d92d1f2a 100644 --- a/packages/sdk/src/contract/edition-v2/read/helpers.ts +++ b/packages/sdk/src/contract/edition-v2/read/helpers.ts @@ -1,5 +1,10 @@ +import type { Address, PublicClient } from 'viem' import { nowUnixTimestamp } from '../../../utils/helpers' +import { SOUND_EDITION_V2_ABI } from '../abi/sound-edition-v2' +import { SUPER_MINTER_V1, SUPER_MINTER_V1_ADDRESS } from '../abi/super-minter-v1' +import { SUPER_MINTER_V1_1, SUPER_MINTER_V1_1_ADDRESS } from '../abi/super-minter-v1_1' import type { GetEditionContractInfoReturnType } from './info' +import { CacheUtils } from '../../../utils/cache-utils' export function getTierCurrentMaxMintable( tierInfo: Pick< @@ -14,3 +19,49 @@ export function getTierCurrentMaxMintable( // This is hardcoded on the contract so we always know its 2 export const MINTER_ROLE = 2n + +export type SuperMinter = typeof SUPER_MINTER_V1 | typeof SUPER_MINTER_V1_1 +export type SuperMinterAddress = SuperMinter['address'] + +export async function getSuperMinterForEdition>( + client: Client, + { editionAddress }: { editionAddress: Address }, +): Promise { + const cacheKey = `superMinter-${editionAddress}` + + return CacheUtils.getOrSetCache(cacheKey, () => _getSuperMinterForEdition({ client, editionAddress })) +} + +async function _getSuperMinterForEdition({ + client, + editionAddress, +}: { + client: Pick + editionAddress: Address +}) { + const [hasSuperMinterV1, hasSuperMinterV1_1] = await client.multicall({ + contracts: [ + { + abi: SOUND_EDITION_V2_ABI, + address: editionAddress, + functionName: 'hasAnyRole', + args: [SUPER_MINTER_V1_ADDRESS, MINTER_ROLE], + }, + { + abi: SOUND_EDITION_V2_ABI, + address: editionAddress, + functionName: 'hasAnyRole', + args: [SUPER_MINTER_V1_1_ADDRESS, MINTER_ROLE], + }, + ], + allowFailure: false, + }) + + if (hasSuperMinterV1) { + return SUPER_MINTER_V1 + } else if (hasSuperMinterV1_1) { + return SUPER_MINTER_V1_1 + } + + throw new Error('No super minter found for edition') +} diff --git a/packages/sdk/src/contract/edition-v2/read/info.ts b/packages/sdk/src/contract/edition-v2/read/info.ts index cbaa6bae..bd8f81ac 100644 --- a/packages/sdk/src/contract/edition-v2/read/info.ts +++ b/packages/sdk/src/contract/edition-v2/read/info.ts @@ -1,9 +1,7 @@ import type { Address, Hex, PublicClient } from 'viem' +import { curry, nowUnixTimestamp } from '../../../utils/helpers' import { SOUND_EDITION_V2_ABI } from '../abi/sound-edition-v2' -import { getTierCurrentMaxMintable } from './helpers' -import { SUPER_MINTER_ABI, SUPER_MINTER_ADDRESS } from '../abi/super-minter' -import { nowUnixTimestamp } from '../../../utils/helpers' -import { curry } from '../../../utils/helpers' +import { getSuperMinterForEdition, getTierCurrentMaxMintable } from './helpers' import { isSoundV2 } from './interface' export type GetEditionContractInfoReturnType = { @@ -101,8 +99,6 @@ export type MerkleScheduleConfig = ScheduleConfigBase & { } export type SignatureScheduleConfig = ScheduleConfigBase & { mode: 'VERIFY_SIGNATURE' - signer: Address - usePlatformSigner: boolean } export type MinterScheduleConfig = DefaultScheduleConfig | MerkleScheduleConfig | SignatureScheduleConfig @@ -121,8 +117,6 @@ export type MerkleSchedule = ScheduleBase & { } export type SignatureSchedule = ScheduleBase & { mode: 'VERIFY_SIGNATURE' - signer: Address - usePlatformSigner: boolean } export type SuperMinterSchedule = DefaultSchedule | MerkleSchedule | SignatureSchedule @@ -137,14 +131,16 @@ export type GetMintingSchedulesReturnType = { activeSchedules: readonly SuperMinterSchedule[] } -export async function mintingSchedules>( +export async function mintingSchedules>( client: Client, { editionAddress, unixTimestamp = nowUnixTimestamp() }: GetMintingSchedulesParams, ): Promise { + const { address, abi } = await getSuperMinterForEdition(client, { editionAddress }) + const schedules: SuperMinterSchedule[] = await client - .readContract({ - abi: SUPER_MINTER_ABI, - address: SUPER_MINTER_ADDRESS, + .readContract({ + abi, + address, functionName: 'mintInfoList', args: [editionAddress], }) diff --git a/packages/sdk/src/contract/edition-v2/read/interface.ts b/packages/sdk/src/contract/edition-v2/read/interface.ts index bf42b115..4d4fc11b 100644 --- a/packages/sdk/src/contract/edition-v2/read/interface.ts +++ b/packages/sdk/src/contract/edition-v2/read/interface.ts @@ -1,7 +1,6 @@ import type { Address, PublicClient } from 'viem' import { SOUND_EDITION_V2_ABI } from '../abi/sound-edition-v2' import { interfaceIds } from '../interfaceIds' -import { SUPER_MINTER_ABI } from '../abi/super-minter' export function isSoundV2>( client: Client, @@ -18,19 +17,3 @@ export function isSoundV2>( args: [interfaceIds.ISoundEditionV2], }) } - -export function isSuperMinter>( - client: Client, - { - editionAddress, - }: { - editionAddress: Address - }, -) { - return client.readContract({ - abi: SUPER_MINTER_ABI, - address: editionAddress, - functionName: 'supportsInterface', - args: [interfaceIds.ISuperMinter], - }) -} diff --git a/packages/sdk/src/contract/edition-v2/read/mint.ts b/packages/sdk/src/contract/edition-v2/read/mint.ts index e5b55e8c..be5a61db 100644 --- a/packages/sdk/src/contract/edition-v2/read/mint.ts +++ b/packages/sdk/src/contract/edition-v2/read/mint.ts @@ -1,13 +1,11 @@ import type { Account, Address, Chain, Hex, PublicClient } from 'viem' -import { SUPER_MINTER_ABI, SUPER_MINTER_ADDRESS } from '../abi/super-minter' +import { MINT_FALLBACK_GAS_LIMIT, MINT_GAS_LIMIT_MULTIPLIER, NULL_ADDRESS, UINT32_MAX } from '../../../utils/constants' +import { curry, scaleAmount } from '../../../utils/helpers' import type { MerkleProvider, TransactionGasOptions, TypeFromUnion } from '../../../utils/types' +import type { MintParameters } from '../../types' import { SOUND_EDITION_V2_ABI } from '../abi/sound-edition-v2' -import { getTierCurrentMaxMintable } from './helpers' +import { getSuperMinterForEdition, getTierCurrentMaxMintable } from './helpers' import type { SuperMinterSchedule } from './info' -import type { MintParameters } from '../../types' -import { scaleAmount } from '../../../utils/helpers' -import { curry } from '../../../utils/helpers' -import { MINT_FALLBACK_GAS_LIMIT, MINT_GAS_LIMIT_MULTIPLIER, NULL_ADDRESS, UINT32_MAX } from '../../../utils/constants' export type GetTotalMintPriceAndFeesParams = { tier: number @@ -41,45 +39,20 @@ export type GetTotalMintPriceAndFeesReturnType = { affiliateFee: bigint } -export async function getTotalMintPriceAndFees>( +export async function getTotalMintPriceAndFees>( client: Client, { tier, scheduleNum, quantity, editionAddress }: GetTotalMintPriceAndFeesParams, -): Promise { - return client.readContract({ - abi: SUPER_MINTER_ABI, - address: SUPER_MINTER_ADDRESS, +) { + const superMinter = await getSuperMinterForEdition(client, { editionAddress }) + + return client.readContract({ + abi: superMinter.abi, + address: superMinter.address, functionName: 'totalPriceAndFees', args: [editionAddress, tier, scheduleNum, quantity], }) } -export type GetPlatformFeesParams = { - platform: Address - tiers: number[] -} - -export type GetPlatformFeesReturnType = { - perTxFlat: bigint - perMintFlat: bigint - perMintBPS: number - active: boolean -}[] - -export async function getPlatformFees>( - client: Client, - { platform, tiers }: GetPlatformFeesParams, -): Promise { - return client.multicall({ - contracts: tiers.map((tier) => ({ - abi: SUPER_MINTER_ABI, - address: SUPER_MINTER_ADDRESS, - functionName: 'platformFeeConfig', - args: [platform, tier], - })), - allowFailure: false, - }) -} - export type GetMintEligibilityParams = { editionAddress: Address @@ -98,17 +71,19 @@ export async function mintEligibility { + const { address, abi } = await getSuperMinterForEdition(client, { editionAddress }) + const [numberMintedOnSchedule, scheduleInfo, tierInfo] = await client.multicall({ contracts: [ { - abi: SUPER_MINTER_ABI, - address: SUPER_MINTER_ADDRESS, + abi, + address, functionName: 'numberMinted', args: [editionAddress, tier, scheduleNum, collectorAddress], }, { - abi: SUPER_MINTER_ABI, - address: SUPER_MINTER_ADDRESS, + abi, + address, functionName: 'mintInfo', args: [editionAddress, tier, scheduleNum], }, @@ -254,9 +229,11 @@ export async function editionMintParameters< editionAddress, }) + const superMinter = await getSuperMinterForEdition(client, { editionAddress }) + const sharedWriteContractParameters = { - address: SUPER_MINTER_ADDRESS, - abi: SUPER_MINTER_ABI, + address: superMinter.address, + abi: superMinter.abi, functionName: 'mintTo', account, value, @@ -291,7 +268,7 @@ export async function editionMintParameters< try { // Add a buffer to the gas estimate to account for node provider estimate variance. gasEstimate = txnOverrides.gas = scaleAmount({ - amount: await client.estimateContractGas({ + amount: await client.estimateContractGas({ args, ...sharedWriteContractParameters, ...txnOverrides, @@ -355,7 +332,7 @@ export async function editionMintParameters< try { // Add a buffer to the gas estimate to account for node provider estimate variance. gasEstimate = txnOverrides.gas = scaleAmount({ - amount: await client.estimateContractGas({ + amount: await client.estimateContractGas({ args, ...sharedWriteContractParameters, ...txnOverrides, @@ -402,9 +379,8 @@ export function editionV2PublicActionsMint< ...client.editionV2, totalMintPriceAndFees: curry(getTotalMintPriceAndFees)(client), - platformFees: curry(getPlatformFees)(client), - eligiblity: curry(mintEligibility)(client)({ merkleProvider: client.merkleProvider }), + eligibility: curry(mintEligibility)(client)({ merkleProvider: client.merkleProvider }), mintParameters: curry(editionMintParameters)(client)({ merkleProvider: client.merkleProvider }), }, diff --git a/packages/sdk/src/contract/edition-v2/write/create.ts b/packages/sdk/src/contract/edition-v2/write/create.ts index 680fbf2f..8d4f75ab 100644 --- a/packages/sdk/src/contract/edition-v2/write/create.ts +++ b/packages/sdk/src/contract/edition-v2/write/create.ts @@ -1,6 +1,6 @@ import type { WalletClient } from 'viem' -import type { EditionCreateContractInput } from '../read/create' import { curry } from '../../../utils/helpers' +import type { EditionCreateContractInput } from '../read/create' export function editionCreate>( client: Client, diff --git a/packages/sdk/src/contract/edition-v2/write/mint.ts b/packages/sdk/src/contract/edition-v2/write/mint.ts index 5aa0feba..9c3710cc 100644 --- a/packages/sdk/src/contract/edition-v2/write/mint.ts +++ b/packages/sdk/src/contract/edition-v2/write/mint.ts @@ -1,12 +1,12 @@ -import type { WalletClient } from 'viem' -import type { EditionMintContractInput } from '../read/mint' +import type { Chain, WalletClient } from 'viem' import { curry } from '../../../utils/helpers' +import type { EditionMintContractInput } from '../read/mint' export function editionMint>( client: Client, { input }: EditionMintContractInput, ) { - return client.writeContract(input) + return client.writeContract(input) } export function editionV2WalletActionsMint & { editionV2?: {} }>( diff --git a/packages/sdk/src/utils/cache-utils.ts b/packages/sdk/src/utils/cache-utils.ts new file mode 100644 index 00000000..625718d0 --- /dev/null +++ b/packages/sdk/src/utils/cache-utils.ts @@ -0,0 +1,12 @@ +export class CacheUtils { + private static cache = new Map() + + public static async getOrSetCache(key: string, fetchData: () => Promise): Promise { + let data = this.cache.get(key) + if (!data) { + data = await fetchData() + this.cache.set(key, data) + } + return data as T + } +}