@zoralabs/protocol-sdk 0.5.17 → 0.6.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 +13 -0
- package/README.md +1 -416
- package/dist/create/1155-create-helper.d.ts +16 -55
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-setup.d.ts +14 -0
- package/dist/create/contract-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +27 -0
- package/dist/create/token-setup.d.ts.map +1 -0
- package/dist/create/types.d.ts +45 -0
- package/dist/create/types.d.ts.map +1 -0
- package/dist/index.cjs +1273 -857
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1233 -831
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +4083 -43
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +17 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- package/dist/mint/types.d.ts +79 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +24 -24
- package/dist/premint/contract-types.d.ts +4 -4
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +3 -1
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +27 -14
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +62 -46
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +19 -7
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +43 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/utils.d.ts +17 -6870
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/create/1155-create-helper.test.ts +235 -56
- package/src/create/1155-create-helper.ts +141 -309
- package/src/create/contract-setup.ts +88 -0
- package/src/create/token-setup.ts +379 -0
- package/src/create/types.ts +57 -0
- package/src/index.ts +5 -1
- package/src/mint/mint-client.test.ts +50 -61
- package/src/mint/mint-client.ts +321 -157
- package/src/mint/{mint-api-client.ts → subgraph-mint-getter.ts} +2 -25
- package/src/mint/types.ts +122 -0
- package/src/mints/mints-contracts.test.ts +1 -1
- package/src/mints/mints-contracts.ts +4 -4
- package/src/premint/contract-types.ts +4 -4
- package/src/premint/conversions.ts +12 -2
- package/src/premint/premint-api-client.ts +55 -43
- package/src/premint/premint-client.test.ts +75 -65
- package/src/premint/premint-client.ts +126 -153
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -13
- package/src/sdk.ts +98 -0
- package/src/utils.ts +30 -23
- package/test-integration/premint-client.test.ts +8 -8
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
|
@@ -2,7 +2,6 @@ import { decodeEventLog, zeroAddress } from "viem";
|
|
|
2
2
|
import type {
|
|
3
3
|
Account,
|
|
4
4
|
Address,
|
|
5
|
-
Chain,
|
|
6
5
|
Hex,
|
|
7
6
|
SimulateContractParameters,
|
|
8
7
|
TransactionReceipt,
|
|
@@ -17,7 +16,6 @@ import {
|
|
|
17
16
|
} from "@zoralabs/protocol-deployments";
|
|
18
17
|
import {
|
|
19
18
|
getPremintCollectionAddress,
|
|
20
|
-
isValidSignature,
|
|
21
19
|
isAuthorizedToCreatePremint,
|
|
22
20
|
getPremintExecutorAddress,
|
|
23
21
|
applyUpdateToPremint,
|
|
@@ -36,27 +34,25 @@ import {
|
|
|
36
34
|
TokenCreationConfigV1,
|
|
37
35
|
TokenCreationConfigV2,
|
|
38
36
|
TokenCreationConfig,
|
|
39
|
-
PremintConfigForVersion,
|
|
40
37
|
PremintConfigWithVersion,
|
|
41
38
|
PremintMintArguments,
|
|
42
39
|
premintTypedDataDefinition,
|
|
43
40
|
} from "@zoralabs/protocol-deployments";
|
|
44
|
-
import {
|
|
41
|
+
import { IPremintAPI, IPremintGetter } from "./premint-api-client";
|
|
45
42
|
import type { DecodeEventLogReturnType } from "viem";
|
|
46
43
|
import { OPEN_EDITION_MINT_SIZE } from "../constants";
|
|
47
|
-
import {
|
|
48
|
-
import { getApiNetworkConfigForChain } from "src/mint/mint-api-client";
|
|
44
|
+
import { getApiNetworkConfigForChain } from "src/mint/subgraph-mint-getter";
|
|
49
45
|
import { MintCosts } from "src/mint/mint-client";
|
|
50
46
|
import {
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
makeContractParameters,
|
|
48
|
+
mintRecipientOrAccount,
|
|
53
49
|
PublicClient,
|
|
54
|
-
setupClient,
|
|
55
50
|
} from "src/utils";
|
|
56
51
|
import {
|
|
57
52
|
ContractCreationConfigAndAddress,
|
|
58
53
|
ContractCreationConfigOrAddress,
|
|
59
54
|
} from "./contract-types";
|
|
55
|
+
import { MakePremintMintParametersArguments } from "src/mint/types";
|
|
60
56
|
|
|
61
57
|
type PremintedV2LogType = DecodeEventLogReturnType<
|
|
62
58
|
typeof zoraCreator1155PremintExecutorImplABI,
|
|
@@ -76,7 +72,7 @@ export const defaultTokenConfigV1MintArguments = (): Omit<
|
|
|
76
72
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
77
73
|
maxTokensPerAddress: 0n,
|
|
78
74
|
pricePerToken: 0n,
|
|
79
|
-
mintDuration:
|
|
75
|
+
mintDuration: 0n,
|
|
80
76
|
mintStart: 0n,
|
|
81
77
|
royaltyMintSchedule: 0,
|
|
82
78
|
royaltyBPS: 1000, // 10%,
|
|
@@ -130,20 +126,29 @@ export const defaultTokenConfigV2MintArguments = (): Omit<
|
|
|
130
126
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
131
127
|
maxTokensPerAddress: 0n,
|
|
132
128
|
pricePerToken: 0n,
|
|
133
|
-
mintDuration:
|
|
129
|
+
mintDuration: 0n,
|
|
134
130
|
mintStart: 0n,
|
|
135
131
|
royaltyBPS: 1000, // 10%,
|
|
136
132
|
});
|
|
137
133
|
|
|
138
134
|
type TokenConfigInput = {
|
|
135
|
+
/** Metadata URI of the token to create. */
|
|
139
136
|
tokenURI: string;
|
|
137
|
+
/** Account to receive creator rewards if it's a free mint, and token price value if its a paid mint. Defaults to the premint signing account. */
|
|
140
138
|
payoutRecipient: Address;
|
|
139
|
+
/** Optional: account to receive the create referral award. */
|
|
141
140
|
createReferral?: Address;
|
|
141
|
+
/** Optional: max supply of tokens that can be minted. Defaults to unlimited. */
|
|
142
142
|
maxSupply?: bigint;
|
|
143
|
+
/** Optional: max tokens that can be minted for an address, 0 if unlimited. Defaults to unlimited. */
|
|
143
144
|
maxTokensPerAddress?: bigint;
|
|
145
|
+
/** Optional: price per token, if this is a paid mint. 0 if a free mint. Defaults to 0, or a free mint. */
|
|
144
146
|
pricePerToken?: bigint;
|
|
147
|
+
/** Optional: duration of the mint, starting from the time the premint is brought onchain. 0 for infinite. Defaults to infinite. */
|
|
145
148
|
mintDuration?: bigint;
|
|
149
|
+
/** Optional: earliest time the premint can be brought onchain and minted. 0 for immediately. Defaults to immediately. */
|
|
146
150
|
mintStart?: bigint;
|
|
151
|
+
/** Optional: The royalty amount in basis points for secondary sales, in basis points. Defaults to 1000. */
|
|
147
152
|
royaltyBPS?: number;
|
|
148
153
|
};
|
|
149
154
|
|
|
@@ -209,30 +214,30 @@ export function getPremintedLogFromReceipt(
|
|
|
209
214
|
/**
|
|
210
215
|
* Preminter API to access ZORA Premint functionality.
|
|
211
216
|
*/
|
|
212
|
-
class PremintClient {
|
|
213
|
-
readonly apiClient:
|
|
217
|
+
export class PremintClient {
|
|
218
|
+
readonly apiClient: IPremintAPI;
|
|
214
219
|
readonly publicClient: PublicClient;
|
|
215
|
-
readonly
|
|
220
|
+
readonly chainId: number;
|
|
216
221
|
|
|
217
|
-
constructor(
|
|
218
|
-
|
|
219
|
-
publicClient
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
222
|
+
constructor({
|
|
223
|
+
chainId,
|
|
224
|
+
publicClient,
|
|
225
|
+
premintApi,
|
|
226
|
+
}: {
|
|
227
|
+
chainId: number;
|
|
228
|
+
publicClient: PublicClient;
|
|
229
|
+
premintApi: IPremintAPI;
|
|
230
|
+
}) {
|
|
231
|
+
this.chainId = chainId;
|
|
232
|
+
this.apiClient = premintApi;
|
|
224
233
|
this.publicClient = publicClient;
|
|
225
234
|
}
|
|
226
235
|
|
|
227
|
-
getDataFromPremintReceipt(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
address: premintedLog?.contractAddress,
|
|
233
|
-
tokenId: premintedLog?.tokenId,
|
|
234
|
-
}),
|
|
235
|
-
};
|
|
236
|
+
getDataFromPremintReceipt(
|
|
237
|
+
receipt: TransactionReceipt,
|
|
238
|
+
blockExplorerUrl?: string,
|
|
239
|
+
) {
|
|
240
|
+
return getDataFromPremintReceipt(receipt, this.chainId, blockExplorerUrl);
|
|
236
241
|
}
|
|
237
242
|
|
|
238
243
|
/**
|
|
@@ -246,7 +251,7 @@ class PremintClient {
|
|
|
246
251
|
...args,
|
|
247
252
|
apiClient: this.apiClient,
|
|
248
253
|
publicClient: this.publicClient,
|
|
249
|
-
chainId: this.
|
|
254
|
+
chainId: this.chainId,
|
|
250
255
|
});
|
|
251
256
|
}
|
|
252
257
|
|
|
@@ -263,7 +268,7 @@ class PremintClient {
|
|
|
263
268
|
...params,
|
|
264
269
|
apiClient: this.apiClient,
|
|
265
270
|
publicClient: this.publicClient,
|
|
266
|
-
chainId: this.
|
|
271
|
+
chainId: this.chainId,
|
|
267
272
|
});
|
|
268
273
|
}
|
|
269
274
|
|
|
@@ -280,7 +285,7 @@ class PremintClient {
|
|
|
280
285
|
...parameters,
|
|
281
286
|
publicClient: this.publicClient,
|
|
282
287
|
apiClient: this.apiClient,
|
|
283
|
-
chainId: this.
|
|
288
|
+
chainId: this.chainId,
|
|
284
289
|
});
|
|
285
290
|
}
|
|
286
291
|
|
|
@@ -291,13 +296,7 @@ class PremintClient {
|
|
|
291
296
|
* @param uid UID for the desired premint
|
|
292
297
|
* @returns PremintSignatureGetResponse of premint data from the API
|
|
293
298
|
*/
|
|
294
|
-
async
|
|
295
|
-
address,
|
|
296
|
-
uid,
|
|
297
|
-
}: {
|
|
298
|
-
address: Address;
|
|
299
|
-
uid: number;
|
|
300
|
-
}) {
|
|
299
|
+
async getPremint({ address, uid }: { address: Address; uid: number }) {
|
|
301
300
|
return await this.apiClient.getSignature({
|
|
302
301
|
collectionAddress: address,
|
|
303
302
|
uid,
|
|
@@ -311,65 +310,11 @@ class PremintClient {
|
|
|
311
310
|
*/
|
|
312
311
|
async getCollectionAddress(collection: ContractCreationConfig) {
|
|
313
312
|
return await getPremintCollectionAddress({
|
|
314
|
-
collection,
|
|
313
|
+
contract: collection,
|
|
315
314
|
publicClient: this.publicClient,
|
|
316
315
|
});
|
|
317
316
|
}
|
|
318
317
|
|
|
319
|
-
/**
|
|
320
|
-
* Check user signature for v1
|
|
321
|
-
*
|
|
322
|
-
* @param data Signature data from the API
|
|
323
|
-
* @returns isValid = signature is valid or not, recoveredSigner = signer from contract
|
|
324
|
-
*/
|
|
325
|
-
async isValidSignature<T extends PremintConfigVersion>({
|
|
326
|
-
signature,
|
|
327
|
-
premintConfig,
|
|
328
|
-
premintConfigVersion,
|
|
329
|
-
...collectionAndOrAddress
|
|
330
|
-
}: {
|
|
331
|
-
signature: Hex;
|
|
332
|
-
premintConfig: PremintConfigForVersion<T>;
|
|
333
|
-
premintConfigVersion?: T;
|
|
334
|
-
} & ContractCreationConfigOrAddress): Promise<{
|
|
335
|
-
isValid: boolean;
|
|
336
|
-
recoveredSigner: Address | undefined;
|
|
337
|
-
}> {
|
|
338
|
-
const collectionAddressToUse = await getPremintCollectionAddress({
|
|
339
|
-
...collectionAndOrAddress,
|
|
340
|
-
publicClient: this.publicClient,
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
const { isAuthorized, recoveredAddress } = await isValidSignature({
|
|
344
|
-
chainId: this.chain.id,
|
|
345
|
-
signature: signature as Hex,
|
|
346
|
-
publicClient: this.publicClient,
|
|
347
|
-
premintConfig,
|
|
348
|
-
premintConfigVersion: premintConfigVersion || PremintConfigVersion.V1,
|
|
349
|
-
collectionAddress: collectionAddressToUse,
|
|
350
|
-
collection: collectionAndOrAddress.collection,
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
return { isValid: isAuthorized, recoveredSigner: recoveredAddress };
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
protected makeUrls({
|
|
357
|
-
uid,
|
|
358
|
-
address,
|
|
359
|
-
tokenId,
|
|
360
|
-
}: {
|
|
361
|
-
uid?: number;
|
|
362
|
-
tokenId?: bigint;
|
|
363
|
-
address?: Address;
|
|
364
|
-
}): URLSReturnType {
|
|
365
|
-
return makeUrls({
|
|
366
|
-
uid,
|
|
367
|
-
address,
|
|
368
|
-
tokenId,
|
|
369
|
-
chain: this.chain,
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
|
|
373
318
|
async getMintCosts({
|
|
374
319
|
tokenContract,
|
|
375
320
|
quantityToMint,
|
|
@@ -394,23 +339,50 @@ class PremintClient {
|
|
|
394
339
|
* @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
|
|
395
340
|
* @returns receipt, log, zoraURL
|
|
396
341
|
*/
|
|
397
|
-
async makeMintParameters(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
342
|
+
async makeMintParameters({
|
|
343
|
+
minterAccount,
|
|
344
|
+
tokenContract,
|
|
345
|
+
uid,
|
|
346
|
+
mintArguments,
|
|
347
|
+
firstMinter,
|
|
348
|
+
}: MakeMintParametersArguments) {
|
|
349
|
+
return await collectPremint({
|
|
350
|
+
uid,
|
|
351
|
+
tokenContract,
|
|
352
|
+
minterAccount,
|
|
353
|
+
quantityToMint: mintArguments?.quantityToMint || 1n,
|
|
354
|
+
mintComment: mintArguments?.mintComment,
|
|
355
|
+
mintReferral: mintArguments?.mintReferral,
|
|
356
|
+
mintRecipient: mintArguments?.mintRecipient,
|
|
357
|
+
firstMinter,
|
|
358
|
+
premintGetter: this.apiClient,
|
|
401
359
|
publicClient: this.publicClient,
|
|
402
360
|
});
|
|
403
361
|
}
|
|
404
362
|
}
|
|
405
363
|
|
|
406
|
-
export function
|
|
407
|
-
|
|
408
|
-
|
|
364
|
+
export function getDataFromPremintReceipt(
|
|
365
|
+
receipt: TransactionReceipt,
|
|
366
|
+
chainId: number,
|
|
367
|
+
blockExplorerUrl?: string,
|
|
368
|
+
) {
|
|
369
|
+
const premintedLog = getPremintedLogFromReceipt(receipt);
|
|
370
|
+
return {
|
|
371
|
+
tokenId: premintedLog?.tokenId,
|
|
372
|
+
collectionAddres: premintedLog?.contractAddress,
|
|
373
|
+
premintedLog,
|
|
374
|
+
urls: makeUrls({
|
|
375
|
+
address: premintedLog?.contractAddress,
|
|
376
|
+
tokenId: premintedLog?.tokenId,
|
|
377
|
+
chainId,
|
|
378
|
+
blockExplorerUrl,
|
|
379
|
+
}),
|
|
380
|
+
};
|
|
409
381
|
}
|
|
410
382
|
|
|
411
383
|
type PremintContext = {
|
|
412
384
|
publicClient: PublicClient;
|
|
413
|
-
apiClient:
|
|
385
|
+
apiClient: IPremintAPI;
|
|
414
386
|
chainId: number;
|
|
415
387
|
};
|
|
416
388
|
|
|
@@ -419,11 +391,7 @@ type PremintContext = {
|
|
|
419
391
|
export type SignAndSubmitParams = {
|
|
420
392
|
/** The WalletClient used to sign the premint */
|
|
421
393
|
walletClient: WalletClient;
|
|
422
|
-
|
|
423
|
-
account: Account | Address;
|
|
424
|
-
/** If the signature should be checked before submitting it to the api */
|
|
425
|
-
checkSignature?: boolean;
|
|
426
|
-
};
|
|
394
|
+
} & CheckSignatureParams;
|
|
427
395
|
|
|
428
396
|
export type SignAndSubmitReturn = {
|
|
429
397
|
/** The signature of the Premint */
|
|
@@ -432,14 +400,23 @@ export type SignAndSubmitReturn = {
|
|
|
432
400
|
signerAccount: Account | Address;
|
|
433
401
|
};
|
|
434
402
|
|
|
403
|
+
export type CheckSignatureParams =
|
|
404
|
+
| {
|
|
405
|
+
/** If the premint signature should be validated before submitting to the API */
|
|
406
|
+
checkSignature: true;
|
|
407
|
+
/** Account that signed the premint */
|
|
408
|
+
account: Account | Address;
|
|
409
|
+
}
|
|
410
|
+
| {
|
|
411
|
+
/** If the premint signature should be validated before submitting to the API */
|
|
412
|
+
checkSignature?: false;
|
|
413
|
+
account?: Account | Address;
|
|
414
|
+
};
|
|
415
|
+
|
|
435
416
|
export type SubmitParams = {
|
|
436
417
|
/** The signature of the Premint */
|
|
437
418
|
signature: Hex;
|
|
438
|
-
|
|
439
|
-
checkSignature?: boolean;
|
|
440
|
-
/** The account that signed the premint */
|
|
441
|
-
signerAccount: Account | Address;
|
|
442
|
-
};
|
|
419
|
+
} & CheckSignatureParams;
|
|
443
420
|
|
|
444
421
|
type PremintReturn<T extends PremintConfigVersion> = {
|
|
445
422
|
/** The typedDataDefinition of the Premint which is to be signed the creator. */
|
|
@@ -472,7 +449,7 @@ function makePremintReturn<T extends PremintConfigVersion>({
|
|
|
472
449
|
|
|
473
450
|
const signAndSubmit = async ({
|
|
474
451
|
walletClient,
|
|
475
|
-
account,
|
|
452
|
+
account: account,
|
|
476
453
|
checkSignature,
|
|
477
454
|
}: SignAndSubmitParams): Promise<SignAndSubmitReturn> => {
|
|
478
455
|
const { signature, signerAccount } = await signPremint({
|
|
@@ -484,7 +461,7 @@ function makePremintReturn<T extends PremintConfigVersion>({
|
|
|
484
461
|
await submit({
|
|
485
462
|
signature,
|
|
486
463
|
checkSignature,
|
|
487
|
-
signerAccount,
|
|
464
|
+
account: signerAccount,
|
|
488
465
|
});
|
|
489
466
|
|
|
490
467
|
return {
|
|
@@ -496,19 +473,15 @@ function makePremintReturn<T extends PremintConfigVersion>({
|
|
|
496
473
|
const submit = async ({
|
|
497
474
|
signature,
|
|
498
475
|
checkSignature,
|
|
499
|
-
|
|
500
|
-
}: {
|
|
501
|
-
signature: Hex;
|
|
502
|
-
checkSignature?: boolean;
|
|
503
|
-
signerAccount: Account | Address;
|
|
504
|
-
}) => {
|
|
476
|
+
account,
|
|
477
|
+
}: SubmitParams) => {
|
|
505
478
|
if (checkSignature) {
|
|
506
479
|
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
507
480
|
collectionAddress,
|
|
508
481
|
additionalAdmins: collection?.additionalAdmins,
|
|
509
482
|
contractAdmin: collection?.contractAdmin,
|
|
510
483
|
publicClient,
|
|
511
|
-
signer:
|
|
484
|
+
signer: account,
|
|
512
485
|
});
|
|
513
486
|
|
|
514
487
|
if (!isAuthorized) {
|
|
@@ -568,13 +541,13 @@ async function signPremint({
|
|
|
568
541
|
|
|
569
542
|
type CreatePremintParameters = {
|
|
570
543
|
/** tokenCreationConfig Token creation settings, optional settings are overridden with sensible defaults */
|
|
571
|
-
|
|
544
|
+
token: TokenConfigInput;
|
|
572
545
|
/** uid the UID to use – optional and retrieved as a fresh UID from ZORA by default. */
|
|
573
546
|
uid?: number;
|
|
574
547
|
} & ContractCreationConfigOrAddress;
|
|
575
548
|
|
|
576
549
|
async function createPremint({
|
|
577
|
-
tokenCreationConfig,
|
|
550
|
+
token: tokenCreationConfig,
|
|
578
551
|
uid,
|
|
579
552
|
publicClient,
|
|
580
553
|
apiClient,
|
|
@@ -598,7 +571,7 @@ async function createPremint({
|
|
|
598
571
|
premintConfig,
|
|
599
572
|
premintConfigVersion,
|
|
600
573
|
collectionAddress: collectionAddressToUse,
|
|
601
|
-
collection: collectionOrAddress.
|
|
574
|
+
collection: collectionOrAddress.contract,
|
|
602
575
|
publicClient,
|
|
603
576
|
apiClient,
|
|
604
577
|
chainId,
|
|
@@ -678,7 +651,7 @@ async function updatePremint({
|
|
|
678
651
|
publicClient,
|
|
679
652
|
chainId,
|
|
680
653
|
}: UpdatePremintParams & {
|
|
681
|
-
apiClient:
|
|
654
|
+
apiClient: IPremintAPI;
|
|
682
655
|
publicClient: PublicClient;
|
|
683
656
|
chainId: number;
|
|
684
657
|
}) {
|
|
@@ -725,7 +698,7 @@ async function deletePremint({
|
|
|
725
698
|
apiClient,
|
|
726
699
|
chainId,
|
|
727
700
|
}: DeletePremintParams & {
|
|
728
|
-
apiClient:
|
|
701
|
+
apiClient: IPremintAPI;
|
|
729
702
|
publicClient: PublicClient;
|
|
730
703
|
chainId: number;
|
|
731
704
|
}) {
|
|
@@ -780,47 +753,46 @@ export type MakeMintParametersArguments = {
|
|
|
780
753
|
|
|
781
754
|
/** ======== MINTING ======== */
|
|
782
755
|
|
|
783
|
-
async function
|
|
756
|
+
export async function collectPremint({
|
|
784
757
|
uid,
|
|
785
758
|
tokenContract,
|
|
786
759
|
minterAccount,
|
|
787
|
-
|
|
760
|
+
quantityToMint,
|
|
761
|
+
mintComment = "",
|
|
762
|
+
mintReferral,
|
|
763
|
+
mintRecipient,
|
|
788
764
|
firstMinter,
|
|
789
|
-
|
|
765
|
+
premintGetter,
|
|
790
766
|
publicClient,
|
|
791
|
-
}:
|
|
792
|
-
|
|
767
|
+
}: Omit<MakePremintMintParametersArguments, "mintType"> & {
|
|
768
|
+
premintGetter: IPremintGetter;
|
|
793
769
|
publicClient: PublicClient;
|
|
794
770
|
}): Promise<
|
|
795
771
|
SimulateContractParameters<
|
|
796
772
|
typeof zoraCreator1155PremintExecutorImplABI,
|
|
797
|
-
"
|
|
773
|
+
"premint",
|
|
798
774
|
any,
|
|
799
775
|
any,
|
|
800
776
|
any,
|
|
801
777
|
Account | Address
|
|
802
778
|
>
|
|
803
779
|
> {
|
|
804
|
-
if (
|
|
780
|
+
if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
|
|
805
781
|
throw new Error("Quantity to mint cannot be below 1");
|
|
806
782
|
}
|
|
807
783
|
|
|
808
|
-
if (!minterAccount) {
|
|
809
|
-
throw new Error("Wallet not passed in");
|
|
810
|
-
}
|
|
811
|
-
|
|
812
784
|
const {
|
|
813
785
|
premintConfig,
|
|
814
786
|
premintConfigVersion,
|
|
815
787
|
collection,
|
|
816
788
|
collectionAddress,
|
|
817
789
|
signature,
|
|
818
|
-
} = await
|
|
790
|
+
} = await premintGetter.getSignature({
|
|
819
791
|
collectionAddress: tokenContract,
|
|
820
792
|
uid,
|
|
821
793
|
});
|
|
822
794
|
|
|
823
|
-
const numberToMint = BigInt(
|
|
795
|
+
const numberToMint = BigInt(quantityToMint || 1);
|
|
824
796
|
|
|
825
797
|
if (premintConfigVersion === PremintConfigVersion.V3) {
|
|
826
798
|
throw new Error("PremintV3 not supported in premint SDK");
|
|
@@ -833,17 +805,16 @@ async function makeMintParameters({
|
|
|
833
805
|
publicClient,
|
|
834
806
|
tokenPrice: premintConfig.tokenConfig.pricePerToken,
|
|
835
807
|
})
|
|
836
|
-
).
|
|
808
|
+
).totalCostEth;
|
|
837
809
|
|
|
838
810
|
const mintArgumentsContract: PremintMintArguments = {
|
|
839
|
-
mintComment:
|
|
840
|
-
mintRecipient:
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
: minterAccount.address),
|
|
811
|
+
mintComment: mintComment,
|
|
812
|
+
mintRecipient: mintRecipientOrAccount({
|
|
813
|
+
mintRecipient,
|
|
814
|
+
minterAccount,
|
|
815
|
+
}),
|
|
845
816
|
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
846
|
-
mintReferral
|
|
817
|
+
mintReferral,
|
|
847
818
|
}),
|
|
848
819
|
};
|
|
849
820
|
|
|
@@ -858,7 +829,7 @@ async function makeMintParameters({
|
|
|
858
829
|
firstMinter ||
|
|
859
830
|
(typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
860
831
|
|
|
861
|
-
return
|
|
832
|
+
return makeContractParameters({
|
|
862
833
|
account: minterAccount,
|
|
863
834
|
abi: zoraCreator1155PremintExecutorImplABI,
|
|
864
835
|
functionName: "premint",
|
|
@@ -884,12 +855,14 @@ export function makeUrls({
|
|
|
884
855
|
uid,
|
|
885
856
|
address,
|
|
886
857
|
tokenId,
|
|
887
|
-
|
|
858
|
+
chainId,
|
|
859
|
+
blockExplorerUrl,
|
|
888
860
|
}: {
|
|
889
861
|
uid?: number;
|
|
890
862
|
tokenId?: bigint;
|
|
891
863
|
address?: Address;
|
|
892
|
-
|
|
864
|
+
chainId: number;
|
|
865
|
+
blockExplorerUrl?: string;
|
|
893
866
|
}): URLSReturnType {
|
|
894
867
|
if ((!uid || !tokenId) && !address) {
|
|
895
868
|
return { explorer: null, zoraCollect: null, zoraManage: null };
|
|
@@ -897,11 +870,11 @@ export function makeUrls({
|
|
|
897
870
|
|
|
898
871
|
const zoraTokenPath = uid ? `premint-${uid}` : tokenId;
|
|
899
872
|
|
|
900
|
-
const network = getApiNetworkConfigForChain(
|
|
873
|
+
const network = getApiNetworkConfigForChain(chainId);
|
|
901
874
|
|
|
902
875
|
return {
|
|
903
876
|
explorer: tokenId
|
|
904
|
-
? `https://${
|
|
877
|
+
? `https://${blockExplorerUrl}/token/${address}/instance/${tokenId}`
|
|
905
878
|
: null,
|
|
906
879
|
zoraCollect: `https://${
|
|
907
880
|
network.isTestnet ? "testnet." : ""
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Address,
|
|
3
|
-
Hex,
|
|
4
3
|
hashTypedData,
|
|
5
4
|
keccak256,
|
|
6
5
|
stringToBytes,
|
|
@@ -379,7 +378,7 @@ describe("ZoraCreator1155Preminter", () => {
|
|
|
379
378
|
tokenContract: contractAddress,
|
|
380
379
|
tokenPrice: premintConfig1.tokenConfig.pricePerToken,
|
|
381
380
|
})
|
|
382
|
-
).
|
|
381
|
+
).totalCostEth;
|
|
383
382
|
|
|
384
383
|
await viemClients.testClient.setBalance({
|
|
385
384
|
address: collectorAccount,
|
|
@@ -488,7 +487,7 @@ describe("ZoraCreator1155Preminter", () => {
|
|
|
488
487
|
tokenContract: contractAddress,
|
|
489
488
|
tokenPrice: premintConfig2.tokenConfig.pricePerToken,
|
|
490
489
|
})
|
|
491
|
-
).
|
|
490
|
+
).totalCostEth;
|
|
492
491
|
|
|
493
492
|
const simulationResult = await viemClients.publicClient.simulateContract({
|
|
494
493
|
abi: preminterAbi,
|
|
@@ -630,7 +629,7 @@ describe("ZoraCreator1155Preminter", () => {
|
|
|
630
629
|
tokenContract: contractAddress,
|
|
631
630
|
tokenPrice: premintConfig.tokenConfig.pricePerToken,
|
|
632
631
|
})
|
|
633
|
-
).
|
|
632
|
+
).totalCostEth;
|
|
634
633
|
|
|
635
634
|
await viemClients.testClient.setBalance({
|
|
636
635
|
address: collectorAccount,
|
|
@@ -752,7 +751,7 @@ describe("ZoraCreator1155Preminter", () => {
|
|
|
752
751
|
tokenContract: contractAddress,
|
|
753
752
|
tokenPrice: premintConfig.tokenConfig.pricePerToken,
|
|
754
753
|
})
|
|
755
|
-
).
|
|
754
|
+
).totalCostEth;
|
|
756
755
|
|
|
757
756
|
const mintArguments: PremintMintArguments = {
|
|
758
757
|
mintComment: "",
|