@zoralabs/protocol-sdk 0.5.10 → 0.5.11

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 (39) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +9 -0
  3. package/README.md +10 -0
  4. package/dist/create/1155-create-helper.d.ts +2 -2
  5. package/dist/create/1155-create-helper.d.ts.map +1 -1
  6. package/dist/index.cjs +136 -212
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +135 -209
  11. package/dist/index.js.map +1 -1
  12. package/dist/mint/mint-client.d.ts +3 -4
  13. package/dist/mint/mint-client.d.ts.map +1 -1
  14. package/dist/mints/mints-contracts.d.ts +2868 -2027
  15. package/dist/mints/mints-contracts.d.ts.map +1 -1
  16. package/dist/mints/mints-eth-unwrapper-and-caller.d.ts +78 -0
  17. package/dist/mints/mints-eth-unwrapper-and-caller.d.ts.map +1 -0
  18. package/dist/mints/mints-relay-example.d.ts +60 -0
  19. package/dist/mints/mints-relay-example.d.ts.map +1 -0
  20. package/dist/premint/premint-client.d.ts +1 -1
  21. package/dist/premint/premint-client.d.ts.map +1 -1
  22. package/dist/preminter.d.ts +23 -11
  23. package/dist/preminter.d.ts.map +1 -1
  24. package/dist/test-utils.d.ts +11 -0
  25. package/dist/test-utils.d.ts.map +1 -0
  26. package/dist/utils.d.ts +3 -0
  27. package/dist/utils.d.ts.map +1 -0
  28. package/package.json +6 -4
  29. package/src/create/1155-create-helper.ts +14 -11
  30. package/src/index.ts +2 -0
  31. package/src/mint/mint-client.ts +16 -19
  32. package/src/mints/mints-contracts.test.ts +32 -225
  33. package/src/mints/mints-contracts.ts +200 -281
  34. package/src/mints/mints-eth-unwrapper-and-caller.test.ts +467 -0
  35. package/src/mints/mints-eth-unwrapper-and-caller.ts +83 -0
  36. package/src/mints/mints-relay-example.ts +313 -0
  37. package/src/premint/premint-client.ts +15 -11
  38. package/src/test-utils.ts +39 -0
  39. package/src/utils.ts +30 -0
@@ -9,7 +9,7 @@ $ tsup
9
9
  ESM Build start
10
10
  CJS dist/index.cjs 1.06 MB
11
11
  CJS dist/index.cjs.map 1.43 MB
12
- CJS ⚡️ Build success in 835ms
13
- ESM dist/index.js 1.06 MB
12
+ CJS ⚡️ Build success in 845ms
13
+ ESM dist/index.js 1.05 MB
14
14
  ESM dist/index.js.map 1.43 MB
15
- ESM ⚡️ Build success in 840ms
15
+ ESM ⚡️ Build success in 856ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @zoralabs/protocol-sdk
2
2
 
3
+ ## 0.5.11
4
+
5
+ ### Patch Changes
6
+
7
+ - 8e514b7: Cleanup protocol-sdk to have better docs around all methods, and remove methods that do not need to be exported and are not used.
8
+ - 598a95b: Bumps protocol-sdk to use viem@2.x- see the [viem 2.X.X migration guide](https://viem.sh/docs/migration-guide#2xx-breaking-changes) for breaking changes when migratring from viem 1.X.X to 2.X.X
9
+ - Updated dependencies [8e514b7]
10
+ - @zoralabs/protocol-deployments@0.1.8
11
+
3
12
  ## 0.5.10
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -9,6 +9,16 @@ Protocol SDK allows developers to create tokens using the Zora Protocol and mint
9
9
  - `npm install viem`
10
10
  - `npm install `
11
11
 
12
+
13
+ ## Examples
14
+
15
+ - [Creating a mint from an on-chain contract](#creating-a-mint-from-an-on-chain-contract)
16
+ - [Creating an 1155 contract](#creating-an-1155-contract)
17
+ - [Premint: create a mint without paying gas](#premint-create-a-mint-without-paying-gas)
18
+ - [Updating a premint before it is brought onchain](#updating-a-premint-before-it-is-brought-onchain)
19
+ - [Deleting a premint before it is brought onchain](#deleting-a-premint-before-it-is-brought-onchain)
20
+ - [Minting a premint and bringing it onchain](#minting-a-premint-and-bringing-it-onchain)
21
+
12
22
  ### Creating a mint from an on-chain contract
13
23
 
14
24
  #### Using viem
@@ -1,4 +1,4 @@
1
- import type { Address, Hex, PublicClient, SimulateContractParameters, TransactionReceipt } from "viem";
1
+ import type { Account, Address, Hex, PublicClient, SimulateContractParameters, TransactionReceipt } from "viem";
2
2
  type SalesConfigParamsType = {
3
3
  pricePerToken?: bigint;
4
4
  saleStart?: bigint;
@@ -35,7 +35,7 @@ export declare function create1155TokenSetupArgs({ nextTokenId, mintToCreatorCou
35
35
  }): `0x${string}`[];
36
36
  export declare const getTokenIdFromCreateReceipt: (receipt: TransactionReceipt) => bigint | undefined;
37
37
  type CreateNew1155TokenReturn = {
38
- request: SimulateContractParameters;
38
+ request: SimulateContractParameters<any, any, any, any, any, Account | Address>;
39
39
  tokenSetupActions: Hex[];
40
40
  contractAddress: Address;
41
41
  contractExists: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"1155-create-helper.d.ts","sourceRoot":"","sources":["../../src/create/1155-create-helper.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,OAAO,EACP,GAAG,EACH,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,MAAM,CAAC;AAUd,KAAK,qBAAqB,GAAG;IAE3B,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;CAUjC,CAAC;AAKF,KAAK,YAAY,GACb;IACE,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,GACD,OAAO,CAAC;AAEZ,KAAK,mBAAmB,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,wBAAgB,wBAAwB,CAAC,EACvC,WAAW,E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B,cAAc,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,EACtC,YAAY,GACb,EAAE;IACD,YAAY,EAAE,YAAY,CAAC;CAC5B;;iBAYY,OAAO;;;;kBAIN,YAAY;0BACJ,MAAM;;;;4CAIW;YACjC,OAAO,EAAE,MAAM,CAAC;YAChB,eAAe,EAAE,OAAO,CAAC;SAC1B,KAAK,GAAG,EAAE;UACT,QAAQ,wBAAwB,CAAC;EA2FtC"}
package/dist/index.cjs CHANGED
@@ -6795,9 +6795,7 @@ __export(src_exports, {
6795
6795
  ZORA_API_BASE: () => ZORA_API_BASE,
6796
6796
  applyUpdateToPremint: () => applyUpdateToPremint,
6797
6797
  collectPremintV2WithMintsParams: () => collectPremintV2WithMintsParams,
6798
- collectPremintWithMintsTypedDataDefinition: () => collectPremintWithMintsTypedDataDefinition,
6799
6798
  collectWithMintsParams: () => collectWithMintsParams,
6800
- collectWithMintsTypedDataDefinition: () => collectWithMintsTypedDataDefinition,
6801
6799
  convertCollectionFromApi: () => convertCollectionFromApi,
6802
6800
  convertGetPremintApiResponse: () => convertGetPremintApiResponse,
6803
6801
  convertPremintFromApi: () => convertPremintFromApi,
@@ -6811,12 +6809,11 @@ __export(src_exports, {
6811
6809
  encodeCollectOnManager: () => encodeCollectOnManager,
6812
6810
  encodePostSignatureInput: () => encodePostSignatureInput,
6813
6811
  encodePremintForAPI: () => encodePremintForAPI,
6814
- encodePremintOnManager: () => encodePremintOnManager,
6815
- fixedPriceMinterMinterArguments: () => fixedPriceMinterMinterArguments,
6816
6812
  getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
6817
6813
  getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
6818
6814
  getMintCosts: () => getMintCosts,
6819
6815
  getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
6816
+ getMintsEthPrice: () => getMintsEthPrice,
6820
6817
  getPremintCollectionAddress: () => getPremintCollectionAddress,
6821
6818
  getPremintExecutorAddress: () => getPremintExecutorAddress,
6822
6819
  getPremintMintCosts: () => getPremintMintCosts,
@@ -6825,26 +6822,27 @@ __export(src_exports, {
6825
6822
  getTokenIdFromCreateReceipt: () => getTokenIdFromCreateReceipt,
6826
6823
  isAuthorizedToCreatePremint: () => isAuthorizedToCreatePremint,
6827
6824
  isValidSignature: () => isValidSignature,
6825
+ makeCallWithEthSafeTransferData: () => makeCallWithEthSafeTransferData,
6828
6826
  makeMintRewardsRecipient: () => makeMintRewardsRecipient,
6829
6827
  makeNewPremint: () => makeNewPremint,
6828
+ makePermitToCollectPremintOrNonPremint: () => makePermitToCollectPremintOrNonPremint,
6829
+ makePermitTransferBatchAndTypeData: () => makePermitTransferBatchAndTypeData,
6830
+ makePermitTransferTypeData: () => makePermitTransferTypeData,
6830
6831
  markPremintDeleted: () => markPremintDeleted,
6831
6832
  migratePremintConfigToV2: () => migratePremintConfigToV2,
6832
6833
  mintWithEthParams: () => mintWithEthParams,
6833
6834
  mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
6834
6835
  permitBatchTypedDataDefinition: () => permitBatchTypedDataDefinition,
6835
- permitTransferBatchToManagerAndCallParams: () => permitTransferBatchToManagerAndCallParams,
6836
6836
  permitTransferTypedDataDefinition: () => permitTransferTypedDataDefinition,
6837
6837
  premintTypedDataDefinition: () => premintTypedDataDefinition,
6838
6838
  recoverCreatorFromCreatorAttribution: () => recoverCreatorFromCreatorAttribution,
6839
6839
  recoverPremintSigner: () => recoverPremintSigner,
6840
- safeTransferAndUnwrapEthParams: () => safeTransferAndUnwrapEthParams,
6841
- safeTransferAndUnwrapTypedDataDefinition: () => safeTransferAndUnwrapTypedDataDefinition,
6842
- safeTransferBatchAndUnwrapTypedDataDefinition: () => safeTransferBatchAndUnwrapTypedDataDefinition,
6843
6840
  selectMintsToCollectWithFromQueryResult: () => selectMintsToCollectWithFromQueryResult,
6844
6841
  sumBalances: () => sumBalances,
6845
6842
  supportedPremintVersions: () => supportedPremintVersions,
6846
6843
  supportsPremintVersion: () => supportsPremintVersion,
6847
6844
  tryRecoverPremintSigner: () => tryRecoverPremintSigner,
6845
+ unwrapAndForwardEthPermitAndTypedDataDefinition: () => unwrapAndForwardEthPermitAndTypedDataDefinition,
6848
6846
  v1Types: () => v1Types,
6849
6847
  v2Types: () => v2Types
6850
6848
  });
@@ -7570,6 +7568,9 @@ var PremintAPIClient = class {
7570
7568
  }
7571
7569
  };
7572
7570
 
7571
+ // src/utils.ts
7572
+ var makeSimulateContractParamaters = (args) => args;
7573
+
7573
7574
  // src/premint/premint-client.ts
7574
7575
  var defaultTokenConfigV1MintArguments = () => ({
7575
7576
  maxSupply: OPEN_EDITION_MINT_SIZE,
@@ -7932,7 +7933,7 @@ var PremintClient = class {
7932
7933
  })
7933
7934
  };
7934
7935
  if (premintConfigVersion === "1" /* V1 */) {
7935
- return {
7936
+ return makeSimulateContractParamaters({
7936
7937
  account: minterAccount,
7937
7938
  abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
7938
7939
  functionName: "premintV1",
@@ -7945,9 +7946,9 @@ var PremintClient = class {
7945
7946
  numberToMint,
7946
7947
  mintArgumentsContract
7947
7948
  ]
7948
- };
7949
+ });
7949
7950
  } else if (premintConfigVersion === "2" /* V2 */) {
7950
- return {
7951
+ return makeSimulateContractParamaters({
7951
7952
  account: minterAccount,
7952
7953
  abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
7953
7954
  functionName: "premintV2",
@@ -7960,7 +7961,7 @@ var PremintClient = class {
7960
7961
  numberToMint,
7961
7962
  mintArgumentsContract
7962
7963
  ]
7963
- };
7964
+ });
7964
7965
  }
7965
7966
  throw new Error(`Invalid premint config version ${premintConfigVersion}`);
7966
7967
  }
@@ -8111,7 +8112,7 @@ async function makePrepareMint721TokenParams({
8111
8112
  salesConfigAndTokenInfo,
8112
8113
  quantityToMint: BigInt(mintArguments.quantityToMint)
8113
8114
  }).totalCost;
8114
- const result = {
8115
+ return makeSimulateContractParamaters({
8115
8116
  abi: zora721Abi,
8116
8117
  address: tokenAddress,
8117
8118
  account: minterAccount,
@@ -8123,8 +8124,7 @@ async function makePrepareMint721TokenParams({
8123
8124
  mintArguments.mintComment || "",
8124
8125
  mintArguments.mintReferral || import_viem5.zeroAddress
8125
8126
  ]
8126
- };
8127
- return result;
8127
+ });
8128
8128
  }
8129
8129
  function getMintCosts({
8130
8130
  salesConfigAndTokenInfo,
@@ -8150,7 +8150,7 @@ async function makePrepareMint1155TokenParams({
8150
8150
  salesConfigAndTokenInfo,
8151
8151
  quantityToMint: mintQuantity
8152
8152
  }).totalCost;
8153
- const result = {
8153
+ return makeSimulateContractParamaters({
8154
8154
  abi: import_protocol_deployments3.zoraCreator1155ImplABI,
8155
8155
  functionName: "mintWithRewards",
8156
8156
  account: minterAccount,
@@ -8167,8 +8167,7 @@ async function makePrepareMint1155TokenParams({
8167
8167
  ]),
8168
8168
  mintArguments.mintReferral || import_viem5.zeroAddress
8169
8169
  ]
8170
- };
8171
- return result;
8170
+ });
8172
8171
  }
8173
8172
 
8174
8173
  // src/create/1155-create-helper.ts
@@ -8376,7 +8375,7 @@ function create1155CreatorClient({
8376
8375
  throw new Error("Invariant: contract cannot be missing and an address");
8377
8376
  }
8378
8377
  if (!contractExists && typeof contract !== "string") {
8379
- const request = {
8378
+ const request = makeSimulateContractParamaters({
8380
8379
  abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
8381
8380
  functionName: "createContractDeterministic",
8382
8381
  account,
@@ -8393,7 +8392,7 @@ function create1155CreatorClient({
8393
8392
  contract.defaultAdmin || account,
8394
8393
  tokenSetupActions
8395
8394
  ]
8396
- };
8395
+ });
8397
8396
  return {
8398
8397
  request,
8399
8398
  tokenSetupActions,
@@ -8401,13 +8400,13 @@ function create1155CreatorClient({
8401
8400
  contractExists
8402
8401
  };
8403
8402
  } else if (contractExists) {
8404
- const request = {
8403
+ const request = makeSimulateContractParamaters({
8405
8404
  abi: import_protocol_deployments4.zoraCreator1155ImplABI,
8406
8405
  functionName: "multicall",
8407
8406
  account,
8408
8407
  address: contractAddress,
8409
8408
  args: [tokenSetupActions]
8410
- };
8409
+ });
8411
8410
  return {
8412
8411
  request,
8413
8412
  tokenSetupActions,
@@ -11743,30 +11742,26 @@ var sumBalances = (mintAccountBalances) => {
11743
11742
  // src/mints/mints-contracts.ts
11744
11743
  var import_protocol_deployments5 = require("@zoralabs/protocol-deployments");
11745
11744
  var import_viem7 = require("viem");
11746
- function mintWithEthParams({
11745
+ var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
11746
+ var mintWithEthParams = ({
11747
11747
  quantity,
11748
11748
  recipient,
11749
11749
  chainId,
11750
11750
  pricePerMint,
11751
11751
  account
11752
- }) {
11753
- return {
11754
- abi: import_protocol_deployments5.zoraMintsManagerImplConfig.abi,
11755
- address: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId],
11756
- functionName: "mintWithEth",
11757
- args: [quantity, recipient],
11758
- value: pricePerMint * quantity,
11759
- account
11760
- };
11761
- }
11752
+ }) => makeSimulateContractParamaters({
11753
+ abi: import_protocol_deployments5.zoraMintsManagerImplConfig.abi,
11754
+ address: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId],
11755
+ functionName: "mintWithEth",
11756
+ args: [quantity, recipient || addressOrAccountAddress(account)],
11757
+ value: pricePerMint * quantity,
11758
+ account
11759
+ });
11762
11760
  var getPaidMintValue = (quantities, pricePerMint) => {
11763
11761
  if (!pricePerMint || pricePerMint === 0n)
11764
11762
  return;
11765
11763
  return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
11766
11764
  };
11767
- var fixedPriceMinterMinterArguments = ({
11768
- mintRecipient
11769
- }) => (0, import_viem7.encodeAbiParameters)((0, import_viem7.parseAbiParameters)("address"), [mintRecipient]);
11770
11765
  var mintsBalanceOfAccountParams = ({
11771
11766
  account,
11772
11767
  chainId
@@ -11795,88 +11790,57 @@ function collectWithMintsParams({
11795
11790
  tokenIds,
11796
11791
  quantities,
11797
11792
  chainId,
11798
- pricePerToken,
11793
+ paidMintPricePerToken,
11799
11794
  account,
11800
- ...rest
11795
+ mintArguments,
11796
+ minter,
11797
+ zoraCreator1155Contract,
11798
+ zoraCreator1155TokenId
11801
11799
  }) {
11802
11800
  const call = encodeCollectOnManager({
11803
11801
  tokenIds,
11804
11802
  quantities,
11805
- ...rest
11803
+ zoraCreator1155Contract,
11804
+ zoraCreator1155TokenId,
11805
+ minter,
11806
+ mintArguments
11806
11807
  });
11807
- return {
11808
+ return makeSimulateContractParamaters({
11808
11809
  abi: import_protocol_deployments5.zoraMints1155Config.abi,
11809
11810
  address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
11810
11811
  functionName: "transferBatchToManagerAndCall",
11811
11812
  args: [tokenIds, quantities, call],
11812
- value: getPaidMintValue(quantities, pricePerToken),
11813
+ // if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
11814
+ // for the paid mint cost.
11815
+ value: getPaidMintValue(quantities, paidMintPricePerToken),
11813
11816
  account
11814
- };
11815
- }
11816
- var collectWithMintsTypedDataDefinition = ({
11817
- tokenIds,
11818
- quantities,
11819
- chainId,
11820
- account,
11821
- nonce,
11822
- deadline,
11823
- ...rest
11824
- }) => {
11825
- const safeTransferData = encodeCollectOnManager({
11826
- tokenIds,
11827
- quantities,
11828
- ...rest
11829
- });
11830
- return makePermitTransferBatchAndTypeData({
11831
- tokenIds,
11832
- quantities,
11833
- chainId,
11834
- account,
11835
- nonce,
11836
- deadline,
11837
- safeTransferData,
11838
- // will safe transfer to manager contract before doing the
11839
- // collect operation
11840
- to: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId]
11841
- });
11842
- };
11843
- var collectPremintWithMintsTypedDataDefinition = ({
11844
- tokenIds,
11845
- quantities,
11846
- chainId,
11847
- account,
11848
- nonce,
11849
- deadline,
11850
- ...rest
11851
- }) => {
11852
- const safeTransferData = encodePremintOnManager({
11853
- ...rest
11854
11817
  });
11855
- return makePermitTransferBatchAndTypeData({
11856
- tokenIds,
11857
- quantities,
11858
- chainId,
11859
- account,
11860
- nonce,
11861
- deadline,
11862
- safeTransferData,
11863
- // will safe transfer to manager contract before doing the
11864
- // collect operation
11865
- to: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId]
11818
+ }
11819
+ function getMintsEthPrice({
11820
+ publicClient
11821
+ }) {
11822
+ const chainId = publicClient.chain?.id;
11823
+ if (!chainId || !import_protocol_deployments5.zoraMintsManagerImplAddress[chainId]) {
11824
+ throw new Error(`Chain id ${chainId} not supported`);
11825
+ }
11826
+ return publicClient.readContract({
11827
+ abi: import_protocol_deployments5.zoraMintsManagerImplABI,
11828
+ address: import_protocol_deployments5.zoraMintsManagerImplAddress[chainId],
11829
+ functionName: "getEthPrice"
11866
11830
  });
11867
- };
11831
+ }
11868
11832
  function makePermitTransferBatchAndTypeData({
11869
11833
  tokenIds,
11870
11834
  quantities,
11871
11835
  chainId,
11872
- account,
11836
+ mintsOwner,
11873
11837
  to,
11874
11838
  nonce,
11875
11839
  deadline,
11876
11840
  safeTransferData
11877
11841
  }) {
11878
11842
  const permit = {
11879
- owner: typeof account === "string" ? account : account.address,
11843
+ owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
11880
11844
  to,
11881
11845
  tokenIds,
11882
11846
  quantities,
@@ -11887,7 +11851,7 @@ function makePermitTransferBatchAndTypeData({
11887
11851
  const typedData = permitBatchTypedDataDefinition({
11888
11852
  chainId,
11889
11853
  permit,
11890
- account
11854
+ account: mintsOwner
11891
11855
  });
11892
11856
  return {
11893
11857
  permit,
@@ -11898,14 +11862,14 @@ function makePermitTransferTypeData({
11898
11862
  tokenId,
11899
11863
  quantity,
11900
11864
  chainId,
11901
- account,
11865
+ mintsOwner,
11902
11866
  to,
11903
11867
  nonce,
11904
11868
  deadline,
11905
11869
  safeTransferData
11906
11870
  }) {
11907
11871
  const permit = {
11908
- owner: typeof account === "string" ? account : account.address,
11872
+ owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
11909
11873
  to,
11910
11874
  tokenId,
11911
11875
  quantity,
@@ -11916,7 +11880,7 @@ function makePermitTransferTypeData({
11916
11880
  const typedData = permitTransferTypedDataDefinition({
11917
11881
  chainId,
11918
11882
  permit,
11919
- account
11883
+ account: mintsOwner
11920
11884
  });
11921
11885
  return {
11922
11886
  permit,
@@ -11940,10 +11904,42 @@ var encodePremintOnManager = ({
11940
11904
  signerContract
11941
11905
  ]
11942
11906
  });
11907
+ var makePermitToCollectPremintOrNonPremint = ({
11908
+ mintsOwner,
11909
+ chainId,
11910
+ deadline,
11911
+ tokenIds,
11912
+ // this quantity of MINTs will be used to collect premint
11913
+ // and will be burned. This same quantity is the quantity of
11914
+ // premint to collect.
11915
+ quantities,
11916
+ nonce,
11917
+ premint,
11918
+ collect
11919
+ }) => {
11920
+ let safeTransferData;
11921
+ if (premint) {
11922
+ safeTransferData = encodePremintOnManager(premint);
11923
+ } else if (collect) {
11924
+ safeTransferData = encodeCollectOnManager(collect);
11925
+ } else {
11926
+ throw new Error("Invalid operation");
11927
+ }
11928
+ return makePermitTransferBatchAndTypeData({
11929
+ tokenIds,
11930
+ quantities,
11931
+ chainId,
11932
+ mintsOwner,
11933
+ nonce,
11934
+ deadline,
11935
+ safeTransferData,
11936
+ to: import_protocol_deployments5.zoraMintsManagerImplConfig.address[chainId]
11937
+ });
11938
+ };
11943
11939
  function collectPremintV2WithMintsParams({
11944
11940
  tokenIds,
11945
11941
  quantities,
11946
- pricePerToken,
11942
+ paidMintPricePerToken,
11947
11943
  account,
11948
11944
  chainId,
11949
11945
  ...rest
@@ -11951,14 +11947,14 @@ function collectPremintV2WithMintsParams({
11951
11947
  const call = encodePremintOnManager({
11952
11948
  ...rest
11953
11949
  });
11954
- return {
11950
+ return makeSimulateContractParamaters({
11955
11951
  abi: import_protocol_deployments5.zoraMints1155Config.abi,
11956
11952
  address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
11957
11953
  functionName: "transferBatchToManagerAndCall",
11958
11954
  args: [tokenIds, quantities, call],
11959
- value: getPaidMintValue(quantities, pricePerToken),
11955
+ value: getPaidMintValue(quantities, paidMintPricePerToken),
11960
11956
  account
11961
- };
11957
+ });
11962
11958
  }
11963
11959
  function makeTypeData(args) {
11964
11960
  return args;
@@ -12063,117 +12059,47 @@ function permitTransferTypedDataDefinition({
12063
12059
  account
12064
12060
  });
12065
12061
  }
12066
- var permitTransferBatchToManagerAndCallParams = ({
12067
- permit,
12068
- chainId,
12069
- signature
12070
- }) => {
12071
- const result = {
12072
- abi: import_protocol_deployments5.zoraMints1155Config.abi,
12073
- address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
12074
- functionName: "permitSafeTransferBatch",
12075
- args: [permit, signature]
12076
- };
12077
- return result;
12078
- };
12079
- var safeTransferAndUnwrapTypedDataDefinition = ({
12080
- chainId,
12081
- tokenId,
12082
- quantity,
12083
- from,
12084
- addressToCall,
12085
- functionToCall,
12086
- valueToSend,
12087
- deadline,
12088
- nonce
12089
- }) => {
12090
- const callArgument = (0, import_viem7.encodeFunctionData)({
12091
- abi: import_protocol_deployments5.iUnwrapAndForwardActionABI,
12092
- functionName: "callWithEth",
12093
- args: [addressToCall, functionToCall, valueToSend]
12094
- });
12095
- return makePermitTransferTypeData({
12096
- account: from,
12097
- chainId,
12098
- deadline,
12099
- tokenId,
12100
- quantity,
12101
- safeTransferData: callArgument,
12102
- to: import_protocol_deployments5.mintsEthUnwrapperAndCallerConfig.address[chainId],
12103
- nonce
12062
+ function decodeCallFailedError(error) {
12063
+ if (error.data?.errorName !== "CallFailed")
12064
+ throw new Error("Not a CallFailed error");
12065
+ const internalErrorData = error.data?.args?.[0];
12066
+ return (0, import_viem7.decodeErrorResult)({
12067
+ abi: import_protocol_deployments5.zoraMintsManagerImplABI,
12068
+ data: internalErrorData
12104
12069
  });
12105
- };
12106
- var safeTransferBatchAndUnwrapTypedDataDefinition = ({
12070
+ }
12071
+
12072
+ // src/mints/mints-eth-unwrapper-and-caller.ts
12073
+ var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
12074
+ var import_viem8 = require("viem");
12075
+ var makeCallWithEthSafeTransferData = ({
12076
+ address: addressToCall,
12077
+ call: functionToCall,
12078
+ value: valueToSend
12079
+ }) => (0, import_viem8.encodeFunctionData)({
12080
+ abi: import_protocol_deployments6.iUnwrapAndForwardActionABI,
12081
+ functionName: "callWithEth",
12082
+ args: [addressToCall, functionToCall, valueToSend]
12083
+ });
12084
+ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
12107
12085
  chainId,
12108
12086
  tokenIds,
12109
12087
  quantities,
12110
12088
  from,
12111
- addressToCall,
12112
- functionToCall,
12113
- valueToSend,
12089
+ callWithEth,
12090
+ safeTransferData,
12114
12091
  deadline,
12115
12092
  nonce
12116
- }) => {
12117
- const callArgument = (0, import_viem7.encodeFunctionData)({
12118
- abi: import_protocol_deployments5.iUnwrapAndForwardActionABI,
12119
- functionName: "callWithEth",
12120
- args: [addressToCall, functionToCall, valueToSend]
12121
- });
12122
- return makePermitTransferBatchAndTypeData({
12123
- account: from,
12124
- chainId,
12125
- deadline,
12126
- tokenIds,
12127
- quantities,
12128
- safeTransferData: callArgument,
12129
- to: import_protocol_deployments5.mintsEthUnwrapperAndCallerConfig.address[chainId],
12130
- nonce
12131
- });
12132
- };
12133
- var safeTransferAndUnwrapEthParams = ({
12093
+ }) => makePermitTransferBatchAndTypeData({
12094
+ mintsOwner: from,
12134
12095
  chainId,
12096
+ deadline,
12135
12097
  tokenIds,
12136
12098
  quantities,
12137
- from,
12138
- addressToCall,
12139
- functionToCall,
12140
- valueToSend
12141
- }) => {
12142
- const callArgument = (0, import_viem7.encodeFunctionData)({
12143
- abi: import_protocol_deployments5.iUnwrapAndForwardActionABI,
12144
- functionName: "callWithEth",
12145
- args: [addressToCall, functionToCall, valueToSend]
12146
- });
12147
- const result = {
12148
- abi: import_protocol_deployments5.zoraMints1155Config.abi,
12149
- functionName: "safeBatchTransferFrom",
12150
- address: import_protocol_deployments5.zoraMints1155Config.address[chainId],
12151
- args: [
12152
- typeof from === "string" ? from : from.address,
12153
- // the mints will be transferred to this address, which
12154
- // will burn/redeem their eth value
12155
- import_protocol_deployments5.mintsEthUnwrapperAndCallerConfig.address[chainId],
12156
- // token ids to transfer/burn/unwrap - must be eth based tokens
12157
- tokenIds,
12158
- // quantities to transfer/burn/unwrap
12159
- quantities,
12160
- // this is the safeTransferData - which gets forwarded to the eth transferrer
12161
- callArgument
12162
- ],
12163
- // the account whos mints will be transferred from
12164
- account: from
12165
- };
12166
- return result;
12167
- };
12168
- function decodeCallFailedError(error) {
12169
- if (error.data?.errorName !== "CallFailed")
12170
- throw new Error("Not a CallFailed error");
12171
- const internalErrorData = error.data?.args?.[0];
12172
- return (0, import_viem7.decodeErrorResult)({
12173
- abi: import_protocol_deployments5.zoraMintsManagerImplABI,
12174
- data: internalErrorData
12175
- });
12176
- }
12099
+ safeTransferData: safeTransferData || makeCallWithEthSafeTransferData(callWithEth),
12100
+ to: import_protocol_deployments6.mintsEthUnwrapperAndCallerAddress[chainId],
12101
+ nonce
12102
+ });
12177
12103
  // Annotate the CommonJS export names for ESM import in node:
12178
12104
  0 && (module.exports = {
12179
12105
  DEFAULT_SALE_SETTINGS,
@@ -12185,9 +12111,7 @@ function decodeCallFailedError(error) {
12185
12111
  ZORA_API_BASE,
12186
12112
  applyUpdateToPremint,
12187
12113
  collectPremintV2WithMintsParams,
12188
- collectPremintWithMintsTypedDataDefinition,
12189
12114
  collectWithMintsParams,
12190
- collectWithMintsTypedDataDefinition,
12191
12115
  convertCollectionFromApi,
12192
12116
  convertGetPremintApiResponse,
12193
12117
  convertPremintFromApi,
@@ -12201,12 +12125,11 @@ function decodeCallFailedError(error) {
12201
12125
  encodeCollectOnManager,
12202
12126
  encodePostSignatureInput,
12203
12127
  encodePremintForAPI,
12204
- encodePremintOnManager,
12205
- fixedPriceMinterMinterArguments,
12206
12128
  getApiNetworkConfigForChain,
12207
12129
  getDefaultFixedPriceMinterAddress,
12208
12130
  getMintCosts,
12209
12131
  getMintsAccountBalanceWithPriceQuery,
12132
+ getMintsEthPrice,
12210
12133
  getPremintCollectionAddress,
12211
12134
  getPremintExecutorAddress,
12212
12135
  getPremintMintCosts,
@@ -12215,26 +12138,27 @@ function decodeCallFailedError(error) {
12215
12138
  getTokenIdFromCreateReceipt,
12216
12139
  isAuthorizedToCreatePremint,
12217
12140
  isValidSignature,
12141
+ makeCallWithEthSafeTransferData,
12218
12142
  makeMintRewardsRecipient,
12219
12143
  makeNewPremint,
12144
+ makePermitToCollectPremintOrNonPremint,
12145
+ makePermitTransferBatchAndTypeData,
12146
+ makePermitTransferTypeData,
12220
12147
  markPremintDeleted,
12221
12148
  migratePremintConfigToV2,
12222
12149
  mintWithEthParams,
12223
12150
  mintsBalanceOfAccountParams,
12224
12151
  permitBatchTypedDataDefinition,
12225
- permitTransferBatchToManagerAndCallParams,
12226
12152
  permitTransferTypedDataDefinition,
12227
12153
  premintTypedDataDefinition,
12228
12154
  recoverCreatorFromCreatorAttribution,
12229
12155
  recoverPremintSigner,
12230
- safeTransferAndUnwrapEthParams,
12231
- safeTransferAndUnwrapTypedDataDefinition,
12232
- safeTransferBatchAndUnwrapTypedDataDefinition,
12233
12156
  selectMintsToCollectWithFromQueryResult,
12234
12157
  sumBalances,
12235
12158
  supportedPremintVersions,
12236
12159
  supportsPremintVersion,
12237
12160
  tryRecoverPremintSigner,
12161
+ unwrapAndForwardEthPermitAndTypedDataDefinition,
12238
12162
  v1Types,
12239
12163
  v2Types
12240
12164
  });