@zoralabs/protocol-sdk 0.3.3 → 0.3.5

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 (37) hide show
  1. package/.turbo/turbo-build.log +7 -7
  2. package/CHANGELOG.md +28 -0
  3. package/README.md +7 -26
  4. package/dist/anvil.d.ts +4 -2
  5. package/dist/anvil.d.ts.map +1 -1
  6. package/dist/constants.d.ts +32 -0
  7. package/dist/constants.d.ts.map +1 -1
  8. package/dist/index.cjs +476 -323
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.js +447 -298
  11. package/dist/index.js.map +1 -1
  12. package/dist/mint/mint-api-client.d.ts +16 -213
  13. package/dist/mint/mint-api-client.d.ts.map +1 -1
  14. package/dist/mint/mint-client.d.ts +7 -226
  15. package/dist/mint/mint-client.d.ts.map +1 -1
  16. package/dist/premint/premint-client.d.ts +63 -17
  17. package/dist/premint/premint-client.d.ts.map +1 -1
  18. package/dist/premint/preminter.d.ts +106 -19
  19. package/dist/premint/preminter.d.ts.map +1 -1
  20. package/dist/types.d.ts +2 -0
  21. package/dist/types.d.ts.map +1 -0
  22. package/package.json +2 -1
  23. package/src/anvil.ts +7 -4
  24. package/src/constants.ts +7 -0
  25. package/src/create/1155-create-helper.ts +1 -1
  26. package/src/mint/mint-api-client.ts +79 -53
  27. package/src/mint/mint-client.test.ts +9 -11
  28. package/src/mint/mint-client.ts +50 -215
  29. package/src/premint/premint-client.test.ts +9 -8
  30. package/src/premint/premint-client.ts +113 -61
  31. package/src/premint/preminter.test.ts +207 -130
  32. package/src/premint/preminter.ts +388 -51
  33. package/src/types.ts +1 -0
  34. package/tsconfig.json +2 -17
  35. package/dist/apis/generated/discover-api-types.d.ts +0 -2131
  36. package/dist/apis/generated/discover-api-types.d.ts.map +0 -1
  37. package/src/apis/generated/discover-api-types.ts +0 -2180
package/dist/index.cjs CHANGED
@@ -25,75 +25,277 @@ __export(src_exports, {
25
25
  Errors: () => Errors,
26
26
  MintAPIClient: () => MintAPIClient,
27
27
  PremintAPIClient: () => PremintAPIClient,
28
+ PremintConfigVersion: () => PremintConfigVersion,
29
+ PreminterDomain: () => PreminterDomain,
28
30
  ZORA_API_BASE: () => ZORA_API_BASE,
29
31
  convertCollection: () => convertCollection,
30
- convertPremint: () => convertPremint,
32
+ convertPremintV1: () => convertPremintV1,
31
33
  create1155CreatorClient: () => create1155CreatorClient,
32
34
  create1155TokenSetupArgs: () => create1155TokenSetupArgs,
33
35
  createMintClient: () => createMintClient,
34
36
  createPremintClient: () => createPremintClient,
35
37
  encodePremintForAPI: () => encodePremintForAPI,
36
- get1155MintCosts: () => get1155MintCosts,
38
+ encodePremintV1ForAPI: () => encodePremintV1ForAPI,
39
+ encodePremintV2ForAPI: () => encodePremintV2ForAPI,
37
40
  getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
41
+ getMintCosts: () => getMintCosts,
42
+ getPremintCollectionAddress: () => getPremintCollectionAddress,
43
+ getPremintExecutorAddress: () => getPremintExecutorAddress,
38
44
  getPremintedLogFromReceipt: () => getPremintedLogFromReceipt,
39
45
  getTokenIdFromCreateReceipt: () => getTokenIdFromCreateReceipt,
40
- preminterTypedDataDefinition: () => preminterTypedDataDefinition
46
+ isAuthorizedToCreatePremint: () => isAuthorizedToCreatePremint,
47
+ isValidSignature: () => isValidSignature,
48
+ migratePremintConfigToV2: () => migratePremintConfigToV2,
49
+ premintTypedDataDefinition: () => premintTypedDataDefinition,
50
+ recoverCreatorFromCreatorAttribution: () => recoverCreatorFromCreatorAttribution,
51
+ recoverPremintSigner: () => recoverPremintSigner,
52
+ supportsPremintVersion: () => supportsPremintVersion,
53
+ tryRecoverPremintSigner: () => tryRecoverPremintSigner
41
54
  });
42
55
  module.exports = __toCommonJS(src_exports);
43
56
 
44
57
  // src/premint/premint-client.ts
45
- var import_viem2 = require("viem");
46
- var import_protocol_deployments = require("@zoralabs/protocol-deployments");
58
+ var import_viem4 = require("viem");
59
+ var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
47
60
 
48
61
  // src/premint/preminter.ts
49
- var preminterTypedDataDefinition = ({
62
+ var import_protocol_deployments = require("@zoralabs/protocol-deployments");
63
+ var import_viem = require("viem");
64
+ var v1Types = {
65
+ CreatorAttribution: [
66
+ { name: "tokenConfig", type: "TokenCreationConfig" },
67
+ // unique id scoped to the contract and token to create.
68
+ // ensure that a signature can be replaced, as long as the replacement
69
+ // has the same uid, and a newer version.
70
+ { name: "uid", type: "uint32" },
71
+ { name: "version", type: "uint32" },
72
+ // if this update should result in the signature being deleted.
73
+ { name: "deleted", type: "bool" }
74
+ ],
75
+ TokenCreationConfig: [
76
+ { name: "tokenURI", type: "string" },
77
+ { name: "maxSupply", type: "uint256" },
78
+ { name: "maxTokensPerAddress", type: "uint64" },
79
+ { name: "pricePerToken", type: "uint96" },
80
+ { name: "mintStart", type: "uint64" },
81
+ { name: "mintDuration", type: "uint64" },
82
+ { name: "royaltyMintSchedule", type: "uint32" },
83
+ { name: "royaltyBPS", type: "uint32" },
84
+ { name: "royaltyRecipient", type: "address" },
85
+ { name: "fixedPriceMinter", type: "address" }
86
+ ]
87
+ };
88
+ var v2Types = {
89
+ CreatorAttribution: [
90
+ { name: "tokenConfig", type: "TokenCreationConfig" },
91
+ // unique id scoped to the contract and token to create.
92
+ // ensure that a signature can be replaced, as long as the replacement
93
+ // has the same uid, and a newer version.
94
+ { name: "uid", type: "uint32" },
95
+ { name: "version", type: "uint32" },
96
+ // if this update should result in the signature being deleted.
97
+ { name: "deleted", type: "bool" }
98
+ ],
99
+ TokenCreationConfig: [
100
+ { name: "tokenURI", type: "string" },
101
+ { name: "maxSupply", type: "uint256" },
102
+ { name: "maxTokensPerAddress", type: "uint64" },
103
+ { name: "pricePerToken", type: "uint96" },
104
+ { name: "mintStart", type: "uint64" },
105
+ { name: "mintDuration", type: "uint64" },
106
+ { name: "royaltyBPS", type: "uint32" },
107
+ { name: "payoutRecipient", type: "address" },
108
+ { name: "fixedPriceMinter", type: "address" },
109
+ { name: "createReferral", type: "address" }
110
+ ]
111
+ };
112
+ var PreminterDomain = "Preminter";
113
+ var PremintConfigVersion = {
114
+ V1: "1",
115
+ V2: "2"
116
+ };
117
+ var getPremintExecutorAddress = () => import_protocol_deployments.zoraCreator1155PremintExecutorImplAddress[999];
118
+ var premintTypedDataDefinition = ({
50
119
  verifyingContract,
51
- premintConfig,
52
- chainId
120
+ chainId,
121
+ premintConfigVersion: version,
122
+ premintConfig
53
123
  }) => {
54
- const { tokenConfig, uid, version, deleted } = premintConfig;
55
- const types = {
56
- CreatorAttribution: [
57
- { name: "tokenConfig", type: "TokenCreationConfig" },
58
- // unique id scoped to the contract and token to create.
59
- // ensure that a signature can be replaced, as long as the replacement
60
- // has the same uid, and a newer version.
61
- { name: "uid", type: "uint32" },
62
- { name: "version", type: "uint32" },
63
- // if this update should result in the signature being deleted.
64
- { name: "deleted", type: "bool" }
65
- ],
66
- TokenCreationConfig: [
67
- { name: "tokenURI", type: "string" },
68
- { name: "maxSupply", type: "uint256" },
69
- { name: "maxTokensPerAddress", type: "uint64" },
70
- { name: "pricePerToken", type: "uint96" },
71
- { name: "mintStart", type: "uint64" },
72
- { name: "mintDuration", type: "uint64" },
73
- { name: "royaltyMintSchedule", type: "uint32" },
74
- { name: "royaltyBPS", type: "uint32" },
75
- { name: "royaltyRecipient", type: "address" },
76
- { name: "fixedPriceMinter", type: "address" }
77
- ]
124
+ const domain = {
125
+ chainId,
126
+ name: PreminterDomain,
127
+ version,
128
+ verifyingContract
78
129
  };
79
- const result = {
130
+ if (version === PremintConfigVersion.V1)
131
+ return {
132
+ domain,
133
+ types: v1Types,
134
+ message: premintConfig,
135
+ primaryType: "CreatorAttribution"
136
+ };
137
+ if (version === PremintConfigVersion.V2) {
138
+ return {
139
+ domain,
140
+ types: v2Types,
141
+ message: premintConfig,
142
+ primaryType: "CreatorAttribution"
143
+ };
144
+ }
145
+ throw new Error(`Invalid version ${version}`);
146
+ };
147
+ async function isAuthorizedToCreatePremint({
148
+ collection,
149
+ collectionAddress,
150
+ publicClient,
151
+ premintConfig,
152
+ premintConfigVersion,
153
+ signature,
154
+ signer
155
+ }) {
156
+ if (premintConfigVersion === PremintConfigVersion.V1) {
157
+ const [isValidSignature2] = await publicClient.readContract({
158
+ abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
159
+ address: getPremintExecutorAddress(),
160
+ functionName: "isValidSignature",
161
+ args: [collection, premintConfig, signature]
162
+ });
163
+ return isValidSignature2;
164
+ }
165
+ return await publicClient.readContract({
166
+ abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
167
+ address: getPremintExecutorAddress(),
168
+ functionName: "isAuthorizedToCreatePremint",
169
+ args: [signer, collection.contractAdmin, collectionAddress]
170
+ });
171
+ }
172
+ async function recoverPremintSigner({
173
+ signature,
174
+ ...rest
175
+ }) {
176
+ const typedData = premintTypedDataDefinition(rest);
177
+ return await (0, import_viem.recoverTypedDataAddress)({
178
+ ...typedData,
179
+ signature
180
+ });
181
+ }
182
+ async function tryRecoverPremintSigner(params) {
183
+ try {
184
+ return await recoverPremintSigner(params);
185
+ } catch (error) {
186
+ console.error(error);
187
+ return void 0;
188
+ }
189
+ }
190
+ async function isValidSignature({
191
+ signature,
192
+ publicClient,
193
+ collection,
194
+ chainId,
195
+ ...premintConfigAndVersion
196
+ }) {
197
+ const tokenContract = await getPremintCollectionAddress({
198
+ collection,
199
+ publicClient
200
+ });
201
+ const recoveredAddress = await tryRecoverPremintSigner({
202
+ ...premintConfigAndVersion,
203
+ signature,
204
+ verifyingContract: tokenContract,
205
+ chainId
206
+ });
207
+ if (!import_viem.recoverAddress) {
208
+ return {
209
+ isAuthorized: false
210
+ };
211
+ }
212
+ const isAuthorized = await isAuthorizedToCreatePremint({
213
+ signer: recoveredAddress,
214
+ collection,
215
+ collectionAddress: tokenContract,
216
+ publicClient,
217
+ signature,
218
+ ...premintConfigAndVersion
219
+ });
220
+ return {
221
+ isAuthorized,
222
+ recoveredAddress
223
+ };
224
+ }
225
+ function migratePremintConfigToV2({
226
+ premintConfig,
227
+ createReferral = import_viem.zeroAddress
228
+ }) {
229
+ return {
230
+ ...premintConfig,
231
+ tokenConfig: {
232
+ tokenURI: premintConfig.tokenConfig.tokenURI,
233
+ maxSupply: premintConfig.tokenConfig.maxSupply,
234
+ maxTokensPerAddress: premintConfig.tokenConfig.maxTokensPerAddress,
235
+ pricePerToken: premintConfig.tokenConfig.pricePerToken,
236
+ mintStart: premintConfig.tokenConfig.mintStart,
237
+ mintDuration: premintConfig.tokenConfig.mintDuration,
238
+ payoutRecipient: premintConfig.tokenConfig.royaltyRecipient,
239
+ royaltyBPS: premintConfig.tokenConfig.royaltyBPS,
240
+ fixedPriceMinter: premintConfig.tokenConfig.fixedPriceMinter,
241
+ createReferral
242
+ }
243
+ };
244
+ }
245
+ var recoverCreatorFromCreatorAttribution = async ({
246
+ creatorAttribution: { version, domainName, structHash, signature },
247
+ chainId,
248
+ tokenContract
249
+ }) => {
250
+ const hashedDomain = (0, import_viem.hashDomain)({
80
251
  domain: {
81
252
  chainId,
82
- name: "Preminter",
83
- version: "1",
84
- verifyingContract
253
+ name: domainName,
254
+ verifyingContract: tokenContract,
255
+ version
85
256
  },
86
- types,
87
- message: {
88
- tokenConfig,
89
- uid,
90
- version,
91
- deleted
92
- },
93
- primaryType: "CreatorAttribution"
94
- };
95
- return result;
257
+ types: {
258
+ EIP712Domain: [
259
+ { name: "name", type: "string" },
260
+ { name: "version", type: "string" },
261
+ {
262
+ name: "chainId",
263
+ type: "uint256"
264
+ },
265
+ {
266
+ name: "verifyingContract",
267
+ type: "address"
268
+ }
269
+ ]
270
+ }
271
+ });
272
+ const parts = ["0x1901", hashedDomain, structHash];
273
+ const hashedTypedData = (0, import_viem.keccak256)((0, import_viem.concat)(parts));
274
+ return await (0, import_viem.recoverAddress)({
275
+ hash: hashedTypedData,
276
+ signature
277
+ });
96
278
  };
279
+ var supportsPremintVersion = async (version, tokenContract, publicClient) => {
280
+ const supportedPremintSignatureVersions = await publicClient.readContract({
281
+ abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
282
+ address: getPremintExecutorAddress(),
283
+ functionName: "supportedPremintSignatureVersions",
284
+ args: [tokenContract]
285
+ });
286
+ return supportedPremintSignatureVersions.includes(version);
287
+ };
288
+ async function getPremintCollectionAddress({
289
+ collection,
290
+ publicClient
291
+ }) {
292
+ return publicClient.readContract({
293
+ address: getPremintExecutorAddress(),
294
+ abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
295
+ functionName: "getContractAddress",
296
+ args: [collection]
297
+ });
298
+ }
97
299
 
98
300
  // src/apis/http-api-base.ts
99
301
  var BadResponseError = class extends Error {
@@ -170,17 +372,22 @@ var httpClient = {
170
372
  };
171
373
 
172
374
  // src/constants.ts
375
+ var import_viem2 = require("viem");
173
376
  var ZORA_API_BASE = "https://api.zora.co/";
174
377
  var OPEN_EDITION_MINT_SIZE = BigInt("18446744073709551615");
175
378
  var SUBGRAPH_CONFIG_BASE = "https://api.goldsky.com/api/public/project_clhk16b61ay9t49vm6ntn4mkz/subgraphs";
176
379
  function getSubgraph(name, version) {
177
380
  return `${SUBGRAPH_CONFIG_BASE}/${name}/${version}/gn`;
178
381
  }
382
+ var zora721Abi = (0, import_viem2.parseAbi)([
383
+ "function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
384
+ "function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
385
+ ]);
179
386
 
180
387
  // src/apis/chain-constants.ts
181
388
  var import_chains = require("viem/chains");
182
- var import_viem = require("viem");
183
- var REWARD_PER_TOKEN = (0, import_viem.parseEther)("0.000777");
389
+ var import_viem3 = require("viem");
390
+ var REWARD_PER_TOKEN = (0, import_viem3.parseEther)("0.000777");
184
391
  var BackendChainNamesLookup = {
185
392
  ZORA_MAINNET: "ZORA-MAINNET",
186
393
  ZORA_GOERLI: "ZORA-GOERLI",
@@ -258,9 +465,6 @@ var networkConfigByChain = {
258
465
  };
259
466
 
260
467
  // src/mint/mint-api-client.ts
261
- function encodeQueryParameters(params) {
262
- return new URLSearchParams(params).toString();
263
- }
264
468
  var getApiNetworkConfigForChain = (chainId) => {
265
469
  if (!networkConfigByChain[chainId]) {
266
470
  throw new Error(`chain id ${chainId} network not configured `);
@@ -272,41 +476,64 @@ var MintAPIClient = class {
272
476
  this.httpClient = httpClient2 || httpClient;
273
477
  this.networkConfig = getApiNetworkConfigForChain(chainId);
274
478
  }
275
- async getMintable(path, query) {
276
- const httpClient2 = this.httpClient;
277
- return httpClient2.retries(() => {
278
- return httpClient2.get(
279
- `${ZORA_API_BASE}discover/mintables/${path.chain_name}/${path.collection_address}${query?.token_id ? `?${encodeQueryParameters(query)}` : ""}`
280
- );
281
- });
282
- }
283
- async getSalesConfigFixedPrice({
284
- contractAddress,
479
+ async getSalesConfigAndTokenInfo({
480
+ tokenAddress,
285
481
  tokenId
286
482
  }) {
287
483
  const { retries: retries2, post: post2 } = this.httpClient;
288
484
  return retries2(async () => {
289
485
  const response = await post2(this.networkConfig.subgraphUrl, {
290
- query: "query($id: ID!) {\n zoraCreateToken(id: $id) {\n id\n salesStrategies{\n fixedPrice {\n address\n }\n }\n }\n}",
486
+ query: `
487
+ fragment SaleStrategy on SalesStrategyConfig {
488
+ type
489
+ fixedPrice {
490
+ address
491
+ pricePerToken
492
+ saleEnd
493
+ saleStart
494
+ maxTokensPerAddress
495
+ }
496
+ }
497
+
498
+ query ($id: ID!) {
499
+ zoraCreateToken(id: $id) {
500
+ id
501
+ contract {
502
+ mintFeePerQuantity
503
+ salesStrategies(where: {type: "FIXED_PRICE"}) {
504
+ ...SaleStrategy
505
+ }
506
+ }
507
+ salesStrategies(where: {type: "FIXED_PRICE"}) {
508
+ ...SaleStrategy
509
+ }
510
+ }
511
+ }
512
+ `,
291
513
  variables: {
292
- id: `${contractAddress.toLowerCase()}-${tokenId.toString()}`
514
+ id: tokenId !== void 0 ? (
515
+ // Generic Token ID types all stringify down to the base numeric equivalent.
516
+ `${tokenAddress.toLowerCase()}-${tokenId}`
517
+ ) : `${tokenAddress.toLowerCase()}-0`
293
518
  }
294
519
  });
295
- return response.zoraCreateToken?.salesStrategies?.find(() => true)?.fixedPriceMinterAddress;
520
+ const token = response.data?.zoraCreateToken;
521
+ if (!token) {
522
+ throw new Error("Cannot find a token to mint");
523
+ }
524
+ const saleStrategies = tokenId !== void 0 ? token.salesStrategies : token.contract.salesStrategies;
525
+ const fixedPrice = saleStrategies?.sort(
526
+ (a, b) => BigInt(a.fixedPrice.saleEnd) > BigInt(b.fixedPrice.saleEnd) ? 1 : -1
527
+ )?.find(() => true)?.fixedPrice;
528
+ if (!fixedPrice) {
529
+ throw new Error("Cannot find fixed price sale strategy");
530
+ }
531
+ return {
532
+ fixedPrice,
533
+ mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
534
+ };
296
535
  });
297
536
  }
298
- async getMintableForToken({
299
- tokenContract,
300
- tokenId
301
- }) {
302
- return await this.getMintable(
303
- {
304
- chain_name: this.networkConfig.zoraBackendChainName,
305
- collection_address: tokenContract
306
- },
307
- { token_id: tokenId?.toString() }
308
- );
309
- }
310
537
  };
311
538
 
312
539
  // src/premint/premint-api-client.ts
@@ -376,8 +603,8 @@ var DefaultMintArguments = {
376
603
  function getPremintedLogFromReceipt(receipt) {
377
604
  for (const data of receipt.logs) {
378
605
  try {
379
- const decodedLog = (0, import_viem2.decodeEventLog)({
380
- abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
606
+ const decodedLog = (0, import_viem4.decodeEventLog)({
607
+ abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
381
608
  eventName: "Preminted",
382
609
  ...data
383
610
  });
@@ -388,7 +615,7 @@ function getPremintedLogFromReceipt(receipt) {
388
615
  }
389
616
  }
390
617
  }
391
- var convertPremint = (premint) => ({
618
+ var convertPremintV1 = (premint) => ({
392
619
  ...premint,
393
620
  tokenConfig: {
394
621
  ...premint.tokenConfig,
@@ -405,7 +632,21 @@ var convertCollection = (collection) => ({
405
632
  ...collection,
406
633
  contractAdmin: collection.contractAdmin
407
634
  });
408
- var encodePremintForAPI = ({
635
+ var encodePremintV1ForAPI = ({
636
+ tokenConfig,
637
+ ...premint
638
+ }) => ({
639
+ ...premint,
640
+ tokenConfig: {
641
+ ...tokenConfig,
642
+ maxSupply: tokenConfig.maxSupply.toString(),
643
+ pricePerToken: tokenConfig.pricePerToken.toString(),
644
+ mintStart: tokenConfig.mintStart.toString(),
645
+ mintDuration: tokenConfig.mintDuration.toString(),
646
+ maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
647
+ }
648
+ });
649
+ var encodePremintV2ForAPI = ({
409
650
  tokenConfig,
410
651
  ...premint
411
652
  }) => ({
@@ -419,20 +660,23 @@ var encodePremintForAPI = ({
419
660
  maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
420
661
  }
421
662
  });
663
+ var encodePremintForAPI = ({
664
+ premintConfig,
665
+ premintConfigVersion
666
+ }) => {
667
+ if (premintConfigVersion === PremintConfigVersion.V1) {
668
+ return encodePremintV1ForAPI(premintConfig);
669
+ }
670
+ if (premintConfigVersion === PremintConfigVersion.V2) {
671
+ return encodePremintV2ForAPI(premintConfig);
672
+ }
673
+ throw new Error(`Invalid premint config version ${premintConfigVersion}`);
674
+ };
422
675
  var PremintClient = class {
423
676
  constructor(chain, publicClient, httpClient2) {
424
677
  this.chain = chain;
425
678
  this.apiClient = new PremintAPIClient(chain.id, httpClient2);
426
- this.publicClient = publicClient || (0, import_viem2.createPublicClient)({ chain, transport: (0, import_viem2.http)() });
427
- }
428
- /**
429
- * The premint executor address is deployed to the same address across all chains.
430
- * Can be overridden as needed by making a parent class.
431
- *
432
- * @returns Executor address for premints
433
- */
434
- getExecutorAddress() {
435
- return import_protocol_deployments.zoraCreator1155PremintExecutorImplAddress[999];
679
+ this.publicClient = publicClient || (0, import_viem4.createPublicClient)({ chain, transport: (0, import_viem4.http)() });
436
680
  }
437
681
  /**
438
682
  * The fixed price minter address is the same across all chains for our current
@@ -442,7 +686,7 @@ var PremintClient = class {
442
686
  * @returns Fixed price sale strategy
443
687
  */
444
688
  getFixedPriceMinterAddress() {
445
- return import_protocol_deployments.zoraCreatorFixedPriceSaleStrategyAddress[999];
689
+ return import_protocol_deployments2.zoraCreatorFixedPriceSaleStrategyAddress[999];
446
690
  }
447
691
  getDataFromPremintReceipt(receipt) {
448
692
  const premintedLog = getPremintedLogFromReceipt(receipt);
@@ -483,7 +727,7 @@ var PremintClient = class {
483
727
  collection_address: collection.toLowerCase(),
484
728
  uid
485
729
  });
486
- const convertedPremint = convertPremint(signatureResponse.premint);
730
+ const convertedPremint = convertPremintV1(signatureResponse.premint);
487
731
  const signerData = {
488
732
  ...signatureResponse,
489
733
  premint: {
@@ -504,7 +748,8 @@ var PremintClient = class {
504
748
  ...signerData.collection,
505
749
  contractAdmin: signerData.collection.contractAdmin
506
750
  },
507
- premintConfig: signerData.premint
751
+ premintConfig: signerData.premint,
752
+ premintConfigVersion: PremintConfigVersion.V1
508
753
  });
509
754
  }
510
755
  /**
@@ -535,7 +780,7 @@ var PremintClient = class {
535
780
  ...signatureResponse,
536
781
  collection: convertCollection(signatureResponse.collection),
537
782
  premint: {
538
- ...convertPremint(signatureResponse.premint),
783
+ ...convertPremintV1(signatureResponse.premint),
539
784
  deleted: true
540
785
  }
541
786
  };
@@ -546,7 +791,8 @@ var PremintClient = class {
546
791
  verifyingContract: collection,
547
792
  uid,
548
793
  collection: signerData.collection,
549
- premintConfig: signerData.premint
794
+ premintConfig: signerData.premint,
795
+ premintConfigVersion: PremintConfigVersion.V1
550
796
  });
551
797
  }
552
798
  /**
@@ -558,11 +804,11 @@ var PremintClient = class {
558
804
  async signAndSubmitPremint({
559
805
  walletClient,
560
806
  verifyingContract,
561
- premintConfig,
562
807
  uid,
563
808
  account,
564
809
  checkSignature,
565
- collection
810
+ collection,
811
+ ...premintConfigAndVersion
566
812
  }) {
567
813
  if (!account) {
568
814
  account = walletClient.account;
@@ -572,26 +818,32 @@ var PremintClient = class {
572
818
  }
573
819
  const signature = await walletClient.signTypedData({
574
820
  account,
575
- ...preminterTypedDataDefinition({
821
+ ...premintTypedDataDefinition({
576
822
  verifyingContract,
577
- premintConfig,
823
+ ...premintConfigAndVersion,
578
824
  chainId: this.chain.id
579
825
  })
580
826
  });
581
827
  if (checkSignature) {
582
- const [isValidSignature] = await this.publicClient.readContract({
583
- abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
584
- address: this.getExecutorAddress(),
585
- functionName: "isValidSignature",
586
- args: [convertCollection(collection), premintConfig, signature]
828
+ const convertedCollection = convertCollection(collection);
829
+ const isAuthorized = await isAuthorizedToCreatePremint({
830
+ collection: convertCollection(collection),
831
+ signature,
832
+ publicClient: this.publicClient,
833
+ signer: typeof account === "string" ? account : account.address,
834
+ collectionAddress: await this.getCollectionAddress(convertedCollection),
835
+ ...premintConfigAndVersion
587
836
  });
588
- if (!isValidSignature) {
589
- throw new Error("Invalid signature");
837
+ if (!isAuthorized) {
838
+ throw new Error("Not authorized to create premint");
590
839
  }
591
840
  }
841
+ if (premintConfigAndVersion.premintConfigVersion === PremintConfigVersion.V2) {
842
+ throw new Error("premint config v2 not supported yet");
843
+ }
592
844
  const apiData = {
593
845
  collection,
594
- premint: encodePremintForAPI(premintConfig),
846
+ premint: encodePremintV1ForAPI(premintConfigAndVersion.premintConfig),
595
847
  signature
596
848
  };
597
849
  const premint = await this.apiClient.postSignature(apiData);
@@ -625,11 +877,9 @@ var PremintClient = class {
625
877
  executionSettings,
626
878
  checkSignature = false
627
879
  }) {
628
- const newContractAddress = await this.publicClient.readContract({
629
- address: this.getExecutorAddress(),
630
- abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
631
- functionName: "getContractAddress",
632
- args: [convertCollection(collection)]
880
+ const newContractAddress = await getPremintCollectionAddress({
881
+ publicClient: this.publicClient,
882
+ collection: convertCollection(collection)
633
883
  });
634
884
  const tokenConfig = {
635
885
  ...DefaultMintArguments,
@@ -658,6 +908,7 @@ var PremintClient = class {
658
908
  uid,
659
909
  verifyingContract: newContractAddress,
660
910
  premintConfig,
911
+ premintConfigVersion: PremintConfigVersion.V1,
661
912
  checkSignature,
662
913
  account,
663
914
  walletClient,
@@ -680,26 +931,37 @@ var PremintClient = class {
680
931
  uid
681
932
  });
682
933
  }
934
+ /**
935
+ * Gets the deterministic contract address for a premint collection
936
+ * @param collection Collection to get the address for
937
+ * @returns deterministic contract address
938
+ */
939
+ async getCollectionAddress(collection) {
940
+ return await getPremintCollectionAddress({
941
+ collection,
942
+ publicClient: this.publicClient
943
+ });
944
+ }
683
945
  /**
684
946
  * Check user signature for v1
685
947
  *
686
948
  * @param data Signature data from the API
687
- * @returns isValid = signature is valid or not, contractAddress = assumed contract address, recoveredSigner = signer from contract
949
+ * @returns isValid = signature is valid or not, recoveredSigner = signer from contract
688
950
  */
689
951
  async isValidSignature({
690
- data
952
+ signature,
953
+ premint,
954
+ collection
691
955
  }) {
692
- const [isValid, contractAddress, recoveredSigner] = await this.publicClient.readContract({
693
- abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
694
- address: this.getExecutorAddress(),
695
- functionName: "isValidSignature",
696
- args: [
697
- convertCollection(data.collection),
698
- convertPremint(data.premint),
699
- data.signature
700
- ]
956
+ const { isAuthorized, recoveredAddress } = await isValidSignature({
957
+ chainId: this.chain.id,
958
+ signature,
959
+ premintConfig: convertPremintV1(premint),
960
+ premintConfigVersion: PremintConfigVersion.V1,
961
+ collection: convertCollection(collection),
962
+ publicClient: this.publicClient
701
963
  });
702
- return { isValid, contractAddress, recoveredSigner };
964
+ return { isValid: isAuthorized, recoveredSigner: recoveredAddress };
703
965
  }
704
966
  makeUrls({
705
967
  uid,
@@ -737,11 +999,10 @@ var PremintClient = class {
737
999
  if (mintArguments && mintArguments?.quantityToMint < 1) {
738
1000
  throw new Error("Quantity to mint cannot be below 1");
739
1001
  }
740
- const targetAddress = this.getExecutorAddress();
741
1002
  const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
742
1003
  const args = [
743
1004
  convertCollection(data.collection),
744
- convertPremint(data.premint),
1005
+ convertPremintV1(data.premint),
745
1006
  data.signature,
746
1007
  numberToMint,
747
1008
  mintArguments?.mintComment || ""
@@ -752,10 +1013,10 @@ var PremintClient = class {
752
1013
  const value = numberToMint * REWARD_PER_TOKEN;
753
1014
  const request = {
754
1015
  account,
755
- abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
1016
+ abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
756
1017
  functionName: "premint",
757
1018
  value,
758
- address: targetAddress,
1019
+ address: getPremintExecutorAddress(),
759
1020
  args
760
1021
  };
761
1022
  return request;
@@ -770,8 +1031,8 @@ function createPremintClient({
770
1031
  }
771
1032
 
772
1033
  // src/mint/mint-client.ts
773
- var import_viem3 = require("viem");
774
- var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
1034
+ var import_viem5 = require("viem");
1035
+ var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
775
1036
  var MintError = class extends Error {
776
1037
  };
777
1038
  var MintInactiveError = class extends Error {
@@ -780,29 +1041,10 @@ var Errors = {
780
1041
  MintError,
781
1042
  MintInactiveError
782
1043
  };
783
- var zora721Abi = (0, import_viem3.parseAbi)([
784
- "function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
785
- "function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
786
- ]);
787
1044
  var MintClient = class {
788
1045
  constructor(chain, publicClient, httpClient2) {
789
1046
  this.apiClient = new MintAPIClient(chain.id, httpClient2);
790
- this.publicClient = publicClient || (0, import_viem3.createPublicClient)({ chain, transport: (0, import_viem3.http)() });
791
- }
792
- /**
793
- * Gets mintable information for a given token
794
- * @param param0.tokenContract The contract address of the token to mint.
795
- * @param param0.tokenId The token id to mint.
796
- * @returns
797
- */
798
- async getMintable({
799
- tokenContract,
800
- tokenId
801
- }) {
802
- return await this.apiClient.getMintableForToken({
803
- tokenContract,
804
- tokenId: tokenId?.toString()
805
- });
1047
+ this.publicClient = publicClient || (0, import_viem5.createPublicClient)({ chain, transport: (0, import_viem5.http)() });
806
1048
  }
807
1049
  /**
808
1050
  * Returns the parameters needed to prepare a transaction mint a token.
@@ -820,35 +1062,6 @@ var MintClient = class {
820
1062
  publicClient: this.publicClient
821
1063
  });
822
1064
  }
823
- /**
824
- * Returns the mintFee, sale fee, and total cost of minting x quantities of a token.
825
- * @param param0.mintable The mintable token to mint.
826
- * @param param0.quantityToMint The quantity of tokens to mint.
827
- * @returns
828
- */
829
- async getMintCosts({
830
- mintable,
831
- quantityToMint
832
- }) {
833
- const mintContextType = validateMintableAndGetContextType(mintable);
834
- if (mintContextType === "zora_create_1155") {
835
- return await get1155MintCosts({
836
- mintable,
837
- publicClient: this.publicClient,
838
- quantityToMint: BigInt(quantityToMint)
839
- });
840
- }
841
- if (mintContextType === "zora_create") {
842
- return await get721MintCosts({
843
- mintable,
844
- publicClient: this.publicClient,
845
- quantityToMint: BigInt(quantityToMint)
846
- });
847
- }
848
- throw new MintError(
849
- `Mintable type ${mintContextType} is currently unsupported.`
850
- );
851
- }
852
1065
  };
853
1066
  function createMintClient({
854
1067
  chain,
@@ -857,91 +1070,44 @@ function createMintClient({
857
1070
  }) {
858
1071
  return new MintClient(chain, publicClient, httpClient2);
859
1072
  }
860
- function validateMintableAndGetContextType(mintable) {
861
- if (!mintable) {
862
- throw new MintError("No mintable found");
863
- }
864
- if (!mintable.is_active) {
865
- throw new MintInactiveError("Minting token is inactive");
866
- }
867
- if (!mintable.mint_context) {
868
- throw new MintError("No minting context data from zora API");
869
- }
870
- if (!["zora_create", "zora_create_1155"].includes(
871
- mintable.mint_context?.mint_context_type
872
- )) {
873
- throw new MintError(
874
- `Mintable type ${mintable.mint_context.mint_context_type} is currently unsupported.`
875
- );
876
- }
877
- return mintable.mint_context.mint_context_type;
878
- }
879
1073
  async function makePrepareMintTokenParams({
880
1074
  publicClient,
881
- mintable,
882
1075
  apiClient,
1076
+ tokenId,
1077
+ tokenAddress,
883
1078
  ...rest
884
1079
  }) {
885
- const mintContextType = validateMintableAndGetContextType(mintable);
886
- const thisPublicClient = publicClient;
887
- if (mintContextType === "zora_create_1155") {
888
- return makePrepareMint1155TokenParams({
889
- apiClient,
890
- publicClient: thisPublicClient,
891
- mintable,
892
- mintContextType,
893
- ...rest
894
- });
895
- }
896
- if (mintContextType === "zora_create") {
1080
+ const salesConfigAndTokenInfo = await apiClient.getSalesConfigAndTokenInfo({
1081
+ tokenId,
1082
+ tokenAddress
1083
+ });
1084
+ if (tokenId === void 0) {
897
1085
  return makePrepareMint721TokenParams({
898
- publicClient: thisPublicClient,
899
- mintable,
900
- mintContextType,
1086
+ salesConfigAndTokenInfo,
1087
+ tokenAddress,
901
1088
  ...rest
902
1089
  });
903
1090
  }
904
- throw new MintError(
905
- `Mintable type ${mintContextType} is currently unsupported.`
906
- );
907
- }
908
- async function get721MintCosts({
909
- mintable,
910
- publicClient,
911
- quantityToMint
912
- }) {
913
- const address = mintable.collection.address;
914
- const [_, mintFee] = await publicClient.readContract({
915
- abi: zora721Abi,
916
- address,
917
- functionName: "zoraFeeForAmount",
918
- args: [BigInt(quantityToMint)]
1091
+ return makePrepareMint1155TokenParams({
1092
+ salesConfigAndTokenInfo,
1093
+ tokenAddress,
1094
+ tokenId,
1095
+ ...rest
919
1096
  });
920
- const tokenPurchaseCost = BigInt(mintable.cost.native_price.raw) * quantityToMint;
921
- return {
922
- mintFee,
923
- tokenPurchaseCost,
924
- totalCost: mintFee + tokenPurchaseCost
925
- };
926
1097
  }
927
1098
  async function makePrepareMint721TokenParams({
928
- publicClient,
1099
+ tokenAddress,
1100
+ salesConfigAndTokenInfo,
929
1101
  minterAccount,
930
- mintable,
931
- mintContextType,
932
1102
  mintArguments
933
1103
  }) {
934
- if (mintContextType !== "zora_create") {
935
- throw new Error("Minted token type must be for 1155");
936
- }
937
- const mintValue = (await get721MintCosts({
938
- mintable,
939
- publicClient,
1104
+ const mintValue = getMintCosts({
1105
+ salesConfigAndTokenInfo,
940
1106
  quantityToMint: BigInt(mintArguments.quantityToMint)
941
- })).totalCost;
1107
+ }).totalCost;
942
1108
  const result = {
943
1109
  abi: zora721Abi,
944
- address: mintable.contract_address,
1110
+ address: tokenAddress,
945
1111
  account: minterAccount,
946
1112
  functionName: "mintWithRewards",
947
1113
  value: mintValue,
@@ -949,33 +1115,17 @@ async function makePrepareMint721TokenParams({
949
1115
  mintArguments.mintToAddress,
950
1116
  BigInt(mintArguments.quantityToMint),
951
1117
  mintArguments.mintComment || "",
952
- mintArguments.mintReferral || import_viem3.zeroAddress
1118
+ mintArguments.mintReferral || import_viem5.zeroAddress
953
1119
  ]
954
1120
  };
955
1121
  return result;
956
1122
  }
957
- async function get1155MintFee({
958
- collectionAddress,
959
- publicClient
960
- }) {
961
- return await publicClient.readContract({
962
- abi: import_protocol_deployments2.zoraCreator1155ImplABI,
963
- functionName: "mintFee",
964
- address: collectionAddress
965
- });
966
- }
967
- async function get1155MintCosts({
968
- mintable,
969
- publicClient,
1123
+ function getMintCosts({
1124
+ salesConfigAndTokenInfo,
970
1125
  quantityToMint
971
1126
  }) {
972
- const address = mintable.collection.address;
973
- const mintFee = await get1155MintFee({
974
- collectionAddress: address,
975
- publicClient
976
- });
977
- const mintFeeForTokens = mintFee * quantityToMint;
978
- const tokenPurchaseCost = BigInt(mintable.cost.native_price.raw) * quantityToMint;
1127
+ const mintFeeForTokens = salesConfigAndTokenInfo.mintFeePerQuantity * quantityToMint;
1128
+ const tokenPurchaseCost = BigInt(salesConfigAndTokenInfo.fixedPrice.pricePerToken) * quantityToMint;
979
1129
  return {
980
1130
  mintFee: mintFeeForTokens,
981
1131
  tokenPurchaseCost,
@@ -983,55 +1133,45 @@ async function get1155MintCosts({
983
1133
  };
984
1134
  }
985
1135
  async function makePrepareMint1155TokenParams({
986
- apiClient,
987
- publicClient,
1136
+ tokenId,
1137
+ salesConfigAndTokenInfo,
988
1138
  minterAccount,
989
- mintable,
990
- mintContextType,
1139
+ tokenAddress,
991
1140
  mintArguments
992
1141
  }) {
993
- if (mintContextType !== "zora_create_1155") {
994
- throw new Error("Minted token type must be for 1155");
995
- }
996
1142
  const mintQuantity = BigInt(mintArguments.quantityToMint);
997
- const address = mintable.collection.address;
998
- const mintValue = (await get1155MintCosts({
999
- mintable,
1000
- publicClient,
1143
+ const mintValue = getMintCosts({
1144
+ salesConfigAndTokenInfo,
1001
1145
  quantityToMint: mintQuantity
1002
- })).totalCost;
1003
- const tokenFixedPriceMinter = await apiClient.getSalesConfigFixedPrice({
1004
- contractAddress: address,
1005
- tokenId: BigInt(mintable.token_id)
1006
- });
1146
+ }).totalCost;
1007
1147
  const result = {
1008
- abi: import_protocol_deployments2.zoraCreator1155ImplABI,
1148
+ abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1009
1149
  functionName: "mintWithRewards",
1010
1150
  account: minterAccount,
1011
1151
  value: mintValue,
1012
- address,
1152
+ address: tokenAddress,
1013
1153
  /* args: minter, tokenId, quantity, minterArguments, mintReferral */
1014
1154
  args: [
1015
- tokenFixedPriceMinter || import_protocol_deployments2.zoraCreatorFixedPriceSaleStrategyAddress[999],
1016
- BigInt(mintable.token_id),
1155
+ salesConfigAndTokenInfo?.fixedPrice.address || import_protocol_deployments3.zoraCreatorFixedPriceSaleStrategyAddress[999],
1156
+ BigInt(tokenId),
1017
1157
  mintQuantity,
1018
- (0, import_viem3.encodeAbiParameters)((0, import_viem3.parseAbiParameters)("address, string"), [
1158
+ (0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
1019
1159
  mintArguments.mintToAddress,
1020
1160
  mintArguments.mintComment || ""
1021
1161
  ]),
1022
- mintArguments.mintReferral || import_viem3.zeroAddress
1162
+ mintArguments.mintReferral || import_viem5.zeroAddress
1023
1163
  ]
1024
1164
  };
1025
1165
  return result;
1026
1166
  }
1027
1167
 
1028
1168
  // src/create/1155-create-helper.ts
1029
- var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
1030
- var import_viem4 = require("viem");
1169
+ var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
1170
+ var import_viem6 = require("viem");
1031
1171
  var SALE_END_FOREVER = 18446744073709551615n;
1032
1172
  var ROYALTY_BPS_DEFAULT = 1e3;
1033
1173
  var DEFAULT_SALE_SETTINGS = {
1034
- fundsRecipient: import_viem4.zeroAddress,
1174
+ fundsRecipient: import_viem6.zeroAddress,
1035
1175
  // Free Mint
1036
1176
  pricePerToken: 0n,
1037
1177
  // Sale start time – defaults to beginning of unix time
@@ -1041,7 +1181,7 @@ var DEFAULT_SALE_SETTINGS = {
1041
1181
  // 0 Here means no limit
1042
1182
  maxTokensPerAddress: 0n
1043
1183
  };
1044
- var PERMISSION_BIT_MINTER = 2n ** 2n;
1184
+ var PERMISSION_BIT_MINTER = 4n;
1045
1185
  function create1155TokenSetupArgs({
1046
1186
  nextTokenId,
1047
1187
  // How many NFTs upon initialization to mint to the creator
@@ -1070,33 +1210,33 @@ function create1155TokenSetupArgs({
1070
1210
  ...salesConfig
1071
1211
  };
1072
1212
  const setupActions = [
1073
- (0, import_viem4.encodeFunctionData)({
1074
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1213
+ (0, import_viem6.encodeFunctionData)({
1214
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1075
1215
  functionName: "assumeLastTokenIdMatches",
1076
1216
  args: [nextTokenId - 1n]
1077
1217
  }),
1078
- createReferral ? (0, import_viem4.encodeFunctionData)({
1079
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1218
+ createReferral ? (0, import_viem6.encodeFunctionData)({
1219
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1080
1220
  functionName: "setupNewTokenWithCreateReferral",
1081
1221
  args: [tokenMetadataURI, maxSupply, createReferral]
1082
- }) : (0, import_viem4.encodeFunctionData)({
1083
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1222
+ }) : (0, import_viem6.encodeFunctionData)({
1223
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1084
1224
  functionName: "setupNewToken",
1085
1225
  args: [tokenMetadataURI, maxSupply]
1086
1226
  }),
1087
- (0, import_viem4.encodeFunctionData)({
1088
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1227
+ (0, import_viem6.encodeFunctionData)({
1228
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1089
1229
  functionName: "addPermission",
1090
1230
  args: [0n, fixedPriceMinterAddress, PERMISSION_BIT_MINTER]
1091
1231
  }),
1092
- (0, import_viem4.encodeFunctionData)({
1093
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1232
+ (0, import_viem6.encodeFunctionData)({
1233
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1094
1234
  functionName: "callSale",
1095
1235
  args: [
1096
1236
  nextTokenId,
1097
1237
  fixedPriceMinterAddress,
1098
- (0, import_viem4.encodeFunctionData)({
1099
- abi: import_protocol_deployments3.zoraCreatorFixedPriceSaleStrategyABI,
1238
+ (0, import_viem6.encodeFunctionData)({
1239
+ abi: import_protocol_deployments4.zoraCreatorFixedPriceSaleStrategyABI,
1100
1240
  functionName: "setSale",
1101
1241
  args: [nextTokenId, salesConfigWithDefaults]
1102
1242
  })
@@ -1105,8 +1245,8 @@ function create1155TokenSetupArgs({
1105
1245
  ];
1106
1246
  if (mintToCreatorCount) {
1107
1247
  setupActions.push(
1108
- (0, import_viem4.encodeFunctionData)({
1109
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1248
+ (0, import_viem6.encodeFunctionData)({
1249
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1110
1250
  functionName: "adminMint",
1111
1251
  args: [account, nextTokenId, mintToCreatorCount, "0x"]
1112
1252
  })
@@ -1114,8 +1254,8 @@ function create1155TokenSetupArgs({
1114
1254
  }
1115
1255
  if (royaltySettings) {
1116
1256
  setupActions.push(
1117
- (0, import_viem4.encodeFunctionData)({
1118
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1257
+ (0, import_viem6.encodeFunctionData)({
1258
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1119
1259
  functionName: "updateRoyaltiesForToken",
1120
1260
  args: [
1121
1261
  nextTokenId,
@@ -1133,8 +1273,8 @@ function create1155TokenSetupArgs({
1133
1273
  var getTokenIdFromCreateReceipt = (receipt) => {
1134
1274
  for (const data of receipt.logs) {
1135
1275
  try {
1136
- const decodedLog = (0, import_viem4.decodeEventLog)({
1137
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1276
+ const decodedLog = (0, import_viem6.decodeEventLog)({
1277
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1138
1278
  eventName: "SetupNewToken",
1139
1279
  ...data
1140
1280
  });
@@ -1150,9 +1290,9 @@ async function getContractExists(publicClient, contract, account) {
1150
1290
  let contractExists = false;
1151
1291
  if (typeof contract !== "string") {
1152
1292
  contractAddress = await publicClient.readContract({
1153
- abi: import_protocol_deployments3.zoraCreator1155FactoryImplABI,
1293
+ abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
1154
1294
  // Since this address is deterministic we can hardcode a chain id safely here.
1155
- address: import_protocol_deployments3.zoraCreator1155FactoryImplAddress[999],
1295
+ address: import_protocol_deployments4.zoraCreator1155FactoryImplAddress[999],
1156
1296
  functionName: "deterministicContractAddress",
1157
1297
  args: [
1158
1298
  account,
@@ -1163,7 +1303,7 @@ async function getContractExists(publicClient, contract, account) {
1163
1303
  });
1164
1304
  try {
1165
1305
  await publicClient.readContract({
1166
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1306
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1167
1307
  address: contractAddress,
1168
1308
  functionName: "contractVersion"
1169
1309
  });
@@ -1198,14 +1338,14 @@ function create1155CreatorClient({
1198
1338
  let nextTokenId = 1n;
1199
1339
  if (contractExists) {
1200
1340
  nextTokenId = await publicClient.readContract({
1201
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1341
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1202
1342
  functionName: "nextTokenId",
1203
1343
  address: contractAddress
1204
1344
  });
1205
1345
  }
1206
1346
  const fixedPriceMinterAddress = await publicClient.readContract({
1207
- abi: import_protocol_deployments3.zoraCreator1155FactoryImplABI,
1208
- address: import_protocol_deployments3.zoraCreator1155FactoryImplAddress[999],
1347
+ abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
1348
+ address: import_protocol_deployments4.zoraCreator1155FactoryImplAddress[999],
1209
1349
  functionName: "fixedPriceMinter"
1210
1350
  });
1211
1351
  let tokenSetupActions = create1155TokenSetupArgs({
@@ -1229,10 +1369,10 @@ function create1155CreatorClient({
1229
1369
  }
1230
1370
  if (!contractExists && typeof contract !== "string") {
1231
1371
  const request = {
1232
- abi: import_protocol_deployments3.zoraCreator1155FactoryImplABI,
1372
+ abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
1233
1373
  functionName: "createContractDeterministic",
1234
1374
  account,
1235
- address: import_protocol_deployments3.zoraCreator1155FactoryImplAddress[999],
1375
+ address: import_protocol_deployments4.zoraCreator1155FactoryImplAddress[999],
1236
1376
  args: [
1237
1377
  contract.uri,
1238
1378
  contract.name,
@@ -1254,7 +1394,7 @@ function create1155CreatorClient({
1254
1394
  };
1255
1395
  } else if (contractExists) {
1256
1396
  const request = {
1257
- abi: import_protocol_deployments3.zoraCreator1155ImplABI,
1397
+ abi: import_protocol_deployments4.zoraCreator1155ImplABI,
1258
1398
  functionName: "multicall",
1259
1399
  account,
1260
1400
  address: contractAddress,
@@ -1278,18 +1418,31 @@ function create1155CreatorClient({
1278
1418
  Errors,
1279
1419
  MintAPIClient,
1280
1420
  PremintAPIClient,
1421
+ PremintConfigVersion,
1422
+ PreminterDomain,
1281
1423
  ZORA_API_BASE,
1282
1424
  convertCollection,
1283
- convertPremint,
1425
+ convertPremintV1,
1284
1426
  create1155CreatorClient,
1285
1427
  create1155TokenSetupArgs,
1286
1428
  createMintClient,
1287
1429
  createPremintClient,
1288
1430
  encodePremintForAPI,
1289
- get1155MintCosts,
1431
+ encodePremintV1ForAPI,
1432
+ encodePremintV2ForAPI,
1290
1433
  getApiNetworkConfigForChain,
1434
+ getMintCosts,
1435
+ getPremintCollectionAddress,
1436
+ getPremintExecutorAddress,
1291
1437
  getPremintedLogFromReceipt,
1292
1438
  getTokenIdFromCreateReceipt,
1293
- preminterTypedDataDefinition
1439
+ isAuthorizedToCreatePremint,
1440
+ isValidSignature,
1441
+ migratePremintConfigToV2,
1442
+ premintTypedDataDefinition,
1443
+ recoverCreatorFromCreatorAttribution,
1444
+ recoverPremintSigner,
1445
+ supportsPremintVersion,
1446
+ tryRecoverPremintSigner
1294
1447
  });
1295
1448
  //# sourceMappingURL=index.cjs.map