@zoralabs/protocol-sdk 0.11.7-COMMENTS.0 → 0.11.7

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 +2 -8
  3. package/dist/create/mint-from-create.d.ts +1 -2
  4. package/dist/create/mint-from-create.d.ts.map +1 -1
  5. package/dist/index.cjs +42 -196
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.js +44 -202
  8. package/dist/index.js.map +1 -1
  9. package/dist/mint/mint-client.d.ts +1 -3
  10. package/dist/mint/mint-client.d.ts.map +1 -1
  11. package/dist/mint/mint-queries.d.ts +3 -5
  12. package/dist/mint/mint-queries.d.ts.map +1 -1
  13. package/dist/mint/mint-transactions.d.ts +2 -4
  14. package/dist/mint/mint-transactions.d.ts.map +1 -1
  15. package/dist/sdk.d.ts.map +1 -1
  16. package/dist/secondary/secondary-client.d.ts +1 -2
  17. package/dist/secondary/secondary-client.d.ts.map +1 -1
  18. package/dist/secondary/types.d.ts +0 -1
  19. package/dist/secondary/types.d.ts.map +1 -1
  20. package/dist/test-utils.d.ts +1 -5
  21. package/dist/test-utils.d.ts.map +1 -1
  22. package/package.json +4 -4
  23. package/src/create/1155-create-helper.test.ts +12 -2
  24. package/src/create/1155-create-helper.ts +0 -2
  25. package/src/create/mint-from-create.ts +0 -3
  26. package/src/mint/mint-client.test.ts +30 -67
  27. package/src/mint/mint-client.ts +1 -10
  28. package/src/mint/mint-queries.ts +5 -16
  29. package/src/mint/mint-transactions.ts +16 -80
  30. package/src/rewards/subgraph-queries.ts +1 -1
  31. package/src/sdk.ts +0 -1
  32. package/src/secondary/secondary-client.test.ts +2 -248
  33. package/src/secondary/secondary-client.ts +6 -136
  34. package/src/secondary/types.ts +0 -2
  35. package/src/sparks/sparks-sponsored-sparks-spender.test.ts +1 -2
  36. package/src/test-utils.ts +0 -19
  37. package/src/comments/comments.test.ts +0 -338
package/dist/index.js CHANGED
@@ -3717,9 +3717,7 @@ import {
3717
3717
  import {
3718
3718
  erc20MinterABI,
3719
3719
  zoraCreator1155ImplABI as zoraCreator1155ImplABI2,
3720
- zoraTimedSaleStrategyABI,
3721
- callerAndCommenterABI,
3722
- callerAndCommenterAddress
3720
+ zoraTimedSaleStrategyABI
3723
3721
  } from "@zoralabs/protocol-deployments";
3724
3722
 
3725
3723
  // src/mint/utils.ts
@@ -3737,8 +3735,7 @@ var contractSupportsNewMintFunction = (contractVersion) => {
3737
3735
  // src/mint/mint-transactions.ts
3738
3736
  function makeOnchainMintCall({
3739
3737
  token,
3740
- mintParams,
3741
- chainId
3738
+ mintParams
3742
3739
  }) {
3743
3740
  if (token.mintType === "721") {
3744
3741
  return makePrepareMint721TokenParams({
@@ -3751,55 +3748,9 @@ function makeOnchainMintCall({
3751
3748
  salesConfigAndTokenInfo: token,
3752
3749
  tokenContract: token.contract.address,
3753
3750
  tokenId: token.tokenId,
3754
- chainId,
3755
3751
  ...mintParams
3756
3752
  });
3757
3753
  }
3758
- function makeZoraTimedSaleStrategyMintCall({
3759
- minterAccount,
3760
- salesConfigAndTokenInfo,
3761
- mintQuantity,
3762
- mintTo,
3763
- tokenContract,
3764
- tokenId,
3765
- mintReferral,
3766
- mintComment,
3767
- chainId
3768
- }) {
3769
- if (mintComment && mintComment !== "") {
3770
- return makeContractParameters({
3771
- abi: callerAndCommenterABI,
3772
- address: callerAndCommenterAddress[chainId],
3773
- functionName: "timedSaleMintAndComment",
3774
- account: minterAccount,
3775
- value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
3776
- args: [
3777
- mintTo,
3778
- mintQuantity,
3779
- tokenContract,
3780
- tokenId,
3781
- mintReferral || zeroAddress3,
3782
- mintComment
3783
- ]
3784
- });
3785
- }
3786
- return makeContractParameters({
3787
- abi: zoraTimedSaleStrategyABI,
3788
- functionName: "mint",
3789
- account: minterAccount,
3790
- address: salesConfigAndTokenInfo.salesConfig.address,
3791
- value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
3792
- /* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
3793
- args: [
3794
- mintTo,
3795
- mintQuantity,
3796
- tokenContract,
3797
- BigInt(tokenId),
3798
- mintReferral || zeroAddress3,
3799
- ""
3800
- ]
3801
- });
3802
- }
3803
3754
  function makePrepareMint1155TokenParams({
3804
3755
  tokenContract,
3805
3756
  tokenId,
@@ -3809,8 +3760,7 @@ function makePrepareMint1155TokenParams({
3809
3760
  mintReferral,
3810
3761
  mintRecipient,
3811
3762
  quantityToMint,
3812
- allowListEntry,
3813
- chainId
3763
+ allowListEntry
3814
3764
  }) {
3815
3765
  const mintQuantity = BigInt(quantityToMint || 1);
3816
3766
  const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
@@ -3829,16 +3779,21 @@ function makePrepareMint1155TokenParams({
3829
3779
  });
3830
3780
  }
3831
3781
  if (saleType === "timed") {
3832
- return makeZoraTimedSaleStrategyMintCall({
3833
- minterAccount,
3834
- salesConfigAndTokenInfo,
3835
- mintQuantity,
3836
- mintTo,
3837
- tokenContract,
3838
- tokenId,
3839
- mintReferral,
3840
- mintComment,
3841
- chainId
3782
+ return makeContractParameters({
3783
+ abi: zoraTimedSaleStrategyABI,
3784
+ functionName: "mint",
3785
+ account: minterAccount,
3786
+ address: salesConfigAndTokenInfo.salesConfig.address,
3787
+ value: salesConfigAndTokenInfo.salesConfig.mintFeePerQuantity * mintQuantity,
3788
+ /* args: mintTo, quantity, collection, tokenId, mintReferral, comment */
3789
+ args: [
3790
+ mintTo,
3791
+ mintQuantity,
3792
+ tokenContract,
3793
+ BigInt(tokenId),
3794
+ mintReferral || zeroAddress3,
3795
+ mintComment || ""
3796
+ ]
3842
3797
  });
3843
3798
  }
3844
3799
  if (saleType === "erc20") {
@@ -4003,8 +3958,7 @@ async function getMint({
4003
3958
  params,
4004
3959
  mintGetter,
4005
3960
  premintGetter,
4006
- publicClient,
4007
- chainId
3961
+ publicClient
4008
3962
  }) {
4009
3963
  const { tokenContract } = params;
4010
3964
  if (isOnChainMint(params)) {
@@ -4016,7 +3970,7 @@ async function getMint({
4016
3970
  preferredSaleType: params.preferredSaleType,
4017
3971
  blockTime
4018
3972
  });
4019
- return toMintableReturn(result, chainId);
3973
+ return toMintableReturn(result);
4020
3974
  }
4021
3975
  const premint = await premintGetter.get({
4022
3976
  collectionAddress: tokenContract,
@@ -4054,12 +4008,11 @@ async function getMintsOfContract({
4054
4008
  params,
4055
4009
  mintGetter,
4056
4010
  premintGetter,
4057
- publicClient,
4058
- chainId
4011
+ publicClient
4059
4012
  }) {
4060
4013
  const onchainMints = (await mintGetter.getContractMintable({
4061
4014
  tokenAddress: params.tokenContract
4062
- })).map((result) => toMintableReturn(result, chainId));
4015
+ })).map(toMintableReturn);
4063
4016
  const offchainMints = await getPremintsOfContractMintable({
4064
4017
  mintGetter,
4065
4018
  premintGetter,
@@ -4176,15 +4129,14 @@ function parsePremint({
4176
4129
  }
4177
4130
  throw new Error("Invalid premint config version");
4178
4131
  }
4179
- var makeOnchainPrepareMint = (result, chainId) => (params) => {
4132
+ var makeOnchainPrepareMint = (result) => (params) => {
4180
4133
  if (!result.salesConfig) {
4181
4134
  throw new Error("No valid sales config found for token");
4182
4135
  }
4183
4136
  return {
4184
4137
  parameters: makeOnchainMintCall({
4185
4138
  token: result,
4186
- mintParams: params,
4187
- chainId
4139
+ mintParams: params
4188
4140
  }),
4189
4141
  erc20Approval: getRequiredErc20Approvals(params, result.salesConfig),
4190
4142
  costs: parseMintCosts({
@@ -4194,7 +4146,7 @@ var makeOnchainPrepareMint = (result, chainId) => (params) => {
4194
4146
  })
4195
4147
  };
4196
4148
  };
4197
- function toMintableReturn(result, chainId) {
4149
+ function toMintableReturn(result) {
4198
4150
  const primaryMintActive = result.primaryMintActive;
4199
4151
  if (!primaryMintActive) {
4200
4152
  return {
@@ -4210,10 +4162,7 @@ function toMintableReturn(result, chainId) {
4210
4162
  primaryMintActive,
4211
4163
  primaryMintEnd: result.primaryMintEnd,
4212
4164
  secondaryMarketActive: result.secondaryMarketActive,
4213
- prepareMint: makeOnchainPrepareMint(
4214
- result.salesConfigAndTokenInfo,
4215
- chainId
4216
- )
4165
+ prepareMint: makeOnchainPrepareMint(result.salesConfigAndTokenInfo)
4217
4166
  };
4218
4167
  }
4219
4168
  var makePremintPrepareMint = (mintable, mintFee, premint) => {
@@ -4276,13 +4225,11 @@ var MintClient = class {
4276
4225
  constructor({
4277
4226
  publicClient,
4278
4227
  premintGetter,
4279
- mintGetter,
4280
- chainId
4228
+ mintGetter
4281
4229
  }) {
4282
4230
  this.publicClient = publicClient;
4283
4231
  this.mintGetter = mintGetter;
4284
4232
  this.premintGetter = premintGetter;
4285
- this.chainId = chainId;
4286
4233
  }
4287
4234
  /**
4288
4235
  * Returns the parameters needed to prepare a transaction mint a token.
@@ -4296,8 +4243,7 @@ var MintClient = class {
4296
4243
  parameters,
4297
4244
  publicClient: this.publicClient,
4298
4245
  mintGetter: this.mintGetter,
4299
- premintGetter: this.premintGetter,
4300
- chainId: this.chainId
4246
+ premintGetter: this.premintGetter
4301
4247
  });
4302
4248
  }
4303
4249
  /**
@@ -4311,8 +4257,7 @@ var MintClient = class {
4311
4257
  params: parameters,
4312
4258
  mintGetter: this.mintGetter,
4313
4259
  premintGetter: this.premintGetter,
4314
- publicClient: this.publicClient,
4315
- chainId: this.chainId
4260
+ publicClient: this.publicClient
4316
4261
  });
4317
4262
  }
4318
4263
  /**
@@ -4326,8 +4271,7 @@ var MintClient = class {
4326
4271
  params,
4327
4272
  mintGetter: this.mintGetter,
4328
4273
  premintGetter: this.premintGetter,
4329
- publicClient: this.publicClient,
4330
- chainId: this.chainId
4274
+ publicClient: this.publicClient
4331
4275
  });
4332
4276
  }
4333
4277
  /**
@@ -4348,15 +4292,13 @@ async function mint({
4348
4292
  parameters,
4349
4293
  publicClient,
4350
4294
  mintGetter,
4351
- premintGetter,
4352
- chainId
4295
+ premintGetter
4353
4296
  }) {
4354
4297
  const { prepareMint, primaryMintActive } = await getMint({
4355
4298
  params: parameters,
4356
4299
  mintGetter,
4357
4300
  premintGetter,
4358
- publicClient,
4359
- chainId
4301
+ publicClient
4360
4302
  });
4361
4303
  if (!primaryMintActive) {
4362
4304
  throw new Error("Primary mint is not active");
@@ -4918,8 +4860,7 @@ function makeOnchainPrepareMintFromCreate({
4918
4860
  result,
4919
4861
  minter,
4920
4862
  getContractMintFee,
4921
- contractVersion,
4922
- chainId
4863
+ contractVersion
4923
4864
  }) {
4924
4865
  return async (params) => {
4925
4866
  const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
@@ -4935,8 +4876,7 @@ function makeOnchainPrepareMintFromCreate({
4935
4876
  },
4936
4877
  ...params,
4937
4878
  tokenContract: contractAddress,
4938
- tokenId,
4939
- chainId
4879
+ tokenId
4940
4880
  }),
4941
4881
  costs: parseMintCosts({
4942
4882
  allowListEntry: params.allowListEntry,
@@ -5109,8 +5049,7 @@ async function createNew1155ContractAndToken({
5109
5049
  getContractMintFee: async () => getNewContractMintFee({
5110
5050
  publicClient,
5111
5051
  chainId
5112
- }),
5113
- chainId
5052
+ })
5114
5053
  });
5115
5054
  return {
5116
5055
  parameters: request,
@@ -5156,8 +5095,7 @@ async function createNew1155Token({
5156
5095
  minter,
5157
5096
  result: newToken.salesConfig,
5158
5097
  tokenId: nextTokenId,
5159
- getContractMintFee: async () => mintFee,
5160
- chainId
5098
+ getContractMintFee: async () => mintFee
5161
5099
  });
5162
5100
  return {
5163
5101
  parameters: request,
@@ -5764,7 +5702,7 @@ function buildCreatorERC20zs({
5764
5702
  query: `
5765
5703
  query ($address: Bytes!) {
5766
5704
  zoraCreateTokens(
5767
- where: { royalties_: { user: $address }, salesStrategies_: { type: "ZORA_TIMED" } }
5705
+ where: { royalties_: { royaltyRecipient: $address }, salesStrategies_: { type: "ZORA_TIMED" } }
5768
5706
  ) {
5769
5707
  royalties {
5770
5708
  user
@@ -5809,9 +5747,7 @@ import {
5809
5747
  secondarySwapAddress,
5810
5748
  zoraCreator1155ImplABI as zoraCreator1155ImplABI7,
5811
5749
  safeTransferSwapAbiParameters,
5812
- secondarySwapABI,
5813
- callerAndCommenterABI as callerAndCommenterABI2,
5814
- callerAndCommenterAddress as callerAndCommenterAddress2
5750
+ secondarySwapABI
5815
5751
  } from "@zoralabs/protocol-deployments";
5816
5752
 
5817
5753
  // src/secondary/uniswap/uniswapQuote.ts
@@ -6099,13 +6035,10 @@ var ERROR_INSUFFICIENT_WALLET_FUNDS = "Insufficient wallet funds";
6099
6035
  var ERROR_INSUFFICIENT_POOL_SUPPLY = "Insufficient pool supply";
6100
6036
  var ERROR_SECONDARY_NOT_CONFIGURED = "Secondary not configured for given contract and token";
6101
6037
  var ERROR_SECONDARY_NOT_STARTED = "Secondary market has not started";
6102
- var ERROR_RECIPIENT_MISMATCH = "Recipient must be the same as the caller if there is a comment";
6103
6038
  function makeError(errorMessage) {
6104
6039
  return { error: errorMessage };
6105
6040
  }
6106
6041
  async function makeBuy({
6107
- contract,
6108
- tokenId,
6109
6042
  erc20z,
6110
6043
  poolBalance,
6111
6044
  amount,
@@ -6114,106 +6047,20 @@ async function makeBuy({
6114
6047
  recipient,
6115
6048
  chainId,
6116
6049
  slippage,
6117
- publicClient,
6118
- comment
6119
- }) {
6120
- const costWithSlippage = calculateSlippageUp(amount, slippage);
6121
- const accountAddress = addressOrAccountAddress(account);
6122
- const validationResult = await validateBuyConditions({
6123
- poolBalance,
6124
- quantity,
6125
- costWithSlippage,
6126
- accountAddress,
6127
- publicClient
6128
- });
6129
- if (validationResult.error) {
6130
- return makeError(validationResult.error);
6131
- }
6132
- if (comment && comment !== "") {
6133
- return handleBuyWithComment({
6134
- accountAddress,
6135
- recipient,
6136
- chainId,
6137
- quantity,
6138
- contract,
6139
- tokenId,
6140
- costWithSlippage,
6141
- comment,
6142
- account
6143
- });
6144
- }
6145
- return handleBuyWithoutComment({
6146
- erc20z,
6147
- quantity,
6148
- recipient,
6149
- accountAddress,
6150
- costWithSlippage,
6151
- chainId,
6152
- account
6153
- });
6154
- }
6155
- async function validateBuyConditions({
6156
- poolBalance,
6157
- quantity,
6158
- costWithSlippage,
6159
- accountAddress,
6160
6050
  publicClient
6161
6051
  }) {
6052
+ const costWithSlippage = calculateSlippageUp(amount, slippage);
6162
6053
  const availableToBuy = poolBalance.erc20z / BigInt(1e18) - 1n;
6054
+ const accountAddress = addressOrAccountAddress(account);
6163
6055
  const availableToSpend = await publicClient.getBalance({
6164
6056
  address: accountAddress
6165
6057
  });
6166
6058
  if (costWithSlippage > availableToSpend) {
6167
- return { error: ERROR_INSUFFICIENT_WALLET_FUNDS };
6059
+ return makeError(ERROR_INSUFFICIENT_WALLET_FUNDS);
6168
6060
  }
6169
6061
  if (availableToBuy < BigInt(quantity)) {
6170
- return { error: ERROR_INSUFFICIENT_POOL_SUPPLY };
6171
- }
6172
- return {};
6173
- }
6174
- function handleBuyWithComment({
6175
- accountAddress,
6176
- recipient,
6177
- chainId,
6178
- quantity,
6179
- contract,
6180
- tokenId,
6181
- costWithSlippage,
6182
- comment,
6183
- account
6184
- }) {
6185
- if (recipient && recipient !== accountAddress) {
6186
- return makeError(ERROR_RECIPIENT_MISMATCH);
6062
+ return makeError(ERROR_INSUFFICIENT_POOL_SUPPLY);
6187
6063
  }
6188
- return {
6189
- parameters: makeContractParameters({
6190
- abi: callerAndCommenterABI2,
6191
- address: callerAndCommenterAddress2[chainId],
6192
- functionName: "buyOnSecondaryAndComment",
6193
- args: [
6194
- accountAddress,
6195
- quantity,
6196
- contract,
6197
- tokenId,
6198
- accountAddress,
6199
- costWithSlippage,
6200
- 0n,
6201
- comment
6202
- ],
6203
- account,
6204
- value: costWithSlippage
6205
- })
6206
- };
6207
- }
6208
- function handleBuyWithoutComment({
6209
- erc20z,
6210
- quantity,
6211
- recipient,
6212
- accountAddress,
6213
- costWithSlippage,
6214
- chainId,
6215
- account
6216
- }) {
6217
6064
  return {
6218
6065
  parameters: makeContractParameters({
6219
6066
  abi: secondarySwapABI,
@@ -6240,8 +6087,7 @@ async function buyWithSlippage({
6240
6087
  chainId,
6241
6088
  account,
6242
6089
  slippage = UNISWAP_SLIPPAGE,
6243
- recipient,
6244
- comment
6090
+ recipient
6245
6091
  }) {
6246
6092
  const secondaryInfo = await getSecondaryInfo({
6247
6093
  contract,
@@ -6268,8 +6114,6 @@ async function buyWithSlippage({
6268
6114
  );
6269
6115
  const call = await makeBuy({
6270
6116
  erc20z,
6271
- contract,
6272
- tokenId,
6273
6117
  poolBalance,
6274
6118
  amount,
6275
6119
  quantity,
@@ -6277,7 +6121,6 @@ async function buyWithSlippage({
6277
6121
  recipient,
6278
6122
  chainId,
6279
6123
  slippage,
6280
- comment,
6281
6124
  publicClient
6282
6125
  });
6283
6126
  return {
@@ -6467,8 +6310,7 @@ function createCollectorClient(params) {
6467
6310
  const mintClient = new MintClient({
6468
6311
  publicClient: params.publicClient,
6469
6312
  premintGetter: premintGetterToUse,
6470
- mintGetter: mintGetterToUse,
6471
- chainId: params.chainId
6313
+ mintGetter: mintGetterToUse
6472
6314
  });
6473
6315
  const secondaryClient = new SecondaryClient({
6474
6316
  publicClient: params.publicClient,