@zoralabs/protocol-sdk 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,9 +7,9 @@ $ tsup
7
7
  CLI Cleaning output folder
8
8
  CJS Build start
9
9
  ESM Build start
10
- CJS dist/index.cjs 48.03 KB
11
- CJS dist/index.cjs.map 93.11 KB
12
- CJS ⚡️ Build success in 46ms
13
- ESM dist/index.js 44.64 KB
14
- ESM dist/index.js.map 93.23 KB
15
- ESM ⚡️ Build success in 45ms
10
+ ESM dist/index.js 46.15 KB
11
+ ESM dist/index.js.map 96.32 KB
12
+ ESM ⚡️ Build success in 37ms
13
+ CJS dist/index.cjs 49.71 KB
14
+ CJS dist/index.cjs.map 96.18 KB
15
+ CJS ⚡️ Build success in 38ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @zoralabs/protocol-sdk
2
2
 
3
+ ## 0.4.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 7e00197: \* For premintV1 and V2 - mintReferrer has been changed to an array `mintRewardsRecipients` - which the first element in array is `mintReferral`, and second element is `platformReferral`. `platformReferral is not used by the premint contract yet`.
8
+ - 0ceb709: Add mint costs getter for premint to protocol sdk
9
+ - Updated dependencies [5156b9e]
10
+ - @zoralabs/protocol-deployments@0.0.9
11
+
3
12
  ## 0.4.0
4
13
 
5
14
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -38,10 +38,13 @@ __export(src_exports, {
38
38
  getMintCosts: () => getMintCosts,
39
39
  getPremintCollectionAddress: () => getPremintCollectionAddress,
40
40
  getPremintExecutorAddress: () => getPremintExecutorAddress,
41
+ getPremintMintCosts: () => getPremintMintCosts,
42
+ getPremintMintFee: () => getPremintMintFee,
41
43
  getPremintedLogFromReceipt: () => getPremintedLogFromReceipt,
42
44
  getTokenIdFromCreateReceipt: () => getTokenIdFromCreateReceipt,
43
45
  isAuthorizedToCreatePremint: () => isAuthorizedToCreatePremint,
44
46
  isValidSignature: () => isValidSignature,
47
+ makeMintRewardsRecipient: () => makeMintRewardsRecipient,
45
48
  makeNewPremint: () => makeNewPremint,
46
49
  markPremintDeleted: () => markPremintDeleted,
47
50
  migratePremintConfigToV2: () => migratePremintConfigToV2,
@@ -353,6 +356,41 @@ function makeNewPremint({
353
356
  tokenConfig
354
357
  };
355
358
  }
359
+ async function getPremintMintFee({
360
+ tokenContract,
361
+ publicClient
362
+ }) {
363
+ try {
364
+ return await publicClient.readContract({
365
+ address: getPremintExecutorAddress(),
366
+ abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
367
+ functionName: "mintFee",
368
+ args: [tokenContract]
369
+ });
370
+ } catch (e) {
371
+ console.error(e);
372
+ return (0, import_viem.parseEther)("0.000777");
373
+ }
374
+ }
375
+ async function getPremintMintCosts({
376
+ publicClient,
377
+ tokenContract,
378
+ tokenPrice,
379
+ quantityToMint
380
+ }) {
381
+ const mintFee = await getPremintMintFee({ tokenContract, publicClient });
382
+ return {
383
+ mintFee: mintFee * quantityToMint,
384
+ tokenPurchaseCost: tokenPrice * quantityToMint,
385
+ totalCost: (mintFee + tokenPrice) * quantityToMint
386
+ };
387
+ }
388
+ function makeMintRewardsRecipient({
389
+ mintReferral = import_viem.zeroAddress,
390
+ platformReferral = import_viem.zeroAddress
391
+ }) {
392
+ return [mintReferral, platformReferral];
393
+ }
356
394
 
357
395
  // src/apis/http-api-base.ts
358
396
  var BadResponseError = class extends Error {
@@ -1050,6 +1088,18 @@ var PremintClient = class {
1050
1088
  chain: this.chain
1051
1089
  });
1052
1090
  }
1091
+ async getMintCosts({
1092
+ tokenContract,
1093
+ quantityToMint,
1094
+ tokenCreationConfig
1095
+ }) {
1096
+ return await getPremintMintCosts({
1097
+ publicClient: this.publicClient,
1098
+ quantityToMint,
1099
+ tokenContract,
1100
+ tokenPrice: tokenCreationConfig.pricePerToken
1101
+ });
1102
+ }
1053
1103
  /**
1054
1104
  * Execute premint on-chain
1055
1105
  *
@@ -1079,7 +1129,12 @@ var PremintClient = class {
1079
1129
  uid
1080
1130
  });
1081
1131
  const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
1082
- const value = numberToMint * REWARD_PER_TOKEN;
1132
+ const value = (await getPremintMintCosts({
1133
+ tokenContract,
1134
+ quantityToMint: numberToMint,
1135
+ publicClient: this.publicClient,
1136
+ tokenPrice: premintConfig.tokenConfig.pricePerToken
1137
+ })).totalCost;
1083
1138
  if (premintConfigVersion === "1" /* V1 */) {
1084
1139
  return {
1085
1140
  account,
@@ -1113,7 +1168,10 @@ var PremintClient = class {
1113
1168
  {
1114
1169
  mintComment: mintArguments?.mintComment || "",
1115
1170
  mintRecipient: mintArguments?.mintRecipient || accountAddress,
1116
- mintReferral: mintArguments?.mintReferral || import_viem4.zeroAddress
1171
+ mintRewardsRecipients: makeMintRewardsRecipient({
1172
+ mintReferral: mintArguments?.mintReferral,
1173
+ platformReferral: mintArguments?.platformReferral
1174
+ })
1117
1175
  }
1118
1176
  ]
1119
1177
  };
@@ -1598,10 +1656,13 @@ function create1155CreatorClient({
1598
1656
  getMintCosts,
1599
1657
  getPremintCollectionAddress,
1600
1658
  getPremintExecutorAddress,
1659
+ getPremintMintCosts,
1660
+ getPremintMintFee,
1601
1661
  getPremintedLogFromReceipt,
1602
1662
  getTokenIdFromCreateReceipt,
1603
1663
  isAuthorizedToCreatePremint,
1604
1664
  isValidSignature,
1665
+ makeMintRewardsRecipient,
1605
1666
  makeNewPremint,
1606
1667
  markPremintDeleted,
1607
1668
  migratePremintConfigToV2,