@zoralabs/protocol-sdk 0.6.0 → 0.7.1

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 (86) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +12 -0
  3. package/dist/constants.d.ts +0 -1
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/index.cjs +2023 -431
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2001 -412
  10. package/dist/index.js.map +1 -1
  11. package/dist/ipfs/arweave.d.ts +3 -0
  12. package/dist/ipfs/arweave.d.ts.map +1 -0
  13. package/dist/ipfs/gateway.d.ts +4 -0
  14. package/dist/ipfs/gateway.d.ts.map +1 -0
  15. package/dist/ipfs/index.d.ts +4 -0
  16. package/dist/ipfs/index.d.ts.map +1 -0
  17. package/dist/ipfs/ipfs.d.ts +5 -0
  18. package/dist/ipfs/ipfs.d.ts.map +1 -0
  19. package/dist/ipfs/mimeTypes.d.ts +25 -0
  20. package/dist/ipfs/mimeTypes.d.ts.map +1 -0
  21. package/dist/ipfs/text-metadata.d.ts +5 -0
  22. package/dist/ipfs/text-metadata.d.ts.map +1 -0
  23. package/dist/ipfs/token-metadata.d.ts +14 -0
  24. package/dist/ipfs/token-metadata.d.ts.map +1 -0
  25. package/dist/ipfs/types.d.ts +49 -0
  26. package/dist/ipfs/types.d.ts.map +1 -0
  27. package/dist/mint/mint-client.d.ts +28 -4071
  28. package/dist/mint/mint-client.d.ts.map +1 -1
  29. package/dist/mint/mint-queries.d.ts +38 -0
  30. package/dist/mint/mint-queries.d.ts.map +1 -0
  31. package/dist/mint/mint-transactions.d.ts +20 -0
  32. package/dist/mint/mint-transactions.d.ts.map +1 -0
  33. package/dist/mint/subgraph-mint-getter.d.ts +14 -7
  34. package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
  35. package/dist/mint/subgraph-queries.d.ts +55 -0
  36. package/dist/mint/subgraph-queries.d.ts.map +1 -0
  37. package/dist/mint/types.d.ts +117 -19
  38. package/dist/mint/types.d.ts.map +1 -1
  39. package/dist/mint/utils.d.ts +2 -0
  40. package/dist/mint/utils.d.ts.map +1 -0
  41. package/dist/mints/mints-contracts.d.ts +3 -4494
  42. package/dist/mints/mints-contracts.d.ts.map +1 -1
  43. package/dist/premint/conversions.d.ts +12 -15
  44. package/dist/premint/conversions.d.ts.map +1 -1
  45. package/dist/premint/premint-api-client.d.ts +14 -11
  46. package/dist/premint/premint-api-client.d.ts.map +1 -1
  47. package/dist/premint/premint-client.d.ts +17 -6
  48. package/dist/premint/premint-client.d.ts.map +1 -1
  49. package/dist/premint/preminter.d.ts +1 -1
  50. package/dist/premint/preminter.d.ts.map +1 -1
  51. package/dist/sdk.d.ts +4 -2
  52. package/dist/sdk.d.ts.map +1 -1
  53. package/dist/types.d.ts +3 -0
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/utils.d.ts +10 -2
  56. package/dist/utils.d.ts.map +1 -1
  57. package/package.json +2 -1
  58. package/src/constants.ts +0 -36
  59. package/src/create/1155-create-helper.test.ts +9 -7
  60. package/src/index.ts +2 -0
  61. package/src/ipfs/arweave.ts +5 -0
  62. package/src/ipfs/gateway.ts +48 -0
  63. package/src/ipfs/index.ts +7 -0
  64. package/src/ipfs/ipfs.ts +82 -0
  65. package/src/ipfs/mimeTypes.ts +141 -0
  66. package/src/ipfs/text-metadata.ts +128 -0
  67. package/src/ipfs/token-metadata.ts +99 -0
  68. package/src/ipfs/types.ts +54 -0
  69. package/src/mint/mint-client.test.ts +96 -47
  70. package/src/mint/mint-client.ts +75 -343
  71. package/src/mint/mint-queries.ts +320 -0
  72. package/src/mint/mint-transactions.ts +253 -0
  73. package/src/mint/subgraph-mint-getter.ts +216 -123
  74. package/src/mint/subgraph-queries.ts +170 -0
  75. package/src/mint/types.ts +140 -23
  76. package/src/mint/utils.ts +14 -0
  77. package/src/premint/conversions.ts +26 -2
  78. package/src/premint/premint-api-client.ts +48 -16
  79. package/src/premint/premint-client.test.ts +29 -23
  80. package/src/premint/premint-client.ts +73 -37
  81. package/src/premint/preminter.ts +2 -3
  82. package/src/sdk.ts +7 -4
  83. package/src/types.ts +18 -0
  84. package/src/utils.ts +29 -28
  85. package/test-integration/setup-test-contracts.ts +96 -0
  86. package/test-integration/premint-client.test.ts +0 -148
package/dist/index.js CHANGED
@@ -42,48 +42,13 @@ import { parseAbi } from "viem";
42
42
  var ZORA_API_BASE = "https://api.zora.co/";
43
43
  var OPEN_EDITION_MINT_SIZE = BigInt("18446744073709551615");
44
44
  var SUBGRAPH_CONFIG_BASE = "https://api.goldsky.com/api/public/project_clhk16b61ay9t49vm6ntn4mkz/subgraphs";
45
- function getSubgraph(name, version) {
46
- return `${SUBGRAPH_CONFIG_BASE}/${name}/${version}/gn`;
45
+ function getSubgraph(name, version2) {
46
+ return `${SUBGRAPH_CONFIG_BASE}/${name}/${version2}/gn`;
47
47
  }
48
48
  var zora721Abi = parseAbi([
49
49
  "function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
50
50
  "function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
51
51
  ]);
52
- var NFT_SALE_QUERY = `
53
- fragment SaleStrategy on SalesStrategyConfig {
54
- type
55
- fixedPrice {
56
- address
57
- pricePerToken
58
- saleEnd
59
- saleStart
60
- maxTokensPerAddress
61
- }
62
- erc20Minter {
63
- address
64
- pricePerToken
65
- currency
66
- saleEnd
67
- saleStart
68
- maxTokensPerAddress
69
- }
70
- }
71
-
72
- query ($id: ID!) {
73
- zoraCreateToken(id: $id) {
74
- id
75
- contract {
76
- mintFeePerQuantity
77
- salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
78
- ...SaleStrategy
79
- }
80
- }
81
- salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
82
- ...SaleStrategy
83
- }
84
- }
85
- }
86
- `;
87
52
 
88
53
  // src/apis/chain-constants.ts
89
54
  var REWARD_PER_TOKEN = parseEther("0.000777");
@@ -212,10 +177,22 @@ var convertPremintFromApi = (premint) => {
212
177
  }
213
178
  };
214
179
  var convertGetPremintApiResponse = (response) => ({
215
- ...convertPremintFromApi(response.premint),
216
180
  collection: convertCollectionFromApi(response.collection),
217
181
  collectionAddress: response.collection_address,
218
- signature: response.signature
182
+ signature: response.signature,
183
+ signer: response.signer,
184
+ premint: convertPremintFromApi(response.premint)
185
+ });
186
+ var convertGetPremintOfCollectionApiResponse = (response) => ({
187
+ collection: convertCollectionFromApi({
188
+ contractAdmin: response.contract_admin,
189
+ contractName: response.contract_name,
190
+ contractURI: response.contract_uri
191
+ }),
192
+ premints: response.premints.map((premint) => ({
193
+ premint: convertPremintFromApi(premint),
194
+ signature: premint.signature
195
+ }))
219
196
  });
220
197
  var encodePremintV1ForAPI = ({
221
198
  tokenConfig,
@@ -369,7 +346,7 @@ function migratePremintConfigToV2({
369
346
  };
370
347
  }
371
348
  var recoverCreatorFromCreatorAttribution = async ({
372
- creatorAttribution: { version, domainName, structHash, signature },
349
+ creatorAttribution: { version: version2, domainName, structHash, signature },
373
350
  chainId,
374
351
  tokenContract
375
352
  }) => {
@@ -378,7 +355,7 @@ var recoverCreatorFromCreatorAttribution = async ({
378
355
  chainId,
379
356
  name: domainName,
380
357
  verifyingContract: tokenContract,
381
- version
358
+ version: version2
382
359
  },
383
360
  types: {
384
361
  EIP712Domain: [
@@ -414,11 +391,11 @@ var supportedPremintVersions = async ({
414
391
  });
415
392
  };
416
393
  var supportsPremintVersion = async ({
417
- version,
394
+ version: version2,
418
395
  tokenContract,
419
396
  publicClient
420
397
  }) => {
421
- return (await supportedPremintVersions({ tokenContract, publicClient })).includes(version);
398
+ return (await supportedPremintVersions({ tokenContract, publicClient })).includes(version2);
422
399
  };
423
400
  async function getPremintCollectionAddress({
424
401
  publicClient,
@@ -442,7 +419,7 @@ async function getPremintCollectionAddress({
442
419
  }
443
420
  function applyUpdateToPremint({
444
421
  uid,
445
- version,
422
+ version: version2,
446
423
  tokenConfig,
447
424
  tokenConfigUpdates
448
425
  }) {
@@ -453,7 +430,7 @@ function applyUpdateToPremint({
453
430
  const result = {
454
431
  deleted: false,
455
432
  uid,
456
- version: version + 1,
433
+ version: version2 + 1,
457
434
  tokenConfig: updatedTokenConfig
458
435
  };
459
436
  return result;
@@ -504,7 +481,7 @@ async function getPremintPricePerToken({
504
481
  uid,
505
482
  premintGetter
506
483
  }) {
507
- const premintConfigWithVersion = await premintGetter.getSignature({
484
+ const { premint: premintConfigWithVersion } = await premintGetter.get({
508
485
  collectionAddress: collection,
509
486
  uid
510
487
  });
@@ -646,6 +623,144 @@ var httpClient = {
646
623
  retries
647
624
  };
648
625
 
626
+ // src/mint/types.ts
627
+ var isOnChainMint = (mint2) => mint2.mintType !== "premint";
628
+ var is1155Mint = (mint2) => mint2.mintType === "1155";
629
+ function isErc20SaleStrategy(salesConfig) {
630
+ return salesConfig.saleType === "erc20";
631
+ }
632
+
633
+ // src/utils.ts
634
+ var makeContractParameters = (args) => args;
635
+ function mintRecipientOrAccount({
636
+ mintRecipient,
637
+ minterAccount
638
+ }) {
639
+ return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
640
+ }
641
+ async function querySubgraphWithRetries({
642
+ httpClient: httpClient2,
643
+ subgraphUrl,
644
+ query,
645
+ variables
646
+ }) {
647
+ const { retries: retries2, post: post2 } = httpClient2;
648
+ const result = await retries2(async () => {
649
+ return await post2(subgraphUrl, {
650
+ query,
651
+ variables
652
+ });
653
+ });
654
+ return result?.data;
655
+ }
656
+
657
+ // src/mint/subgraph-queries.ts
658
+ var NFT_SALE_STRATEGY_FRAGMENT = `
659
+ fragment SaleStrategy on SalesStrategyConfig {
660
+ type
661
+ fixedPrice {
662
+ address
663
+ pricePerToken
664
+ saleEnd
665
+ saleStart
666
+ maxTokensPerAddress
667
+ }
668
+ erc20Minter {
669
+ address
670
+ pricePerToken
671
+ currency
672
+ saleEnd
673
+ saleStart
674
+ maxTokensPerAddress
675
+ }
676
+ }`;
677
+ var TOKEN_FRAGMENT = `
678
+ fragment Token on ZoraCreateToken {
679
+ creator
680
+ tokenId
681
+ uri
682
+ totalMinted
683
+ maxSupply
684
+ tokenStandard
685
+ salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
686
+ ...SaleStrategy
687
+ }
688
+ contract {
689
+ address
690
+ mintFeePerQuantity
691
+ contractVersion
692
+ contractURI
693
+ name
694
+ salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
695
+ ...SaleStrategy
696
+ }
697
+ }
698
+ }`;
699
+ var FRAGMENTS = `
700
+ ${NFT_SALE_STRATEGY_FRAGMENT}
701
+ ${TOKEN_FRAGMENT}
702
+ `;
703
+ function buildNftTokenSalesQuery({
704
+ tokenId,
705
+ tokenAddress
706
+ }) {
707
+ return {
708
+ query: `
709
+ ${FRAGMENTS}
710
+ query ($id: ID!) {
711
+ zoraCreateToken(id: $id) {
712
+ ...Token
713
+ }
714
+ }
715
+ `,
716
+ variables: {
717
+ id: tokenId !== void 0 ? (
718
+ // Generic Token ID types all stringify down to the base numeric equivalent.
719
+ `${tokenAddress.toLowerCase()}-${tokenId}`
720
+ ) : `${tokenAddress.toLowerCase()}-0`
721
+ },
722
+ parseResponseData: (responseData) => responseData?.zoraCreateToken
723
+ };
724
+ }
725
+ function buildContractTokensQuery({
726
+ tokenAddress
727
+ }) {
728
+ return {
729
+ query: `
730
+ ${FRAGMENTS}
731
+ query ($contract: Bytes!) {
732
+ zoraCreateTokens(
733
+ where: {address: $contract}
734
+ ) {
735
+ ...Token
736
+ }
737
+ }
738
+ `,
739
+ variables: {
740
+ contract: tokenAddress.toLowerCase()
741
+ },
742
+ parseResponseData: (responseData) => responseData?.zoraCreateTokens
743
+ };
744
+ }
745
+ function buildPremintsOfContractQuery({
746
+ tokenAddress
747
+ }) {
748
+ return {
749
+ query: `
750
+ query ($contractAddress: Bytes!) {
751
+ premints(where:{contractAddress:$contractAddress}) {
752
+ uid
753
+ tokenId
754
+ }
755
+ }
756
+ `,
757
+ variables: {
758
+ contractAddress: tokenAddress.toLowerCase()
759
+ },
760
+ parseResponseData: (responseData) => responseData?.premints
761
+ };
762
+ }
763
+
649
764
  // src/mint/subgraph-mint-getter.ts
650
765
  var getApiNetworkConfigForChain = (chainId) => {
651
766
  if (!networkConfigByChain[chainId]) {
@@ -653,92 +768,171 @@ var getApiNetworkConfigForChain = (chainId) => {
653
768
  }
654
769
  return networkConfigByChain[chainId];
655
770
  };
771
+ function parseSalesConfig(targetStrategy) {
772
+ if (targetStrategy.type === "FIXED_PRICE")
773
+ return {
774
+ saleType: "fixedPrice",
775
+ ...targetStrategy.fixedPrice,
776
+ maxTokensPerAddress: BigInt(
777
+ targetStrategy.fixedPrice.maxTokensPerAddress
778
+ ),
779
+ pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
780
+ };
781
+ if (targetStrategy.type === "ERC_20_MINTER") {
782
+ return {
783
+ saleType: "erc20",
784
+ ...targetStrategy.erc20Minter,
785
+ maxTokensPerAddress: BigInt(
786
+ targetStrategy.erc20Minter.maxTokensPerAddress
787
+ ),
788
+ pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
789
+ };
790
+ }
791
+ throw new Error("Unknown saleType");
792
+ }
793
+ function getSaleEnd(a) {
794
+ return BigInt(
795
+ a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
796
+ );
797
+ }
798
+ function getTargetStrategy({
799
+ tokenId,
800
+ preferredSaleType,
801
+ token
802
+ }) {
803
+ const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
804
+ const saleStrategies = allStrategies.sort(
805
+ (a, b) => getSaleEnd(a) > getSaleEnd(b) ? 1 : -1
806
+ );
807
+ let targetStrategy;
808
+ if (!preferredSaleType) {
809
+ targetStrategy = saleStrategies[0];
810
+ if (!targetStrategy) {
811
+ throw new Error("Cannot find sale strategy");
812
+ }
813
+ } else {
814
+ const mappedSaleType = preferredSaleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
815
+ targetStrategy = saleStrategies.find(
816
+ (strategy) => strategy.type === mappedSaleType
817
+ );
818
+ if (!targetStrategy) {
819
+ const targetStrategy2 = saleStrategies.find(
820
+ (strategy) => strategy.type === "FIXED_PRICE" || strategy.type === "ERC_20_MINTER"
821
+ );
822
+ if (!targetStrategy2)
823
+ throw new Error("Cannot find valid sale strategy");
824
+ return targetStrategy2;
825
+ }
826
+ }
827
+ return targetStrategy;
828
+ }
656
829
  var SubgraphMintGetter = class {
657
830
  constructor(chainId, httpClient2) {
831
+ this.getMintable = async ({
832
+ tokenAddress,
833
+ tokenId,
834
+ preferredSaleType: saleType
835
+ }) => {
836
+ const token = await this.querySubgraphWithRetries(
837
+ buildNftTokenSalesQuery({
838
+ tokenId,
839
+ tokenAddress
840
+ })
841
+ );
842
+ if (!token) {
843
+ throw new Error("Cannot find token");
844
+ }
845
+ return parseTokenQueryResult({
846
+ token,
847
+ tokenId,
848
+ preferredSaleType: saleType
849
+ });
850
+ };
658
851
  this.httpClient = httpClient2 || httpClient;
659
852
  this.networkConfig = getApiNetworkConfigForChain(chainId);
660
853
  }
661
- async getSalesConfigAndTokenInfo({
662
- tokenAddress,
663
- tokenId,
664
- saleType
854
+ async querySubgraphWithRetries({
855
+ query,
856
+ variables,
857
+ parseResponseData
665
858
  }) {
666
- const { retries: retries2, post: post2 } = this.httpClient;
667
- return retries2(async () => {
668
- const response = await post2(this.networkConfig.subgraphUrl, {
669
- query: NFT_SALE_QUERY,
670
- variables: {
671
- id: tokenId !== void 0 ? (
672
- // Generic Token ID types all stringify down to the base numeric equivalent.
673
- `${tokenAddress.toLowerCase()}-${tokenId}`
674
- ) : `${tokenAddress.toLowerCase()}-0`
675
- }
676
- });
677
- const token = response.data?.zoraCreateToken;
678
- if (!token) {
679
- throw new Error("Cannot find a token to mint");
680
- }
681
- const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
682
- const saleStrategies = allStrategies.sort(
683
- (a, b) => BigInt(
684
- a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
685
- ) > BigInt(
686
- b.type === "FIXED_PRICE" ? b.fixedPrice.saleEnd : b.erc20Minter.saleEnd
687
- ) ? 1 : -1
688
- );
689
- let targetStrategy;
690
- if (!saleType) {
691
- targetStrategy = saleStrategies[0];
692
- if (!targetStrategy) {
693
- throw new Error("Cannot find sale strategy");
694
- }
695
- } else {
696
- const mappedSaleType = saleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
697
- targetStrategy = saleStrategies.find(
698
- (strategy) => strategy.type === mappedSaleType
699
- );
700
- if (!targetStrategy) {
701
- throw new Error(`Cannot find sale strategy for ${mappedSaleType}`);
702
- }
703
- }
704
- if (targetStrategy.type === "FIXED_PRICE") {
705
- return {
706
- salesConfig: {
707
- saleType: "fixedPrice",
708
- ...targetStrategy.fixedPrice,
709
- maxTokensPerAddress: BigInt(
710
- targetStrategy.fixedPrice.maxTokensPerAddress
711
- ),
712
- pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
713
- },
714
- mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
715
- };
716
- }
717
- if (targetStrategy.type === "ERC_20_MINTER") {
718
- return {
719
- salesConfig: {
720
- saleType: "erc20",
721
- ...targetStrategy.erc20Minter,
722
- maxTokensPerAddress: BigInt(
723
- targetStrategy.erc20Minter.maxTokensPerAddress
724
- ),
725
- pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
726
- },
727
- mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
728
- };
729
- }
730
- throw new Error("Invalid saleType");
859
+ const responseData = await querySubgraphWithRetries({
860
+ httpClient: this.httpClient,
861
+ subgraphUrl: this.networkConfig.subgraphUrl,
862
+ query,
863
+ variables
731
864
  });
865
+ return parseResponseData(responseData);
866
+ }
867
+ async getContractMintable({
868
+ tokenAddress,
869
+ preferredSaleType
870
+ }) {
871
+ const tokens = await this.querySubgraphWithRetries(
872
+ buildContractTokensQuery({
873
+ tokenAddress
874
+ })
875
+ );
876
+ if (!tokens)
877
+ return [];
878
+ return tokens.filter((x) => x.tokenId !== "0").map(
879
+ (token) => parseTokenQueryResult({
880
+ token,
881
+ tokenId: token.tokenId,
882
+ preferredSaleType
883
+ })
884
+ );
885
+ }
886
+ async getContractPremintTokenIds({
887
+ tokenAddress
888
+ }) {
889
+ const premints = await this.querySubgraphWithRetries(
890
+ buildPremintsOfContractQuery({
891
+ tokenAddress
892
+ })
893
+ );
894
+ return premints?.map((premint) => ({
895
+ tokenId: BigInt(premint.tokenId),
896
+ uid: +premint.uid
897
+ })) || [];
732
898
  }
733
899
  };
734
-
735
- // src/utils.ts
736
- var makeContractParameters = (args) => args;
737
- function mintRecipientOrAccount({
738
- mintRecipient,
739
- minterAccount
900
+ function parseTokenQueryResult({
901
+ token,
902
+ tokenId,
903
+ preferredSaleType
740
904
  }) {
741
- return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
905
+ const targetStrategy = getTargetStrategy({
906
+ tokenId,
907
+ preferredSaleType,
908
+ token
909
+ });
910
+ const tokenInfo = parseTokenInfo(token);
911
+ const salesConfig = parseSalesConfig(targetStrategy);
912
+ if (isErc20SaleStrategy(salesConfig)) {
913
+ tokenInfo.mintFeePerQuantity = 0n;
914
+ }
915
+ return {
916
+ ...tokenInfo,
917
+ salesConfig
918
+ };
919
+ }
920
+ function parseTokenInfo(token) {
921
+ return {
922
+ contract: {
923
+ address: token.contract.address,
924
+ name: token.contract.name,
925
+ URI: token.contract.contractURI
926
+ },
927
+ tokenURI: token.uri,
928
+ tokenId: token.tokenId ? BigInt(token.tokenId) : void 0,
929
+ mintType: token.tokenStandard === "ERC721" ? "721" : "1155",
930
+ creator: token.creator,
931
+ totalMinted: BigInt(token.totalMinted),
932
+ maxSupply: BigInt(token.maxSupply),
933
+ mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity),
934
+ contractVersion: token.contract.contractVersion
935
+ };
742
936
  }
743
937
 
744
938
  // src/premint/premint-client.ts
@@ -896,7 +1090,7 @@ var PremintClient = class {
896
1090
  * @returns PremintSignatureGetResponse of premint data from the API
897
1091
  */
898
1092
  async getPremint({ address, uid }) {
899
- return await this.apiClient.getSignature({
1093
+ return await this.apiClient.get({
900
1094
  collectionAddress: address,
901
1095
  uid
902
1096
  });
@@ -1025,13 +1219,19 @@ function makePremintReturn({
1025
1219
  premintConfigVersion
1026
1220
  });
1027
1221
  };
1222
+ const urls = makeUrls({
1223
+ chainId,
1224
+ address: collectionAddress,
1225
+ uid: premintConfig.uid
1226
+ });
1028
1227
  return {
1029
1228
  premintConfig,
1030
1229
  premintConfigVersion,
1031
1230
  typedDataDefinition,
1032
1231
  collectionAddress,
1033
1232
  signAndSubmit,
1034
- submit
1233
+ submit,
1234
+ urls
1035
1235
  };
1036
1236
  }
1037
1237
  async function signPremint({
@@ -1131,10 +1331,9 @@ async function updatePremint({
1131
1331
  chainId
1132
1332
  }) {
1133
1333
  const {
1134
- premintConfig,
1135
- collection: collectionCreationConfig,
1136
- premintConfigVersion
1137
- } = await apiClient.getSignature({
1334
+ premint: { premintConfig, premintConfigVersion },
1335
+ collection: collectionCreationConfig
1336
+ } = await apiClient.get({
1138
1337
  collectionAddress: collection,
1139
1338
  uid
1140
1339
  });
@@ -1162,11 +1361,10 @@ async function deletePremint({
1162
1361
  chainId
1163
1362
  }) {
1164
1363
  const {
1165
- premintConfig,
1166
- premintConfigVersion,
1364
+ premint: { premintConfig, premintConfigVersion },
1167
1365
  collection: collectionCreationConfig,
1168
1366
  collectionAddress
1169
- } = await apiClient.getSignature({
1367
+ } = await apiClient.get({
1170
1368
  collectionAddress: collection,
1171
1369
  uid
1172
1370
  });
@@ -1200,26 +1398,39 @@ async function collectPremint({
1200
1398
  if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
1201
1399
  throw new Error("Quantity to mint cannot be below 1");
1202
1400
  }
1203
- const {
1204
- premintConfig,
1205
- premintConfigVersion,
1206
- collection,
1207
- collectionAddress,
1208
- signature
1209
- } = await premintGetter.getSignature({
1401
+ const premint = await premintGetter.get({
1210
1402
  collectionAddress: tokenContract,
1211
1403
  uid
1212
1404
  });
1213
- const numberToMint = BigInt(quantityToMint || 1);
1214
- if (premintConfigVersion === PremintConfigVersion2.V3) {
1215
- throw new Error("PremintV3 not supported in premint SDK");
1216
- }
1217
- const value = (await getPremintMintCosts({
1405
+ const mintFee = await getPremintMintFee({
1218
1406
  tokenContract,
1219
- quantityToMint: numberToMint,
1220
- publicClient,
1221
- tokenPrice: premintConfig.tokenConfig.pricePerToken
1222
- })).totalCostEth;
1407
+ publicClient
1408
+ });
1409
+ return buildPremintMintCall({
1410
+ mintArguments: {
1411
+ minterAccount,
1412
+ quantityToMint,
1413
+ firstMinter,
1414
+ mintComment,
1415
+ mintRecipient,
1416
+ mintReferral
1417
+ },
1418
+ mintFee,
1419
+ premint
1420
+ });
1421
+ }
1422
+ var buildPremintMintCall = ({
1423
+ mintArguments: {
1424
+ minterAccount,
1425
+ mintComment = "",
1426
+ mintRecipient,
1427
+ mintReferral,
1428
+ firstMinter,
1429
+ quantityToMint
1430
+ },
1431
+ premint: { collection, collectionAddress, premint, signature },
1432
+ mintFee
1433
+ }) => {
1223
1434
  const mintArgumentsContract = {
1224
1435
  mintComment,
1225
1436
  mintRecipient: mintRecipientOrAccount({
@@ -1233,6 +1444,10 @@ async function collectPremint({
1233
1444
  const collectionOrEmpty = collection ? defaultAdditionalAdmins(collection) : emptyContractCreationConfig();
1234
1445
  const collectionAddressToSubmit = collection ? zeroAddress2 : collectionAddress;
1235
1446
  const firstMinterToSubmit = firstMinter || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
1447
+ if (premint.premintConfigVersion === PremintConfigVersion2.V3) {
1448
+ throw new Error("PremintV3 not supported in premint SDK");
1449
+ }
1450
+ const value = (mintFee + premint.premintConfig.tokenConfig.pricePerToken) * BigInt(quantityToMint);
1236
1451
  return makeContractParameters({
1237
1452
  account: minterAccount,
1238
1453
  abi: zoraCreator1155PremintExecutorImplABI2,
@@ -1242,18 +1457,15 @@ async function collectPremint({
1242
1457
  args: [
1243
1458
  collectionOrEmpty,
1244
1459
  collectionAddressToSubmit,
1245
- encodePremintConfig({
1246
- premintConfig,
1247
- premintConfigVersion
1248
- }),
1460
+ encodePremintConfig(premint),
1249
1461
  signature,
1250
- numberToMint,
1462
+ BigInt(quantityToMint),
1251
1463
  mintArgumentsContract,
1252
1464
  firstMinterToSubmit,
1253
1465
  zeroAddress2
1254
1466
  ]
1255
1467
  });
1256
- }
1468
+ };
1257
1469
  function makeUrls({
1258
1470
  uid,
1259
1471
  address,
@@ -1314,6 +1526,19 @@ var getSignature = async ({
1314
1526
  );
1315
1527
  return convertGetPremintApiResponse(result);
1316
1528
  };
1529
+ var getOfCollection = async ({
1530
+ collectionAddress,
1531
+ chainId,
1532
+ httpClient: { retries: retries2, get: get2 } = httpClient
1533
+ }) => {
1534
+ const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
1535
+ const result = await retries2(
1536
+ () => get2(
1537
+ `${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}`
1538
+ )
1539
+ );
1540
+ return convertGetPremintOfCollectionApiResponse(result);
1541
+ };
1317
1542
  var PremintAPIClient = class {
1318
1543
  constructor(chainId, httpClient2) {
1319
1544
  this.postSignature = ({
@@ -1335,10 +1560,7 @@ var PremintAPIClient = class {
1335
1560
  chainId: this.chainId,
1336
1561
  httpClient: this.httpClient
1337
1562
  })).next_uid;
1338
- this.getSignature = async ({
1339
- collectionAddress,
1340
- uid
1341
- }) => {
1563
+ this.get = async ({ collectionAddress, uid }) => {
1342
1564
  return getSignature({
1343
1565
  collectionAddress,
1344
1566
  uid,
@@ -1346,180 +1568,109 @@ var PremintAPIClient = class {
1346
1568
  httpClient: this.httpClient
1347
1569
  });
1348
1570
  };
1571
+ this.getOfCollection = async ({
1572
+ collectionAddress
1573
+ }) => {
1574
+ return getOfCollection({
1575
+ collectionAddress,
1576
+ chainId: this.chainId,
1577
+ httpClient: this.httpClient
1578
+ });
1579
+ };
1349
1580
  this.chainId = chainId;
1350
1581
  this.httpClient = httpClient2 || httpClient;
1351
1582
  }
1352
1583
  };
1353
1584
 
1354
- // src/mint/mint-client.ts
1585
+ // src/mint/mint-transactions.ts
1355
1586
  import {
1356
1587
  encodeAbiParameters,
1357
1588
  parseAbiParameters,
1358
- zeroAddress as zeroAddress3,
1359
- erc20Abi
1589
+ zeroAddress as zeroAddress3
1360
1590
  } from "viem";
1361
1591
  import {
1362
1592
  erc20MinterABI,
1363
- erc20MinterAddress,
1364
- zoraCreator1155ImplABI as zoraCreator1155ImplABI2,
1365
- zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress2
1593
+ zoraCreator1155ImplABI as zoraCreator1155ImplABI2
1366
1594
  } from "@zoralabs/protocol-deployments";
1367
1595
 
1368
- // src/mint/types.ts
1369
- var isOnChainMint = (mint2) => mint2.mintType !== "premint";
1370
- var is1155Mint = (mint2) => mint2.mintType === "1155";
1371
- function isErc20SaleStrategy(salesConfig) {
1372
- return salesConfig.saleType === "erc20";
1373
- }
1374
-
1375
- // src/mint/mint-client.ts
1376
- var MintError = class extends Error {
1377
- };
1378
- var MintInactiveError = class extends Error {
1379
- };
1380
- var Errors = {
1381
- MintError,
1382
- MintInactiveError
1596
+ // src/mint/utils.ts
1597
+ import * as semver from "semver";
1598
+ var contractSupportsNewMintFunction = (contractVersion) => {
1599
+ if (!contractVersion) {
1600
+ return false;
1601
+ }
1602
+ const semVerContractVersion = semver.coerce(contractVersion)?.raw;
1603
+ if (!semVerContractVersion)
1604
+ return false;
1605
+ return semver.gte(semVerContractVersion, "2.9.0");
1383
1606
  };
1384
- var MintClient = class {
1385
- constructor({
1386
- chainId,
1387
- publicClient,
1388
- premintGetter,
1389
- mintGetter
1390
- }) {
1391
- this.chainId = chainId;
1392
- this.publicClient = publicClient;
1393
- this.mintGetter = mintGetter;
1394
- this.premintGetter = premintGetter;
1395
- }
1396
- /**
1397
- * Returns the parameters needed to prepare a transaction mint a token.
1398
- * Works with premint, onchain 1155, and onchain 721.
1399
- *
1400
- * @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
1401
- * @returns Parameters for simulating/executing the mint transaction
1402
- */
1403
- async mint(parameters) {
1404
- return mint({
1405
- parameters,
1406
- chainId: this.chainId,
1407
- publicClient: this.publicClient,
1408
- mintGetter: this.mintGetter,
1409
- premintGetter: this.premintGetter
1410
- });
1411
- }
1412
- /**
1413
- * Gets the costs to mint the quantity of tokens specified for a mint.
1414
- * @param parameters - Parameters for the mint {@link GetMintCostsParameters}
1415
- * @returns Costs to mint the quantity of tokens specified
1416
- */
1417
- async getMintCosts(parameters) {
1418
- return getMintCosts({
1419
- ...parameters,
1420
- mintGetter: this.mintGetter,
1421
- premintGetter: this.premintGetter,
1422
- publicClient: this.publicClient
1423
- });
1424
- }
1425
- };
1426
- function isPremintCollect(parameters) {
1427
- return parameters.mintType === "premint";
1428
- }
1429
- function is721Collect(parameters) {
1430
- return parameters.mintType === "721";
1431
- }
1432
- async function mint({
1433
- parameters,
1434
- chainId,
1435
- publicClient,
1436
- mintGetter,
1437
- premintGetter
1607
+
1608
+ // src/mint/mint-transactions.ts
1609
+ function makeOnchainMintCall({
1610
+ token,
1611
+ mintParams
1438
1612
  }) {
1439
- if (isPremintCollect(parameters)) {
1440
- return {
1441
- parameters: await collectPremint({
1442
- ...parameters,
1443
- premintGetter,
1444
- publicClient
1445
- })
1446
- };
1613
+ if (token.mintType === "721") {
1614
+ return makePrepareMint721TokenParams({
1615
+ salesConfigAndTokenInfo: token,
1616
+ tokenContract: token.contract.address,
1617
+ ...mintParams
1618
+ });
1447
1619
  }
1448
- return {
1449
- parameters: await collectOnchain({
1450
- ...parameters,
1451
- mintGetter,
1452
- chainId
1453
- })
1454
- };
1455
- }
1456
- function requestErc20ApprovalForMint({
1457
- account,
1458
- tokenAddress,
1459
- quantityErc20,
1460
- erc20MinterAddress: erc20MinterAddress2
1461
- }) {
1462
- return makeContractParameters({
1463
- abi: erc20Abi,
1464
- address: tokenAddress,
1465
- account,
1466
- functionName: "approve",
1467
- args: [erc20MinterAddress2, quantityErc20]
1620
+ return makePrepareMint1155TokenParams({
1621
+ salesConfigAndTokenInfo: token,
1622
+ tokenContract: token.contract.address,
1623
+ tokenId: token.tokenId,
1624
+ ...mintParams
1468
1625
  });
1469
1626
  }
1470
- async function getNecessaryErc20Approval({
1471
- chainId,
1472
- account,
1473
- tokenAddress,
1474
- quantityErc20,
1475
- publicClient
1627
+ function makePrepareMint1155TokenParams({
1628
+ tokenContract,
1629
+ tokenId,
1630
+ salesConfigAndTokenInfo,
1631
+ minterAccount,
1632
+ mintComment,
1633
+ mintReferral,
1634
+ mintRecipient,
1635
+ quantityToMint
1476
1636
  }) {
1477
- const destination = erc20MinterAddress[chainId];
1478
- const allowance = await publicClient.readContract({
1479
- abi: erc20Abi,
1480
- address: tokenAddress,
1481
- functionName: "allowance",
1482
- account,
1483
- args: [
1484
- destination,
1485
- erc20MinterAddress[chainId]
1486
- ]
1487
- });
1488
- if (allowance < quantityErc20) {
1489
- return requestErc20ApprovalForMint({
1490
- erc20MinterAddress: destination,
1491
- account,
1492
- tokenAddress,
1493
- quantityErc20: quantityErc20 - allowance
1637
+ const mintQuantity = BigInt(quantityToMint || 1);
1638
+ const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
1639
+ const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
1640
+ if (saleType === "fixedPrice") {
1641
+ return makeEthMintCall({
1642
+ mintComment,
1643
+ minterAccount,
1644
+ mintQuantity,
1645
+ mintReferral,
1646
+ mintTo,
1647
+ salesConfigAndTokenInfo,
1648
+ tokenContract,
1649
+ tokenId
1494
1650
  });
1495
1651
  }
1496
- return void 0;
1497
- }
1498
- async function collectOnchain({
1499
- chainId,
1500
- mintGetter,
1501
- ...parameters
1502
- }) {
1503
- const { tokenContract, saleType } = parameters;
1504
- const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
1505
- const salesConfigAndTokenInfo = await mintGetter.getSalesConfigAndTokenInfo({
1506
- tokenId,
1507
- tokenAddress: tokenContract,
1508
- saleType
1509
- });
1510
- if (is721Collect(parameters)) {
1511
- return makePrepareMint721TokenParams({
1512
- salesConfigAndTokenInfo,
1513
- ...parameters
1652
+ if (saleType === "erc20") {
1653
+ return makeContractParameters({
1654
+ abi: erc20MinterABI,
1655
+ functionName: "mint",
1656
+ account: minterAccount,
1657
+ address: salesConfigAndTokenInfo.salesConfig.address,
1658
+ /* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
1659
+ args: [
1660
+ mintTo,
1661
+ mintQuantity,
1662
+ tokenContract,
1663
+ BigInt(tokenId),
1664
+ salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
1665
+ salesConfigAndTokenInfo.salesConfig.currency,
1666
+ mintReferral || zeroAddress3,
1667
+ mintComment || ""
1668
+ ]
1514
1669
  });
1515
1670
  }
1516
- return makePrepareMint1155TokenParams({
1517
- salesConfigAndTokenInfo,
1518
- chainId,
1519
- ...parameters
1520
- });
1671
+ throw new Error("Unsupported sale type");
1521
1672
  }
1522
- async function makePrepareMint721TokenParams({
1673
+ function makePrepareMint721TokenParams({
1523
1674
  salesConfigAndTokenInfo,
1524
1675
  minterAccount,
1525
1676
  tokenContract,
@@ -1530,7 +1681,8 @@ async function makePrepareMint721TokenParams({
1530
1681
  }) {
1531
1682
  const actualQuantityToMint = BigInt(quantityToMint || 1);
1532
1683
  const mintValue = parseMintCosts({
1533
- salesConfigAndTokenInfo,
1684
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
1685
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
1534
1686
  quantityToMint: actualQuantityToMint
1535
1687
  }).totalCostEth;
1536
1688
  return makeContractParameters({
@@ -1547,15 +1699,65 @@ async function makePrepareMint721TokenParams({
1547
1699
  ]
1548
1700
  });
1549
1701
  }
1550
- function parseMintCosts({
1702
+ function makeEthMintCall({
1703
+ tokenContract,
1704
+ tokenId,
1551
1705
  salesConfigAndTokenInfo,
1706
+ minterAccount,
1707
+ mintComment,
1708
+ mintReferral,
1709
+ mintQuantity,
1710
+ mintTo
1711
+ }) {
1712
+ const mintValue = parseMintCosts({
1713
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
1714
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
1715
+ quantityToMint: mintQuantity
1716
+ }).totalCostEth;
1717
+ const minterArguments = encodeAbiParameters(
1718
+ parseAbiParameters("address, string"),
1719
+ [mintTo, mintComment || ""]
1720
+ );
1721
+ if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
1722
+ return makeContractParameters({
1723
+ abi: zoraCreator1155ImplABI2,
1724
+ functionName: "mint",
1725
+ account: minterAccount,
1726
+ value: mintValue,
1727
+ address: tokenContract,
1728
+ args: [
1729
+ salesConfigAndTokenInfo.salesConfig.address,
1730
+ BigInt(tokenId),
1731
+ mintQuantity,
1732
+ mintReferral ? [mintReferral] : [],
1733
+ minterArguments
1734
+ ]
1735
+ });
1736
+ }
1737
+ return makeContractParameters({
1738
+ abi: zoraCreator1155ImplABI2,
1739
+ functionName: "mintWithRewards",
1740
+ account: minterAccount,
1741
+ value: mintValue,
1742
+ address: tokenContract,
1743
+ /* args: minter, tokenId, quantity, minterArguments, mintReferral */
1744
+ args: [
1745
+ salesConfigAndTokenInfo.salesConfig.address,
1746
+ BigInt(tokenId),
1747
+ mintQuantity,
1748
+ minterArguments,
1749
+ mintReferral || zeroAddress3
1750
+ ]
1751
+ });
1752
+ }
1753
+ function parseMintCosts({
1754
+ salesConfig,
1755
+ mintFeePerQuantity,
1552
1756
  quantityToMint
1553
1757
  }) {
1554
- const mintFeeForTokens = salesConfigAndTokenInfo.mintFeePerQuantity * quantityToMint;
1555
- const tokenPurchaseCost = BigInt(salesConfigAndTokenInfo.salesConfig.pricePerToken) * quantityToMint;
1556
- const totalPurchaseCostCurrency = isErc20SaleStrategy(
1557
- salesConfigAndTokenInfo.salesConfig
1558
- ) ? salesConfigAndTokenInfo.salesConfig.currency : void 0;
1758
+ const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
1759
+ const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
1760
+ const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
1559
1761
  const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
1560
1762
  return {
1561
1763
  mintFee: mintFeeForTokens,
@@ -1564,93 +1766,337 @@ function parseMintCosts({
1564
1766
  totalCostEth: mintFeeForTokens + totalPurchaseCostEth
1565
1767
  };
1566
1768
  }
1567
- async function getMintCosts(params) {
1568
- const { quantityMinted: quantityToMint, collection, publicClient } = params;
1769
+
1770
+ // src/mint/mint-queries.ts
1771
+ import { zeroAddress as zeroAddress4 } from "viem";
1772
+ async function getMint({
1773
+ params,
1774
+ mintGetter,
1775
+ premintGetter,
1776
+ publicClient
1777
+ }) {
1778
+ const { tokenContract } = params;
1779
+ if (isOnChainMint(params)) {
1780
+ const tokenId = is1155Mint(params) ? params.tokenId : void 0;
1781
+ const result = await mintGetter.getMintable({
1782
+ tokenId,
1783
+ tokenAddress: tokenContract,
1784
+ preferredSaleType: params.preferredSaleType
1785
+ });
1786
+ return toMintableReturn(result);
1787
+ }
1788
+ const premint = await premintGetter.get({
1789
+ collectionAddress: tokenContract,
1790
+ uid: params.uid
1791
+ });
1792
+ const mintFee = await getPremintMintFee({
1793
+ publicClient,
1794
+ tokenContract
1795
+ });
1796
+ return toPremintMintReturn({ premint, mintFee });
1797
+ }
1798
+ async function getPremintsOfCollectionWithTokenIds({
1799
+ premintGetter,
1800
+ mintGetter,
1801
+ tokenContract
1802
+ }) {
1803
+ const { collection, premints } = await premintGetter.getOfCollection({
1804
+ collectionAddress: tokenContract
1805
+ });
1806
+ const premintUidsAndTokenIds = await mintGetter.getContractPremintTokenIds({
1807
+ tokenAddress: tokenContract
1808
+ });
1809
+ const premintsWithTokenId = premints.map((premint) => ({
1810
+ ...premint,
1811
+ tokenId: premintUidsAndTokenIds.find(
1812
+ ({ uid }) => uid === premint.premint.premintConfig.uid
1813
+ )?.tokenId
1814
+ }));
1815
+ return {
1816
+ collection,
1817
+ premints: premintsWithTokenId
1818
+ };
1819
+ }
1820
+ async function getMintsOfContract({
1821
+ params,
1822
+ mintGetter,
1823
+ premintGetter,
1824
+ publicClient
1825
+ }) {
1826
+ const onchainMints = (await mintGetter.getContractMintable({
1827
+ tokenAddress: params.tokenContract
1828
+ })).map(toMintableReturn);
1829
+ const offchainMints = await getPremintsOfContractMintable({
1830
+ mintGetter,
1831
+ premintGetter,
1832
+ publicClient,
1833
+ params: {
1834
+ tokenContract: params.tokenContract
1835
+ }
1836
+ });
1837
+ const tokens = [...onchainMints, ...offchainMints];
1838
+ return {
1839
+ tokens,
1840
+ contract: tokens[0]?.token.contract
1841
+ };
1842
+ }
1843
+ async function getMintCosts({
1844
+ params,
1845
+ mintGetter,
1846
+ premintGetter,
1847
+ publicClient
1848
+ }) {
1849
+ const { quantityMinted: quantityToMint, collection } = params;
1569
1850
  if (isOnChainMint(params)) {
1570
1851
  const tokenId = is1155Mint(params) ? params.tokenId : void 0;
1571
- const salesConfigAndTokenInfo = await params.mintGetter.getSalesConfigAndTokenInfo({
1852
+ const salesConfigAndTokenInfo = await mintGetter.getMintable({
1572
1853
  tokenId,
1573
1854
  tokenAddress: collection
1574
1855
  });
1575
1856
  return parseMintCosts({
1576
- salesConfigAndTokenInfo,
1857
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
1858
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
1577
1859
  quantityToMint: BigInt(quantityToMint)
1578
1860
  });
1579
1861
  }
1580
1862
  return getPremintMintCostsWithUnknownTokenPrice({
1581
- premintGetter: params.premintGetter,
1863
+ premintGetter,
1582
1864
  publicClient,
1583
1865
  quantityToMint: BigInt(quantityToMint),
1584
1866
  uid: params.uid,
1585
1867
  tokenContract: collection
1586
1868
  });
1587
1869
  }
1588
- function makePrepareMint1155TokenParams({
1589
- tokenContract,
1590
- tokenId,
1591
- salesConfigAndTokenInfo,
1592
- minterAccount,
1593
- mintComment,
1594
- mintReferral,
1595
- mintRecipient,
1596
- quantityToMint,
1597
- chainId
1870
+ async function getPremintsOfContractMintable({
1871
+ mintGetter,
1872
+ premintGetter,
1873
+ publicClient,
1874
+ params
1598
1875
  }) {
1599
- const mintQuantity = BigInt(quantityToMint || 1);
1600
- const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
1601
- const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
1602
- if (saleType === "fixedPrice") {
1603
- const mintValue = parseMintCosts({
1604
- salesConfigAndTokenInfo,
1605
- quantityToMint: mintQuantity
1606
- }).totalCostEth;
1607
- return makeContractParameters({
1608
- abi: zoraCreator1155ImplABI2,
1609
- functionName: "mintWithRewards",
1610
- account: minterAccount,
1611
- value: mintValue,
1612
- address: tokenContract,
1613
- /* args: minter, tokenId, quantity, minterArguments, mintReferral */
1614
- args: [
1615
- salesConfigAndTokenInfo.salesConfig.address || zoraCreatorFixedPriceSaleStrategyAddress2[chainId],
1616
- BigInt(tokenId),
1617
- mintQuantity,
1618
- encodeAbiParameters(parseAbiParameters("address, string"), [
1619
- mintTo,
1620
- mintComment || ""
1621
- ]),
1622
- mintReferral || zeroAddress3
1623
- ]
1624
- });
1625
- }
1626
- if (saleType === "erc20") {
1627
- return makeContractParameters({
1628
- abi: erc20MinterABI,
1629
- functionName: "mint",
1630
- account: minterAccount,
1631
- address: salesConfigAndTokenInfo?.salesConfig.address || erc20MinterAddress[chainId],
1632
- /* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
1633
- args: [
1634
- mintTo,
1635
- mintQuantity,
1636
- tokenContract,
1637
- BigInt(tokenId),
1638
- salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
1639
- salesConfigAndTokenInfo.salesConfig.currency,
1640
- mintReferral || zeroAddress3,
1641
- mintComment || ""
1642
- ]
1876
+ const { premints, collection } = await getPremintsOfCollectionWithTokenIds({
1877
+ mintGetter,
1878
+ premintGetter,
1879
+ tokenContract: params.tokenContract
1880
+ });
1881
+ const offChainPremints = premints.filter(
1882
+ (premint) => (
1883
+ // if premint's uid is not in the list of uids from the subgraph, it is offchain
1884
+ typeof premint.tokenId === "undefined"
1885
+ )
1886
+ );
1887
+ if (offChainPremints.length === 0)
1888
+ return [];
1889
+ const mintFee = await getPremintMintFee({
1890
+ publicClient,
1891
+ tokenContract: params.tokenContract
1892
+ });
1893
+ return offChainPremints.map((premint) => {
1894
+ return toPremintMintReturn({
1895
+ premint: {
1896
+ premint: premint.premint,
1897
+ // todo: fix when api returns signer
1898
+ signer: zeroAddress4,
1899
+ collection,
1900
+ collectionAddress: params.tokenContract,
1901
+ signature: premint.signature
1902
+ },
1903
+ mintFee
1643
1904
  });
1905
+ });
1906
+ }
1907
+ function parsePremint({
1908
+ premint,
1909
+ mintFee
1910
+ }) {
1911
+ if (isPremintConfigV1(premint.premint) || isPremintConfigV2(premint.premint)) {
1912
+ return {
1913
+ creator: premint.signer,
1914
+ maxSupply: premint.premint.premintConfig.tokenConfig.maxSupply,
1915
+ mintFeePerQuantity: mintFee,
1916
+ mintType: "premint",
1917
+ uid: premint.premint.premintConfig.uid,
1918
+ contract: {
1919
+ address: premint.collectionAddress,
1920
+ name: premint.collection.contractName,
1921
+ URI: premint.collection.contractURI
1922
+ },
1923
+ tokenURI: premint.premint.premintConfig.tokenConfig.tokenURI,
1924
+ totalMinted: 0n,
1925
+ salesConfig: {
1926
+ duration: premint.premint.premintConfig.tokenConfig.mintDuration,
1927
+ maxTokensPerAddress: premint.premint.premintConfig.tokenConfig.maxTokensPerAddress,
1928
+ pricePerToken: premint.premint.premintConfig.tokenConfig.pricePerToken,
1929
+ saleType: "premint"
1930
+ }
1931
+ };
1644
1932
  }
1645
- throw new MintError("Unsupported sale type");
1933
+ throw new Error("Invalid premint config version");
1646
1934
  }
1647
-
1648
- // src/create/1155-create-helper.ts
1649
- import {
1650
- zoraCreator1155FactoryImplABI as zoraCreator1155FactoryImplABI2,
1651
- zoraCreator1155FactoryImplAddress as zoraCreator1155FactoryImplAddress2,
1652
- zoraCreator1155ImplABI as zoraCreator1155ImplABI5
1653
- } from "@zoralabs/protocol-deployments";
1935
+ var makeOnchainPrepareMint = (result) => (params) => ({
1936
+ parameters: makeOnchainMintCall({ token: result, mintParams: params }),
1937
+ erc20Approval: getRequiredErc20Approvals(params, result),
1938
+ costs: parseMintCosts({
1939
+ salesConfig: result.salesConfig,
1940
+ quantityToMint: BigInt(params.quantityToMint),
1941
+ mintFeePerQuantity: result.mintFeePerQuantity
1942
+ })
1943
+ });
1944
+ function toMintableReturn(result) {
1945
+ return { token: result, prepareMint: makeOnchainPrepareMint(result) };
1946
+ }
1947
+ var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
1948
+ parameters: buildPremintMintCall({
1949
+ mintArguments: params,
1950
+ mintFee,
1951
+ premint
1952
+ }),
1953
+ costs: parseMintCosts({
1954
+ mintFeePerQuantity: mintFee,
1955
+ quantityToMint: BigInt(params.quantityToMint),
1956
+ salesConfig: mintable.salesConfig
1957
+ })
1958
+ });
1959
+ function toPremintMintReturn({
1960
+ premint,
1961
+ mintFee
1962
+ }) {
1963
+ const mintable = parsePremint({ premint, mintFee });
1964
+ return {
1965
+ token: mintable,
1966
+ prepareMint: makePremintPrepareMint(mintable, mintFee, premint)
1967
+ };
1968
+ }
1969
+ function getRequiredErc20Approvals(params, result) {
1970
+ if (result.salesConfig.saleType !== "erc20")
1971
+ return void 0;
1972
+ return {
1973
+ quantity: result.salesConfig.pricePerToken * BigInt(params.quantityToMint),
1974
+ approveTo: result.salesConfig.address,
1975
+ erc20: result.salesConfig.currency
1976
+ };
1977
+ }
1978
+
1979
+ // src/mint/mint-client.ts
1980
+ var MintError = class extends Error {
1981
+ };
1982
+ var MintInactiveError = class extends Error {
1983
+ };
1984
+ var Errors = {
1985
+ MintError,
1986
+ MintInactiveError
1987
+ };
1988
+ var MintClient = class {
1989
+ constructor({
1990
+ publicClient,
1991
+ premintGetter,
1992
+ mintGetter
1993
+ }) {
1994
+ this.publicClient = publicClient;
1995
+ this.mintGetter = mintGetter;
1996
+ this.premintGetter = premintGetter;
1997
+ }
1998
+ /**
1999
+ * Returns the parameters needed to prepare a transaction mint a token.
2000
+ * Works with premint, onchain 1155, and onchain 721.
2001
+ *
2002
+ * @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
2003
+ * @returns Parameters for simulating/executing the mint transaction, any necessary erc20 approval, and costs to mint
2004
+ */
2005
+ async mint(parameters) {
2006
+ return mint({
2007
+ parameters,
2008
+ publicClient: this.publicClient,
2009
+ mintGetter: this.mintGetter,
2010
+ premintGetter: this.premintGetter
2011
+ });
2012
+ }
2013
+ /**
2014
+ * Gets an 1155, 721, or premint, and returns both information about it, and a function
2015
+ * that can be used to build a mint transaction for a quantity of items to mint.
2016
+ * @param parameters - Token to get {@link GetMintParameters}
2017
+ * @Returns Information about the mint and a function to build a mint transaction {@link MintableReturn}
2018
+ */
2019
+ async get(parameters) {
2020
+ return getMint({
2021
+ params: parameters,
2022
+ mintGetter: this.mintGetter,
2023
+ premintGetter: this.premintGetter,
2024
+ publicClient: this.publicClient
2025
+ });
2026
+ }
2027
+ /**
2028
+ * Gets onchain and premint tokens of an 1155 contract. For each token returns both information about it, and a function
2029
+ * that can be used to build a mint transaction for a quantity of items to mint.
2030
+ * @param parameters - Contract address to get tokens for {@link GetMintsOfContractParameters}
2031
+ * @Returns Array of tokens, each containing information about the token and a function to build a mint transaction.
2032
+ */
2033
+ async getOfContract(params) {
2034
+ return getMintsOfContract({
2035
+ params,
2036
+ mintGetter: this.mintGetter,
2037
+ premintGetter: this.premintGetter,
2038
+ publicClient: this.publicClient
2039
+ });
2040
+ }
2041
+ /**
2042
+ * Gets the costs to mint the quantity of tokens specified for a mint.
2043
+ * @param parameters - Parameters for the mint {@link GetMintCostsParameters}
2044
+ * @returns Costs to mint the quantity of tokens specified
2045
+ */
2046
+ async getMintCosts(parameters) {
2047
+ return getMintCosts({
2048
+ params: parameters,
2049
+ mintGetter: this.mintGetter,
2050
+ premintGetter: this.premintGetter,
2051
+ publicClient: this.publicClient
2052
+ });
2053
+ }
2054
+ };
2055
+ async function mint({
2056
+ parameters,
2057
+ publicClient,
2058
+ mintGetter,
2059
+ premintGetter
2060
+ }) {
2061
+ const { prepareMint } = await getMint({
2062
+ params: parameters,
2063
+ mintGetter,
2064
+ premintGetter,
2065
+ publicClient
2066
+ });
2067
+ return prepareMint({
2068
+ minterAccount: parameters.minterAccount,
2069
+ quantityToMint: parameters.quantityToMint,
2070
+ firstMinter: parameters.firstMinter,
2071
+ mintComment: parameters.mintComment,
2072
+ mintRecipient: parameters.mintRecipient,
2073
+ mintReferral: parameters.mintReferral
2074
+ });
2075
+ }
2076
+ async function collectOnchain({
2077
+ chainId,
2078
+ mintGetter,
2079
+ ...parameters
2080
+ }) {
2081
+ const { tokenContract, preferredSaleType: saleType } = parameters;
2082
+ const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
2083
+ const salesConfigAndTokenInfo = await mintGetter.getMintable({
2084
+ tokenId,
2085
+ tokenAddress: tokenContract,
2086
+ preferredSaleType: saleType
2087
+ });
2088
+ return makeOnchainMintCall({
2089
+ mintParams: parameters,
2090
+ token: salesConfigAndTokenInfo
2091
+ });
2092
+ }
2093
+
2094
+ // src/create/1155-create-helper.ts
2095
+ import {
2096
+ zoraCreator1155FactoryImplABI as zoraCreator1155FactoryImplABI2,
2097
+ zoraCreator1155FactoryImplAddress as zoraCreator1155FactoryImplAddress2,
2098
+ zoraCreator1155ImplABI as zoraCreator1155ImplABI5
2099
+ } from "@zoralabs/protocol-deployments";
1654
2100
  import { decodeEventLog as decodeEventLog2 } from "viem";
1655
2101
 
1656
2102
  // src/create/contract-setup.ts
@@ -1717,17 +2163,17 @@ import {
1717
2163
  erc20MinterAddress as erc20MinterAddresses,
1718
2164
  zoraCreator1155ImplABI as zoraCreator1155ImplABI4,
1719
2165
  zoraCreatorFixedPriceSaleStrategyABI,
1720
- zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress3
2166
+ zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress2
1721
2167
  } from "@zoralabs/protocol-deployments";
1722
- import { encodeFunctionData, zeroAddress as zeroAddress4 } from "viem";
1723
- import * as semver from "semver";
2168
+ import { encodeFunctionData, zeroAddress as zeroAddress5 } from "viem";
2169
+ import * as semver2 from "semver";
1724
2170
  var PERMISSION_BITS = {
1725
2171
  MINTER: 2n ** 2n
1726
2172
  };
1727
2173
  var saleSettingsOrDefault = (saleSettings) => {
1728
2174
  const SALE_END_FOREVER = 18446744073709551615n;
1729
2175
  const DEFAULT_SALE_SETTINGS = {
1730
- currency: zeroAddress4,
2176
+ currency: zeroAddress5,
1731
2177
  // Free Mint
1732
2178
  pricePerToken: 0n,
1733
2179
  // Sale start time – defaults to beginning of unix time
@@ -1744,10 +2190,10 @@ var saleSettingsOrDefault = (saleSettings) => {
1744
2190
  };
1745
2191
  function applyNew1155Defaults(props, ownerAddress) {
1746
2192
  const { payoutRecipient: fundsRecipient } = props;
1747
- const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== zeroAddress4 ? fundsRecipient : ownerAddress;
2193
+ const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== zeroAddress5 ? fundsRecipient : ownerAddress;
1748
2194
  return {
1749
2195
  payoutRecipient: fundsRecipientOrOwner,
1750
- createReferral: props.createReferral || zeroAddress4,
2196
+ createReferral: props.createReferral || zeroAddress5,
1751
2197
  maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
1752
2198
  royaltyBPS: props.royaltyBPS || 1e3,
1753
2199
  salesConfig: saleSettingsOrDefault(props.salesConfig),
@@ -1764,13 +2210,13 @@ function setupErc20Minter({
1764
2210
  maxTokensPerAddress: mintLimit,
1765
2211
  fundsRecipient
1766
2212
  }) {
1767
- const erc20MinterAddress2 = erc20MinterAddresses[chainId];
1768
- if (!erc20MinterAddress2)
2213
+ const erc20MinterAddress = erc20MinterAddresses[chainId];
2214
+ if (!erc20MinterAddress)
1769
2215
  throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
1770
2216
  const erc20MinterApproval = encodeFunctionData({
1771
2217
  abi: zoraCreator1155ImplABI4,
1772
2218
  functionName: "addPermission",
1773
- args: [BigInt(nextTokenId), erc20MinterAddress2, PERMISSION_BITS.MINTER]
2219
+ args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
1774
2220
  });
1775
2221
  const saleData = encodeFunctionData({
1776
2222
  abi: erc20MinterABI2,
@@ -1790,10 +2236,10 @@ function setupErc20Minter({
1790
2236
  const callSale = encodeFunctionData({
1791
2237
  abi: zoraCreator1155ImplABI4,
1792
2238
  functionName: "callSale",
1793
- args: [BigInt(nextTokenId), erc20MinterAddress2, saleData]
2239
+ args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
1794
2240
  });
1795
2241
  return {
1796
- minter: erc20MinterAddress2,
2242
+ minter: erc20MinterAddress,
1797
2243
  setupActions: [erc20MinterApproval, callSale]
1798
2244
  };
1799
2245
  }
@@ -1806,7 +2252,7 @@ function setupFixedPriceMinter({
1806
2252
  maxTokensPerAddress: mintLimit,
1807
2253
  fundsRecipient
1808
2254
  }) {
1809
- const fixedPriceStrategyAddress = zoraCreatorFixedPriceSaleStrategyAddress3[chainId];
2255
+ const fixedPriceStrategyAddress = zoraCreatorFixedPriceSaleStrategyAddress2[chainId];
1810
2256
  const fixedPriceApproval = encodeFunctionData({
1811
2257
  abi: zoraCreator1155ImplABI4,
1812
2258
  functionName: "addPermission",
@@ -1844,7 +2290,7 @@ function setupMinters({ salesConfig, ...rest }) {
1844
2290
  if (!salesConfig)
1845
2291
  throw new Error("No sales config for token");
1846
2292
  const { currency: currencyAddress } = salesConfig;
1847
- if (currencyAddress === zeroAddress4) {
2293
+ if (currencyAddress === zeroAddress5) {
1848
2294
  return setupFixedPriceMinter({
1849
2295
  ...salesConfig,
1850
2296
  ...rest
@@ -1859,7 +2305,7 @@ function setupMinters({ salesConfig, ...rest }) {
1859
2305
  function buildSetupNewToken({
1860
2306
  tokenURI,
1861
2307
  maxSupply = OPEN_EDITION_MINT_SIZE,
1862
- createReferral = zeroAddress4,
2308
+ createReferral = zeroAddress5,
1863
2309
  contractVersion
1864
2310
  }) {
1865
2311
  if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
@@ -1869,7 +2315,7 @@ function buildSetupNewToken({
1869
2315
  args: [tokenURI, BigInt(maxSupply), createReferral]
1870
2316
  });
1871
2317
  }
1872
- if (createReferral !== zeroAddress4) {
2318
+ if (createReferral !== zeroAddress5) {
1873
2319
  throw new Error(
1874
2320
  "Contract does not support create referral, but one was provided"
1875
2321
  );
@@ -1885,7 +2331,7 @@ function setupRoyaltyConfig({
1885
2331
  royaltyRecipient,
1886
2332
  nextTokenId
1887
2333
  }) {
1888
- if (royaltyBPS > 0 && royaltyRecipient != zeroAddress4) {
2334
+ if (royaltyBPS > 0 && royaltyRecipient != zeroAddress5) {
1889
2335
  return encodeFunctionData({
1890
2336
  abi: zoraCreator1155ImplABI4,
1891
2337
  functionName: "updateRoyaltiesForToken",
@@ -1912,7 +2358,7 @@ function makeAdminMintCall({
1912
2358
  return encodeFunctionData({
1913
2359
  abi: zoraCreator1155ImplABI4,
1914
2360
  functionName: "adminMint",
1915
- args: [ownerAddress, nextTokenId, BigInt(mintQuantity), zeroAddress4]
2361
+ args: [ownerAddress, nextTokenId, BigInt(mintQuantity), zeroAddress5]
1916
2362
  });
1917
2363
  }
1918
2364
  function constructCreate1155TokenCalls(props) {
@@ -1971,13 +2417,13 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
1971
2417
  if (!contractStandard || !contractVersion) {
1972
2418
  return false;
1973
2419
  }
1974
- const semVerContractVersion = semver.coerce(contractVersion)?.raw;
2420
+ const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
1975
2421
  if (!semVerContractVersion)
1976
2422
  return false;
1977
2423
  if (contractStandard === "ERC1155") {
1978
- return semver.gte(semVerContractVersion, "1.3.5");
2424
+ return semver2.gte(semVerContractVersion, "1.3.5");
1979
2425
  } else {
1980
- return semver.gte(semVerContractVersion, "14.0.0");
2426
+ return semver2.gte(semVerContractVersion, "14.0.0");
1981
2427
  }
1982
2428
  };
1983
2429
 
@@ -2178,7 +2624,7 @@ import {
2178
2624
  import {
2179
2625
  decodeErrorResult,
2180
2626
  encodeFunctionData as encodeFunctionData2,
2181
- zeroAddress as zeroAddress5
2627
+ zeroAddress as zeroAddress6
2182
2628
  } from "viem";
2183
2629
  var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
2184
2630
  var mintWithEthParams = ({
@@ -2334,7 +2780,7 @@ var encodePremintOnManager = ({
2334
2780
  premintConfig,
2335
2781
  premintSignature,
2336
2782
  mintArguments,
2337
- signerContract = zeroAddress5
2783
+ signerContract = zeroAddress6
2338
2784
  }) => encodeFunctionData2({
2339
2785
  abi: zoraMintsManagerImplConfig.abi,
2340
2786
  functionName: "collectPremintV2",
@@ -2427,13 +2873,13 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
2427
2873
  chainId,
2428
2874
  tokenIds,
2429
2875
  quantities,
2430
- from,
2876
+ from: from2,
2431
2877
  callWithEth,
2432
2878
  safeTransferData,
2433
2879
  deadline,
2434
2880
  nonce
2435
2881
  }) => makePermitTransferBatchAndTypeData({
2436
- mintsOwner: from,
2882
+ mintsOwner: from2,
2437
2883
  chainId,
2438
2884
  deadline,
2439
2885
  tokenIds,
@@ -2465,21 +2911,1164 @@ function createCollectorClient(params) {
2465
2911
  const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
2466
2912
  const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
2467
2913
  const mintClient = new MintClient({
2468
- chainId: params.chainId,
2469
2914
  publicClient: params.publicClient,
2470
2915
  premintGetter: premintGetterToUse,
2471
2916
  mintGetter: mintGetterToUse
2472
2917
  });
2473
2918
  return {
2474
- getPremint: (p) => premintGetterToUse.getSignature({
2919
+ getPremint: (p) => premintGetterToUse.get({
2475
2920
  collectionAddress: p.address,
2476
2921
  uid: p.uid
2477
2922
  }),
2478
2923
  getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
2924
+ getToken: (p) => mintClient.get(p),
2925
+ getTokensOfContract: (p) => mintClient.getOfContract(p),
2479
2926
  mint: (p) => mintClient.mint(p),
2480
2927
  getMintCosts: (p) => mintClient.getMintCosts(p)
2481
2928
  };
2482
2929
  }
2930
+
2931
+ // src/ipfs/arweave.ts
2932
+ function isArweaveURL(url) {
2933
+ return url && typeof url === "string" ? url.startsWith("ar://") : false;
2934
+ }
2935
+
2936
+ // ../../node_modules/multiformats/esm/vendor/varint.js
2937
+ var encode_1 = encode;
2938
+ var MSB = 128;
2939
+ var REST = 127;
2940
+ var MSBALL = ~REST;
2941
+ var INT = Math.pow(2, 31);
2942
+ function encode(num, out, offset) {
2943
+ out = out || [];
2944
+ offset = offset || 0;
2945
+ var oldOffset = offset;
2946
+ while (num >= INT) {
2947
+ out[offset++] = num & 255 | MSB;
2948
+ num /= 128;
2949
+ }
2950
+ while (num & MSBALL) {
2951
+ out[offset++] = num & 255 | MSB;
2952
+ num >>>= 7;
2953
+ }
2954
+ out[offset] = num | 0;
2955
+ encode.bytes = offset - oldOffset + 1;
2956
+ return out;
2957
+ }
2958
+ var decode = read;
2959
+ var MSB$1 = 128;
2960
+ var REST$1 = 127;
2961
+ function read(buf, offset) {
2962
+ var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
2963
+ do {
2964
+ if (counter >= l) {
2965
+ read.bytes = 0;
2966
+ throw new RangeError("Could not decode varint");
2967
+ }
2968
+ b = buf[counter++];
2969
+ res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
2970
+ shift += 7;
2971
+ } while (b >= MSB$1);
2972
+ read.bytes = counter - offset;
2973
+ return res;
2974
+ }
2975
+ var N1 = Math.pow(2, 7);
2976
+ var N2 = Math.pow(2, 14);
2977
+ var N3 = Math.pow(2, 21);
2978
+ var N4 = Math.pow(2, 28);
2979
+ var N5 = Math.pow(2, 35);
2980
+ var N6 = Math.pow(2, 42);
2981
+ var N7 = Math.pow(2, 49);
2982
+ var N8 = Math.pow(2, 56);
2983
+ var N9 = Math.pow(2, 63);
2984
+ var length = function(value) {
2985
+ return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
2986
+ };
2987
+ var varint = {
2988
+ encode: encode_1,
2989
+ decode,
2990
+ encodingLength: length
2991
+ };
2992
+ var _brrp_varint = varint;
2993
+ var varint_default = _brrp_varint;
2994
+
2995
+ // ../../node_modules/multiformats/esm/src/varint.js
2996
+ var decode2 = (data, offset = 0) => {
2997
+ const code = varint_default.decode(data, offset);
2998
+ return [
2999
+ code,
3000
+ varint_default.decode.bytes
3001
+ ];
3002
+ };
3003
+ var encodeTo = (int, target, offset = 0) => {
3004
+ varint_default.encode(int, target, offset);
3005
+ return target;
3006
+ };
3007
+ var encodingLength = (int) => {
3008
+ return varint_default.encodingLength(int);
3009
+ };
3010
+
3011
+ // ../../node_modules/multiformats/esm/src/bytes.js
3012
+ var empty = new Uint8Array(0);
3013
+ var equals = (aa, bb) => {
3014
+ if (aa === bb)
3015
+ return true;
3016
+ if (aa.byteLength !== bb.byteLength) {
3017
+ return false;
3018
+ }
3019
+ for (let ii = 0; ii < aa.byteLength; ii++) {
3020
+ if (aa[ii] !== bb[ii]) {
3021
+ return false;
3022
+ }
3023
+ }
3024
+ return true;
3025
+ };
3026
+ var coerce3 = (o) => {
3027
+ if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
3028
+ return o;
3029
+ if (o instanceof ArrayBuffer)
3030
+ return new Uint8Array(o);
3031
+ if (ArrayBuffer.isView(o)) {
3032
+ return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
3033
+ }
3034
+ throw new Error("Unknown type, must be binary type");
3035
+ };
3036
+
3037
+ // ../../node_modules/multiformats/esm/src/hashes/digest.js
3038
+ var create = (code, digest) => {
3039
+ const size = digest.byteLength;
3040
+ const sizeOffset = encodingLength(code);
3041
+ const digestOffset = sizeOffset + encodingLength(size);
3042
+ const bytes = new Uint8Array(digestOffset + size);
3043
+ encodeTo(code, bytes, 0);
3044
+ encodeTo(size, bytes, sizeOffset);
3045
+ bytes.set(digest, digestOffset);
3046
+ return new Digest(code, size, digest, bytes);
3047
+ };
3048
+ var decode3 = (multihash) => {
3049
+ const bytes = coerce3(multihash);
3050
+ const [code, sizeOffset] = decode2(bytes);
3051
+ const [size, digestOffset] = decode2(bytes.subarray(sizeOffset));
3052
+ const digest = bytes.subarray(sizeOffset + digestOffset);
3053
+ if (digest.byteLength !== size) {
3054
+ throw new Error("Incorrect length");
3055
+ }
3056
+ return new Digest(code, size, digest, bytes);
3057
+ };
3058
+ var equals2 = (a, b) => {
3059
+ if (a === b) {
3060
+ return true;
3061
+ } else {
3062
+ return a.code === b.code && a.size === b.size && equals(a.bytes, b.bytes);
3063
+ }
3064
+ };
3065
+ var Digest = class {
3066
+ constructor(code, size, digest, bytes) {
3067
+ this.code = code;
3068
+ this.size = size;
3069
+ this.digest = digest;
3070
+ this.bytes = bytes;
3071
+ }
3072
+ };
3073
+
3074
+ // ../../node_modules/multiformats/esm/vendor/base-x.js
3075
+ function base2(ALPHABET, name) {
3076
+ if (ALPHABET.length >= 255) {
3077
+ throw new TypeError("Alphabet too long");
3078
+ }
3079
+ var BASE_MAP = new Uint8Array(256);
3080
+ for (var j = 0; j < BASE_MAP.length; j++) {
3081
+ BASE_MAP[j] = 255;
3082
+ }
3083
+ for (var i = 0; i < ALPHABET.length; i++) {
3084
+ var x = ALPHABET.charAt(i);
3085
+ var xc = x.charCodeAt(0);
3086
+ if (BASE_MAP[xc] !== 255) {
3087
+ throw new TypeError(x + " is ambiguous");
3088
+ }
3089
+ BASE_MAP[xc] = i;
3090
+ }
3091
+ var BASE = ALPHABET.length;
3092
+ var LEADER = ALPHABET.charAt(0);
3093
+ var FACTOR = Math.log(BASE) / Math.log(256);
3094
+ var iFACTOR = Math.log(256) / Math.log(BASE);
3095
+ function encode3(source) {
3096
+ if (source instanceof Uint8Array)
3097
+ ;
3098
+ else if (ArrayBuffer.isView(source)) {
3099
+ source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
3100
+ } else if (Array.isArray(source)) {
3101
+ source = Uint8Array.from(source);
3102
+ }
3103
+ if (!(source instanceof Uint8Array)) {
3104
+ throw new TypeError("Expected Uint8Array");
3105
+ }
3106
+ if (source.length === 0) {
3107
+ return "";
3108
+ }
3109
+ var zeroes = 0;
3110
+ var length2 = 0;
3111
+ var pbegin = 0;
3112
+ var pend = source.length;
3113
+ while (pbegin !== pend && source[pbegin] === 0) {
3114
+ pbegin++;
3115
+ zeroes++;
3116
+ }
3117
+ var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
3118
+ var b58 = new Uint8Array(size);
3119
+ while (pbegin !== pend) {
3120
+ var carry = source[pbegin];
3121
+ var i2 = 0;
3122
+ for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
3123
+ carry += 256 * b58[it1] >>> 0;
3124
+ b58[it1] = carry % BASE >>> 0;
3125
+ carry = carry / BASE >>> 0;
3126
+ }
3127
+ if (carry !== 0) {
3128
+ throw new Error("Non-zero carry");
3129
+ }
3130
+ length2 = i2;
3131
+ pbegin++;
3132
+ }
3133
+ var it2 = size - length2;
3134
+ while (it2 !== size && b58[it2] === 0) {
3135
+ it2++;
3136
+ }
3137
+ var str = LEADER.repeat(zeroes);
3138
+ for (; it2 < size; ++it2) {
3139
+ str += ALPHABET.charAt(b58[it2]);
3140
+ }
3141
+ return str;
3142
+ }
3143
+ function decodeUnsafe(source) {
3144
+ if (typeof source !== "string") {
3145
+ throw new TypeError("Expected String");
3146
+ }
3147
+ if (source.length === 0) {
3148
+ return new Uint8Array();
3149
+ }
3150
+ var psz = 0;
3151
+ if (source[psz] === " ") {
3152
+ return;
3153
+ }
3154
+ var zeroes = 0;
3155
+ var length2 = 0;
3156
+ while (source[psz] === LEADER) {
3157
+ zeroes++;
3158
+ psz++;
3159
+ }
3160
+ var size = (source.length - psz) * FACTOR + 1 >>> 0;
3161
+ var b256 = new Uint8Array(size);
3162
+ while (source[psz]) {
3163
+ var carry = BASE_MAP[source.charCodeAt(psz)];
3164
+ if (carry === 255) {
3165
+ return;
3166
+ }
3167
+ var i2 = 0;
3168
+ for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
3169
+ carry += BASE * b256[it3] >>> 0;
3170
+ b256[it3] = carry % 256 >>> 0;
3171
+ carry = carry / 256 >>> 0;
3172
+ }
3173
+ if (carry !== 0) {
3174
+ throw new Error("Non-zero carry");
3175
+ }
3176
+ length2 = i2;
3177
+ psz++;
3178
+ }
3179
+ if (source[psz] === " ") {
3180
+ return;
3181
+ }
3182
+ var it4 = size - length2;
3183
+ while (it4 !== size && b256[it4] === 0) {
3184
+ it4++;
3185
+ }
3186
+ var vch = new Uint8Array(zeroes + (size - it4));
3187
+ var j2 = zeroes;
3188
+ while (it4 !== size) {
3189
+ vch[j2++] = b256[it4++];
3190
+ }
3191
+ return vch;
3192
+ }
3193
+ function decode5(string) {
3194
+ var buffer = decodeUnsafe(string);
3195
+ if (buffer) {
3196
+ return buffer;
3197
+ }
3198
+ throw new Error(`Non-${name} character`);
3199
+ }
3200
+ return {
3201
+ encode: encode3,
3202
+ decodeUnsafe,
3203
+ decode: decode5
3204
+ };
3205
+ }
3206
+ var src = base2;
3207
+ var _brrp__multiformats_scope_baseX = src;
3208
+ var base_x_default = _brrp__multiformats_scope_baseX;
3209
+
3210
+ // ../../node_modules/multiformats/esm/src/bases/base.js
3211
+ var Encoder = class {
3212
+ constructor(name, prefix, baseEncode) {
3213
+ this.name = name;
3214
+ this.prefix = prefix;
3215
+ this.baseEncode = baseEncode;
3216
+ }
3217
+ encode(bytes) {
3218
+ if (bytes instanceof Uint8Array) {
3219
+ return `${this.prefix}${this.baseEncode(bytes)}`;
3220
+ } else {
3221
+ throw Error("Unknown type, must be binary type");
3222
+ }
3223
+ }
3224
+ };
3225
+ var Decoder = class {
3226
+ constructor(name, prefix, baseDecode) {
3227
+ this.name = name;
3228
+ this.prefix = prefix;
3229
+ if (prefix.codePointAt(0) === void 0) {
3230
+ throw new Error("Invalid prefix character");
3231
+ }
3232
+ this.prefixCodePoint = prefix.codePointAt(0);
3233
+ this.baseDecode = baseDecode;
3234
+ }
3235
+ decode(text) {
3236
+ if (typeof text === "string") {
3237
+ if (text.codePointAt(0) !== this.prefixCodePoint) {
3238
+ throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
3239
+ }
3240
+ return this.baseDecode(text.slice(this.prefix.length));
3241
+ } else {
3242
+ throw Error("Can only multibase decode strings");
3243
+ }
3244
+ }
3245
+ or(decoder) {
3246
+ return or(this, decoder);
3247
+ }
3248
+ };
3249
+ var ComposedDecoder = class {
3250
+ constructor(decoders) {
3251
+ this.decoders = decoders;
3252
+ }
3253
+ or(decoder) {
3254
+ return or(this, decoder);
3255
+ }
3256
+ decode(input) {
3257
+ const prefix = input[0];
3258
+ const decoder = this.decoders[prefix];
3259
+ if (decoder) {
3260
+ return decoder.decode(input);
3261
+ } else {
3262
+ throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
3263
+ }
3264
+ }
3265
+ };
3266
+ var or = (left, right) => new ComposedDecoder({
3267
+ ...left.decoders || { [left.prefix]: left },
3268
+ ...right.decoders || { [right.prefix]: right }
3269
+ });
3270
+ var Codec = class {
3271
+ constructor(name, prefix, baseEncode, baseDecode) {
3272
+ this.name = name;
3273
+ this.prefix = prefix;
3274
+ this.baseEncode = baseEncode;
3275
+ this.baseDecode = baseDecode;
3276
+ this.encoder = new Encoder(name, prefix, baseEncode);
3277
+ this.decoder = new Decoder(name, prefix, baseDecode);
3278
+ }
3279
+ encode(input) {
3280
+ return this.encoder.encode(input);
3281
+ }
3282
+ decode(input) {
3283
+ return this.decoder.decode(input);
3284
+ }
3285
+ };
3286
+ var from = ({ name, prefix, encode: encode3, decode: decode5 }) => new Codec(name, prefix, encode3, decode5);
3287
+ var baseX = ({ prefix, name, alphabet }) => {
3288
+ const { encode: encode3, decode: decode5 } = base_x_default(alphabet, name);
3289
+ return from({
3290
+ prefix,
3291
+ name,
3292
+ encode: encode3,
3293
+ decode: (text) => coerce3(decode5(text))
3294
+ });
3295
+ };
3296
+ var decode4 = (string, alphabet, bitsPerChar, name) => {
3297
+ const codes = {};
3298
+ for (let i = 0; i < alphabet.length; ++i) {
3299
+ codes[alphabet[i]] = i;
3300
+ }
3301
+ let end = string.length;
3302
+ while (string[end - 1] === "=") {
3303
+ --end;
3304
+ }
3305
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
3306
+ let bits = 0;
3307
+ let buffer = 0;
3308
+ let written = 0;
3309
+ for (let i = 0; i < end; ++i) {
3310
+ const value = codes[string[i]];
3311
+ if (value === void 0) {
3312
+ throw new SyntaxError(`Non-${name} character`);
3313
+ }
3314
+ buffer = buffer << bitsPerChar | value;
3315
+ bits += bitsPerChar;
3316
+ if (bits >= 8) {
3317
+ bits -= 8;
3318
+ out[written++] = 255 & buffer >> bits;
3319
+ }
3320
+ }
3321
+ if (bits >= bitsPerChar || 255 & buffer << 8 - bits) {
3322
+ throw new SyntaxError("Unexpected end of data");
3323
+ }
3324
+ return out;
3325
+ };
3326
+ var encode2 = (data, alphabet, bitsPerChar) => {
3327
+ const pad = alphabet[alphabet.length - 1] === "=";
3328
+ const mask = (1 << bitsPerChar) - 1;
3329
+ let out = "";
3330
+ let bits = 0;
3331
+ let buffer = 0;
3332
+ for (let i = 0; i < data.length; ++i) {
3333
+ buffer = buffer << 8 | data[i];
3334
+ bits += 8;
3335
+ while (bits > bitsPerChar) {
3336
+ bits -= bitsPerChar;
3337
+ out += alphabet[mask & buffer >> bits];
3338
+ }
3339
+ }
3340
+ if (bits) {
3341
+ out += alphabet[mask & buffer << bitsPerChar - bits];
3342
+ }
3343
+ if (pad) {
3344
+ while (out.length * bitsPerChar & 7) {
3345
+ out += "=";
3346
+ }
3347
+ }
3348
+ return out;
3349
+ };
3350
+ var rfc4648 = ({ name, prefix, bitsPerChar, alphabet }) => {
3351
+ return from({
3352
+ prefix,
3353
+ name,
3354
+ encode(input) {
3355
+ return encode2(input, alphabet, bitsPerChar);
3356
+ },
3357
+ decode(input) {
3358
+ return decode4(input, alphabet, bitsPerChar, name);
3359
+ }
3360
+ });
3361
+ };
3362
+
3363
+ // ../../node_modules/multiformats/esm/src/bases/base58.js
3364
+ var base58btc = baseX({
3365
+ name: "base58btc",
3366
+ prefix: "z",
3367
+ alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
3368
+ });
3369
+ var base58flickr = baseX({
3370
+ name: "base58flickr",
3371
+ prefix: "Z",
3372
+ alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
3373
+ });
3374
+
3375
+ // ../../node_modules/multiformats/esm/src/bases/base32.js
3376
+ var base32 = rfc4648({
3377
+ prefix: "b",
3378
+ name: "base32",
3379
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567",
3380
+ bitsPerChar: 5
3381
+ });
3382
+ var base32upper = rfc4648({
3383
+ prefix: "B",
3384
+ name: "base32upper",
3385
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
3386
+ bitsPerChar: 5
3387
+ });
3388
+ var base32pad = rfc4648({
3389
+ prefix: "c",
3390
+ name: "base32pad",
3391
+ alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
3392
+ bitsPerChar: 5
3393
+ });
3394
+ var base32padupper = rfc4648({
3395
+ prefix: "C",
3396
+ name: "base32padupper",
3397
+ alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
3398
+ bitsPerChar: 5
3399
+ });
3400
+ var base32hex = rfc4648({
3401
+ prefix: "v",
3402
+ name: "base32hex",
3403
+ alphabet: "0123456789abcdefghijklmnopqrstuv",
3404
+ bitsPerChar: 5
3405
+ });
3406
+ var base32hexupper = rfc4648({
3407
+ prefix: "V",
3408
+ name: "base32hexupper",
3409
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
3410
+ bitsPerChar: 5
3411
+ });
3412
+ var base32hexpad = rfc4648({
3413
+ prefix: "t",
3414
+ name: "base32hexpad",
3415
+ alphabet: "0123456789abcdefghijklmnopqrstuv=",
3416
+ bitsPerChar: 5
3417
+ });
3418
+ var base32hexpadupper = rfc4648({
3419
+ prefix: "T",
3420
+ name: "base32hexpadupper",
3421
+ alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
3422
+ bitsPerChar: 5
3423
+ });
3424
+ var base32z = rfc4648({
3425
+ prefix: "h",
3426
+ name: "base32z",
3427
+ alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
3428
+ bitsPerChar: 5
3429
+ });
3430
+
3431
+ // ../../node_modules/multiformats/esm/src/cid.js
3432
+ var CID = class _CID {
3433
+ constructor(version2, code, multihash, bytes) {
3434
+ this.code = code;
3435
+ this.version = version2;
3436
+ this.multihash = multihash;
3437
+ this.bytes = bytes;
3438
+ this.byteOffset = bytes.byteOffset;
3439
+ this.byteLength = bytes.byteLength;
3440
+ this.asCID = this;
3441
+ this._baseCache = /* @__PURE__ */ new Map();
3442
+ Object.defineProperties(this, {
3443
+ byteOffset: hidden,
3444
+ byteLength: hidden,
3445
+ code: readonly,
3446
+ version: readonly,
3447
+ multihash: readonly,
3448
+ bytes: readonly,
3449
+ _baseCache: hidden,
3450
+ asCID: hidden
3451
+ });
3452
+ }
3453
+ toV0() {
3454
+ switch (this.version) {
3455
+ case 0: {
3456
+ return this;
3457
+ }
3458
+ default: {
3459
+ const { code, multihash } = this;
3460
+ if (code !== DAG_PB_CODE) {
3461
+ throw new Error("Cannot convert a non dag-pb CID to CIDv0");
3462
+ }
3463
+ if (multihash.code !== SHA_256_CODE) {
3464
+ throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
3465
+ }
3466
+ return _CID.createV0(multihash);
3467
+ }
3468
+ }
3469
+ }
3470
+ toV1() {
3471
+ switch (this.version) {
3472
+ case 0: {
3473
+ const { code, digest } = this.multihash;
3474
+ const multihash = create(code, digest);
3475
+ return _CID.createV1(this.code, multihash);
3476
+ }
3477
+ case 1: {
3478
+ return this;
3479
+ }
3480
+ default: {
3481
+ throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
3482
+ }
3483
+ }
3484
+ }
3485
+ equals(other) {
3486
+ return other && this.code === other.code && this.version === other.version && equals2(this.multihash, other.multihash);
3487
+ }
3488
+ toString(base3) {
3489
+ const { bytes, version: version2, _baseCache } = this;
3490
+ switch (version2) {
3491
+ case 0:
3492
+ return toStringV0(bytes, _baseCache, base3 || base58btc.encoder);
3493
+ default:
3494
+ return toStringV1(bytes, _baseCache, base3 || base32.encoder);
3495
+ }
3496
+ }
3497
+ toJSON() {
3498
+ return {
3499
+ code: this.code,
3500
+ version: this.version,
3501
+ hash: this.multihash.bytes
3502
+ };
3503
+ }
3504
+ get [Symbol.toStringTag]() {
3505
+ return "CID";
3506
+ }
3507
+ [Symbol.for("nodejs.util.inspect.custom")]() {
3508
+ return "CID(" + this.toString() + ")";
3509
+ }
3510
+ static isCID(value) {
3511
+ deprecate(/^0\.0/, IS_CID_DEPRECATION);
3512
+ return !!(value && (value[cidSymbol] || value.asCID === value));
3513
+ }
3514
+ get toBaseEncodedString() {
3515
+ throw new Error("Deprecated, use .toString()");
3516
+ }
3517
+ get codec() {
3518
+ throw new Error('"codec" property is deprecated, use integer "code" property instead');
3519
+ }
3520
+ get buffer() {
3521
+ throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead");
3522
+ }
3523
+ get multibaseName() {
3524
+ throw new Error('"multibaseName" property is deprecated');
3525
+ }
3526
+ get prefix() {
3527
+ throw new Error('"prefix" property is deprecated');
3528
+ }
3529
+ static asCID(value) {
3530
+ if (value instanceof _CID) {
3531
+ return value;
3532
+ } else if (value != null && value.asCID === value) {
3533
+ const { version: version2, code, multihash, bytes } = value;
3534
+ return new _CID(version2, code, multihash, bytes || encodeCID(version2, code, multihash.bytes));
3535
+ } else if (value != null && value[cidSymbol] === true) {
3536
+ const { version: version2, multihash, code } = value;
3537
+ const digest = decode3(multihash);
3538
+ return _CID.create(version2, code, digest);
3539
+ } else {
3540
+ return null;
3541
+ }
3542
+ }
3543
+ static create(version2, code, digest) {
3544
+ if (typeof code !== "number") {
3545
+ throw new Error("String codecs are no longer supported");
3546
+ }
3547
+ switch (version2) {
3548
+ case 0: {
3549
+ if (code !== DAG_PB_CODE) {
3550
+ throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
3551
+ } else {
3552
+ return new _CID(version2, code, digest, digest.bytes);
3553
+ }
3554
+ }
3555
+ case 1: {
3556
+ const bytes = encodeCID(version2, code, digest.bytes);
3557
+ return new _CID(version2, code, digest, bytes);
3558
+ }
3559
+ default: {
3560
+ throw new Error("Invalid version");
3561
+ }
3562
+ }
3563
+ }
3564
+ static createV0(digest) {
3565
+ return _CID.create(0, DAG_PB_CODE, digest);
3566
+ }
3567
+ static createV1(code, digest) {
3568
+ return _CID.create(1, code, digest);
3569
+ }
3570
+ static decode(bytes) {
3571
+ const [cid, remainder] = _CID.decodeFirst(bytes);
3572
+ if (remainder.length) {
3573
+ throw new Error("Incorrect length");
3574
+ }
3575
+ return cid;
3576
+ }
3577
+ static decodeFirst(bytes) {
3578
+ const specs = _CID.inspectBytes(bytes);
3579
+ const prefixSize = specs.size - specs.multihashSize;
3580
+ const multihashBytes = coerce3(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
3581
+ if (multihashBytes.byteLength !== specs.multihashSize) {
3582
+ throw new Error("Incorrect length");
3583
+ }
3584
+ const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
3585
+ const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
3586
+ const cid = specs.version === 0 ? _CID.createV0(digest) : _CID.createV1(specs.codec, digest);
3587
+ return [
3588
+ cid,
3589
+ bytes.subarray(specs.size)
3590
+ ];
3591
+ }
3592
+ static inspectBytes(initialBytes) {
3593
+ let offset = 0;
3594
+ const next = () => {
3595
+ const [i, length2] = decode2(initialBytes.subarray(offset));
3596
+ offset += length2;
3597
+ return i;
3598
+ };
3599
+ let version2 = next();
3600
+ let codec = DAG_PB_CODE;
3601
+ if (version2 === 18) {
3602
+ version2 = 0;
3603
+ offset = 0;
3604
+ } else if (version2 === 1) {
3605
+ codec = next();
3606
+ }
3607
+ if (version2 !== 0 && version2 !== 1) {
3608
+ throw new RangeError(`Invalid CID version ${version2}`);
3609
+ }
3610
+ const prefixSize = offset;
3611
+ const multihashCode = next();
3612
+ const digestSize = next();
3613
+ const size = offset + digestSize;
3614
+ const multihashSize = size - prefixSize;
3615
+ return {
3616
+ version: version2,
3617
+ codec,
3618
+ multihashCode,
3619
+ digestSize,
3620
+ multihashSize,
3621
+ size
3622
+ };
3623
+ }
3624
+ static parse(source, base3) {
3625
+ const [prefix, bytes] = parseCIDtoBytes(source, base3);
3626
+ const cid = _CID.decode(bytes);
3627
+ cid._baseCache.set(prefix, source);
3628
+ return cid;
3629
+ }
3630
+ };
3631
+ var parseCIDtoBytes = (source, base3) => {
3632
+ switch (source[0]) {
3633
+ case "Q": {
3634
+ const decoder = base3 || base58btc;
3635
+ return [
3636
+ base58btc.prefix,
3637
+ decoder.decode(`${base58btc.prefix}${source}`)
3638
+ ];
3639
+ }
3640
+ case base58btc.prefix: {
3641
+ const decoder = base3 || base58btc;
3642
+ return [
3643
+ base58btc.prefix,
3644
+ decoder.decode(source)
3645
+ ];
3646
+ }
3647
+ case base32.prefix: {
3648
+ const decoder = base3 || base32;
3649
+ return [
3650
+ base32.prefix,
3651
+ decoder.decode(source)
3652
+ ];
3653
+ }
3654
+ default: {
3655
+ if (base3 == null) {
3656
+ throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");
3657
+ }
3658
+ return [
3659
+ source[0],
3660
+ base3.decode(source)
3661
+ ];
3662
+ }
3663
+ }
3664
+ };
3665
+ var toStringV0 = (bytes, cache, base3) => {
3666
+ const { prefix } = base3;
3667
+ if (prefix !== base58btc.prefix) {
3668
+ throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
3669
+ }
3670
+ const cid = cache.get(prefix);
3671
+ if (cid == null) {
3672
+ const cid2 = base3.encode(bytes).slice(1);
3673
+ cache.set(prefix, cid2);
3674
+ return cid2;
3675
+ } else {
3676
+ return cid;
3677
+ }
3678
+ };
3679
+ var toStringV1 = (bytes, cache, base3) => {
3680
+ const { prefix } = base3;
3681
+ const cid = cache.get(prefix);
3682
+ if (cid == null) {
3683
+ const cid2 = base3.encode(bytes);
3684
+ cache.set(prefix, cid2);
3685
+ return cid2;
3686
+ } else {
3687
+ return cid;
3688
+ }
3689
+ };
3690
+ var DAG_PB_CODE = 112;
3691
+ var SHA_256_CODE = 18;
3692
+ var encodeCID = (version2, code, multihash) => {
3693
+ const codeOffset = encodingLength(version2);
3694
+ const hashOffset = codeOffset + encodingLength(code);
3695
+ const bytes = new Uint8Array(hashOffset + multihash.byteLength);
3696
+ encodeTo(version2, bytes, 0);
3697
+ encodeTo(code, bytes, codeOffset);
3698
+ bytes.set(multihash, hashOffset);
3699
+ return bytes;
3700
+ };
3701
+ var cidSymbol = Symbol.for("@ipld/js-cid/CID");
3702
+ var readonly = {
3703
+ writable: false,
3704
+ configurable: false,
3705
+ enumerable: true
3706
+ };
3707
+ var hidden = {
3708
+ writable: false,
3709
+ enumerable: false,
3710
+ configurable: false
3711
+ };
3712
+ var version = "0.0.0-dev";
3713
+ var deprecate = (range, message) => {
3714
+ if (range.test(version)) {
3715
+ console.warn(message);
3716
+ } else {
3717
+ throw new Error(message);
3718
+ }
3719
+ };
3720
+ var IS_CID_DEPRECATION = `CID.isCID(v) is deprecated and will be removed in the next major release.
3721
+ Following code pattern:
3722
+
3723
+ if (CID.isCID(value)) {
3724
+ doSomethingWithCID(value)
3725
+ }
3726
+
3727
+ Is replaced with:
3728
+
3729
+ const cid = CID.asCID(value)
3730
+ if (cid) {
3731
+ // Make sure to use cid instead of value
3732
+ doSomethingWithCID(cid)
3733
+ }
3734
+ `;
3735
+
3736
+ // src/ipfs/ipfs.ts
3737
+ function isCID(str) {
3738
+ if (!str)
3739
+ return false;
3740
+ try {
3741
+ CID.parse(str);
3742
+ return true;
3743
+ } catch (e) {
3744
+ if (/^(bafy|Qm)/.test(str))
3745
+ return true;
3746
+ return false;
3747
+ }
3748
+ }
3749
+ function normalizeIPFSUrl(url) {
3750
+ if (!url || typeof url !== "string")
3751
+ return null;
3752
+ url = url.replace(/"/g, "");
3753
+ if (isNormalizedIPFSURL(url))
3754
+ return url;
3755
+ if (isCID(url))
3756
+ return `ipfs://${url}`;
3757
+ if (!isIPFSUrl(url))
3758
+ return null;
3759
+ if (isGatewayIPFSUrl(url)) {
3760
+ const parsed = new URL(url.replace(/^\/\//, "http://"));
3761
+ parsed.pathname = parsed.pathname.replace(/^\/ipfs\//, "");
3762
+ const cid = parsed.toString().replace(`${parsed.protocol}//${parsed.host}/`, "");
3763
+ return `ipfs://${cid}`;
3764
+ }
3765
+ return null;
3766
+ }
3767
+ function isNormalizedIPFSURL(url) {
3768
+ return url && typeof url === "string" ? url.startsWith("ipfs://") : false;
3769
+ }
3770
+ function isGatewayIPFSUrl(url) {
3771
+ if (url && typeof url === "string") {
3772
+ try {
3773
+ const parsed = new URL(url.replace(/^"|'(.*)"|'$/, "$1"));
3774
+ return !isNormalizedIPFSURL(url) && parsed && parsed.pathname.startsWith("/ipfs/");
3775
+ } catch {
3776
+ return false;
3777
+ }
3778
+ }
3779
+ return false;
3780
+ }
3781
+ function isIPFSUrl(url) {
3782
+ return url ? isNormalizedIPFSURL(url) || isGatewayIPFSUrl(url) : false;
3783
+ }
3784
+ function isNormalizeableIPFSUrl(url) {
3785
+ return url ? isIPFSUrl(url) || isCID(url) : false;
3786
+ }
3787
+
3788
+ // src/ipfs/gateway.ts
3789
+ var IPFS_GATEWAY = "https://magic.decentralized-content.com";
3790
+ var ARWEAVE_GATEWAY = "https://arweave.net";
3791
+ function arweaveGatewayUrl(normalizedArweaveUrl) {
3792
+ if (!normalizedArweaveUrl || typeof normalizedArweaveUrl !== "string")
3793
+ return null;
3794
+ return normalizedArweaveUrl.replace("ar://", `${ARWEAVE_GATEWAY}/`);
3795
+ }
3796
+ function ipfsGatewayUrl(url) {
3797
+ if (!url || typeof url !== "string")
3798
+ return null;
3799
+ const normalizedIPFSUrl = normalizeIPFSUrl(url);
3800
+ if (normalizedIPFSUrl) {
3801
+ return normalizedIPFSUrl.replace("ipfs://", `${IPFS_GATEWAY}/ipfs/`);
3802
+ }
3803
+ return null;
3804
+ }
3805
+ function getFetchableUrl(uri) {
3806
+ if (!uri || typeof uri !== "string")
3807
+ return null;
3808
+ if (uri.startsWith("http://"))
3809
+ return null;
3810
+ if (isNormalizeableIPFSUrl(uri)) {
3811
+ return ipfsGatewayUrl(uri);
3812
+ }
3813
+ if (isArweaveURL(uri)) {
3814
+ return arweaveGatewayUrl(uri);
3815
+ }
3816
+ if (/^(https|data|blob):/.test(uri)) {
3817
+ return uri;
3818
+ }
3819
+ return null;
3820
+ }
3821
+
3822
+ // src/ipfs/mimeTypes.ts
3823
+ var HTML = "text/html";
3824
+ var MARKDOWN = "text/markdown";
3825
+ var MARKDOWN_UTF8 = "text/markdown; charset=utf-8";
3826
+ var TEXT_PLAIN_UTF8 = "text/plain; charset=utf-8";
3827
+ var TEXT_PLAIN = "text/plain";
3828
+ var CSV = "text/csv";
3829
+ var NUMBERS = ".numbers";
3830
+ var EXCEL = ".xlsx";
3831
+ var PDF = "application/pdf";
3832
+ var JPG = "image/jpg";
3833
+ var JPEG = "image/jpeg";
3834
+ var PNG = "image/png";
3835
+ var WEBP = "image/webp";
3836
+ var SVG = "image/svg+xml";
3837
+ var TIFF = "image/tiff";
3838
+ var GIF = "image/gif";
3839
+ var isImage = (mimeType) => {
3840
+ if (!mimeType)
3841
+ return false;
3842
+ return [JPG, JPEG, PNG, WEBP, SVG, TIFF, GIF].includes(mimeType);
3843
+ };
3844
+ var DEFAULT_THUMBNAIL_CID_HASHES = {
3845
+ ["AUDIO" /* AUDIO */]: "bafkreidir5laqi26ta6ivnpe2zpekgrfcyi4tb5x6vhwmwnledmzxshfb4",
3846
+ ["VIDEO" /* VIDEO */]: "bafkreifm4edadl3j5luoyvw4p6elxeqd77la7bulee6vhq5gq4chfk32mu",
3847
+ ["HTML" /* HTML */]: "bafkreifgvi6xfwqy2l6g45csyokejpaib52ee7zrw6etrxl2tas4xkkclq",
3848
+ ["ZIP" /* ZIP */]: "bafkreihe5rr5jbkwzegisjlhxbb7jw22xw5oilfmgd2re6tz6buo4pasdq",
3849
+ // assuming all zip files are html directories
3850
+ ["TEXT" /* TEXT */]: "bafkreiaez25nfgggzrnza2loxf6xueb2esm44pnyjyulwoslnipowrf56q",
3851
+ default: "bafkreihcoahllisbpb4eeypdwtm7go5uh275wxd7wf2tantpxlpjhviok4"
3852
+ };
3853
+ var MP4 = "video/mp4";
3854
+ var QUICKTIME = "video/quicktime";
3855
+ var M4V = "video/x-m4v";
3856
+ var WEBM = "video/webm";
3857
+ var M4A = "audio/x-m4a";
3858
+ var MPEG = "audio/mpeg";
3859
+ var MP3 = "audio/mp3";
3860
+ var WAV = "audio/wav";
3861
+ var VND_WAV = "audio/vnd.wav";
3862
+ var VND_WAVE = "audio/vnd.wave";
3863
+ var WAVE = "audio/wave";
3864
+ var X_WAV = "audio/x-wav";
3865
+ var AIFF = "audio/aiff";
3866
+ var GLTF = "model/gltf+json";
3867
+ var GLB = "model/gltf-binary";
3868
+ var GLTF_EXT = ".gltf";
3869
+ var GLB_EXT = ".glb";
3870
+ var JSON_MIME_TYPE = "application/json";
3871
+ var ZIP = "application/zip";
3872
+ var mimeToMediaType = {
3873
+ [HTML]: "HTML" /* HTML */,
3874
+ [JPG]: "IMAGE" /* IMAGE */,
3875
+ [JPEG]: "IMAGE" /* IMAGE */,
3876
+ [PNG]: "IMAGE" /* IMAGE */,
3877
+ [WEBP]: "IMAGE" /* IMAGE */,
3878
+ [SVG]: "IMAGE" /* IMAGE */,
3879
+ [TIFF]: "TIFF" /* TIFF */,
3880
+ [GIF]: "IMAGE" /* IMAGE */,
3881
+ [MP4]: "VIDEO" /* VIDEO */,
3882
+ [WEBM]: "VIDEO" /* VIDEO */,
3883
+ [QUICKTIME]: "VIDEO" /* VIDEO */,
3884
+ [M4V]: "VIDEO" /* VIDEO */,
3885
+ [MPEG]: "AUDIO" /* AUDIO */,
3886
+ [MP3]: "AUDIO" /* AUDIO */,
3887
+ [M4A]: "AUDIO" /* AUDIO */,
3888
+ [VND_WAV]: "AUDIO" /* AUDIO */,
3889
+ [VND_WAVE]: "AUDIO" /* AUDIO */,
3890
+ [WAV]: "AUDIO" /* AUDIO */,
3891
+ [WAVE]: "AUDIO" /* AUDIO */,
3892
+ [X_WAV]: "AUDIO" /* AUDIO */,
3893
+ [AIFF]: "AUDIO" /* AUDIO */,
3894
+ [TEXT_PLAIN]: "TEXT" /* TEXT */,
3895
+ [TEXT_PLAIN_UTF8]: "TEXT" /* TEXT */,
3896
+ [MARKDOWN]: "TEXT" /* TEXT */,
3897
+ [MARKDOWN_UTF8]: "TEXT" /* TEXT */,
3898
+ [CSV]: "CSV" /* CSV */,
3899
+ [NUMBERS]: "NUMBERS" /* NUMBERS */,
3900
+ [EXCEL]: "EXCEL" /* EXCEL */,
3901
+ [PDF]: "PDF" /* PDF */,
3902
+ [ZIP]: "ZIP" /* ZIP */,
3903
+ [GLTF]: "MODEL" /* MODEL */,
3904
+ [GLTF_EXT]: "MODEL" /* MODEL */,
3905
+ [GLB]: "MODEL" /* MODEL */,
3906
+ // GLTF returns 'application/json' as the mimetype,
3907
+ // and as the only JSON-encoded media we currently support,
3908
+ // we assume that if the mimetype is JSON, it's a GLTF
3909
+ [JSON_MIME_TYPE]: "MODEL" /* MODEL */,
3910
+ [GLB_EXT]: "MODEL" /* MODEL */
3911
+ };
3912
+ function mimeTypeToMedia(mimeType) {
3913
+ if (!mimeType)
3914
+ return "UNKNOWN" /* UNKNOWN */;
3915
+ return mimeToMediaType[mimeType] || "UNKNOWN" /* UNKNOWN */;
3916
+ }
3917
+ async function getMimeType(uri) {
3918
+ if (!uri)
3919
+ return uri;
3920
+ const res = await fetch(uri, { method: "HEAD" });
3921
+ let mimeType = res.headers.get("content-type");
3922
+ return mimeType;
3923
+ }
3924
+
3925
+ // src/ipfs/token-metadata.ts
3926
+ var makeTextTokenMetadata = (parameters) => {
3927
+ const { name, textFileUrl, thumbnailUrl, attributes = [] } = parameters;
3928
+ const content = textFileUrl ? {
3929
+ mime: TEXT_PLAIN,
3930
+ uri: textFileUrl
3931
+ } : null;
3932
+ const image = thumbnailUrl;
3933
+ const animation_url = textFileUrl;
3934
+ return {
3935
+ name,
3936
+ image,
3937
+ animation_url,
3938
+ content,
3939
+ attributes
3940
+ };
3941
+ };
3942
+ var makeMediaTokenMetadata = async ({
3943
+ name,
3944
+ description,
3945
+ attributes = [],
3946
+ mediaUrl,
3947
+ thumbnailUrl
3948
+ }) => {
3949
+ const contentUrl = mediaUrl;
3950
+ const fetchableContentUrl = getFetchableUrl(contentUrl);
3951
+ if (!fetchableContentUrl)
3952
+ throw new Error(`Content url (${contentUrl}) is not fetchable`);
3953
+ const mimeType = await getMimeType(fetchableContentUrl);
3954
+ const mediaType = mimeTypeToMedia(mimeType);
3955
+ let image = void 0;
3956
+ let animation_url = null;
3957
+ if (isImage(mimeType)) {
3958
+ image = contentUrl;
3959
+ } else {
3960
+ image = thumbnailUrl;
3961
+ animation_url = mediaUrl;
3962
+ }
3963
+ if (!image)
3964
+ image = `ipfs://${DEFAULT_THUMBNAIL_CID_HASHES[mediaType] || DEFAULT_THUMBNAIL_CID_HASHES.default}`;
3965
+ const content = contentUrl ? {
3966
+ mime: mimeType || "application/octet-stream",
3967
+ uri: contentUrl
3968
+ } : null;
3969
+ return {
3970
+ name,
3971
+ description,
3972
+ image,
3973
+ animation_url,
3974
+ content,
3975
+ attributes
3976
+ };
3977
+ };
3978
+
3979
+ // src/ipfs/text-metadata.ts
3980
+ var CHAR_LIMIT = 1111;
3981
+ var wrapText = ({
3982
+ ctx,
3983
+ text,
3984
+ x,
3985
+ y,
3986
+ maxWidth,
3987
+ lineHeight
3988
+ }) => {
3989
+ let words = text.replaceAll("\n", " \n ").split(/ +/);
3990
+ let line = "";
3991
+ let testLine = "";
3992
+ let lineArray = [];
3993
+ for (var n = 0; n < words.length; n++) {
3994
+ testLine += `${words[n]} `;
3995
+ let metrics = ctx.measureText(testLine);
3996
+ let testWidth = metrics.width;
3997
+ if (words[n]?.includes("\n") || testWidth > maxWidth && n > 0) {
3998
+ lineArray.push({ text: line, x, y });
3999
+ y += lineHeight;
4000
+ if (words[n]?.includes("\n")) {
4001
+ line = ``;
4002
+ testLine = ``;
4003
+ } else {
4004
+ line = `${words[n]} `;
4005
+ testLine = `${words[n]} `;
4006
+ }
4007
+ } else {
4008
+ line += `${words[n]} `;
4009
+ }
4010
+ if (n === words.length - 1) {
4011
+ lineArray.push({ text: line, x, y });
4012
+ }
4013
+ }
4014
+ return lineArray;
4015
+ };
4016
+ async function generateTextPreview(text) {
4017
+ const trimmedText = text.trim().slice(0, CHAR_LIMIT);
4018
+ const [width, height] = [500, 500];
4019
+ const padding = 20;
4020
+ const dpr = 2;
4021
+ const fontFamily = "Inter";
4022
+ const [fontSize, lineHeight] = [16, 24];
4023
+ const [textColor, backgroundColor] = ["black", "white"];
4024
+ return new Promise((resolve, reject) => {
4025
+ const canvas = document.createElement("canvas");
4026
+ canvas.width = width * dpr;
4027
+ canvas.height = height * dpr;
4028
+ const ctx = canvas.getContext("2d");
4029
+ if (!ctx) {
4030
+ return reject(new Error("Could not create canvas context"));
4031
+ }
4032
+ ctx.fillStyle = backgroundColor;
4033
+ ctx.fillRect(0, 0, width * dpr, width * dpr);
4034
+ ctx.fillStyle = textColor;
4035
+ ctx.font = `${fontSize * dpr}px ${fontFamily}`;
4036
+ const wrapped = wrapText({
4037
+ ctx,
4038
+ text: trimmedText,
4039
+ x: padding * dpr,
4040
+ y: fontSize * dpr + padding * dpr,
4041
+ maxWidth: width * dpr - padding * 2 * dpr,
4042
+ lineHeight: lineHeight * dpr
4043
+ });
4044
+ wrapped.forEach((line) => ctx.fillText(line.text, line.x, line.y));
4045
+ canvas.toBlob((blob) => {
4046
+ if (!blob) {
4047
+ return reject(new Error("Could not create blob"));
4048
+ }
4049
+ resolve(new File([blob], "thumbnail.png", { type: "image/png" }));
4050
+ });
4051
+ });
4052
+ }
4053
+ function generateTextTitle(text) {
4054
+ const firstLine = text.split("\n")[0];
4055
+ const firstSentence = firstLine?.split(". ")[0];
4056
+ if (firstSentence.length > 50) {
4057
+ return firstSentence.slice(0, 50) + "...";
4058
+ }
4059
+ return firstSentence;
4060
+ }
4061
+ var toTextFile = (text) => new File([text], "Untitled.txt", { type: "text/plain" });
4062
+ async function generateTextNftMetadataFiles(text) {
4063
+ const name = generateTextTitle(text);
4064
+ const textFile = toTextFile(text);
4065
+ const thumbnailFile = await generateTextPreview(text);
4066
+ return {
4067
+ name,
4068
+ mediaUrlFile: textFile,
4069
+ thumbnailFile
4070
+ };
4071
+ }
2483
4072
  export {
2484
4073
  Create1155Client,
2485
4074
  Errors,
@@ -2490,12 +4079,14 @@ export {
2490
4079
  SubgraphMintGetter,
2491
4080
  ZORA_API_BASE,
2492
4081
  applyUpdateToPremint,
4082
+ buildPremintMintCall,
2493
4083
  collectOnchain,
2494
4084
  collectPremint,
2495
4085
  collectPremintV2WithMintsParams,
2496
4086
  collectWithMintsParams,
2497
4087
  convertCollectionFromApi,
2498
4088
  convertGetPremintApiResponse,
4089
+ convertGetPremintOfCollectionApiResponse,
2499
4090
  convertPremintFromApi,
2500
4091
  createCollectorClient,
2501
4092
  createCreatorClient,
@@ -2507,13 +4098,12 @@ export {
2507
4098
  encodeCollectOnManager,
2508
4099
  encodePostSignatureInput,
2509
4100
  encodePremintForAPI,
4101
+ generateTextNftMetadataFiles,
2510
4102
  getApiNetworkConfigForChain,
2511
4103
  getDataFromPremintReceipt,
2512
4104
  getDefaultFixedPriceMinterAddress,
2513
- getMintCosts,
2514
4105
  getMintsAccountBalanceWithPriceQuery,
2515
4106
  getMintsEthPrice,
2516
- getNecessaryErc20Approval,
2517
4107
  getPremintCollectionAddress,
2518
4108
  getPremintExecutorAddress,
2519
4109
  getPremintMintCosts,
@@ -2528,20 +4118,19 @@ export {
2528
4118
  isPremintConfigV2,
2529
4119
  isValidSignature,
2530
4120
  makeCallWithEthSafeTransferData,
4121
+ makeMediaTokenMetadata,
2531
4122
  makeMintRewardsRecipient,
2532
4123
  makeNewPremint,
2533
4124
  makePermitToCollectPremintOrNonPremint,
2534
4125
  makePermitTransferBatchAndTypeData,
2535
4126
  makePermitTransferTypeData,
2536
- makePrepareMint1155TokenParams,
4127
+ makeTextTokenMetadata,
2537
4128
  makeUrls,
2538
4129
  migratePremintConfigToV2,
2539
4130
  mintWithEthParams,
2540
4131
  mintsBalanceOfAccountParams,
2541
- parseMintCosts,
2542
4132
  recoverCreatorFromCreatorAttribution,
2543
4133
  recoverPremintSigner,
2544
- requestErc20ApprovalForMint,
2545
4134
  selectMintsToCollectWithFromQueryResult,
2546
4135
  sumBalances,
2547
4136
  supportedPremintVersions,