@zoralabs/protocol-sdk 0.5.17 → 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 +19 -0
- package/README.md +1 -416
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- 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 +1745 -891
- 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 +1698 -858
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +48 -51
- 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 +24 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- 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 +177 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mint/utils.d.ts +2 -0
- package/dist/mint/utils.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +27 -4518
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- 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 +15 -16
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +32 -16
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +76 -50
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +20 -8
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +45 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -6869
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/constants.ts +0 -36
- package/src/create/1155-create-helper.test.ts +236 -55
- 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 +116 -78
- package/src/mint/mint-client.ts +130 -234
- package/src/mint/mint-queries.ts +320 -0
- package/src/mint/mint-transactions.ts +253 -0
- package/src/mint/subgraph-mint-getter.ts +247 -0
- package/src/mint/subgraph-queries.ts +170 -0
- package/src/mint/types.ts +239 -0
- package/src/mint/utils.ts +14 -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 +38 -4
- package/src/premint/premint-api-client.ts +92 -48
- package/src/premint/premint-client.test.ts +100 -84
- package/src/premint/premint-client.ts +186 -185
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -14
- package/src/sdk.ts +101 -0
- package/src/types.ts +18 -0
- package/src/utils.ts +54 -46
- package/test-integration/setup-test-contracts.ts +96 -0
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
- package/src/mint/mint-api-client.ts +0 -177
- package/test-integration/premint-client.test.ts +0 -148
|
@@ -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,
|
|
@@ -29,6 +27,7 @@ import {
|
|
|
29
27
|
emptyContractCreationConfig,
|
|
30
28
|
defaultAdditionalAdmins,
|
|
31
29
|
toContractCreationConfigOrAddress,
|
|
30
|
+
getPremintMintFee,
|
|
32
31
|
} from "./preminter";
|
|
33
32
|
import {
|
|
34
33
|
PremintConfigVersion,
|
|
@@ -36,27 +35,30 @@ import {
|
|
|
36
35
|
TokenCreationConfigV1,
|
|
37
36
|
TokenCreationConfigV2,
|
|
38
37
|
TokenCreationConfig,
|
|
39
|
-
PremintConfigForVersion,
|
|
40
38
|
PremintConfigWithVersion,
|
|
41
39
|
PremintMintArguments,
|
|
42
40
|
premintTypedDataDefinition,
|
|
43
41
|
} from "@zoralabs/protocol-deployments";
|
|
44
|
-
import {
|
|
42
|
+
import { IPremintAPI, IPremintGetter } from "./premint-api-client";
|
|
45
43
|
import type { DecodeEventLogReturnType } from "viem";
|
|
46
44
|
import { OPEN_EDITION_MINT_SIZE } from "../constants";
|
|
47
|
-
import {
|
|
48
|
-
import { getApiNetworkConfigForChain } from "src/mint/mint-api-client";
|
|
49
|
-
import { MintCosts } from "src/mint/mint-client";
|
|
45
|
+
import { getApiNetworkConfigForChain } from "src/mint/subgraph-mint-getter";
|
|
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 {
|
|
56
|
+
MakeMintParametersArgumentsBase,
|
|
57
|
+
MakePremintMintParametersArguments,
|
|
58
|
+
MintCosts,
|
|
59
|
+
} from "src/mint/types";
|
|
60
|
+
import { PremintFromApi } from "./conversions";
|
|
61
|
+
import { SimulateContractParametersWithAccount } from "src/types";
|
|
60
62
|
|
|
61
63
|
type PremintedV2LogType = DecodeEventLogReturnType<
|
|
62
64
|
typeof zoraCreator1155PremintExecutorImplABI,
|
|
@@ -76,7 +78,7 @@ export const defaultTokenConfigV1MintArguments = (): Omit<
|
|
|
76
78
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
77
79
|
maxTokensPerAddress: 0n,
|
|
78
80
|
pricePerToken: 0n,
|
|
79
|
-
mintDuration:
|
|
81
|
+
mintDuration: 0n,
|
|
80
82
|
mintStart: 0n,
|
|
81
83
|
royaltyMintSchedule: 0,
|
|
82
84
|
royaltyBPS: 1000, // 10%,
|
|
@@ -130,20 +132,29 @@ export const defaultTokenConfigV2MintArguments = (): Omit<
|
|
|
130
132
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
131
133
|
maxTokensPerAddress: 0n,
|
|
132
134
|
pricePerToken: 0n,
|
|
133
|
-
mintDuration:
|
|
135
|
+
mintDuration: 0n,
|
|
134
136
|
mintStart: 0n,
|
|
135
137
|
royaltyBPS: 1000, // 10%,
|
|
136
138
|
});
|
|
137
139
|
|
|
138
140
|
type TokenConfigInput = {
|
|
141
|
+
/** Metadata URI of the token to create. */
|
|
139
142
|
tokenURI: string;
|
|
143
|
+
/** 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
144
|
payoutRecipient: Address;
|
|
145
|
+
/** Optional: account to receive the create referral award. */
|
|
141
146
|
createReferral?: Address;
|
|
147
|
+
/** Optional: max supply of tokens that can be minted. Defaults to unlimited. */
|
|
142
148
|
maxSupply?: bigint;
|
|
149
|
+
/** Optional: max tokens that can be minted for an address, 0 if unlimited. Defaults to unlimited. */
|
|
143
150
|
maxTokensPerAddress?: bigint;
|
|
151
|
+
/** Optional: price per token, if this is a paid mint. 0 if a free mint. Defaults to 0, or a free mint. */
|
|
144
152
|
pricePerToken?: bigint;
|
|
153
|
+
/** Optional: duration of the mint, starting from the time the premint is brought onchain. 0 for infinite. Defaults to infinite. */
|
|
145
154
|
mintDuration?: bigint;
|
|
155
|
+
/** Optional: earliest time the premint can be brought onchain and minted. 0 for immediately. Defaults to immediately. */
|
|
146
156
|
mintStart?: bigint;
|
|
157
|
+
/** Optional: The royalty amount in basis points for secondary sales, in basis points. Defaults to 1000. */
|
|
147
158
|
royaltyBPS?: number;
|
|
148
159
|
};
|
|
149
160
|
|
|
@@ -209,30 +220,30 @@ export function getPremintedLogFromReceipt(
|
|
|
209
220
|
/**
|
|
210
221
|
* Preminter API to access ZORA Premint functionality.
|
|
211
222
|
*/
|
|
212
|
-
class PremintClient {
|
|
213
|
-
readonly apiClient:
|
|
223
|
+
export class PremintClient {
|
|
224
|
+
readonly apiClient: IPremintAPI;
|
|
214
225
|
readonly publicClient: PublicClient;
|
|
215
|
-
readonly
|
|
226
|
+
readonly chainId: number;
|
|
216
227
|
|
|
217
|
-
constructor(
|
|
218
|
-
|
|
219
|
-
publicClient
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
228
|
+
constructor({
|
|
229
|
+
chainId,
|
|
230
|
+
publicClient,
|
|
231
|
+
premintApi,
|
|
232
|
+
}: {
|
|
233
|
+
chainId: number;
|
|
234
|
+
publicClient: PublicClient;
|
|
235
|
+
premintApi: IPremintAPI;
|
|
236
|
+
}) {
|
|
237
|
+
this.chainId = chainId;
|
|
238
|
+
this.apiClient = premintApi;
|
|
224
239
|
this.publicClient = publicClient;
|
|
225
240
|
}
|
|
226
241
|
|
|
227
|
-
getDataFromPremintReceipt(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
address: premintedLog?.contractAddress,
|
|
233
|
-
tokenId: premintedLog?.tokenId,
|
|
234
|
-
}),
|
|
235
|
-
};
|
|
242
|
+
getDataFromPremintReceipt(
|
|
243
|
+
receipt: TransactionReceipt,
|
|
244
|
+
blockExplorerUrl?: string,
|
|
245
|
+
) {
|
|
246
|
+
return getDataFromPremintReceipt(receipt, this.chainId, blockExplorerUrl);
|
|
236
247
|
}
|
|
237
248
|
|
|
238
249
|
/**
|
|
@@ -246,7 +257,7 @@ class PremintClient {
|
|
|
246
257
|
...args,
|
|
247
258
|
apiClient: this.apiClient,
|
|
248
259
|
publicClient: this.publicClient,
|
|
249
|
-
chainId: this.
|
|
260
|
+
chainId: this.chainId,
|
|
250
261
|
});
|
|
251
262
|
}
|
|
252
263
|
|
|
@@ -263,7 +274,7 @@ class PremintClient {
|
|
|
263
274
|
...params,
|
|
264
275
|
apiClient: this.apiClient,
|
|
265
276
|
publicClient: this.publicClient,
|
|
266
|
-
chainId: this.
|
|
277
|
+
chainId: this.chainId,
|
|
267
278
|
});
|
|
268
279
|
}
|
|
269
280
|
|
|
@@ -280,7 +291,7 @@ class PremintClient {
|
|
|
280
291
|
...parameters,
|
|
281
292
|
publicClient: this.publicClient,
|
|
282
293
|
apiClient: this.apiClient,
|
|
283
|
-
chainId: this.
|
|
294
|
+
chainId: this.chainId,
|
|
284
295
|
});
|
|
285
296
|
}
|
|
286
297
|
|
|
@@ -291,14 +302,8 @@ class PremintClient {
|
|
|
291
302
|
* @param uid UID for the desired premint
|
|
292
303
|
* @returns PremintSignatureGetResponse of premint data from the API
|
|
293
304
|
*/
|
|
294
|
-
async
|
|
295
|
-
|
|
296
|
-
uid,
|
|
297
|
-
}: {
|
|
298
|
-
address: Address;
|
|
299
|
-
uid: number;
|
|
300
|
-
}) {
|
|
301
|
-
return await this.apiClient.getSignature({
|
|
305
|
+
async getPremint({ address, uid }: { address: Address; uid: number }) {
|
|
306
|
+
return await this.apiClient.get({
|
|
302
307
|
collectionAddress: address,
|
|
303
308
|
uid,
|
|
304
309
|
});
|
|
@@ -311,65 +316,11 @@ class PremintClient {
|
|
|
311
316
|
*/
|
|
312
317
|
async getCollectionAddress(collection: ContractCreationConfig) {
|
|
313
318
|
return await getPremintCollectionAddress({
|
|
314
|
-
collection,
|
|
319
|
+
contract: collection,
|
|
315
320
|
publicClient: this.publicClient,
|
|
316
321
|
});
|
|
317
322
|
}
|
|
318
323
|
|
|
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
324
|
async getMintCosts({
|
|
374
325
|
tokenContract,
|
|
375
326
|
quantityToMint,
|
|
@@ -394,23 +345,50 @@ class PremintClient {
|
|
|
394
345
|
* @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
|
|
395
346
|
* @returns receipt, log, zoraURL
|
|
396
347
|
*/
|
|
397
|
-
async makeMintParameters(
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
348
|
+
async makeMintParameters({
|
|
349
|
+
minterAccount,
|
|
350
|
+
tokenContract,
|
|
351
|
+
uid,
|
|
352
|
+
mintArguments,
|
|
353
|
+
firstMinter,
|
|
354
|
+
}: MakeMintParametersArguments) {
|
|
355
|
+
return await collectPremint({
|
|
356
|
+
uid,
|
|
357
|
+
tokenContract,
|
|
358
|
+
minterAccount,
|
|
359
|
+
quantityToMint: mintArguments?.quantityToMint || 1n,
|
|
360
|
+
mintComment: mintArguments?.mintComment,
|
|
361
|
+
mintReferral: mintArguments?.mintReferral,
|
|
362
|
+
mintRecipient: mintArguments?.mintRecipient,
|
|
363
|
+
firstMinter,
|
|
364
|
+
premintGetter: this.apiClient,
|
|
401
365
|
publicClient: this.publicClient,
|
|
402
366
|
});
|
|
403
367
|
}
|
|
404
368
|
}
|
|
405
369
|
|
|
406
|
-
export function
|
|
407
|
-
|
|
408
|
-
|
|
370
|
+
export function getDataFromPremintReceipt(
|
|
371
|
+
receipt: TransactionReceipt,
|
|
372
|
+
chainId: number,
|
|
373
|
+
blockExplorerUrl?: string,
|
|
374
|
+
) {
|
|
375
|
+
const premintedLog = getPremintedLogFromReceipt(receipt);
|
|
376
|
+
return {
|
|
377
|
+
tokenId: premintedLog?.tokenId,
|
|
378
|
+
collectionAddres: premintedLog?.contractAddress,
|
|
379
|
+
premintedLog,
|
|
380
|
+
urls: makeUrls({
|
|
381
|
+
address: premintedLog?.contractAddress,
|
|
382
|
+
tokenId: premintedLog?.tokenId,
|
|
383
|
+
chainId,
|
|
384
|
+
blockExplorerUrl,
|
|
385
|
+
}),
|
|
386
|
+
};
|
|
409
387
|
}
|
|
410
388
|
|
|
411
389
|
type PremintContext = {
|
|
412
390
|
publicClient: PublicClient;
|
|
413
|
-
apiClient:
|
|
391
|
+
apiClient: IPremintAPI;
|
|
414
392
|
chainId: number;
|
|
415
393
|
};
|
|
416
394
|
|
|
@@ -419,11 +397,7 @@ type PremintContext = {
|
|
|
419
397
|
export type SignAndSubmitParams = {
|
|
420
398
|
/** The WalletClient used to sign the premint */
|
|
421
399
|
walletClient: WalletClient;
|
|
422
|
-
|
|
423
|
-
account: Account | Address;
|
|
424
|
-
/** If the signature should be checked before submitting it to the api */
|
|
425
|
-
checkSignature?: boolean;
|
|
426
|
-
};
|
|
400
|
+
} & CheckSignatureParams;
|
|
427
401
|
|
|
428
402
|
export type SignAndSubmitReturn = {
|
|
429
403
|
/** The signature of the Premint */
|
|
@@ -432,14 +406,23 @@ export type SignAndSubmitReturn = {
|
|
|
432
406
|
signerAccount: Account | Address;
|
|
433
407
|
};
|
|
434
408
|
|
|
409
|
+
export type CheckSignatureParams =
|
|
410
|
+
| {
|
|
411
|
+
/** If the premint signature should be validated before submitting to the API */
|
|
412
|
+
checkSignature: true;
|
|
413
|
+
/** Account that signed the premint */
|
|
414
|
+
account: Account | Address;
|
|
415
|
+
}
|
|
416
|
+
| {
|
|
417
|
+
/** If the premint signature should be validated before submitting to the API */
|
|
418
|
+
checkSignature?: false;
|
|
419
|
+
account?: Account | Address;
|
|
420
|
+
};
|
|
421
|
+
|
|
435
422
|
export type SubmitParams = {
|
|
436
423
|
/** The signature of the Premint */
|
|
437
424
|
signature: Hex;
|
|
438
|
-
|
|
439
|
-
checkSignature?: boolean;
|
|
440
|
-
/** The account that signed the premint */
|
|
441
|
-
signerAccount: Account | Address;
|
|
442
|
-
};
|
|
425
|
+
} & CheckSignatureParams;
|
|
443
426
|
|
|
444
427
|
type PremintReturn<T extends PremintConfigVersion> = {
|
|
445
428
|
/** The typedDataDefinition of the Premint which is to be signed the creator. */
|
|
@@ -449,7 +432,7 @@ type PremintReturn<T extends PremintConfigVersion> = {
|
|
|
449
432
|
/** Signs the Premint, and submits it and the signature to the Zora Premint API */
|
|
450
433
|
signAndSubmit: (params: SignAndSubmitParams) => Promise<SignAndSubmitReturn>;
|
|
451
434
|
/** For the case where the premint is signed externally, takes the signature for the Premint, and submits it and the Premint to the Zora Premint API */
|
|
452
|
-
submit: (params: SubmitParams) => void
|
|
435
|
+
submit: (params: SubmitParams) => Promise<void>;
|
|
453
436
|
} & PremintConfigWithVersion<T>;
|
|
454
437
|
|
|
455
438
|
function makePremintReturn<T extends PremintConfigVersion>({
|
|
@@ -472,7 +455,7 @@ function makePremintReturn<T extends PremintConfigVersion>({
|
|
|
472
455
|
|
|
473
456
|
const signAndSubmit = async ({
|
|
474
457
|
walletClient,
|
|
475
|
-
account,
|
|
458
|
+
account: account,
|
|
476
459
|
checkSignature,
|
|
477
460
|
}: SignAndSubmitParams): Promise<SignAndSubmitReturn> => {
|
|
478
461
|
const { signature, signerAccount } = await signPremint({
|
|
@@ -484,7 +467,7 @@ function makePremintReturn<T extends PremintConfigVersion>({
|
|
|
484
467
|
await submit({
|
|
485
468
|
signature,
|
|
486
469
|
checkSignature,
|
|
487
|
-
signerAccount,
|
|
470
|
+
account: signerAccount,
|
|
488
471
|
});
|
|
489
472
|
|
|
490
473
|
return {
|
|
@@ -496,19 +479,15 @@ function makePremintReturn<T extends PremintConfigVersion>({
|
|
|
496
479
|
const submit = async ({
|
|
497
480
|
signature,
|
|
498
481
|
checkSignature,
|
|
499
|
-
|
|
500
|
-
}: {
|
|
501
|
-
signature: Hex;
|
|
502
|
-
checkSignature?: boolean;
|
|
503
|
-
signerAccount: Account | Address;
|
|
504
|
-
}) => {
|
|
482
|
+
account,
|
|
483
|
+
}: SubmitParams) => {
|
|
505
484
|
if (checkSignature) {
|
|
506
485
|
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
507
486
|
collectionAddress,
|
|
508
487
|
additionalAdmins: collection?.additionalAdmins,
|
|
509
488
|
contractAdmin: collection?.contractAdmin,
|
|
510
489
|
publicClient,
|
|
511
|
-
signer:
|
|
490
|
+
signer: account,
|
|
512
491
|
});
|
|
513
492
|
|
|
514
493
|
if (!isAuthorized) {
|
|
@@ -568,13 +547,13 @@ async function signPremint({
|
|
|
568
547
|
|
|
569
548
|
type CreatePremintParameters = {
|
|
570
549
|
/** tokenCreationConfig Token creation settings, optional settings are overridden with sensible defaults */
|
|
571
|
-
|
|
550
|
+
token: TokenConfigInput;
|
|
572
551
|
/** uid the UID to use – optional and retrieved as a fresh UID from ZORA by default. */
|
|
573
552
|
uid?: number;
|
|
574
553
|
} & ContractCreationConfigOrAddress;
|
|
575
554
|
|
|
576
555
|
async function createPremint({
|
|
577
|
-
tokenCreationConfig,
|
|
556
|
+
token: tokenCreationConfig,
|
|
578
557
|
uid,
|
|
579
558
|
publicClient,
|
|
580
559
|
apiClient,
|
|
@@ -598,7 +577,7 @@ async function createPremint({
|
|
|
598
577
|
premintConfig,
|
|
599
578
|
premintConfigVersion,
|
|
600
579
|
collectionAddress: collectionAddressToUse,
|
|
601
|
-
collection: collectionOrAddress.
|
|
580
|
+
collection: collectionOrAddress.contract,
|
|
602
581
|
publicClient,
|
|
603
582
|
apiClient,
|
|
604
583
|
chainId,
|
|
@@ -678,15 +657,14 @@ async function updatePremint({
|
|
|
678
657
|
publicClient,
|
|
679
658
|
chainId,
|
|
680
659
|
}: UpdatePremintParams & {
|
|
681
|
-
apiClient:
|
|
660
|
+
apiClient: IPremintAPI;
|
|
682
661
|
publicClient: PublicClient;
|
|
683
662
|
chainId: number;
|
|
684
663
|
}) {
|
|
685
664
|
const {
|
|
686
|
-
premintConfig,
|
|
665
|
+
premint: { premintConfig, premintConfigVersion },
|
|
687
666
|
collection: collectionCreationConfig,
|
|
688
|
-
|
|
689
|
-
} = await apiClient.getSignature({
|
|
667
|
+
} = await apiClient.get({
|
|
690
668
|
collectionAddress: collection,
|
|
691
669
|
uid: uid,
|
|
692
670
|
});
|
|
@@ -725,16 +703,15 @@ async function deletePremint({
|
|
|
725
703
|
apiClient,
|
|
726
704
|
chainId,
|
|
727
705
|
}: DeletePremintParams & {
|
|
728
|
-
apiClient:
|
|
706
|
+
apiClient: IPremintAPI;
|
|
729
707
|
publicClient: PublicClient;
|
|
730
708
|
chainId: number;
|
|
731
709
|
}) {
|
|
732
710
|
const {
|
|
733
|
-
premintConfig,
|
|
734
|
-
premintConfigVersion,
|
|
711
|
+
premint: { premintConfig, premintConfigVersion },
|
|
735
712
|
collection: collectionCreationConfig,
|
|
736
713
|
collectionAddress,
|
|
737
|
-
} = await apiClient.
|
|
714
|
+
} = await apiClient.get({
|
|
738
715
|
collectionAddress: collection,
|
|
739
716
|
uid: uid,
|
|
740
717
|
});
|
|
@@ -780,70 +757,87 @@ export type MakeMintParametersArguments = {
|
|
|
780
757
|
|
|
781
758
|
/** ======== MINTING ======== */
|
|
782
759
|
|
|
783
|
-
async function
|
|
760
|
+
export async function collectPremint({
|
|
784
761
|
uid,
|
|
785
762
|
tokenContract,
|
|
786
763
|
minterAccount,
|
|
787
|
-
|
|
764
|
+
quantityToMint,
|
|
765
|
+
mintComment = "",
|
|
766
|
+
mintReferral,
|
|
767
|
+
mintRecipient,
|
|
788
768
|
firstMinter,
|
|
789
|
-
|
|
769
|
+
premintGetter,
|
|
790
770
|
publicClient,
|
|
791
|
-
}:
|
|
792
|
-
|
|
771
|
+
}: Omit<MakePremintMintParametersArguments, "mintType"> & {
|
|
772
|
+
premintGetter: IPremintGetter;
|
|
793
773
|
publicClient: PublicClient;
|
|
794
774
|
}): Promise<
|
|
795
775
|
SimulateContractParameters<
|
|
796
776
|
typeof zoraCreator1155PremintExecutorImplABI,
|
|
797
|
-
"
|
|
777
|
+
"premint",
|
|
798
778
|
any,
|
|
799
779
|
any,
|
|
800
780
|
any,
|
|
801
781
|
Account | Address
|
|
802
782
|
>
|
|
803
783
|
> {
|
|
804
|
-
if (
|
|
784
|
+
if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
|
|
805
785
|
throw new Error("Quantity to mint cannot be below 1");
|
|
806
786
|
}
|
|
807
787
|
|
|
808
|
-
|
|
809
|
-
throw new Error("Wallet not passed in");
|
|
810
|
-
}
|
|
811
|
-
|
|
812
|
-
const {
|
|
813
|
-
premintConfig,
|
|
814
|
-
premintConfigVersion,
|
|
815
|
-
collection,
|
|
816
|
-
collectionAddress,
|
|
817
|
-
signature,
|
|
818
|
-
} = await apiClient.getSignature({
|
|
788
|
+
const premint = await premintGetter.get({
|
|
819
789
|
collectionAddress: tokenContract,
|
|
820
790
|
uid,
|
|
821
791
|
});
|
|
822
792
|
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
793
|
+
const mintFee = await getPremintMintFee({
|
|
794
|
+
tokenContract,
|
|
795
|
+
publicClient,
|
|
796
|
+
});
|
|
828
797
|
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
quantityToMint
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
798
|
+
return buildPremintMintCall({
|
|
799
|
+
mintArguments: {
|
|
800
|
+
minterAccount,
|
|
801
|
+
quantityToMint,
|
|
802
|
+
firstMinter,
|
|
803
|
+
mintComment,
|
|
804
|
+
mintRecipient,
|
|
805
|
+
mintReferral,
|
|
806
|
+
},
|
|
807
|
+
mintFee,
|
|
808
|
+
premint,
|
|
809
|
+
});
|
|
810
|
+
}
|
|
837
811
|
|
|
812
|
+
export const buildPremintMintCall = ({
|
|
813
|
+
mintArguments: {
|
|
814
|
+
minterAccount,
|
|
815
|
+
mintComment = "",
|
|
816
|
+
mintRecipient,
|
|
817
|
+
mintReferral,
|
|
818
|
+
firstMinter,
|
|
819
|
+
quantityToMint,
|
|
820
|
+
},
|
|
821
|
+
premint: { collection, collectionAddress, premint, signature },
|
|
822
|
+
mintFee,
|
|
823
|
+
}: {
|
|
824
|
+
mintArguments: Omit<MakeMintParametersArgumentsBase, "tokenContract"> & {
|
|
825
|
+
firstMinter?: Address;
|
|
826
|
+
};
|
|
827
|
+
premint: Pick<
|
|
828
|
+
PremintFromApi,
|
|
829
|
+
"collection" | "collectionAddress" | "premint" | "signature"
|
|
830
|
+
>;
|
|
831
|
+
mintFee: bigint;
|
|
832
|
+
}): SimulateContractParametersWithAccount => {
|
|
838
833
|
const mintArgumentsContract: PremintMintArguments = {
|
|
839
|
-
mintComment:
|
|
840
|
-
mintRecipient:
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
: minterAccount.address),
|
|
834
|
+
mintComment: mintComment,
|
|
835
|
+
mintRecipient: mintRecipientOrAccount({
|
|
836
|
+
mintRecipient,
|
|
837
|
+
minterAccount,
|
|
838
|
+
}),
|
|
845
839
|
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
846
|
-
mintReferral
|
|
840
|
+
mintReferral,
|
|
847
841
|
}),
|
|
848
842
|
};
|
|
849
843
|
|
|
@@ -858,7 +852,15 @@ async function makeMintParameters({
|
|
|
858
852
|
firstMinter ||
|
|
859
853
|
(typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
860
854
|
|
|
861
|
-
|
|
855
|
+
if (premint.premintConfigVersion === PremintConfigVersion.V3) {
|
|
856
|
+
throw new Error("PremintV3 not supported in premint SDK");
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
const value =
|
|
860
|
+
(mintFee + premint.premintConfig.tokenConfig.pricePerToken) *
|
|
861
|
+
BigInt(quantityToMint);
|
|
862
|
+
|
|
863
|
+
return makeContractParameters({
|
|
862
864
|
account: minterAccount,
|
|
863
865
|
abi: zoraCreator1155PremintExecutorImplABI,
|
|
864
866
|
functionName: "premint",
|
|
@@ -867,29 +869,28 @@ async function makeMintParameters({
|
|
|
867
869
|
args: [
|
|
868
870
|
collectionOrEmpty,
|
|
869
871
|
collectionAddressToSubmit,
|
|
870
|
-
encodePremintConfig(
|
|
871
|
-
premintConfig,
|
|
872
|
-
premintConfigVersion,
|
|
873
|
-
}),
|
|
872
|
+
encodePremintConfig(premint),
|
|
874
873
|
signature,
|
|
875
|
-
|
|
874
|
+
BigInt(quantityToMint),
|
|
876
875
|
mintArgumentsContract,
|
|
877
876
|
firstMinterToSubmit,
|
|
878
877
|
zeroAddress,
|
|
879
878
|
],
|
|
880
879
|
});
|
|
881
|
-
}
|
|
880
|
+
};
|
|
882
881
|
|
|
883
882
|
export function makeUrls({
|
|
884
883
|
uid,
|
|
885
884
|
address,
|
|
886
885
|
tokenId,
|
|
887
|
-
|
|
886
|
+
chainId,
|
|
887
|
+
blockExplorerUrl,
|
|
888
888
|
}: {
|
|
889
889
|
uid?: number;
|
|
890
890
|
tokenId?: bigint;
|
|
891
891
|
address?: Address;
|
|
892
|
-
|
|
892
|
+
chainId: number;
|
|
893
|
+
blockExplorerUrl?: string;
|
|
893
894
|
}): URLSReturnType {
|
|
894
895
|
if ((!uid || !tokenId) && !address) {
|
|
895
896
|
return { explorer: null, zoraCollect: null, zoraManage: null };
|
|
@@ -897,11 +898,11 @@ export function makeUrls({
|
|
|
897
898
|
|
|
898
899
|
const zoraTokenPath = uid ? `premint-${uid}` : tokenId;
|
|
899
900
|
|
|
900
|
-
const network = getApiNetworkConfigForChain(
|
|
901
|
+
const network = getApiNetworkConfigForChain(chainId);
|
|
901
902
|
|
|
902
903
|
return {
|
|
903
904
|
explorer: tokenId
|
|
904
|
-
? `https://${
|
|
905
|
+
? `https://${blockExplorerUrl}/token/${address}/instance/${tokenId}`
|
|
905
906
|
: null,
|
|
906
907
|
zoraCollect: `https://${
|
|
907
908
|
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: "",
|