@zoralabs/protocol-sdk 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +6 -0
  3. package/dist/constants.d.ts +0 -1
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/index.cjs +845 -407
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.js +829 -391
  8. package/dist/index.js.map +1 -1
  9. package/dist/mint/mint-client.d.ts +28 -4071
  10. package/dist/mint/mint-client.d.ts.map +1 -1
  11. package/dist/mint/mint-queries.d.ts +38 -0
  12. package/dist/mint/mint-queries.d.ts.map +1 -0
  13. package/dist/mint/mint-transactions.d.ts +20 -0
  14. package/dist/mint/mint-transactions.d.ts.map +1 -0
  15. package/dist/mint/subgraph-mint-getter.d.ts +14 -7
  16. package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
  17. package/dist/mint/subgraph-queries.d.ts +55 -0
  18. package/dist/mint/subgraph-queries.d.ts.map +1 -0
  19. package/dist/mint/types.d.ts +117 -19
  20. package/dist/mint/types.d.ts.map +1 -1
  21. package/dist/mint/utils.d.ts +2 -0
  22. package/dist/mint/utils.d.ts.map +1 -0
  23. package/dist/mints/mints-contracts.d.ts +3 -4494
  24. package/dist/mints/mints-contracts.d.ts.map +1 -1
  25. package/dist/premint/conversions.d.ts +12 -15
  26. package/dist/premint/conversions.d.ts.map +1 -1
  27. package/dist/premint/premint-api-client.d.ts +14 -11
  28. package/dist/premint/premint-api-client.d.ts.map +1 -1
  29. package/dist/premint/premint-client.d.ts +15 -5
  30. package/dist/premint/premint-client.d.ts.map +1 -1
  31. package/dist/premint/preminter.d.ts +1 -1
  32. package/dist/premint/preminter.d.ts.map +1 -1
  33. package/dist/sdk.d.ts +4 -2
  34. package/dist/sdk.d.ts.map +1 -1
  35. package/dist/types.d.ts +3 -0
  36. package/dist/types.d.ts.map +1 -1
  37. package/dist/utils.d.ts +10 -2
  38. package/dist/utils.d.ts.map +1 -1
  39. package/package.json +1 -1
  40. package/src/constants.ts +0 -36
  41. package/src/create/1155-create-helper.test.ts +9 -7
  42. package/src/mint/mint-client.test.ts +96 -47
  43. package/src/mint/mint-client.ts +75 -343
  44. package/src/mint/mint-queries.ts +320 -0
  45. package/src/mint/mint-transactions.ts +253 -0
  46. package/src/mint/subgraph-mint-getter.ts +216 -123
  47. package/src/mint/subgraph-queries.ts +170 -0
  48. package/src/mint/types.ts +140 -23
  49. package/src/mint/utils.ts +14 -0
  50. package/src/premint/conversions.ts +26 -2
  51. package/src/premint/premint-api-client.ts +48 -16
  52. package/src/premint/premint-client.test.ts +29 -23
  53. package/src/premint/premint-client.ts +64 -36
  54. package/src/premint/preminter.ts +2 -3
  55. package/src/sdk.ts +7 -4
  56. package/src/types.ts +18 -0
  57. package/src/utils.ts +29 -28
  58. package/test-integration/setup-test-contracts.ts +96 -0
  59. package/test-integration/premint-client.test.ts +0 -148
package/dist/index.cjs CHANGED
@@ -39,12 +39,14 @@ __export(src_exports, {
39
39
  SubgraphMintGetter: () => SubgraphMintGetter,
40
40
  ZORA_API_BASE: () => ZORA_API_BASE,
41
41
  applyUpdateToPremint: () => applyUpdateToPremint,
42
+ buildPremintMintCall: () => buildPremintMintCall,
42
43
  collectOnchain: () => collectOnchain,
43
44
  collectPremint: () => collectPremint,
44
45
  collectPremintV2WithMintsParams: () => collectPremintV2WithMintsParams,
45
46
  collectWithMintsParams: () => collectWithMintsParams,
46
47
  convertCollectionFromApi: () => convertCollectionFromApi,
47
48
  convertGetPremintApiResponse: () => convertGetPremintApiResponse,
49
+ convertGetPremintOfCollectionApiResponse: () => convertGetPremintOfCollectionApiResponse,
48
50
  convertPremintFromApi: () => convertPremintFromApi,
49
51
  createCollectorClient: () => createCollectorClient,
50
52
  createCreatorClient: () => createCreatorClient,
@@ -59,10 +61,8 @@ __export(src_exports, {
59
61
  getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
60
62
  getDataFromPremintReceipt: () => getDataFromPremintReceipt,
61
63
  getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
62
- getMintCosts: () => getMintCosts,
63
64
  getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
64
65
  getMintsEthPrice: () => getMintsEthPrice,
65
- getNecessaryErc20Approval: () => getNecessaryErc20Approval,
66
66
  getPremintCollectionAddress: () => getPremintCollectionAddress,
67
67
  getPremintExecutorAddress: () => getPremintExecutorAddress,
68
68
  getPremintMintCosts: () => getPremintMintCosts,
@@ -82,15 +82,12 @@ __export(src_exports, {
82
82
  makePermitToCollectPremintOrNonPremint: () => makePermitToCollectPremintOrNonPremint,
83
83
  makePermitTransferBatchAndTypeData: () => makePermitTransferBatchAndTypeData,
84
84
  makePermitTransferTypeData: () => makePermitTransferTypeData,
85
- makePrepareMint1155TokenParams: () => makePrepareMint1155TokenParams,
86
85
  makeUrls: () => makeUrls,
87
86
  migratePremintConfigToV2: () => migratePremintConfigToV2,
88
87
  mintWithEthParams: () => mintWithEthParams,
89
88
  mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
90
- parseMintCosts: () => parseMintCosts,
91
89
  recoverCreatorFromCreatorAttribution: () => recoverCreatorFromCreatorAttribution,
92
90
  recoverPremintSigner: () => recoverPremintSigner,
93
- requestErc20ApprovalForMint: () => requestErc20ApprovalForMint,
94
91
  selectMintsToCollectWithFromQueryResult: () => selectMintsToCollectWithFromQueryResult,
95
92
  sumBalances: () => sumBalances,
96
93
  supportedPremintVersions: () => supportedPremintVersions,
@@ -125,41 +122,6 @@ var zora721Abi = (0, import_viem.parseAbi)([
125
122
  "function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
126
123
  "function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
127
124
  ]);
128
- var NFT_SALE_QUERY = `
129
- fragment SaleStrategy on SalesStrategyConfig {
130
- type
131
- fixedPrice {
132
- address
133
- pricePerToken
134
- saleEnd
135
- saleStart
136
- maxTokensPerAddress
137
- }
138
- erc20Minter {
139
- address
140
- pricePerToken
141
- currency
142
- saleEnd
143
- saleStart
144
- maxTokensPerAddress
145
- }
146
- }
147
-
148
- query ($id: ID!) {
149
- zoraCreateToken(id: $id) {
150
- id
151
- contract {
152
- mintFeePerQuantity
153
- salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
154
- ...SaleStrategy
155
- }
156
- }
157
- salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
158
- ...SaleStrategy
159
- }
160
- }
161
- }
162
- `;
163
125
 
164
126
  // src/apis/chain-constants.ts
165
127
  var REWARD_PER_TOKEN = (0, import_viem2.parseEther)("0.000777");
@@ -286,10 +248,22 @@ var convertPremintFromApi = (premint) => {
286
248
  }
287
249
  };
288
250
  var convertGetPremintApiResponse = (response) => ({
289
- ...convertPremintFromApi(response.premint),
290
251
  collection: convertCollectionFromApi(response.collection),
291
252
  collectionAddress: response.collection_address,
292
- signature: response.signature
253
+ signature: response.signature,
254
+ signer: response.signer,
255
+ premint: convertPremintFromApi(response.premint)
256
+ });
257
+ var convertGetPremintOfCollectionApiResponse = (response) => ({
258
+ collection: convertCollectionFromApi({
259
+ contractAdmin: response.contract_admin,
260
+ contractName: response.contract_name,
261
+ contractURI: response.contract_uri
262
+ }),
263
+ premints: response.premints.map((premint) => ({
264
+ premint: convertPremintFromApi(premint),
265
+ signature: premint.signature
266
+ }))
293
267
  });
294
268
  var encodePremintV1ForAPI = ({
295
269
  tokenConfig,
@@ -578,7 +552,7 @@ async function getPremintPricePerToken({
578
552
  uid,
579
553
  premintGetter
580
554
  }) {
581
- const premintConfigWithVersion = await premintGetter.getSignature({
555
+ const { premint: premintConfigWithVersion } = await premintGetter.get({
582
556
  collectionAddress: collection,
583
557
  uid
584
558
  });
@@ -717,6 +691,144 @@ var httpClient = {
717
691
  retries
718
692
  };
719
693
 
694
+ // src/mint/types.ts
695
+ var isOnChainMint = (mint2) => mint2.mintType !== "premint";
696
+ var is1155Mint = (mint2) => mint2.mintType === "1155";
697
+ function isErc20SaleStrategy(salesConfig) {
698
+ return salesConfig.saleType === "erc20";
699
+ }
700
+
701
+ // src/utils.ts
702
+ var makeContractParameters = (args) => args;
703
+ function mintRecipientOrAccount({
704
+ mintRecipient,
705
+ minterAccount
706
+ }) {
707
+ return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
708
+ }
709
+ async function querySubgraphWithRetries({
710
+ httpClient: httpClient2,
711
+ subgraphUrl,
712
+ query,
713
+ variables
714
+ }) {
715
+ const { retries: retries2, post: post2 } = httpClient2;
716
+ const result = await retries2(async () => {
717
+ return await post2(subgraphUrl, {
718
+ query,
719
+ variables
720
+ });
721
+ });
722
+ return result?.data;
723
+ }
724
+
725
+ // src/mint/subgraph-queries.ts
726
+ var NFT_SALE_STRATEGY_FRAGMENT = `
727
+ fragment SaleStrategy on SalesStrategyConfig {
728
+ type
729
+ fixedPrice {
730
+ address
731
+ pricePerToken
732
+ saleEnd
733
+ saleStart
734
+ maxTokensPerAddress
735
+ }
736
+ erc20Minter {
737
+ address
738
+ pricePerToken
739
+ currency
740
+ saleEnd
741
+ saleStart
742
+ maxTokensPerAddress
743
+ }
744
+ }`;
745
+ var TOKEN_FRAGMENT = `
746
+ fragment Token on ZoraCreateToken {
747
+ creator
748
+ tokenId
749
+ uri
750
+ totalMinted
751
+ maxSupply
752
+ tokenStandard
753
+ salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
754
+ ...SaleStrategy
755
+ }
756
+ contract {
757
+ address
758
+ mintFeePerQuantity
759
+ contractVersion
760
+ contractURI
761
+ name
762
+ salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
763
+ ...SaleStrategy
764
+ }
765
+ }
766
+ }`;
767
+ var FRAGMENTS = `
768
+ ${NFT_SALE_STRATEGY_FRAGMENT}
769
+ ${TOKEN_FRAGMENT}
770
+ `;
771
+ function buildNftTokenSalesQuery({
772
+ tokenId,
773
+ tokenAddress
774
+ }) {
775
+ return {
776
+ query: `
777
+ ${FRAGMENTS}
778
+ query ($id: ID!) {
779
+ zoraCreateToken(id: $id) {
780
+ ...Token
781
+ }
782
+ }
783
+ `,
784
+ variables: {
785
+ id: tokenId !== void 0 ? (
786
+ // Generic Token ID types all stringify down to the base numeric equivalent.
787
+ `${tokenAddress.toLowerCase()}-${tokenId}`
788
+ ) : `${tokenAddress.toLowerCase()}-0`
789
+ },
790
+ parseResponseData: (responseData) => responseData?.zoraCreateToken
791
+ };
792
+ }
793
+ function buildContractTokensQuery({
794
+ tokenAddress
795
+ }) {
796
+ return {
797
+ query: `
798
+ ${FRAGMENTS}
799
+ query ($contract: Bytes!) {
800
+ zoraCreateTokens(
801
+ where: {address: $contract}
802
+ ) {
803
+ ...Token
804
+ }
805
+ }
806
+ `,
807
+ variables: {
808
+ contract: tokenAddress.toLowerCase()
809
+ },
810
+ parseResponseData: (responseData) => responseData?.zoraCreateTokens
811
+ };
812
+ }
813
+ function buildPremintsOfContractQuery({
814
+ tokenAddress
815
+ }) {
816
+ return {
817
+ query: `
818
+ query ($contractAddress: Bytes!) {
819
+ premints(where:{contractAddress:$contractAddress}) {
820
+ uid
821
+ tokenId
822
+ }
823
+ }
824
+ `,
825
+ variables: {
826
+ contractAddress: tokenAddress.toLowerCase()
827
+ },
828
+ parseResponseData: (responseData) => responseData?.premints
829
+ };
830
+ }
831
+
720
832
  // src/mint/subgraph-mint-getter.ts
721
833
  var getApiNetworkConfigForChain = (chainId) => {
722
834
  if (!networkConfigByChain[chainId]) {
@@ -724,92 +836,171 @@ var getApiNetworkConfigForChain = (chainId) => {
724
836
  }
725
837
  return networkConfigByChain[chainId];
726
838
  };
839
+ function parseSalesConfig(targetStrategy) {
840
+ if (targetStrategy.type === "FIXED_PRICE")
841
+ return {
842
+ saleType: "fixedPrice",
843
+ ...targetStrategy.fixedPrice,
844
+ maxTokensPerAddress: BigInt(
845
+ targetStrategy.fixedPrice.maxTokensPerAddress
846
+ ),
847
+ pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
848
+ };
849
+ if (targetStrategy.type === "ERC_20_MINTER") {
850
+ return {
851
+ saleType: "erc20",
852
+ ...targetStrategy.erc20Minter,
853
+ maxTokensPerAddress: BigInt(
854
+ targetStrategy.erc20Minter.maxTokensPerAddress
855
+ ),
856
+ pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
857
+ };
858
+ }
859
+ throw new Error("Unknown saleType");
860
+ }
861
+ function getSaleEnd(a) {
862
+ return BigInt(
863
+ a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
864
+ );
865
+ }
866
+ function getTargetStrategy({
867
+ tokenId,
868
+ preferredSaleType,
869
+ token
870
+ }) {
871
+ const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
872
+ const saleStrategies = allStrategies.sort(
873
+ (a, b) => getSaleEnd(a) > getSaleEnd(b) ? 1 : -1
874
+ );
875
+ let targetStrategy;
876
+ if (!preferredSaleType) {
877
+ targetStrategy = saleStrategies[0];
878
+ if (!targetStrategy) {
879
+ throw new Error("Cannot find sale strategy");
880
+ }
881
+ } else {
882
+ const mappedSaleType = preferredSaleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
883
+ targetStrategy = saleStrategies.find(
884
+ (strategy) => strategy.type === mappedSaleType
885
+ );
886
+ if (!targetStrategy) {
887
+ const targetStrategy2 = saleStrategies.find(
888
+ (strategy) => strategy.type === "FIXED_PRICE" || strategy.type === "ERC_20_MINTER"
889
+ );
890
+ if (!targetStrategy2)
891
+ throw new Error("Cannot find valid sale strategy");
892
+ return targetStrategy2;
893
+ }
894
+ }
895
+ return targetStrategy;
896
+ }
727
897
  var SubgraphMintGetter = class {
728
898
  constructor(chainId, httpClient2) {
899
+ this.getMintable = async ({
900
+ tokenAddress,
901
+ tokenId,
902
+ preferredSaleType: saleType
903
+ }) => {
904
+ const token = await this.querySubgraphWithRetries(
905
+ buildNftTokenSalesQuery({
906
+ tokenId,
907
+ tokenAddress
908
+ })
909
+ );
910
+ if (!token) {
911
+ throw new Error("Cannot find token");
912
+ }
913
+ return parseTokenQueryResult({
914
+ token,
915
+ tokenId,
916
+ preferredSaleType: saleType
917
+ });
918
+ };
729
919
  this.httpClient = httpClient2 || httpClient;
730
920
  this.networkConfig = getApiNetworkConfigForChain(chainId);
731
921
  }
732
- async getSalesConfigAndTokenInfo({
733
- tokenAddress,
734
- tokenId,
735
- saleType
922
+ async querySubgraphWithRetries({
923
+ query,
924
+ variables,
925
+ parseResponseData
736
926
  }) {
737
- const { retries: retries2, post: post2 } = this.httpClient;
738
- return retries2(async () => {
739
- const response = await post2(this.networkConfig.subgraphUrl, {
740
- query: NFT_SALE_QUERY,
741
- variables: {
742
- id: tokenId !== void 0 ? (
743
- // Generic Token ID types all stringify down to the base numeric equivalent.
744
- `${tokenAddress.toLowerCase()}-${tokenId}`
745
- ) : `${tokenAddress.toLowerCase()}-0`
746
- }
747
- });
748
- const token = response.data?.zoraCreateToken;
749
- if (!token) {
750
- throw new Error("Cannot find a token to mint");
751
- }
752
- const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
753
- const saleStrategies = allStrategies.sort(
754
- (a, b) => BigInt(
755
- a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
756
- ) > BigInt(
757
- b.type === "FIXED_PRICE" ? b.fixedPrice.saleEnd : b.erc20Minter.saleEnd
758
- ) ? 1 : -1
759
- );
760
- let targetStrategy;
761
- if (!saleType) {
762
- targetStrategy = saleStrategies[0];
763
- if (!targetStrategy) {
764
- throw new Error("Cannot find sale strategy");
765
- }
766
- } else {
767
- const mappedSaleType = saleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
768
- targetStrategy = saleStrategies.find(
769
- (strategy) => strategy.type === mappedSaleType
770
- );
771
- if (!targetStrategy) {
772
- throw new Error(`Cannot find sale strategy for ${mappedSaleType}`);
773
- }
774
- }
775
- if (targetStrategy.type === "FIXED_PRICE") {
776
- return {
777
- salesConfig: {
778
- saleType: "fixedPrice",
779
- ...targetStrategy.fixedPrice,
780
- maxTokensPerAddress: BigInt(
781
- targetStrategy.fixedPrice.maxTokensPerAddress
782
- ),
783
- pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
784
- },
785
- mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
786
- };
787
- }
788
- if (targetStrategy.type === "ERC_20_MINTER") {
789
- return {
790
- salesConfig: {
791
- saleType: "erc20",
792
- ...targetStrategy.erc20Minter,
793
- maxTokensPerAddress: BigInt(
794
- targetStrategy.erc20Minter.maxTokensPerAddress
795
- ),
796
- pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
797
- },
798
- mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
799
- };
800
- }
801
- throw new Error("Invalid saleType");
927
+ const responseData = await querySubgraphWithRetries({
928
+ httpClient: this.httpClient,
929
+ subgraphUrl: this.networkConfig.subgraphUrl,
930
+ query,
931
+ variables
802
932
  });
933
+ return parseResponseData(responseData);
934
+ }
935
+ async getContractMintable({
936
+ tokenAddress,
937
+ preferredSaleType
938
+ }) {
939
+ const tokens = await this.querySubgraphWithRetries(
940
+ buildContractTokensQuery({
941
+ tokenAddress
942
+ })
943
+ );
944
+ if (!tokens)
945
+ return [];
946
+ return tokens.filter((x) => x.tokenId !== "0").map(
947
+ (token) => parseTokenQueryResult({
948
+ token,
949
+ tokenId: token.tokenId,
950
+ preferredSaleType
951
+ })
952
+ );
953
+ }
954
+ async getContractPremintTokenIds({
955
+ tokenAddress
956
+ }) {
957
+ const premints = await this.querySubgraphWithRetries(
958
+ buildPremintsOfContractQuery({
959
+ tokenAddress
960
+ })
961
+ );
962
+ return premints?.map((premint) => ({
963
+ tokenId: BigInt(premint.tokenId),
964
+ uid: +premint.uid
965
+ })) || [];
803
966
  }
804
967
  };
805
-
806
- // src/utils.ts
807
- var makeContractParameters = (args) => args;
808
- function mintRecipientOrAccount({
809
- mintRecipient,
810
- minterAccount
968
+ function parseTokenQueryResult({
969
+ token,
970
+ tokenId,
971
+ preferredSaleType
811
972
  }) {
812
- return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
973
+ const targetStrategy = getTargetStrategy({
974
+ tokenId,
975
+ preferredSaleType,
976
+ token
977
+ });
978
+ const tokenInfo = parseTokenInfo(token);
979
+ const salesConfig = parseSalesConfig(targetStrategy);
980
+ if (isErc20SaleStrategy(salesConfig)) {
981
+ tokenInfo.mintFeePerQuantity = 0n;
982
+ }
983
+ return {
984
+ ...tokenInfo,
985
+ salesConfig
986
+ };
987
+ }
988
+ function parseTokenInfo(token) {
989
+ return {
990
+ contract: {
991
+ address: token.contract.address,
992
+ name: token.contract.name,
993
+ URI: token.contract.contractURI
994
+ },
995
+ tokenURI: token.uri,
996
+ tokenId: token.tokenId ? BigInt(token.tokenId) : void 0,
997
+ mintType: token.tokenStandard === "ERC721" ? "721" : "1155",
998
+ creator: token.creator,
999
+ totalMinted: BigInt(token.totalMinted),
1000
+ maxSupply: BigInt(token.maxSupply),
1001
+ mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity),
1002
+ contractVersion: token.contract.contractVersion
1003
+ };
813
1004
  }
814
1005
 
815
1006
  // src/premint/premint-client.ts
@@ -967,7 +1158,7 @@ var PremintClient = class {
967
1158
  * @returns PremintSignatureGetResponse of premint data from the API
968
1159
  */
969
1160
  async getPremint({ address, uid }) {
970
- return await this.apiClient.getSignature({
1161
+ return await this.apiClient.get({
971
1162
  collectionAddress: address,
972
1163
  uid
973
1164
  });
@@ -1202,10 +1393,9 @@ async function updatePremint({
1202
1393
  chainId
1203
1394
  }) {
1204
1395
  const {
1205
- premintConfig,
1206
- collection: collectionCreationConfig,
1207
- premintConfigVersion
1208
- } = await apiClient.getSignature({
1396
+ premint: { premintConfig, premintConfigVersion },
1397
+ collection: collectionCreationConfig
1398
+ } = await apiClient.get({
1209
1399
  collectionAddress: collection,
1210
1400
  uid
1211
1401
  });
@@ -1233,11 +1423,10 @@ async function deletePremint({
1233
1423
  chainId
1234
1424
  }) {
1235
1425
  const {
1236
- premintConfig,
1237
- premintConfigVersion,
1426
+ premint: { premintConfig, premintConfigVersion },
1238
1427
  collection: collectionCreationConfig,
1239
1428
  collectionAddress
1240
- } = await apiClient.getSignature({
1429
+ } = await apiClient.get({
1241
1430
  collectionAddress: collection,
1242
1431
  uid
1243
1432
  });
@@ -1271,26 +1460,39 @@ async function collectPremint({
1271
1460
  if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
1272
1461
  throw new Error("Quantity to mint cannot be below 1");
1273
1462
  }
1274
- const {
1275
- premintConfig,
1276
- premintConfigVersion,
1277
- collection,
1278
- collectionAddress,
1279
- signature
1280
- } = await premintGetter.getSignature({
1463
+ const premint = await premintGetter.get({
1281
1464
  collectionAddress: tokenContract,
1282
1465
  uid
1283
1466
  });
1284
- const numberToMint = BigInt(quantityToMint || 1);
1285
- if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
1286
- throw new Error("PremintV3 not supported in premint SDK");
1287
- }
1288
- const value = (await getPremintMintCosts({
1467
+ const mintFee = await getPremintMintFee({
1289
1468
  tokenContract,
1290
- quantityToMint: numberToMint,
1291
- publicClient,
1292
- tokenPrice: premintConfig.tokenConfig.pricePerToken
1293
- })).totalCostEth;
1469
+ publicClient
1470
+ });
1471
+ return buildPremintMintCall({
1472
+ mintArguments: {
1473
+ minterAccount,
1474
+ quantityToMint,
1475
+ firstMinter,
1476
+ mintComment,
1477
+ mintRecipient,
1478
+ mintReferral
1479
+ },
1480
+ mintFee,
1481
+ premint
1482
+ });
1483
+ }
1484
+ var buildPremintMintCall = ({
1485
+ mintArguments: {
1486
+ minterAccount,
1487
+ mintComment = "",
1488
+ mintRecipient,
1489
+ mintReferral,
1490
+ firstMinter,
1491
+ quantityToMint
1492
+ },
1493
+ premint: { collection, collectionAddress, premint, signature },
1494
+ mintFee
1495
+ }) => {
1294
1496
  const mintArgumentsContract = {
1295
1497
  mintComment,
1296
1498
  mintRecipient: mintRecipientOrAccount({
@@ -1304,6 +1506,10 @@ async function collectPremint({
1304
1506
  const collectionOrEmpty = collection ? defaultAdditionalAdmins(collection) : emptyContractCreationConfig();
1305
1507
  const collectionAddressToSubmit = collection ? import_viem4.zeroAddress : collectionAddress;
1306
1508
  const firstMinterToSubmit = firstMinter || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
1509
+ if (premint.premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
1510
+ throw new Error("PremintV3 not supported in premint SDK");
1511
+ }
1512
+ const value = (mintFee + premint.premintConfig.tokenConfig.pricePerToken) * BigInt(quantityToMint);
1307
1513
  return makeContractParameters({
1308
1514
  account: minterAccount,
1309
1515
  abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
@@ -1313,18 +1519,15 @@ async function collectPremint({
1313
1519
  args: [
1314
1520
  collectionOrEmpty,
1315
1521
  collectionAddressToSubmit,
1316
- (0, import_protocol_deployments3.encodePremintConfig)({
1317
- premintConfig,
1318
- premintConfigVersion
1319
- }),
1522
+ (0, import_protocol_deployments3.encodePremintConfig)(premint),
1320
1523
  signature,
1321
- numberToMint,
1524
+ BigInt(quantityToMint),
1322
1525
  mintArgumentsContract,
1323
1526
  firstMinterToSubmit,
1324
1527
  import_viem4.zeroAddress
1325
1528
  ]
1326
1529
  });
1327
- }
1530
+ };
1328
1531
  function makeUrls({
1329
1532
  uid,
1330
1533
  address,
@@ -1383,6 +1586,19 @@ var getSignature = async ({
1383
1586
  );
1384
1587
  return convertGetPremintApiResponse(result);
1385
1588
  };
1589
+ var getOfCollection = async ({
1590
+ collectionAddress,
1591
+ chainId,
1592
+ httpClient: { retries: retries2, get: get2 } = httpClient
1593
+ }) => {
1594
+ const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
1595
+ const result = await retries2(
1596
+ () => get2(
1597
+ `${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}`
1598
+ )
1599
+ );
1600
+ return convertGetPremintOfCollectionApiResponse(result);
1601
+ };
1386
1602
  var PremintAPIClient = class {
1387
1603
  constructor(chainId, httpClient2) {
1388
1604
  this.postSignature = ({
@@ -1404,10 +1620,7 @@ var PremintAPIClient = class {
1404
1620
  chainId: this.chainId,
1405
1621
  httpClient: this.httpClient
1406
1622
  })).next_uid;
1407
- this.getSignature = async ({
1408
- collectionAddress,
1409
- uid
1410
- }) => {
1623
+ this.get = async ({ collectionAddress, uid }) => {
1411
1624
  return getSignature({
1412
1625
  collectionAddress,
1413
1626
  uid,
@@ -1415,170 +1628,102 @@ var PremintAPIClient = class {
1415
1628
  httpClient: this.httpClient
1416
1629
  });
1417
1630
  };
1631
+ this.getOfCollection = async ({
1632
+ collectionAddress
1633
+ }) => {
1634
+ return getOfCollection({
1635
+ collectionAddress,
1636
+ chainId: this.chainId,
1637
+ httpClient: this.httpClient
1638
+ });
1639
+ };
1418
1640
  this.chainId = chainId;
1419
1641
  this.httpClient = httpClient2 || httpClient;
1420
1642
  }
1421
1643
  };
1422
1644
 
1423
- // src/mint/mint-client.ts
1645
+ // src/mint/mint-transactions.ts
1424
1646
  var import_viem5 = require("viem");
1425
1647
  var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
1426
1648
 
1427
- // src/mint/types.ts
1428
- var isOnChainMint = (mint2) => mint2.mintType !== "premint";
1429
- var is1155Mint = (mint2) => mint2.mintType === "1155";
1430
- function isErc20SaleStrategy(salesConfig) {
1431
- return salesConfig.saleType === "erc20";
1432
- }
1433
-
1434
- // src/mint/mint-client.ts
1435
- var MintError = class extends Error {
1436
- };
1437
- var MintInactiveError = class extends Error {
1438
- };
1439
- var Errors = {
1440
- MintError,
1441
- MintInactiveError
1442
- };
1443
- var MintClient = class {
1444
- constructor({
1445
- chainId,
1446
- publicClient,
1447
- premintGetter,
1448
- mintGetter
1449
- }) {
1450
- this.chainId = chainId;
1451
- this.publicClient = publicClient;
1452
- this.mintGetter = mintGetter;
1453
- this.premintGetter = premintGetter;
1454
- }
1455
- /**
1456
- * Returns the parameters needed to prepare a transaction mint a token.
1457
- * Works with premint, onchain 1155, and onchain 721.
1458
- *
1459
- * @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
1460
- * @returns Parameters for simulating/executing the mint transaction
1461
- */
1462
- async mint(parameters) {
1463
- return mint({
1464
- parameters,
1465
- chainId: this.chainId,
1466
- publicClient: this.publicClient,
1467
- mintGetter: this.mintGetter,
1468
- premintGetter: this.premintGetter
1469
- });
1470
- }
1471
- /**
1472
- * Gets the costs to mint the quantity of tokens specified for a mint.
1473
- * @param parameters - Parameters for the mint {@link GetMintCostsParameters}
1474
- * @returns Costs to mint the quantity of tokens specified
1475
- */
1476
- async getMintCosts(parameters) {
1477
- return getMintCosts({
1478
- ...parameters,
1479
- mintGetter: this.mintGetter,
1480
- premintGetter: this.premintGetter,
1481
- publicClient: this.publicClient
1482
- });
1649
+ // src/mint/utils.ts
1650
+ var semver = __toESM(require("semver"), 1);
1651
+ var contractSupportsNewMintFunction = (contractVersion) => {
1652
+ if (!contractVersion) {
1653
+ return false;
1483
1654
  }
1655
+ const semVerContractVersion = semver.coerce(contractVersion)?.raw;
1656
+ if (!semVerContractVersion)
1657
+ return false;
1658
+ return semver.gte(semVerContractVersion, "2.9.0");
1484
1659
  };
1485
- function isPremintCollect(parameters) {
1486
- return parameters.mintType === "premint";
1487
- }
1488
- function is721Collect(parameters) {
1489
- return parameters.mintType === "721";
1490
- }
1491
- async function mint({
1492
- parameters,
1493
- chainId,
1494
- publicClient,
1495
- mintGetter,
1496
- premintGetter
1660
+
1661
+ // src/mint/mint-transactions.ts
1662
+ function makeOnchainMintCall({
1663
+ token,
1664
+ mintParams
1497
1665
  }) {
1498
- if (isPremintCollect(parameters)) {
1499
- return {
1500
- parameters: await collectPremint({
1501
- ...parameters,
1502
- premintGetter,
1503
- publicClient
1504
- })
1505
- };
1666
+ if (token.mintType === "721") {
1667
+ return makePrepareMint721TokenParams({
1668
+ salesConfigAndTokenInfo: token,
1669
+ tokenContract: token.contract.address,
1670
+ ...mintParams
1671
+ });
1506
1672
  }
1507
- return {
1508
- parameters: await collectOnchain({
1509
- ...parameters,
1510
- mintGetter,
1511
- chainId
1512
- })
1513
- };
1514
- }
1515
- function requestErc20ApprovalForMint({
1516
- account,
1517
- tokenAddress,
1518
- quantityErc20,
1519
- erc20MinterAddress: erc20MinterAddress2
1520
- }) {
1521
- return makeContractParameters({
1522
- abi: import_viem5.erc20Abi,
1523
- address: tokenAddress,
1524
- account,
1525
- functionName: "approve",
1526
- args: [erc20MinterAddress2, quantityErc20]
1673
+ return makePrepareMint1155TokenParams({
1674
+ salesConfigAndTokenInfo: token,
1675
+ tokenContract: token.contract.address,
1676
+ tokenId: token.tokenId,
1677
+ ...mintParams
1527
1678
  });
1528
1679
  }
1529
- async function getNecessaryErc20Approval({
1530
- chainId,
1531
- account,
1532
- tokenAddress,
1533
- quantityErc20,
1534
- publicClient
1680
+ function makePrepareMint1155TokenParams({
1681
+ tokenContract,
1682
+ tokenId,
1683
+ salesConfigAndTokenInfo,
1684
+ minterAccount,
1685
+ mintComment,
1686
+ mintReferral,
1687
+ mintRecipient,
1688
+ quantityToMint
1535
1689
  }) {
1536
- const destination = import_protocol_deployments6.erc20MinterAddress[chainId];
1537
- const allowance = await publicClient.readContract({
1538
- abi: import_viem5.erc20Abi,
1539
- address: tokenAddress,
1540
- functionName: "allowance",
1541
- account,
1542
- args: [
1543
- destination,
1544
- import_protocol_deployments6.erc20MinterAddress[chainId]
1545
- ]
1546
- });
1547
- if (allowance < quantityErc20) {
1548
- return requestErc20ApprovalForMint({
1549
- erc20MinterAddress: destination,
1550
- account,
1551
- tokenAddress,
1552
- quantityErc20: quantityErc20 - allowance
1690
+ const mintQuantity = BigInt(quantityToMint || 1);
1691
+ const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
1692
+ const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
1693
+ if (saleType === "fixedPrice") {
1694
+ return makeEthMintCall({
1695
+ mintComment,
1696
+ minterAccount,
1697
+ mintQuantity,
1698
+ mintReferral,
1699
+ mintTo,
1700
+ salesConfigAndTokenInfo,
1701
+ tokenContract,
1702
+ tokenId
1553
1703
  });
1554
1704
  }
1555
- return void 0;
1556
- }
1557
- async function collectOnchain({
1558
- chainId,
1559
- mintGetter,
1560
- ...parameters
1561
- }) {
1562
- const { tokenContract, saleType } = parameters;
1563
- const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
1564
- const salesConfigAndTokenInfo = await mintGetter.getSalesConfigAndTokenInfo({
1565
- tokenId,
1566
- tokenAddress: tokenContract,
1567
- saleType
1568
- });
1569
- if (is721Collect(parameters)) {
1570
- return makePrepareMint721TokenParams({
1571
- salesConfigAndTokenInfo,
1572
- ...parameters
1705
+ if (saleType === "erc20") {
1706
+ return makeContractParameters({
1707
+ abi: import_protocol_deployments6.erc20MinterABI,
1708
+ functionName: "mint",
1709
+ account: minterAccount,
1710
+ address: salesConfigAndTokenInfo.salesConfig.address,
1711
+ /* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
1712
+ args: [
1713
+ mintTo,
1714
+ mintQuantity,
1715
+ tokenContract,
1716
+ BigInt(tokenId),
1717
+ salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
1718
+ salesConfigAndTokenInfo.salesConfig.currency,
1719
+ mintReferral || import_viem5.zeroAddress,
1720
+ mintComment || ""
1721
+ ]
1573
1722
  });
1574
1723
  }
1575
- return makePrepareMint1155TokenParams({
1576
- salesConfigAndTokenInfo,
1577
- chainId,
1578
- ...parameters
1579
- });
1724
+ throw new Error("Unsupported sale type");
1580
1725
  }
1581
- async function makePrepareMint721TokenParams({
1726
+ function makePrepareMint721TokenParams({
1582
1727
  salesConfigAndTokenInfo,
1583
1728
  minterAccount,
1584
1729
  tokenContract,
@@ -1589,7 +1734,8 @@ async function makePrepareMint721TokenParams({
1589
1734
  }) {
1590
1735
  const actualQuantityToMint = BigInt(quantityToMint || 1);
1591
1736
  const mintValue = parseMintCosts({
1592
- salesConfigAndTokenInfo,
1737
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
1738
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
1593
1739
  quantityToMint: actualQuantityToMint
1594
1740
  }).totalCostEth;
1595
1741
  return makeContractParameters({
@@ -1606,15 +1752,65 @@ async function makePrepareMint721TokenParams({
1606
1752
  ]
1607
1753
  });
1608
1754
  }
1609
- function parseMintCosts({
1755
+ function makeEthMintCall({
1756
+ tokenContract,
1757
+ tokenId,
1610
1758
  salesConfigAndTokenInfo,
1759
+ minterAccount,
1760
+ mintComment,
1761
+ mintReferral,
1762
+ mintQuantity,
1763
+ mintTo
1764
+ }) {
1765
+ const mintValue = parseMintCosts({
1766
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
1767
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
1768
+ quantityToMint: mintQuantity
1769
+ }).totalCostEth;
1770
+ const minterArguments = (0, import_viem5.encodeAbiParameters)(
1771
+ (0, import_viem5.parseAbiParameters)("address, string"),
1772
+ [mintTo, mintComment || ""]
1773
+ );
1774
+ if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
1775
+ return makeContractParameters({
1776
+ abi: import_protocol_deployments6.zoraCreator1155ImplABI,
1777
+ functionName: "mint",
1778
+ account: minterAccount,
1779
+ value: mintValue,
1780
+ address: tokenContract,
1781
+ args: [
1782
+ salesConfigAndTokenInfo.salesConfig.address,
1783
+ BigInt(tokenId),
1784
+ mintQuantity,
1785
+ mintReferral ? [mintReferral] : [],
1786
+ minterArguments
1787
+ ]
1788
+ });
1789
+ }
1790
+ return makeContractParameters({
1791
+ abi: import_protocol_deployments6.zoraCreator1155ImplABI,
1792
+ functionName: "mintWithRewards",
1793
+ account: minterAccount,
1794
+ value: mintValue,
1795
+ address: tokenContract,
1796
+ /* args: minter, tokenId, quantity, minterArguments, mintReferral */
1797
+ args: [
1798
+ salesConfigAndTokenInfo.salesConfig.address,
1799
+ BigInt(tokenId),
1800
+ mintQuantity,
1801
+ minterArguments,
1802
+ mintReferral || import_viem5.zeroAddress
1803
+ ]
1804
+ });
1805
+ }
1806
+ function parseMintCosts({
1807
+ salesConfig,
1808
+ mintFeePerQuantity,
1611
1809
  quantityToMint
1612
1810
  }) {
1613
- const mintFeeForTokens = salesConfigAndTokenInfo.mintFeePerQuantity * quantityToMint;
1614
- const tokenPurchaseCost = BigInt(salesConfigAndTokenInfo.salesConfig.pricePerToken) * quantityToMint;
1615
- const totalPurchaseCostCurrency = isErc20SaleStrategy(
1616
- salesConfigAndTokenInfo.salesConfig
1617
- ) ? salesConfigAndTokenInfo.salesConfig.currency : void 0;
1811
+ const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
1812
+ const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
1813
+ const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
1618
1814
  const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
1619
1815
  return {
1620
1816
  mintFee: mintFeeForTokens,
@@ -1623,90 +1819,334 @@ function parseMintCosts({
1623
1819
  totalCostEth: mintFeeForTokens + totalPurchaseCostEth
1624
1820
  };
1625
1821
  }
1626
- async function getMintCosts(params) {
1627
- const { quantityMinted: quantityToMint, collection, publicClient } = params;
1822
+
1823
+ // src/mint/mint-queries.ts
1824
+ var import_viem6 = require("viem");
1825
+ async function getMint({
1826
+ params,
1827
+ mintGetter,
1828
+ premintGetter,
1829
+ publicClient
1830
+ }) {
1831
+ const { tokenContract } = params;
1832
+ if (isOnChainMint(params)) {
1833
+ const tokenId = is1155Mint(params) ? params.tokenId : void 0;
1834
+ const result = await mintGetter.getMintable({
1835
+ tokenId,
1836
+ tokenAddress: tokenContract,
1837
+ preferredSaleType: params.preferredSaleType
1838
+ });
1839
+ return toMintableReturn(result);
1840
+ }
1841
+ const premint = await premintGetter.get({
1842
+ collectionAddress: tokenContract,
1843
+ uid: params.uid
1844
+ });
1845
+ const mintFee = await getPremintMintFee({
1846
+ publicClient,
1847
+ tokenContract
1848
+ });
1849
+ return toPremintMintReturn({ premint, mintFee });
1850
+ }
1851
+ async function getPremintsOfCollectionWithTokenIds({
1852
+ premintGetter,
1853
+ mintGetter,
1854
+ tokenContract
1855
+ }) {
1856
+ const { collection, premints } = await premintGetter.getOfCollection({
1857
+ collectionAddress: tokenContract
1858
+ });
1859
+ const premintUidsAndTokenIds = await mintGetter.getContractPremintTokenIds({
1860
+ tokenAddress: tokenContract
1861
+ });
1862
+ const premintsWithTokenId = premints.map((premint) => ({
1863
+ ...premint,
1864
+ tokenId: premintUidsAndTokenIds.find(
1865
+ ({ uid }) => uid === premint.premint.premintConfig.uid
1866
+ )?.tokenId
1867
+ }));
1868
+ return {
1869
+ collection,
1870
+ premints: premintsWithTokenId
1871
+ };
1872
+ }
1873
+ async function getMintsOfContract({
1874
+ params,
1875
+ mintGetter,
1876
+ premintGetter,
1877
+ publicClient
1878
+ }) {
1879
+ const onchainMints = (await mintGetter.getContractMintable({
1880
+ tokenAddress: params.tokenContract
1881
+ })).map(toMintableReturn);
1882
+ const offchainMints = await getPremintsOfContractMintable({
1883
+ mintGetter,
1884
+ premintGetter,
1885
+ publicClient,
1886
+ params: {
1887
+ tokenContract: params.tokenContract
1888
+ }
1889
+ });
1890
+ const tokens = [...onchainMints, ...offchainMints];
1891
+ return {
1892
+ tokens,
1893
+ contract: tokens[0]?.token.contract
1894
+ };
1895
+ }
1896
+ async function getMintCosts({
1897
+ params,
1898
+ mintGetter,
1899
+ premintGetter,
1900
+ publicClient
1901
+ }) {
1902
+ const { quantityMinted: quantityToMint, collection } = params;
1628
1903
  if (isOnChainMint(params)) {
1629
1904
  const tokenId = is1155Mint(params) ? params.tokenId : void 0;
1630
- const salesConfigAndTokenInfo = await params.mintGetter.getSalesConfigAndTokenInfo({
1905
+ const salesConfigAndTokenInfo = await mintGetter.getMintable({
1631
1906
  tokenId,
1632
1907
  tokenAddress: collection
1633
1908
  });
1634
1909
  return parseMintCosts({
1635
- salesConfigAndTokenInfo,
1910
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
1911
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
1636
1912
  quantityToMint: BigInt(quantityToMint)
1637
1913
  });
1638
1914
  }
1639
1915
  return getPremintMintCostsWithUnknownTokenPrice({
1640
- premintGetter: params.premintGetter,
1916
+ premintGetter,
1641
1917
  publicClient,
1642
1918
  quantityToMint: BigInt(quantityToMint),
1643
1919
  uid: params.uid,
1644
1920
  tokenContract: collection
1645
1921
  });
1646
1922
  }
1647
- function makePrepareMint1155TokenParams({
1648
- tokenContract,
1649
- tokenId,
1650
- salesConfigAndTokenInfo,
1651
- minterAccount,
1652
- mintComment,
1653
- mintReferral,
1654
- mintRecipient,
1655
- quantityToMint,
1656
- chainId
1923
+ async function getPremintsOfContractMintable({
1924
+ mintGetter,
1925
+ premintGetter,
1926
+ publicClient,
1927
+ params
1657
1928
  }) {
1658
- const mintQuantity = BigInt(quantityToMint || 1);
1659
- const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
1660
- const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
1661
- if (saleType === "fixedPrice") {
1662
- const mintValue = parseMintCosts({
1663
- salesConfigAndTokenInfo,
1664
- quantityToMint: mintQuantity
1665
- }).totalCostEth;
1666
- return makeContractParameters({
1667
- abi: import_protocol_deployments6.zoraCreator1155ImplABI,
1668
- functionName: "mintWithRewards",
1669
- account: minterAccount,
1670
- value: mintValue,
1671
- address: tokenContract,
1672
- /* args: minter, tokenId, quantity, minterArguments, mintReferral */
1673
- args: [
1674
- salesConfigAndTokenInfo.salesConfig.address || import_protocol_deployments6.zoraCreatorFixedPriceSaleStrategyAddress[chainId],
1675
- BigInt(tokenId),
1676
- mintQuantity,
1677
- (0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
1678
- mintTo,
1679
- mintComment || ""
1680
- ]),
1681
- mintReferral || import_viem5.zeroAddress
1682
- ]
1929
+ const { premints, collection } = await getPremintsOfCollectionWithTokenIds({
1930
+ mintGetter,
1931
+ premintGetter,
1932
+ tokenContract: params.tokenContract
1933
+ });
1934
+ const offChainPremints = premints.filter(
1935
+ (premint) => (
1936
+ // if premint's uid is not in the list of uids from the subgraph, it is offchain
1937
+ typeof premint.tokenId === "undefined"
1938
+ )
1939
+ );
1940
+ if (offChainPremints.length === 0)
1941
+ return [];
1942
+ const mintFee = await getPremintMintFee({
1943
+ publicClient,
1944
+ tokenContract: params.tokenContract
1945
+ });
1946
+ return offChainPremints.map((premint) => {
1947
+ return toPremintMintReturn({
1948
+ premint: {
1949
+ premint: premint.premint,
1950
+ // todo: fix when api returns signer
1951
+ signer: import_viem6.zeroAddress,
1952
+ collection,
1953
+ collectionAddress: params.tokenContract,
1954
+ signature: premint.signature
1955
+ },
1956
+ mintFee
1683
1957
  });
1958
+ });
1959
+ }
1960
+ function parsePremint({
1961
+ premint,
1962
+ mintFee
1963
+ }) {
1964
+ if (isPremintConfigV1(premint.premint) || isPremintConfigV2(premint.premint)) {
1965
+ return {
1966
+ creator: premint.signer,
1967
+ maxSupply: premint.premint.premintConfig.tokenConfig.maxSupply,
1968
+ mintFeePerQuantity: mintFee,
1969
+ mintType: "premint",
1970
+ uid: premint.premint.premintConfig.uid,
1971
+ contract: {
1972
+ address: premint.collectionAddress,
1973
+ name: premint.collection.contractName,
1974
+ URI: premint.collection.contractURI
1975
+ },
1976
+ tokenURI: premint.premint.premintConfig.tokenConfig.tokenURI,
1977
+ totalMinted: 0n,
1978
+ salesConfig: {
1979
+ duration: premint.premint.premintConfig.tokenConfig.mintDuration,
1980
+ maxTokensPerAddress: premint.premint.premintConfig.tokenConfig.maxTokensPerAddress,
1981
+ pricePerToken: premint.premint.premintConfig.tokenConfig.pricePerToken,
1982
+ saleType: "premint"
1983
+ }
1984
+ };
1684
1985
  }
1685
- if (saleType === "erc20") {
1686
- return makeContractParameters({
1687
- abi: import_protocol_deployments6.erc20MinterABI,
1688
- functionName: "mint",
1689
- account: minterAccount,
1690
- address: salesConfigAndTokenInfo?.salesConfig.address || import_protocol_deployments6.erc20MinterAddress[chainId],
1691
- /* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
1692
- args: [
1693
- mintTo,
1694
- mintQuantity,
1695
- tokenContract,
1696
- BigInt(tokenId),
1697
- salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
1698
- salesConfigAndTokenInfo.salesConfig.currency,
1699
- mintReferral || import_viem5.zeroAddress,
1700
- mintComment || ""
1701
- ]
1986
+ throw new Error("Invalid premint config version");
1987
+ }
1988
+ var makeOnchainPrepareMint = (result) => (params) => ({
1989
+ parameters: makeOnchainMintCall({ token: result, mintParams: params }),
1990
+ erc20Approval: getRequiredErc20Approvals(params, result),
1991
+ costs: parseMintCosts({
1992
+ salesConfig: result.salesConfig,
1993
+ quantityToMint: BigInt(params.quantityToMint),
1994
+ mintFeePerQuantity: result.mintFeePerQuantity
1995
+ })
1996
+ });
1997
+ function toMintableReturn(result) {
1998
+ return { token: result, prepareMint: makeOnchainPrepareMint(result) };
1999
+ }
2000
+ var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
2001
+ parameters: buildPremintMintCall({
2002
+ mintArguments: params,
2003
+ mintFee,
2004
+ premint
2005
+ }),
2006
+ costs: parseMintCosts({
2007
+ mintFeePerQuantity: mintFee,
2008
+ quantityToMint: BigInt(params.quantityToMint),
2009
+ salesConfig: mintable.salesConfig
2010
+ })
2011
+ });
2012
+ function toPremintMintReturn({
2013
+ premint,
2014
+ mintFee
2015
+ }) {
2016
+ const mintable = parsePremint({ premint, mintFee });
2017
+ return {
2018
+ token: mintable,
2019
+ prepareMint: makePremintPrepareMint(mintable, mintFee, premint)
2020
+ };
2021
+ }
2022
+ function getRequiredErc20Approvals(params, result) {
2023
+ if (result.salesConfig.saleType !== "erc20")
2024
+ return void 0;
2025
+ return {
2026
+ quantity: result.salesConfig.pricePerToken * BigInt(params.quantityToMint),
2027
+ approveTo: result.salesConfig.address,
2028
+ erc20: result.salesConfig.currency
2029
+ };
2030
+ }
2031
+
2032
+ // src/mint/mint-client.ts
2033
+ var MintError = class extends Error {
2034
+ };
2035
+ var MintInactiveError = class extends Error {
2036
+ };
2037
+ var Errors = {
2038
+ MintError,
2039
+ MintInactiveError
2040
+ };
2041
+ var MintClient = class {
2042
+ constructor({
2043
+ publicClient,
2044
+ premintGetter,
2045
+ mintGetter
2046
+ }) {
2047
+ this.publicClient = publicClient;
2048
+ this.mintGetter = mintGetter;
2049
+ this.premintGetter = premintGetter;
2050
+ }
2051
+ /**
2052
+ * Returns the parameters needed to prepare a transaction mint a token.
2053
+ * Works with premint, onchain 1155, and onchain 721.
2054
+ *
2055
+ * @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
2056
+ * @returns Parameters for simulating/executing the mint transaction, any necessary erc20 approval, and costs to mint
2057
+ */
2058
+ async mint(parameters) {
2059
+ return mint({
2060
+ parameters,
2061
+ publicClient: this.publicClient,
2062
+ mintGetter: this.mintGetter,
2063
+ premintGetter: this.premintGetter
2064
+ });
2065
+ }
2066
+ /**
2067
+ * Gets an 1155, 721, or premint, and returns both information about it, and a function
2068
+ * that can be used to build a mint transaction for a quantity of items to mint.
2069
+ * @param parameters - Token to get {@link GetMintParameters}
2070
+ * @Returns Information about the mint and a function to build a mint transaction {@link MintableReturn}
2071
+ */
2072
+ async get(parameters) {
2073
+ return getMint({
2074
+ params: parameters,
2075
+ mintGetter: this.mintGetter,
2076
+ premintGetter: this.premintGetter,
2077
+ publicClient: this.publicClient
1702
2078
  });
1703
2079
  }
1704
- throw new MintError("Unsupported sale type");
2080
+ /**
2081
+ * Gets onchain and premint tokens of an 1155 contract. For each token returns both information about it, and a function
2082
+ * that can be used to build a mint transaction for a quantity of items to mint.
2083
+ * @param parameters - Contract address to get tokens for {@link GetMintsOfContractParameters}
2084
+ * @Returns Array of tokens, each containing information about the token and a function to build a mint transaction.
2085
+ */
2086
+ async getOfContract(params) {
2087
+ return getMintsOfContract({
2088
+ params,
2089
+ mintGetter: this.mintGetter,
2090
+ premintGetter: this.premintGetter,
2091
+ publicClient: this.publicClient
2092
+ });
2093
+ }
2094
+ /**
2095
+ * Gets the costs to mint the quantity of tokens specified for a mint.
2096
+ * @param parameters - Parameters for the mint {@link GetMintCostsParameters}
2097
+ * @returns Costs to mint the quantity of tokens specified
2098
+ */
2099
+ async getMintCosts(parameters) {
2100
+ return getMintCosts({
2101
+ params: parameters,
2102
+ mintGetter: this.mintGetter,
2103
+ premintGetter: this.premintGetter,
2104
+ publicClient: this.publicClient
2105
+ });
2106
+ }
2107
+ };
2108
+ async function mint({
2109
+ parameters,
2110
+ publicClient,
2111
+ mintGetter,
2112
+ premintGetter
2113
+ }) {
2114
+ const { prepareMint } = await getMint({
2115
+ params: parameters,
2116
+ mintGetter,
2117
+ premintGetter,
2118
+ publicClient
2119
+ });
2120
+ return prepareMint({
2121
+ minterAccount: parameters.minterAccount,
2122
+ quantityToMint: parameters.quantityToMint,
2123
+ firstMinter: parameters.firstMinter,
2124
+ mintComment: parameters.mintComment,
2125
+ mintRecipient: parameters.mintRecipient,
2126
+ mintReferral: parameters.mintReferral
2127
+ });
2128
+ }
2129
+ async function collectOnchain({
2130
+ chainId,
2131
+ mintGetter,
2132
+ ...parameters
2133
+ }) {
2134
+ const { tokenContract, preferredSaleType: saleType } = parameters;
2135
+ const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
2136
+ const salesConfigAndTokenInfo = await mintGetter.getMintable({
2137
+ tokenId,
2138
+ tokenAddress: tokenContract,
2139
+ preferredSaleType: saleType
2140
+ });
2141
+ return makeOnchainMintCall({
2142
+ mintParams: parameters,
2143
+ token: salesConfigAndTokenInfo
2144
+ });
1705
2145
  }
1706
2146
 
1707
2147
  // src/create/1155-create-helper.ts
1708
2148
  var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
1709
- var import_viem7 = require("viem");
2149
+ var import_viem8 = require("viem");
1710
2150
 
1711
2151
  // src/create/contract-setup.ts
1712
2152
  var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
@@ -1763,15 +2203,15 @@ async function getContractInfo({
1763
2203
 
1764
2204
  // src/create/token-setup.ts
1765
2205
  var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
1766
- var import_viem6 = require("viem");
1767
- var semver = __toESM(require("semver"), 1);
2206
+ var import_viem7 = require("viem");
2207
+ var semver2 = __toESM(require("semver"), 1);
1768
2208
  var PERMISSION_BITS = {
1769
2209
  MINTER: 2n ** 2n
1770
2210
  };
1771
2211
  var saleSettingsOrDefault = (saleSettings) => {
1772
2212
  const SALE_END_FOREVER = 18446744073709551615n;
1773
2213
  const DEFAULT_SALE_SETTINGS = {
1774
- currency: import_viem6.zeroAddress,
2214
+ currency: import_viem7.zeroAddress,
1775
2215
  // Free Mint
1776
2216
  pricePerToken: 0n,
1777
2217
  // Sale start time – defaults to beginning of unix time
@@ -1788,10 +2228,10 @@ var saleSettingsOrDefault = (saleSettings) => {
1788
2228
  };
1789
2229
  function applyNew1155Defaults(props, ownerAddress) {
1790
2230
  const { payoutRecipient: fundsRecipient } = props;
1791
- const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem6.zeroAddress ? fundsRecipient : ownerAddress;
2231
+ const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem7.zeroAddress ? fundsRecipient : ownerAddress;
1792
2232
  return {
1793
2233
  payoutRecipient: fundsRecipientOrOwner,
1794
- createReferral: props.createReferral || import_viem6.zeroAddress,
2234
+ createReferral: props.createReferral || import_viem7.zeroAddress,
1795
2235
  maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
1796
2236
  royaltyBPS: props.royaltyBPS || 1e3,
1797
2237
  salesConfig: saleSettingsOrDefault(props.salesConfig),
@@ -1808,15 +2248,15 @@ function setupErc20Minter({
1808
2248
  maxTokensPerAddress: mintLimit,
1809
2249
  fundsRecipient
1810
2250
  }) {
1811
- const erc20MinterAddress2 = import_protocol_deployments8.erc20MinterAddress[chainId];
1812
- if (!erc20MinterAddress2)
2251
+ const erc20MinterAddress = import_protocol_deployments8.erc20MinterAddress[chainId];
2252
+ if (!erc20MinterAddress)
1813
2253
  throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
1814
- const erc20MinterApproval = (0, import_viem6.encodeFunctionData)({
2254
+ const erc20MinterApproval = (0, import_viem7.encodeFunctionData)({
1815
2255
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1816
2256
  functionName: "addPermission",
1817
- args: [BigInt(nextTokenId), erc20MinterAddress2, PERMISSION_BITS.MINTER]
2257
+ args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
1818
2258
  });
1819
- const saleData = (0, import_viem6.encodeFunctionData)({
2259
+ const saleData = (0, import_viem7.encodeFunctionData)({
1820
2260
  abi: import_protocol_deployments8.erc20MinterABI,
1821
2261
  functionName: "setSale",
1822
2262
  args: [
@@ -1831,13 +2271,13 @@ function setupErc20Minter({
1831
2271
  }
1832
2272
  ]
1833
2273
  });
1834
- const callSale = (0, import_viem6.encodeFunctionData)({
2274
+ const callSale = (0, import_viem7.encodeFunctionData)({
1835
2275
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1836
2276
  functionName: "callSale",
1837
- args: [BigInt(nextTokenId), erc20MinterAddress2, saleData]
2277
+ args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
1838
2278
  });
1839
2279
  return {
1840
- minter: erc20MinterAddress2,
2280
+ minter: erc20MinterAddress,
1841
2281
  setupActions: [erc20MinterApproval, callSale]
1842
2282
  };
1843
2283
  }
@@ -1851,7 +2291,7 @@ function setupFixedPriceMinter({
1851
2291
  fundsRecipient
1852
2292
  }) {
1853
2293
  const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
1854
- const fixedPriceApproval = (0, import_viem6.encodeFunctionData)({
2294
+ const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
1855
2295
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1856
2296
  functionName: "addPermission",
1857
2297
  args: [
@@ -1860,7 +2300,7 @@ function setupFixedPriceMinter({
1860
2300
  PERMISSION_BITS.MINTER
1861
2301
  ]
1862
2302
  });
1863
- const saleData = (0, import_viem6.encodeFunctionData)({
2303
+ const saleData = (0, import_viem7.encodeFunctionData)({
1864
2304
  abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
1865
2305
  functionName: "setSale",
1866
2306
  args: [
@@ -1874,7 +2314,7 @@ function setupFixedPriceMinter({
1874
2314
  }
1875
2315
  ]
1876
2316
  });
1877
- const callSale = (0, import_viem6.encodeFunctionData)({
2317
+ const callSale = (0, import_viem7.encodeFunctionData)({
1878
2318
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1879
2319
  functionName: "callSale",
1880
2320
  args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
@@ -1888,7 +2328,7 @@ function setupMinters({ salesConfig, ...rest }) {
1888
2328
  if (!salesConfig)
1889
2329
  throw new Error("No sales config for token");
1890
2330
  const { currency: currencyAddress } = salesConfig;
1891
- if (currencyAddress === import_viem6.zeroAddress) {
2331
+ if (currencyAddress === import_viem7.zeroAddress) {
1892
2332
  return setupFixedPriceMinter({
1893
2333
  ...salesConfig,
1894
2334
  ...rest
@@ -1903,22 +2343,22 @@ function setupMinters({ salesConfig, ...rest }) {
1903
2343
  function buildSetupNewToken({
1904
2344
  tokenURI,
1905
2345
  maxSupply = OPEN_EDITION_MINT_SIZE,
1906
- createReferral = import_viem6.zeroAddress,
2346
+ createReferral = import_viem7.zeroAddress,
1907
2347
  contractVersion
1908
2348
  }) {
1909
2349
  if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
1910
- return (0, import_viem6.encodeFunctionData)({
2350
+ return (0, import_viem7.encodeFunctionData)({
1911
2351
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1912
2352
  functionName: "setupNewTokenWithCreateReferral",
1913
2353
  args: [tokenURI, BigInt(maxSupply), createReferral]
1914
2354
  });
1915
2355
  }
1916
- if (createReferral !== import_viem6.zeroAddress) {
2356
+ if (createReferral !== import_viem7.zeroAddress) {
1917
2357
  throw new Error(
1918
2358
  "Contract does not support create referral, but one was provided"
1919
2359
  );
1920
2360
  }
1921
- return (0, import_viem6.encodeFunctionData)({
2361
+ return (0, import_viem7.encodeFunctionData)({
1922
2362
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1923
2363
  functionName: "setupNewToken",
1924
2364
  args: [tokenURI, BigInt(maxSupply)]
@@ -1929,8 +2369,8 @@ function setupRoyaltyConfig({
1929
2369
  royaltyRecipient,
1930
2370
  nextTokenId
1931
2371
  }) {
1932
- if (royaltyBPS > 0 && royaltyRecipient != import_viem6.zeroAddress) {
1933
- return (0, import_viem6.encodeFunctionData)({
2372
+ if (royaltyBPS > 0 && royaltyRecipient != import_viem7.zeroAddress) {
2373
+ return (0, import_viem7.encodeFunctionData)({
1934
2374
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1935
2375
  functionName: "updateRoyaltiesForToken",
1936
2376
  args: [
@@ -1953,10 +2393,10 @@ function makeAdminMintCall({
1953
2393
  if (!mintQuantity || mintQuantity <= 0 || !ownerAddress) {
1954
2394
  return null;
1955
2395
  }
1956
- return (0, import_viem6.encodeFunctionData)({
2396
+ return (0, import_viem7.encodeFunctionData)({
1957
2397
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1958
2398
  functionName: "adminMint",
1959
- args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem6.zeroAddress]
2399
+ args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem7.zeroAddress]
1960
2400
  });
1961
2401
  }
1962
2402
  function constructCreate1155TokenCalls(props) {
@@ -1971,7 +2411,7 @@ function constructCreate1155TokenCalls(props) {
1971
2411
  props,
1972
2412
  ownerAddress
1973
2413
  );
1974
- const verifyTokenIdExpected = (0, import_viem6.encodeFunctionData)({
2414
+ const verifyTokenIdExpected = (0, import_viem7.encodeFunctionData)({
1975
2415
  abi: import_protocol_deployments8.zoraCreator1155ImplABI,
1976
2416
  functionName: "assumeLastTokenIdMatches",
1977
2417
  args: [nextTokenId - 1n]
@@ -2015,13 +2455,13 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
2015
2455
  if (!contractStandard || !contractVersion) {
2016
2456
  return false;
2017
2457
  }
2018
- const semVerContractVersion = semver.coerce(contractVersion)?.raw;
2458
+ const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
2019
2459
  if (!semVerContractVersion)
2020
2460
  return false;
2021
2461
  if (contractStandard === "ERC1155") {
2022
- return semver.gte(semVerContractVersion, "1.3.5");
2462
+ return semver2.gte(semVerContractVersion, "1.3.5");
2023
2463
  } else {
2024
- return semver.gte(semVerContractVersion, "14.0.0");
2464
+ return semver2.gte(semVerContractVersion, "14.0.0");
2025
2465
  }
2026
2466
  };
2027
2467
 
@@ -2030,7 +2470,7 @@ var ROYALTY_BPS_DEFAULT = 1e3;
2030
2470
  var getTokenIdFromCreateReceipt = (receipt) => {
2031
2471
  for (const data of receipt.logs) {
2032
2472
  try {
2033
- const decodedLog = (0, import_viem7.decodeEventLog)({
2473
+ const decodedLog = (0, import_viem8.decodeEventLog)({
2034
2474
  abi: import_protocol_deployments9.zoraCreator1155ImplABI,
2035
2475
  eventName: "SetupNewToken",
2036
2476
  ...data
@@ -2212,7 +2652,7 @@ var sumBalances = (mintAccountBalances) => {
2212
2652
 
2213
2653
  // src/mints/mints-contracts.ts
2214
2654
  var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
2215
- var import_viem8 = require("viem");
2655
+ var import_viem9 = require("viem");
2216
2656
  var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
2217
2657
  var mintWithEthParams = ({
2218
2658
  quantity,
@@ -2247,7 +2687,7 @@ var encodeCollectOnManager = ({
2247
2687
  minter,
2248
2688
  zoraCreator1155TokenId,
2249
2689
  mintArguments
2250
- }) => (0, import_viem8.encodeFunctionData)({
2690
+ }) => (0, import_viem9.encodeFunctionData)({
2251
2691
  abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
2252
2692
  functionName: "collect",
2253
2693
  args: [
@@ -2367,8 +2807,8 @@ var encodePremintOnManager = ({
2367
2807
  premintConfig,
2368
2808
  premintSignature,
2369
2809
  mintArguments,
2370
- signerContract = import_viem8.zeroAddress
2371
- }) => (0, import_viem8.encodeFunctionData)({
2810
+ signerContract = import_viem9.zeroAddress
2811
+ }) => (0, import_viem9.encodeFunctionData)({
2372
2812
  abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
2373
2813
  functionName: "collectPremintV2",
2374
2814
  args: [
@@ -2435,7 +2875,7 @@ function decodeCallFailedError(error) {
2435
2875
  if (error.data?.errorName !== "CallFailed")
2436
2876
  throw new Error("Not a CallFailed error");
2437
2877
  const internalErrorData = error.data?.args?.[0];
2438
- return (0, import_viem8.decodeErrorResult)({
2878
+ return (0, import_viem9.decodeErrorResult)({
2439
2879
  abi: import_protocol_deployments10.zoraMintsManagerImplABI,
2440
2880
  data: internalErrorData
2441
2881
  });
@@ -2443,12 +2883,12 @@ function decodeCallFailedError(error) {
2443
2883
 
2444
2884
  // src/mints/mints-eth-unwrapper-and-caller.ts
2445
2885
  var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
2446
- var import_viem9 = require("viem");
2886
+ var import_viem10 = require("viem");
2447
2887
  var makeCallWithEthSafeTransferData = ({
2448
2888
  address: addressToCall,
2449
2889
  call: functionToCall,
2450
2890
  value: valueToSend
2451
- }) => (0, import_viem9.encodeFunctionData)({
2891
+ }) => (0, import_viem10.encodeFunctionData)({
2452
2892
  abi: import_protocol_deployments11.iUnwrapAndForwardActionABI,
2453
2893
  functionName: "callWithEth",
2454
2894
  args: [addressToCall, functionToCall, valueToSend]
@@ -2495,17 +2935,18 @@ function createCollectorClient(params) {
2495
2935
  const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
2496
2936
  const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
2497
2937
  const mintClient = new MintClient({
2498
- chainId: params.chainId,
2499
2938
  publicClient: params.publicClient,
2500
2939
  premintGetter: premintGetterToUse,
2501
2940
  mintGetter: mintGetterToUse
2502
2941
  });
2503
2942
  return {
2504
- getPremint: (p) => premintGetterToUse.getSignature({
2943
+ getPremint: (p) => premintGetterToUse.get({
2505
2944
  collectionAddress: p.address,
2506
2945
  uid: p.uid
2507
2946
  }),
2508
2947
  getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
2948
+ getToken: (p) => mintClient.get(p),
2949
+ getTokensOfContract: (p) => mintClient.getOfContract(p),
2509
2950
  mint: (p) => mintClient.mint(p),
2510
2951
  getMintCosts: (p) => mintClient.getMintCosts(p)
2511
2952
  };
@@ -2521,12 +2962,14 @@ function createCollectorClient(params) {
2521
2962
  SubgraphMintGetter,
2522
2963
  ZORA_API_BASE,
2523
2964
  applyUpdateToPremint,
2965
+ buildPremintMintCall,
2524
2966
  collectOnchain,
2525
2967
  collectPremint,
2526
2968
  collectPremintV2WithMintsParams,
2527
2969
  collectWithMintsParams,
2528
2970
  convertCollectionFromApi,
2529
2971
  convertGetPremintApiResponse,
2972
+ convertGetPremintOfCollectionApiResponse,
2530
2973
  convertPremintFromApi,
2531
2974
  createCollectorClient,
2532
2975
  createCreatorClient,
@@ -2541,10 +2984,8 @@ function createCollectorClient(params) {
2541
2984
  getApiNetworkConfigForChain,
2542
2985
  getDataFromPremintReceipt,
2543
2986
  getDefaultFixedPriceMinterAddress,
2544
- getMintCosts,
2545
2987
  getMintsAccountBalanceWithPriceQuery,
2546
2988
  getMintsEthPrice,
2547
- getNecessaryErc20Approval,
2548
2989
  getPremintCollectionAddress,
2549
2990
  getPremintExecutorAddress,
2550
2991
  getPremintMintCosts,
@@ -2564,15 +3005,12 @@ function createCollectorClient(params) {
2564
3005
  makePermitToCollectPremintOrNonPremint,
2565
3006
  makePermitTransferBatchAndTypeData,
2566
3007
  makePermitTransferTypeData,
2567
- makePrepareMint1155TokenParams,
2568
3008
  makeUrls,
2569
3009
  migratePremintConfigToV2,
2570
3010
  mintWithEthParams,
2571
3011
  mintsBalanceOfAccountParams,
2572
- parseMintCosts,
2573
3012
  recoverCreatorFromCreatorAttribution,
2574
3013
  recoverPremintSigner,
2575
- requestErc20ApprovalForMint,
2576
3014
  selectMintsToCollectWithFromQueryResult,
2577
3015
  sumBalances,
2578
3016
  supportedPremintVersions,