@zoralabs/protocol-sdk 0.6.0 → 0.7.0
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 +6 -0
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.cjs +845 -407
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +829 -391
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +28 -4071
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +38 -0
- package/dist/mint/mint-queries.d.ts.map +1 -0
- package/dist/mint/mint-transactions.d.ts +20 -0
- package/dist/mint/mint-transactions.d.ts.map +1 -0
- package/dist/mint/subgraph-mint-getter.d.ts +14 -7
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +55 -0
- package/dist/mint/subgraph-queries.d.ts.map +1 -0
- package/dist/mint/types.d.ts +117 -19
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/mint/utils.d.ts +2 -0
- package/dist/mint/utils.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +3 -4494
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +12 -15
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +14 -11
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +15 -5
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +1 -1
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +4 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +10 -2
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +0 -36
- package/src/create/1155-create-helper.test.ts +9 -7
- package/src/mint/mint-client.test.ts +96 -47
- package/src/mint/mint-client.ts +75 -343
- package/src/mint/mint-queries.ts +320 -0
- package/src/mint/mint-transactions.ts +253 -0
- package/src/mint/subgraph-mint-getter.ts +216 -123
- package/src/mint/subgraph-queries.ts +170 -0
- package/src/mint/types.ts +140 -23
- package/src/mint/utils.ts +14 -0
- package/src/premint/conversions.ts +26 -2
- package/src/premint/premint-api-client.ts +48 -16
- package/src/premint/premint-client.test.ts +29 -23
- package/src/premint/premint-client.ts +64 -36
- package/src/premint/preminter.ts +2 -3
- package/src/sdk.ts +7 -4
- package/src/types.ts +18 -0
- package/src/utils.ts +29 -28
- package/test-integration/setup-test-contracts.ts +96 -0
- package/test-integration/premint-client.test.ts +0 -148
package/src/mint/mint-client.ts
CHANGED
|
@@ -1,43 +1,23 @@
|
|
|
1
|
+
import { Address, Account, SimulateContractParameters } from "viem";
|
|
2
|
+
import { IPublicClient } from "src/types";
|
|
1
3
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
SimulateContractParameters,
|
|
8
|
-
erc20Abi,
|
|
9
|
-
} from "viem";
|
|
10
|
-
import {
|
|
11
|
-
erc20MinterABI,
|
|
12
|
-
erc20MinterAddress,
|
|
13
|
-
zoraCreator1155ImplABI,
|
|
14
|
-
zoraCreatorFixedPriceSaleStrategyAddress,
|
|
15
|
-
} from "@zoralabs/protocol-deployments";
|
|
16
|
-
import { zora721Abi } from "src/constants";
|
|
17
|
-
import { GenericTokenIdTypes } from "src/types";
|
|
18
|
-
import {
|
|
19
|
-
makeContractParameters,
|
|
20
|
-
PublicClient,
|
|
21
|
-
mintRecipientOrAccount,
|
|
22
|
-
} from "src/utils";
|
|
23
|
-
import {
|
|
24
|
-
IMintGetter,
|
|
25
|
-
SalesConfigAndTokenInfo,
|
|
26
|
-
isErc20SaleStrategy,
|
|
4
|
+
GetMintParameters,
|
|
5
|
+
IOnchainMintGetter,
|
|
6
|
+
MintCosts,
|
|
7
|
+
PrepareMintReturn,
|
|
8
|
+
SaleType,
|
|
27
9
|
} from "./types";
|
|
28
10
|
import {
|
|
29
11
|
MakeMintParametersArguments,
|
|
30
|
-
MakeMintParametersArgumentsBase,
|
|
31
12
|
Make1155MintArguments,
|
|
32
|
-
MakePremintMintParametersArguments,
|
|
33
13
|
Make721MintArguments,
|
|
34
14
|
GetMintCostsParameters,
|
|
35
|
-
isOnChainMint,
|
|
36
15
|
is1155Mint,
|
|
37
16
|
} from "./types";
|
|
38
|
-
import { collectPremint } from "src/premint/premint-client";
|
|
39
17
|
import { IPremintGetter } from "src/premint/premint-api-client";
|
|
40
|
-
|
|
18
|
+
|
|
19
|
+
import { makeOnchainMintCall } from "./mint-transactions";
|
|
20
|
+
import { getMint, getMintCosts, getMintsOfContract } from "./mint-queries";
|
|
41
21
|
|
|
42
22
|
class MintError extends Error {}
|
|
43
23
|
class MintInactiveError extends Error {}
|
|
@@ -48,23 +28,19 @@ export const Errors = {
|
|
|
48
28
|
};
|
|
49
29
|
|
|
50
30
|
export class MintClient {
|
|
51
|
-
private readonly
|
|
52
|
-
private readonly
|
|
53
|
-
private readonly mintGetter: IMintGetter;
|
|
31
|
+
private readonly publicClient: IPublicClient;
|
|
32
|
+
private readonly mintGetter: IOnchainMintGetter;
|
|
54
33
|
private readonly premintGetter: IPremintGetter;
|
|
55
34
|
|
|
56
35
|
constructor({
|
|
57
|
-
chainId,
|
|
58
36
|
publicClient,
|
|
59
37
|
premintGetter,
|
|
60
38
|
mintGetter,
|
|
61
39
|
}: {
|
|
62
|
-
|
|
63
|
-
publicClient: PublicClient;
|
|
40
|
+
publicClient: IPublicClient;
|
|
64
41
|
premintGetter: IPremintGetter;
|
|
65
|
-
mintGetter:
|
|
42
|
+
mintGetter: IOnchainMintGetter;
|
|
66
43
|
}) {
|
|
67
|
-
this.chainId = chainId;
|
|
68
44
|
this.publicClient = publicClient;
|
|
69
45
|
this.mintGetter = mintGetter;
|
|
70
46
|
this.premintGetter = premintGetter;
|
|
@@ -75,18 +51,52 @@ export class MintClient {
|
|
|
75
51
|
* Works with premint, onchain 1155, and onchain 721.
|
|
76
52
|
*
|
|
77
53
|
* @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
|
|
78
|
-
* @returns Parameters for simulating/executing the mint transaction
|
|
54
|
+
* @returns Parameters for simulating/executing the mint transaction, any necessary erc20 approval, and costs to mint
|
|
79
55
|
*/
|
|
80
|
-
async mint(
|
|
56
|
+
async mint(
|
|
57
|
+
parameters: MakeMintParametersArguments,
|
|
58
|
+
): Promise<PrepareMintReturn> {
|
|
81
59
|
return mint({
|
|
82
60
|
parameters,
|
|
83
|
-
chainId: this.chainId,
|
|
84
61
|
publicClient: this.publicClient,
|
|
85
62
|
mintGetter: this.mintGetter,
|
|
86
63
|
premintGetter: this.premintGetter,
|
|
87
64
|
});
|
|
88
65
|
}
|
|
89
66
|
|
|
67
|
+
/**
|
|
68
|
+
* Gets an 1155, 721, or premint, and returns both information about it, and a function
|
|
69
|
+
* that can be used to build a mint transaction for a quantity of items to mint.
|
|
70
|
+
* @param parameters - Token to get {@link GetMintParameters}
|
|
71
|
+
* @Returns Information about the mint and a function to build a mint transaction {@link MintableReturn}
|
|
72
|
+
*/
|
|
73
|
+
async get(parameters: GetMintParameters) {
|
|
74
|
+
return getMint({
|
|
75
|
+
params: parameters,
|
|
76
|
+
mintGetter: this.mintGetter,
|
|
77
|
+
premintGetter: this.premintGetter,
|
|
78
|
+
publicClient: this.publicClient,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Gets onchain and premint tokens of an 1155 contract. For each token returns both information about it, and a function
|
|
84
|
+
* that can be used to build a mint transaction for a quantity of items to mint.
|
|
85
|
+
* @param parameters - Contract address to get tokens for {@link GetMintsOfContractParameters}
|
|
86
|
+
* @Returns Array of tokens, each containing information about the token and a function to build a mint transaction.
|
|
87
|
+
*/
|
|
88
|
+
async getOfContract(params: {
|
|
89
|
+
tokenContract: Address;
|
|
90
|
+
preferredSaleType?: SaleType;
|
|
91
|
+
}) {
|
|
92
|
+
return getMintsOfContract({
|
|
93
|
+
params,
|
|
94
|
+
mintGetter: this.mintGetter,
|
|
95
|
+
premintGetter: this.premintGetter,
|
|
96
|
+
publicClient: this.publicClient,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
90
100
|
/**
|
|
91
101
|
* Gets the costs to mint the quantity of tokens specified for a mint.
|
|
92
102
|
* @param parameters - Parameters for the mint {@link GetMintCostsParameters}
|
|
@@ -94,7 +104,7 @@ export class MintClient {
|
|
|
94
104
|
*/
|
|
95
105
|
async getMintCosts(parameters: GetMintCostsParameters): Promise<MintCosts> {
|
|
96
106
|
return getMintCosts({
|
|
97
|
-
|
|
107
|
+
params: parameters,
|
|
98
108
|
mintGetter: this.mintGetter,
|
|
99
109
|
premintGetter: this.premintGetter,
|
|
100
110
|
publicClient: this.publicClient,
|
|
@@ -102,106 +112,32 @@ export class MintClient {
|
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
|
|
105
|
-
function isPremintCollect(
|
|
106
|
-
parameters: MakeMintParametersArguments,
|
|
107
|
-
): parameters is MakePremintMintParametersArguments {
|
|
108
|
-
return parameters.mintType === "premint";
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function is721Collect(
|
|
112
|
-
parameters: MakeMintParametersArguments,
|
|
113
|
-
): parameters is Make721MintArguments {
|
|
114
|
-
return parameters.mintType === "721";
|
|
115
|
-
}
|
|
116
|
-
|
|
117
115
|
async function mint({
|
|
118
116
|
parameters,
|
|
119
|
-
chainId,
|
|
120
117
|
publicClient,
|
|
121
118
|
mintGetter,
|
|
122
119
|
premintGetter,
|
|
123
120
|
}: {
|
|
124
121
|
parameters: MakeMintParametersArguments;
|
|
125
|
-
publicClient:
|
|
126
|
-
mintGetter:
|
|
122
|
+
publicClient: IPublicClient;
|
|
123
|
+
mintGetter: IOnchainMintGetter;
|
|
127
124
|
premintGetter: IPremintGetter;
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
premintGetter: premintGetter,
|
|
135
|
-
publicClient,
|
|
136
|
-
}),
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
parameters: await collectOnchain({
|
|
142
|
-
...parameters,
|
|
143
|
-
mintGetter: mintGetter,
|
|
144
|
-
chainId,
|
|
145
|
-
}),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export function requestErc20ApprovalForMint({
|
|
150
|
-
account,
|
|
151
|
-
tokenAddress,
|
|
152
|
-
quantityErc20,
|
|
153
|
-
erc20MinterAddress,
|
|
154
|
-
}: {
|
|
155
|
-
account: Account | Address;
|
|
156
|
-
tokenAddress: Address;
|
|
157
|
-
quantityErc20: bigint;
|
|
158
|
-
erc20MinterAddress: Address;
|
|
159
|
-
}) {
|
|
160
|
-
return makeContractParameters({
|
|
161
|
-
abi: erc20Abi,
|
|
162
|
-
address: tokenAddress,
|
|
163
|
-
account,
|
|
164
|
-
functionName: "approve",
|
|
165
|
-
args: [erc20MinterAddress, quantityErc20],
|
|
125
|
+
}): Promise<PrepareMintReturn> {
|
|
126
|
+
const { prepareMint } = await getMint({
|
|
127
|
+
params: parameters,
|
|
128
|
+
mintGetter,
|
|
129
|
+
premintGetter,
|
|
130
|
+
publicClient,
|
|
166
131
|
});
|
|
167
|
-
}
|
|
168
132
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
chainId: number;
|
|
177
|
-
account: Account | Address;
|
|
178
|
-
tokenAddress: Address;
|
|
179
|
-
quantityErc20: bigint;
|
|
180
|
-
publicClient: PublicClient;
|
|
181
|
-
}) {
|
|
182
|
-
const destination =
|
|
183
|
-
erc20MinterAddress[chainId as keyof typeof erc20MinterAddress];
|
|
184
|
-
const allowance = await publicClient.readContract({
|
|
185
|
-
abi: erc20Abi,
|
|
186
|
-
address: tokenAddress,
|
|
187
|
-
functionName: "allowance",
|
|
188
|
-
account,
|
|
189
|
-
args: [
|
|
190
|
-
destination,
|
|
191
|
-
erc20MinterAddress[chainId as keyof typeof erc20MinterAddress],
|
|
192
|
-
],
|
|
133
|
+
return prepareMint({
|
|
134
|
+
minterAccount: parameters.minterAccount,
|
|
135
|
+
quantityToMint: parameters.quantityToMint,
|
|
136
|
+
firstMinter: parameters.firstMinter,
|
|
137
|
+
mintComment: parameters.mintComment,
|
|
138
|
+
mintRecipient: parameters.mintRecipient,
|
|
139
|
+
mintReferral: parameters.mintReferral,
|
|
193
140
|
});
|
|
194
|
-
|
|
195
|
-
if (allowance < quantityErc20) {
|
|
196
|
-
return requestErc20ApprovalForMint({
|
|
197
|
-
erc20MinterAddress: destination,
|
|
198
|
-
account,
|
|
199
|
-
tokenAddress,
|
|
200
|
-
quantityErc20: quantityErc20 - allowance,
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return undefined;
|
|
205
141
|
}
|
|
206
142
|
|
|
207
143
|
export async function collectOnchain({
|
|
@@ -209,226 +145,22 @@ export async function collectOnchain({
|
|
|
209
145
|
mintGetter,
|
|
210
146
|
...parameters
|
|
211
147
|
}: (Make1155MintArguments | Make721MintArguments) & {
|
|
212
|
-
mintGetter:
|
|
148
|
+
mintGetter: IOnchainMintGetter;
|
|
213
149
|
chainId: number;
|
|
214
150
|
}): Promise<
|
|
215
151
|
SimulateContractParameters<any, any, any, any, any, Account | Address>
|
|
216
152
|
> {
|
|
217
|
-
const { tokenContract: tokenContract, saleType } =
|
|
153
|
+
const { tokenContract: tokenContract, preferredSaleType: saleType } =
|
|
154
|
+
parameters;
|
|
218
155
|
const tokenId = is1155Mint(parameters) ? parameters.tokenId : undefined;
|
|
219
|
-
const salesConfigAndTokenInfo = await mintGetter.
|
|
156
|
+
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
220
157
|
tokenId,
|
|
221
158
|
tokenAddress: tokenContract,
|
|
222
|
-
saleType,
|
|
159
|
+
preferredSaleType: saleType,
|
|
223
160
|
});
|
|
224
161
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
...parameters,
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
return makePrepareMint1155TokenParams({
|
|
233
|
-
salesConfigAndTokenInfo,
|
|
234
|
-
chainId,
|
|
235
|
-
...parameters,
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
async function makePrepareMint721TokenParams({
|
|
240
|
-
salesConfigAndTokenInfo,
|
|
241
|
-
minterAccount,
|
|
242
|
-
tokenContract,
|
|
243
|
-
mintComment,
|
|
244
|
-
mintReferral,
|
|
245
|
-
mintRecipient,
|
|
246
|
-
quantityToMint,
|
|
247
|
-
}: {
|
|
248
|
-
salesConfigAndTokenInfo: SalesConfigAndTokenInfo;
|
|
249
|
-
} & Pick<
|
|
250
|
-
MakeMintParametersArgumentsBase,
|
|
251
|
-
| "minterAccount"
|
|
252
|
-
| "tokenContract"
|
|
253
|
-
| "mintComment"
|
|
254
|
-
| "mintReferral"
|
|
255
|
-
| "quantityToMint"
|
|
256
|
-
| "mintRecipient"
|
|
257
|
-
>) {
|
|
258
|
-
const actualQuantityToMint = BigInt(quantityToMint || 1);
|
|
259
|
-
const mintValue = parseMintCosts({
|
|
260
|
-
salesConfigAndTokenInfo,
|
|
261
|
-
quantityToMint: actualQuantityToMint,
|
|
262
|
-
}).totalCostEth;
|
|
263
|
-
|
|
264
|
-
return makeContractParameters({
|
|
265
|
-
abi: zora721Abi,
|
|
266
|
-
address: tokenContract,
|
|
267
|
-
account: minterAccount,
|
|
268
|
-
functionName: "mintWithRewards",
|
|
269
|
-
value: mintValue,
|
|
270
|
-
args: [
|
|
271
|
-
mintRecipientOrAccount({ mintRecipient, minterAccount }),
|
|
272
|
-
actualQuantityToMint,
|
|
273
|
-
mintComment || "",
|
|
274
|
-
mintReferral || zeroAddress,
|
|
275
|
-
],
|
|
276
|
-
});
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export type MintCosts = {
|
|
280
|
-
/** The total of the mint fee, in eth */
|
|
281
|
-
mintFee: bigint;
|
|
282
|
-
/** If it is a paid or erc20 mint, the total price of the paid or erc20 mint in eth or erc20 value correspondingly. */
|
|
283
|
-
totalPurchaseCost: bigint;
|
|
284
|
-
/** If it is an erc20 mint, the erc20 address */
|
|
285
|
-
totalPurchaseCostCurrency?: Address;
|
|
286
|
-
/** The total cost in eth (mint fee + purchase cost) to mint */
|
|
287
|
-
totalCostEth: bigint;
|
|
288
|
-
};
|
|
289
|
-
|
|
290
|
-
export function parseMintCosts({
|
|
291
|
-
salesConfigAndTokenInfo,
|
|
292
|
-
quantityToMint,
|
|
293
|
-
}: {
|
|
294
|
-
salesConfigAndTokenInfo: SalesConfigAndTokenInfo;
|
|
295
|
-
quantityToMint: bigint;
|
|
296
|
-
}): MintCosts {
|
|
297
|
-
const mintFeeForTokens =
|
|
298
|
-
salesConfigAndTokenInfo.mintFeePerQuantity * quantityToMint;
|
|
299
|
-
|
|
300
|
-
const tokenPurchaseCost =
|
|
301
|
-
BigInt(salesConfigAndTokenInfo.salesConfig.pricePerToken) * quantityToMint;
|
|
302
|
-
|
|
303
|
-
const totalPurchaseCostCurrency = isErc20SaleStrategy(
|
|
304
|
-
salesConfigAndTokenInfo.salesConfig,
|
|
305
|
-
)
|
|
306
|
-
? salesConfigAndTokenInfo.salesConfig.currency
|
|
307
|
-
: undefined;
|
|
308
|
-
|
|
309
|
-
const totalPurchaseCostEth = totalPurchaseCostCurrency
|
|
310
|
-
? 0n
|
|
311
|
-
: tokenPurchaseCost;
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
mintFee: mintFeeForTokens,
|
|
315
|
-
totalPurchaseCost: tokenPurchaseCost,
|
|
316
|
-
totalPurchaseCostCurrency,
|
|
317
|
-
totalCostEth: mintFeeForTokens + totalPurchaseCostEth,
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
export async function getMintCosts(
|
|
322
|
-
params: GetMintCostsParameters & {
|
|
323
|
-
mintGetter: IMintGetter;
|
|
324
|
-
premintGetter: IPremintGetter;
|
|
325
|
-
publicClient: PublicClient;
|
|
326
|
-
},
|
|
327
|
-
) {
|
|
328
|
-
const { quantityMinted: quantityToMint, collection, publicClient } = params;
|
|
329
|
-
if (isOnChainMint(params)) {
|
|
330
|
-
const tokenId = is1155Mint(params) ? params.tokenId : undefined;
|
|
331
|
-
const salesConfigAndTokenInfo =
|
|
332
|
-
await params.mintGetter.getSalesConfigAndTokenInfo({
|
|
333
|
-
tokenId,
|
|
334
|
-
tokenAddress: collection,
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
return parseMintCosts({
|
|
338
|
-
salesConfigAndTokenInfo,
|
|
339
|
-
quantityToMint: BigInt(quantityToMint),
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
return getPremintMintCostsWithUnknownTokenPrice({
|
|
344
|
-
premintGetter: params.premintGetter,
|
|
345
|
-
publicClient: publicClient,
|
|
346
|
-
quantityToMint: BigInt(quantityToMint),
|
|
347
|
-
uid: params.uid,
|
|
348
|
-
tokenContract: collection,
|
|
162
|
+
return makeOnchainMintCall({
|
|
163
|
+
mintParams: parameters,
|
|
164
|
+
token: salesConfigAndTokenInfo,
|
|
349
165
|
});
|
|
350
166
|
}
|
|
351
|
-
|
|
352
|
-
export function makePrepareMint1155TokenParams({
|
|
353
|
-
tokenContract: tokenContract,
|
|
354
|
-
tokenId,
|
|
355
|
-
salesConfigAndTokenInfo,
|
|
356
|
-
minterAccount,
|
|
357
|
-
mintComment,
|
|
358
|
-
mintReferral,
|
|
359
|
-
mintRecipient,
|
|
360
|
-
quantityToMint,
|
|
361
|
-
chainId,
|
|
362
|
-
}: {
|
|
363
|
-
salesConfigAndTokenInfo: SalesConfigAndTokenInfo;
|
|
364
|
-
chainId: number;
|
|
365
|
-
tokenId: GenericTokenIdTypes;
|
|
366
|
-
} & Pick<
|
|
367
|
-
MakeMintParametersArgumentsBase,
|
|
368
|
-
| "minterAccount"
|
|
369
|
-
| "tokenContract"
|
|
370
|
-
| "mintComment"
|
|
371
|
-
| "mintReferral"
|
|
372
|
-
| "quantityToMint"
|
|
373
|
-
| "mintRecipient"
|
|
374
|
-
>) {
|
|
375
|
-
const mintQuantity = BigInt(quantityToMint || 1);
|
|
376
|
-
|
|
377
|
-
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
378
|
-
|
|
379
|
-
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
380
|
-
|
|
381
|
-
if (saleType === "fixedPrice") {
|
|
382
|
-
const mintValue = parseMintCosts({
|
|
383
|
-
salesConfigAndTokenInfo,
|
|
384
|
-
quantityToMint: mintQuantity,
|
|
385
|
-
}).totalCostEth;
|
|
386
|
-
|
|
387
|
-
return makeContractParameters({
|
|
388
|
-
abi: zoraCreator1155ImplABI,
|
|
389
|
-
functionName: "mintWithRewards",
|
|
390
|
-
account: minterAccount,
|
|
391
|
-
value: mintValue,
|
|
392
|
-
address: tokenContract,
|
|
393
|
-
/* args: minter, tokenId, quantity, minterArguments, mintReferral */
|
|
394
|
-
args: [
|
|
395
|
-
(salesConfigAndTokenInfo.salesConfig.address ||
|
|
396
|
-
zoraCreatorFixedPriceSaleStrategyAddress[
|
|
397
|
-
chainId as keyof typeof zoraCreatorFixedPriceSaleStrategyAddress
|
|
398
|
-
]) as Address,
|
|
399
|
-
BigInt(tokenId),
|
|
400
|
-
mintQuantity,
|
|
401
|
-
encodeAbiParameters(parseAbiParameters("address, string"), [
|
|
402
|
-
mintTo,
|
|
403
|
-
mintComment || "",
|
|
404
|
-
]),
|
|
405
|
-
mintReferral || zeroAddress,
|
|
406
|
-
],
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (saleType === "erc20") {
|
|
411
|
-
return makeContractParameters({
|
|
412
|
-
abi: erc20MinterABI,
|
|
413
|
-
functionName: "mint",
|
|
414
|
-
account: minterAccount,
|
|
415
|
-
address: (salesConfigAndTokenInfo?.salesConfig.address ||
|
|
416
|
-
erc20MinterAddress[
|
|
417
|
-
chainId as keyof typeof erc20MinterAddress
|
|
418
|
-
]) as Address,
|
|
419
|
-
/* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
|
|
420
|
-
args: [
|
|
421
|
-
mintTo,
|
|
422
|
-
mintQuantity,
|
|
423
|
-
tokenContract,
|
|
424
|
-
BigInt(tokenId),
|
|
425
|
-
salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
|
|
426
|
-
salesConfigAndTokenInfo.salesConfig.currency,
|
|
427
|
-
mintReferral || zeroAddress,
|
|
428
|
-
mintComment || "",
|
|
429
|
-
],
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
throw new MintError("Unsupported sale type");
|
|
434
|
-
}
|