@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.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +9 -0
- package/dist/index.cjs +63 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +64 -5
- package/dist/index.js.map +1 -1
- package/dist/premint/premint-client.d.ts +7 -0
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +15 -0
- package/dist/premint/preminter.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/premint/premint-client.test.ts +6 -4
- package/src/premint/premint-client.ts +33 -3
- package/src/premint/preminter.test.ts +36 -20
- package/src/premint/preminter.ts +55 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,9 +7,9 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Cleaning output folder
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m46.15 KB[39m
|
|
11
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m96.32 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 37ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m49.71 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m96.18 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ 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 =
|
|
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
|
-
|
|
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,
|