@zoralabs/protocol-sdk 0.6.0 → 0.7.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.
Files changed (86) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/CHANGELOG.md +12 -0
  3. package/dist/constants.d.ts +0 -1
  4. package/dist/constants.d.ts.map +1 -1
  5. package/dist/index.cjs +2023 -431
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +2001 -412
  10. package/dist/index.js.map +1 -1
  11. package/dist/ipfs/arweave.d.ts +3 -0
  12. package/dist/ipfs/arweave.d.ts.map +1 -0
  13. package/dist/ipfs/gateway.d.ts +4 -0
  14. package/dist/ipfs/gateway.d.ts.map +1 -0
  15. package/dist/ipfs/index.d.ts +4 -0
  16. package/dist/ipfs/index.d.ts.map +1 -0
  17. package/dist/ipfs/ipfs.d.ts +5 -0
  18. package/dist/ipfs/ipfs.d.ts.map +1 -0
  19. package/dist/ipfs/mimeTypes.d.ts +25 -0
  20. package/dist/ipfs/mimeTypes.d.ts.map +1 -0
  21. package/dist/ipfs/text-metadata.d.ts +5 -0
  22. package/dist/ipfs/text-metadata.d.ts.map +1 -0
  23. package/dist/ipfs/token-metadata.d.ts +14 -0
  24. package/dist/ipfs/token-metadata.d.ts.map +1 -0
  25. package/dist/ipfs/types.d.ts +49 -0
  26. package/dist/ipfs/types.d.ts.map +1 -0
  27. package/dist/mint/mint-client.d.ts +28 -4071
  28. package/dist/mint/mint-client.d.ts.map +1 -1
  29. package/dist/mint/mint-queries.d.ts +38 -0
  30. package/dist/mint/mint-queries.d.ts.map +1 -0
  31. package/dist/mint/mint-transactions.d.ts +20 -0
  32. package/dist/mint/mint-transactions.d.ts.map +1 -0
  33. package/dist/mint/subgraph-mint-getter.d.ts +14 -7
  34. package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
  35. package/dist/mint/subgraph-queries.d.ts +55 -0
  36. package/dist/mint/subgraph-queries.d.ts.map +1 -0
  37. package/dist/mint/types.d.ts +117 -19
  38. package/dist/mint/types.d.ts.map +1 -1
  39. package/dist/mint/utils.d.ts +2 -0
  40. package/dist/mint/utils.d.ts.map +1 -0
  41. package/dist/mints/mints-contracts.d.ts +3 -4494
  42. package/dist/mints/mints-contracts.d.ts.map +1 -1
  43. package/dist/premint/conversions.d.ts +12 -15
  44. package/dist/premint/conversions.d.ts.map +1 -1
  45. package/dist/premint/premint-api-client.d.ts +14 -11
  46. package/dist/premint/premint-api-client.d.ts.map +1 -1
  47. package/dist/premint/premint-client.d.ts +17 -6
  48. package/dist/premint/premint-client.d.ts.map +1 -1
  49. package/dist/premint/preminter.d.ts +1 -1
  50. package/dist/premint/preminter.d.ts.map +1 -1
  51. package/dist/sdk.d.ts +4 -2
  52. package/dist/sdk.d.ts.map +1 -1
  53. package/dist/types.d.ts +3 -0
  54. package/dist/types.d.ts.map +1 -1
  55. package/dist/utils.d.ts +10 -2
  56. package/dist/utils.d.ts.map +1 -1
  57. package/package.json +2 -1
  58. package/src/constants.ts +0 -36
  59. package/src/create/1155-create-helper.test.ts +9 -7
  60. package/src/index.ts +2 -0
  61. package/src/ipfs/arweave.ts +5 -0
  62. package/src/ipfs/gateway.ts +48 -0
  63. package/src/ipfs/index.ts +7 -0
  64. package/src/ipfs/ipfs.ts +82 -0
  65. package/src/ipfs/mimeTypes.ts +141 -0
  66. package/src/ipfs/text-metadata.ts +128 -0
  67. package/src/ipfs/token-metadata.ts +99 -0
  68. package/src/ipfs/types.ts +54 -0
  69. package/src/mint/mint-client.test.ts +96 -47
  70. package/src/mint/mint-client.ts +75 -343
  71. package/src/mint/mint-queries.ts +320 -0
  72. package/src/mint/mint-transactions.ts +253 -0
  73. package/src/mint/subgraph-mint-getter.ts +216 -123
  74. package/src/mint/subgraph-queries.ts +170 -0
  75. package/src/mint/types.ts +140 -23
  76. package/src/mint/utils.ts +14 -0
  77. package/src/premint/conversions.ts +26 -2
  78. package/src/premint/premint-api-client.ts +48 -16
  79. package/src/premint/premint-client.test.ts +29 -23
  80. package/src/premint/premint-client.ts +73 -37
  81. package/src/premint/preminter.ts +2 -3
  82. package/src/sdk.ts +7 -4
  83. package/src/types.ts +18 -0
  84. package/src/utils.ts +29 -28
  85. package/test-integration/setup-test-contracts.ts +96 -0
  86. package/test-integration/premint-client.test.ts +0 -148
@@ -0,0 +1,320 @@
1
+ import { IPremintGetter } from "src/premint/premint-api-client";
2
+ import {
3
+ ContractInfo,
4
+ Erc20Approval,
5
+ GetMintCostsParameters,
6
+ GetMintParameters,
7
+ GetMintsOfContractParameters,
8
+ IOnchainMintGetter,
9
+ MintParametersBase,
10
+ MintableReturn,
11
+ OnchainSalesConfigAndTokenInfo,
12
+ PremintSalesConfigAndTokenInfo,
13
+ PrepareMint,
14
+ is1155Mint,
15
+ isOnChainMint,
16
+ } from "./types";
17
+ import { Address, zeroAddress } from "viem";
18
+ import {
19
+ getPremintMintCostsWithUnknownTokenPrice,
20
+ getPremintMintFee,
21
+ } from "src/premint/preminter";
22
+ import {
23
+ PremintFromApi,
24
+ isPremintConfigV1,
25
+ isPremintConfigV2,
26
+ } from "src/premint/conversions";
27
+ import { makeOnchainMintCall, parseMintCosts } from "./mint-transactions";
28
+ import { buildPremintMintCall } from "src/premint/premint-client";
29
+ import { IPublicClient } from "src/types";
30
+
31
+ export async function getMint({
32
+ params,
33
+ mintGetter,
34
+ premintGetter,
35
+ publicClient,
36
+ }: {
37
+ params: GetMintParameters;
38
+ mintGetter: IOnchainMintGetter;
39
+ premintGetter: IPremintGetter;
40
+ publicClient: IPublicClient;
41
+ }): Promise<MintableReturn> {
42
+ const { tokenContract } = params;
43
+ if (isOnChainMint(params)) {
44
+ const tokenId = is1155Mint(params) ? params.tokenId : undefined;
45
+ const result = await mintGetter.getMintable({
46
+ tokenId,
47
+ tokenAddress: tokenContract,
48
+ preferredSaleType: params.preferredSaleType,
49
+ });
50
+
51
+ return toMintableReturn(result);
52
+ }
53
+
54
+ const premint = await premintGetter.get({
55
+ collectionAddress: tokenContract,
56
+ uid: params.uid,
57
+ });
58
+
59
+ const mintFee = await getPremintMintFee({
60
+ publicClient,
61
+ tokenContract: tokenContract,
62
+ });
63
+
64
+ return toPremintMintReturn({ premint, mintFee });
65
+ }
66
+ export async function getPremintsOfCollectionWithTokenIds({
67
+ premintGetter,
68
+ mintGetter,
69
+ tokenContract,
70
+ }: {
71
+ premintGetter: IPremintGetter;
72
+ mintGetter: IOnchainMintGetter;
73
+ tokenContract: Address;
74
+ }) {
75
+ const { collection, premints } = await premintGetter.getOfCollection({
76
+ collectionAddress: tokenContract,
77
+ });
78
+
79
+ const premintUidsAndTokenIds = await mintGetter.getContractPremintTokenIds({
80
+ tokenAddress: tokenContract,
81
+ });
82
+
83
+ const premintsWithTokenId = premints.map((premint) => ({
84
+ ...premint,
85
+ tokenId: premintUidsAndTokenIds.find(
86
+ ({ uid }) => uid === premint.premint.premintConfig.uid,
87
+ )?.tokenId,
88
+ }));
89
+
90
+ return {
91
+ collection: collection,
92
+ premints: premintsWithTokenId,
93
+ };
94
+ }
95
+
96
+ export async function getMintsOfContract({
97
+ params,
98
+ mintGetter,
99
+ premintGetter,
100
+ publicClient,
101
+ }: {
102
+ params: GetMintsOfContractParameters;
103
+ mintGetter: IOnchainMintGetter;
104
+ premintGetter: IPremintGetter;
105
+ publicClient: IPublicClient;
106
+ }): Promise<{ contract?: ContractInfo; tokens: MintableReturn[] }> {
107
+ const onchainMints = (
108
+ await mintGetter.getContractMintable({
109
+ tokenAddress: params.tokenContract,
110
+ })
111
+ ).map(toMintableReturn);
112
+
113
+ const offchainMints = await getPremintsOfContractMintable({
114
+ mintGetter,
115
+ premintGetter,
116
+ publicClient,
117
+ params: {
118
+ tokenContract: params.tokenContract,
119
+ },
120
+ });
121
+
122
+ const tokens = [...onchainMints, ...offchainMints];
123
+
124
+ return {
125
+ tokens: tokens,
126
+ contract: tokens[0]?.token.contract,
127
+ };
128
+ }
129
+
130
+ export async function getMintCosts({
131
+ params,
132
+ mintGetter,
133
+ premintGetter,
134
+ publicClient,
135
+ }: {
136
+ params: GetMintCostsParameters;
137
+ mintGetter: IOnchainMintGetter;
138
+ premintGetter: IPremintGetter;
139
+ publicClient: IPublicClient;
140
+ }) {
141
+ const { quantityMinted: quantityToMint, collection } = params;
142
+ if (isOnChainMint(params)) {
143
+ const tokenId = is1155Mint(params) ? params.tokenId : undefined;
144
+ const salesConfigAndTokenInfo = await mintGetter.getMintable({
145
+ tokenId,
146
+ tokenAddress: collection,
147
+ });
148
+
149
+ return parseMintCosts({
150
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
151
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
152
+ quantityToMint: BigInt(quantityToMint),
153
+ });
154
+ }
155
+
156
+ return getPremintMintCostsWithUnknownTokenPrice({
157
+ premintGetter,
158
+ publicClient: publicClient,
159
+ quantityToMint: BigInt(quantityToMint),
160
+ uid: params.uid,
161
+ tokenContract: collection,
162
+ });
163
+ }
164
+
165
+ async function getPremintsOfContractMintable({
166
+ mintGetter,
167
+ premintGetter,
168
+ publicClient,
169
+ params,
170
+ }: {
171
+ mintGetter: IOnchainMintGetter;
172
+ premintGetter: IPremintGetter;
173
+ publicClient: IPublicClient;
174
+ params: { tokenContract: Address };
175
+ }): Promise<MintableReturn[]> {
176
+ const { premints, collection } = await getPremintsOfCollectionWithTokenIds({
177
+ mintGetter,
178
+ premintGetter,
179
+ tokenContract: params.tokenContract,
180
+ });
181
+
182
+ const offChainPremints = premints.filter(
183
+ (premint) =>
184
+ // if premint's uid is not in the list of uids from the subgraph, it is offchain
185
+ typeof premint.tokenId === "undefined",
186
+ );
187
+
188
+ if (offChainPremints.length === 0) return [];
189
+
190
+ const mintFee = await getPremintMintFee({
191
+ publicClient,
192
+ tokenContract: params.tokenContract,
193
+ });
194
+
195
+ return offChainPremints.map((premint) => {
196
+ return toPremintMintReturn({
197
+ premint: {
198
+ premint: premint.premint,
199
+ // todo: fix when api returns signer
200
+ signer: zeroAddress,
201
+ collection,
202
+ collectionAddress: params.tokenContract,
203
+ signature: premint.signature,
204
+ },
205
+ mintFee,
206
+ });
207
+ });
208
+ }
209
+
210
+ /** Parsing */
211
+
212
+ function parsePremint({
213
+ premint,
214
+ mintFee,
215
+ }: {
216
+ premint: Pick<
217
+ PremintFromApi,
218
+ "premint" | "signer" | "collectionAddress" | "collection"
219
+ >;
220
+ mintFee: bigint;
221
+ }): PremintSalesConfigAndTokenInfo {
222
+ if (
223
+ isPremintConfigV1(premint.premint) ||
224
+ isPremintConfigV2(premint.premint)
225
+ ) {
226
+ return {
227
+ creator: premint.signer,
228
+ maxSupply: premint.premint.premintConfig.tokenConfig.maxSupply,
229
+ mintFeePerQuantity: mintFee,
230
+ mintType: "premint",
231
+ uid: premint.premint.premintConfig.uid,
232
+ contract: {
233
+ address: premint.collectionAddress,
234
+ name: premint.collection!.contractName,
235
+ URI: premint.collection!.contractURI,
236
+ },
237
+ tokenURI: premint.premint.premintConfig.tokenConfig.tokenURI,
238
+ totalMinted: 0n,
239
+ salesConfig: {
240
+ duration: premint.premint.premintConfig.tokenConfig.mintDuration,
241
+ maxTokensPerAddress:
242
+ premint.premint.premintConfig.tokenConfig.maxTokensPerAddress,
243
+ pricePerToken: premint.premint.premintConfig.tokenConfig.pricePerToken,
244
+ saleType: "premint",
245
+ },
246
+ };
247
+ }
248
+
249
+ throw new Error("Invalid premint config version");
250
+ }
251
+
252
+ const makeOnchainPrepareMint =
253
+ (result: OnchainSalesConfigAndTokenInfo): PrepareMint =>
254
+ (params: MintParametersBase) => ({
255
+ parameters: makeOnchainMintCall({ token: result, mintParams: params }),
256
+ erc20Approval: getRequiredErc20Approvals(params, result),
257
+ costs: parseMintCosts({
258
+ salesConfig: result.salesConfig,
259
+ quantityToMint: BigInt(params.quantityToMint),
260
+ mintFeePerQuantity: result.mintFeePerQuantity,
261
+ }),
262
+ });
263
+
264
+ function toMintableReturn(
265
+ result: OnchainSalesConfigAndTokenInfo,
266
+ ): MintableReturn {
267
+ return { token: result, prepareMint: makeOnchainPrepareMint(result) };
268
+ }
269
+
270
+ const makePremintPrepareMint =
271
+ (
272
+ mintable: PremintSalesConfigAndTokenInfo,
273
+ mintFee: bigint,
274
+ premint: Pick<
275
+ PremintFromApi,
276
+ "premint" | "signer" | "collectionAddress" | "collection" | "signature"
277
+ >,
278
+ ): PrepareMint =>
279
+ (params: MintParametersBase) => ({
280
+ parameters: buildPremintMintCall({
281
+ mintArguments: params,
282
+ mintFee,
283
+ premint,
284
+ }),
285
+ costs: parseMintCosts({
286
+ mintFeePerQuantity: mintFee,
287
+ quantityToMint: BigInt(params.quantityToMint),
288
+ salesConfig: mintable.salesConfig,
289
+ }),
290
+ });
291
+
292
+ function toPremintMintReturn({
293
+ premint,
294
+ mintFee,
295
+ }: {
296
+ premint: Pick<
297
+ PremintFromApi,
298
+ "premint" | "signer" | "collectionAddress" | "collection" | "signature"
299
+ >;
300
+ mintFee: bigint;
301
+ }): MintableReturn {
302
+ const mintable = parsePremint({ premint, mintFee });
303
+
304
+ return {
305
+ token: mintable,
306
+ prepareMint: makePremintPrepareMint(mintable, mintFee, premint),
307
+ };
308
+ }
309
+ function getRequiredErc20Approvals(
310
+ params: MintParametersBase,
311
+ result: OnchainSalesConfigAndTokenInfo,
312
+ ): Erc20Approval | undefined {
313
+ if (result.salesConfig.saleType !== "erc20") return undefined;
314
+
315
+ return {
316
+ quantity: result.salesConfig.pricePerToken * BigInt(params.quantityToMint),
317
+ approveTo: result.salesConfig.address,
318
+ erc20: result.salesConfig.currency,
319
+ };
320
+ }
@@ -0,0 +1,253 @@
1
+ import {
2
+ Address,
3
+ encodeAbiParameters,
4
+ parseAbiParameters,
5
+ zeroAddress,
6
+ Account,
7
+ SimulateContractParameters,
8
+ } from "viem";
9
+ import {
10
+ erc20MinterABI,
11
+ zoraCreator1155ImplABI,
12
+ } from "@zoralabs/protocol-deployments";
13
+ import { zora721Abi } from "src/constants";
14
+ import {
15
+ GenericTokenIdTypes,
16
+ SimulateContractParametersWithAccount,
17
+ } from "src/types";
18
+ import { makeContractParameters, mintRecipientOrAccount } from "src/utils";
19
+ import { MintCosts, SaleStrategies, isErc20SaleStrategy } from "./types";
20
+ import { MakeMintParametersArgumentsBase } from "./types";
21
+
22
+ import { contractSupportsNewMintFunction } from "./utils";
23
+ import { OnchainSalesConfigAndTokenInfo } from "./types";
24
+
25
+ export function makeOnchainMintCall({
26
+ token,
27
+ mintParams,
28
+ }: {
29
+ token: OnchainSalesConfigAndTokenInfo;
30
+ mintParams: Omit<MakeMintParametersArgumentsBase, "tokenContract">;
31
+ }): SimulateContractParametersWithAccount {
32
+ if (token.mintType === "721") {
33
+ return makePrepareMint721TokenParams({
34
+ salesConfigAndTokenInfo: token,
35
+ tokenContract: token.contract.address,
36
+ ...mintParams,
37
+ });
38
+ }
39
+
40
+ return makePrepareMint1155TokenParams({
41
+ salesConfigAndTokenInfo: token,
42
+ tokenContract: token.contract.address,
43
+ tokenId: token.tokenId!,
44
+ ...mintParams,
45
+ });
46
+ }
47
+
48
+ export type MintableParameters = Pick<
49
+ OnchainSalesConfigAndTokenInfo,
50
+ "contractVersion" | "mintFeePerQuantity" | "salesConfig"
51
+ >;
52
+
53
+ export function makePrepareMint1155TokenParams({
54
+ tokenContract: tokenContract,
55
+ tokenId,
56
+ salesConfigAndTokenInfo,
57
+ minterAccount,
58
+ mintComment,
59
+ mintReferral,
60
+ mintRecipient,
61
+ quantityToMint,
62
+ }: {
63
+ salesConfigAndTokenInfo: MintableParameters;
64
+ tokenId: GenericTokenIdTypes;
65
+ } & Pick<
66
+ MakeMintParametersArgumentsBase,
67
+ | "minterAccount"
68
+ | "tokenContract"
69
+ | "mintComment"
70
+ | "mintReferral"
71
+ | "quantityToMint"
72
+ | "mintRecipient"
73
+ >): SimulateContractParameters<any, any, any, any, any, Address | Account> {
74
+ const mintQuantity = BigInt(quantityToMint || 1);
75
+
76
+ const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
77
+
78
+ const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
79
+
80
+ if (saleType === "fixedPrice") {
81
+ return makeEthMintCall({
82
+ mintComment,
83
+ minterAccount,
84
+ mintQuantity,
85
+ mintReferral,
86
+ mintTo,
87
+ salesConfigAndTokenInfo,
88
+ tokenContract,
89
+ tokenId,
90
+ });
91
+ }
92
+
93
+ if (saleType === "erc20") {
94
+ return makeContractParameters({
95
+ abi: erc20MinterABI,
96
+ functionName: "mint",
97
+ account: minterAccount,
98
+ address: salesConfigAndTokenInfo.salesConfig.address,
99
+ /* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
100
+ args: [
101
+ mintTo,
102
+ mintQuantity,
103
+ tokenContract,
104
+ BigInt(tokenId),
105
+ salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
106
+ salesConfigAndTokenInfo.salesConfig.currency,
107
+ mintReferral || zeroAddress,
108
+ mintComment || "",
109
+ ],
110
+ });
111
+ }
112
+
113
+ throw new Error("Unsupported sale type");
114
+ }
115
+
116
+ function makePrepareMint721TokenParams({
117
+ salesConfigAndTokenInfo,
118
+ minterAccount,
119
+ tokenContract,
120
+ mintComment,
121
+ mintReferral,
122
+ mintRecipient,
123
+ quantityToMint,
124
+ }: {
125
+ salesConfigAndTokenInfo: MintableParameters;
126
+ } & Pick<
127
+ MakeMintParametersArgumentsBase,
128
+ | "minterAccount"
129
+ | "tokenContract"
130
+ | "mintComment"
131
+ | "mintReferral"
132
+ | "quantityToMint"
133
+ | "mintRecipient"
134
+ >): SimulateContractParametersWithAccount {
135
+ const actualQuantityToMint = BigInt(quantityToMint || 1);
136
+ const mintValue = parseMintCosts({
137
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
138
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
139
+ quantityToMint: actualQuantityToMint,
140
+ }).totalCostEth;
141
+
142
+ return makeContractParameters({
143
+ abi: zora721Abi,
144
+ address: tokenContract,
145
+ account: minterAccount,
146
+ functionName: "mintWithRewards",
147
+ value: mintValue,
148
+ args: [
149
+ mintRecipientOrAccount({ mintRecipient, minterAccount }),
150
+ actualQuantityToMint,
151
+ mintComment || "",
152
+ mintReferral || zeroAddress,
153
+ ],
154
+ });
155
+ }
156
+
157
+ function makeEthMintCall({
158
+ tokenContract,
159
+ tokenId,
160
+ salesConfigAndTokenInfo,
161
+ minterAccount,
162
+ mintComment,
163
+ mintReferral,
164
+ mintQuantity,
165
+ mintTo,
166
+ }: {
167
+ minterAccount: Account | Address;
168
+ tokenContract: Address;
169
+ mintTo: Address;
170
+ salesConfigAndTokenInfo: MintableParameters;
171
+ tokenId: GenericTokenIdTypes;
172
+ mintQuantity: bigint;
173
+ mintComment?: string;
174
+ mintReferral?: Address;
175
+ }): SimulateContractParametersWithAccount {
176
+ const mintValue = parseMintCosts({
177
+ mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
178
+ salesConfig: salesConfigAndTokenInfo.salesConfig,
179
+ quantityToMint: mintQuantity,
180
+ }).totalCostEth;
181
+
182
+ const minterArguments = encodeAbiParameters(
183
+ parseAbiParameters("address, string"),
184
+ [mintTo, mintComment || ""],
185
+ );
186
+
187
+ // if based on contract version it has the new mint function,
188
+ // call the new mint function.
189
+ if (
190
+ contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)
191
+ ) {
192
+ return makeContractParameters({
193
+ abi: zoraCreator1155ImplABI,
194
+ functionName: "mint",
195
+ account: minterAccount,
196
+ value: mintValue,
197
+ address: tokenContract,
198
+ args: [
199
+ salesConfigAndTokenInfo.salesConfig.address,
200
+ BigInt(tokenId),
201
+ mintQuantity,
202
+ mintReferral ? [mintReferral] : [],
203
+ minterArguments,
204
+ ],
205
+ });
206
+ }
207
+
208
+ // otherwise call the deprecated mint function
209
+ return makeContractParameters({
210
+ abi: zoraCreator1155ImplABI,
211
+ functionName: "mintWithRewards",
212
+ account: minterAccount,
213
+ value: mintValue,
214
+ address: tokenContract,
215
+ /* args: minter, tokenId, quantity, minterArguments, mintReferral */
216
+ args: [
217
+ salesConfigAndTokenInfo.salesConfig.address,
218
+ BigInt(tokenId),
219
+ mintQuantity,
220
+ minterArguments,
221
+ mintReferral || zeroAddress,
222
+ ],
223
+ });
224
+ }
225
+
226
+ export function parseMintCosts({
227
+ salesConfig,
228
+ mintFeePerQuantity,
229
+ quantityToMint,
230
+ }: {
231
+ salesConfig: SaleStrategies;
232
+ mintFeePerQuantity: bigint;
233
+ quantityToMint: bigint;
234
+ }): MintCosts {
235
+ const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
236
+
237
+ const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
238
+
239
+ const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig)
240
+ ? salesConfig.currency
241
+ : undefined;
242
+
243
+ const totalPurchaseCostEth = totalPurchaseCostCurrency
244
+ ? 0n
245
+ : tokenPurchaseCost;
246
+
247
+ return {
248
+ mintFee: mintFeeForTokens,
249
+ totalPurchaseCost: tokenPurchaseCost,
250
+ totalPurchaseCostCurrency,
251
+ totalCostEth: mintFeeForTokens + totalPurchaseCostEth,
252
+ };
253
+ }