@zoralabs/protocol-sdk 0.5.14 → 0.5.16
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 +15 -0
- package/README.md +42 -2
- package/dist/anvil.d.ts +4 -4
- package/dist/anvil.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +3 -4
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/index.cjs +534 -375
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +517 -356
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-api-client.d.ts +14 -6
- package/dist/mint/mint-api-client.d.ts.map +1 -1
- package/dist/mint/mint-client.d.ts +25 -19
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mints/mints-contracts.d.ts +688 -3
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +111 -1465
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +2 -1
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/utils.d.ts +6872 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/constants.ts +36 -0
- package/src/create/1155-create-helper.test.ts +10 -3
- package/src/create/1155-create-helper.ts +8 -7
- package/src/mint/mint-api-client.ts +107 -45
- package/src/mint/mint-client.test.ts +113 -2
- package/src/mint/mint-client.ts +95 -53
- package/src/premint/premint-client.test.ts +16 -10
- package/src/premint/premint-client.ts +566 -374
- package/src/premint/preminter.ts +3 -1
- package/src/utils.ts +25 -0
- package/test-integration/premint-client.test.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -61,6 +61,7 @@ __export(src_exports, {
|
|
|
61
61
|
makePermitToCollectPremintOrNonPremint: () => makePermitToCollectPremintOrNonPremint,
|
|
62
62
|
makePermitTransferBatchAndTypeData: () => makePermitTransferBatchAndTypeData,
|
|
63
63
|
makePermitTransferTypeData: () => makePermitTransferTypeData,
|
|
64
|
+
makeUrls: () => makeUrls,
|
|
64
65
|
migratePremintConfigToV2: () => migratePremintConfigToV2,
|
|
65
66
|
mintWithEthParams: () => mintWithEthParams,
|
|
66
67
|
mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
|
|
@@ -76,7 +77,7 @@ __export(src_exports, {
|
|
|
76
77
|
module.exports = __toCommonJS(src_exports);
|
|
77
78
|
|
|
78
79
|
// src/premint/premint-client.ts
|
|
79
|
-
var
|
|
80
|
+
var import_viem5 = require("viem");
|
|
80
81
|
var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
|
|
81
82
|
|
|
82
83
|
// src/premint/preminter.ts
|
|
@@ -89,6 +90,8 @@ async function isAuthorizedToCreatePremint({
|
|
|
89
90
|
publicClient,
|
|
90
91
|
signer
|
|
91
92
|
}) {
|
|
93
|
+
if (collection.additionalAdmins.length > 0)
|
|
94
|
+
throw new Error("additionalAdmins not supported yet.");
|
|
92
95
|
return await publicClient.readContract({
|
|
93
96
|
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
94
97
|
address: getPremintExecutorAddress(),
|
|
@@ -391,6 +394,41 @@ var zora721Abi = (0, import_viem2.parseAbi)([
|
|
|
391
394
|
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
392
395
|
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
393
396
|
]);
|
|
397
|
+
var NFT_SALE_QUERY = `
|
|
398
|
+
fragment SaleStrategy on SalesStrategyConfig {
|
|
399
|
+
type
|
|
400
|
+
fixedPrice {
|
|
401
|
+
address
|
|
402
|
+
pricePerToken
|
|
403
|
+
saleEnd
|
|
404
|
+
saleStart
|
|
405
|
+
maxTokensPerAddress
|
|
406
|
+
}
|
|
407
|
+
erc20Minter {
|
|
408
|
+
address
|
|
409
|
+
pricePerToken
|
|
410
|
+
currency
|
|
411
|
+
saleEnd
|
|
412
|
+
saleStart
|
|
413
|
+
maxTokensPerAddress
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
query ($id: ID!) {
|
|
418
|
+
zoraCreateToken(id: $id) {
|
|
419
|
+
id
|
|
420
|
+
contract {
|
|
421
|
+
mintFeePerQuantity
|
|
422
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
423
|
+
...SaleStrategy
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
427
|
+
...SaleStrategy
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
`;
|
|
394
432
|
|
|
395
433
|
// src/apis/chain-constants.ts
|
|
396
434
|
var import_chains = require("viem/chains");
|
|
@@ -476,38 +514,13 @@ var MintAPIClient = class {
|
|
|
476
514
|
}
|
|
477
515
|
async getSalesConfigAndTokenInfo({
|
|
478
516
|
tokenAddress,
|
|
479
|
-
tokenId
|
|
517
|
+
tokenId,
|
|
518
|
+
saleType
|
|
480
519
|
}) {
|
|
481
520
|
const { retries: retries2, post: post2 } = this.httpClient;
|
|
482
521
|
return retries2(async () => {
|
|
483
522
|
const response = await post2(this.networkConfig.subgraphUrl, {
|
|
484
|
-
query:
|
|
485
|
-
fragment SaleStrategy on SalesStrategyConfig {
|
|
486
|
-
type
|
|
487
|
-
fixedPrice {
|
|
488
|
-
address
|
|
489
|
-
pricePerToken
|
|
490
|
-
saleEnd
|
|
491
|
-
saleStart
|
|
492
|
-
maxTokensPerAddress
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
query ($id: ID!) {
|
|
497
|
-
zoraCreateToken(id: $id) {
|
|
498
|
-
id
|
|
499
|
-
contract {
|
|
500
|
-
mintFeePerQuantity
|
|
501
|
-
salesStrategies(where: { type: "FIXED_PRICE" }) {
|
|
502
|
-
...SaleStrategy
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
salesStrategies(where: { type: "FIXED_PRICE" }) {
|
|
506
|
-
...SaleStrategy
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
`,
|
|
523
|
+
query: NFT_SALE_QUERY,
|
|
511
524
|
variables: {
|
|
512
525
|
id: tokenId !== void 0 ? (
|
|
513
526
|
// Generic Token ID types all stringify down to the base numeric equivalent.
|
|
@@ -519,17 +532,56 @@ var MintAPIClient = class {
|
|
|
519
532
|
if (!token) {
|
|
520
533
|
throw new Error("Cannot find a token to mint");
|
|
521
534
|
}
|
|
522
|
-
const
|
|
523
|
-
const
|
|
524
|
-
(a, b) => BigInt(
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
535
|
+
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
536
|
+
const saleStrategies = allStrategies.sort(
|
|
537
|
+
(a, b) => BigInt(
|
|
538
|
+
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
539
|
+
) > BigInt(
|
|
540
|
+
b.type === "FIXED_PRICE" ? b.fixedPrice.saleEnd : b.erc20Minter.saleEnd
|
|
541
|
+
) ? 1 : -1
|
|
542
|
+
);
|
|
543
|
+
let targetStrategy;
|
|
544
|
+
if (!saleType) {
|
|
545
|
+
targetStrategy = saleStrategies[0];
|
|
546
|
+
if (!targetStrategy) {
|
|
547
|
+
throw new Error("Cannot find sale strategy");
|
|
548
|
+
}
|
|
549
|
+
} else {
|
|
550
|
+
const mappedSaleType = saleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
551
|
+
targetStrategy = saleStrategies.find(
|
|
552
|
+
(strategy) => strategy.type === mappedSaleType
|
|
553
|
+
);
|
|
554
|
+
if (!targetStrategy) {
|
|
555
|
+
throw new Error(`Cannot find sale strategy for ${mappedSaleType}`);
|
|
556
|
+
}
|
|
528
557
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
558
|
+
if (targetStrategy.type === "FIXED_PRICE") {
|
|
559
|
+
return {
|
|
560
|
+
salesConfig: {
|
|
561
|
+
saleType: "fixedPrice",
|
|
562
|
+
...targetStrategy.fixedPrice,
|
|
563
|
+
maxTokensPerAddress: BigInt(
|
|
564
|
+
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
565
|
+
),
|
|
566
|
+
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
567
|
+
},
|
|
568
|
+
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
572
|
+
return {
|
|
573
|
+
salesConfig: {
|
|
574
|
+
saleType: "erc20",
|
|
575
|
+
...targetStrategy.erc20Minter,
|
|
576
|
+
maxTokensPerAddress: BigInt(
|
|
577
|
+
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
578
|
+
),
|
|
579
|
+
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
580
|
+
},
|
|
581
|
+
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
throw new Error("Invalid saleType");
|
|
533
585
|
});
|
|
534
586
|
}
|
|
535
587
|
};
|
|
@@ -718,7 +770,15 @@ var PremintAPIClient = class {
|
|
|
718
770
|
};
|
|
719
771
|
|
|
720
772
|
// src/utils.ts
|
|
773
|
+
var import_viem4 = require("viem");
|
|
721
774
|
var makeSimulateContractParamaters = (args) => args;
|
|
775
|
+
function setupClient({ chain, httpClient: httpClient2, publicClient }) {
|
|
776
|
+
return {
|
|
777
|
+
chain,
|
|
778
|
+
httpClient: httpClient2 || httpClient,
|
|
779
|
+
publicClient: publicClient || (0, import_viem4.createPublicClient)({ chain, transport: (0, import_viem4.http)() })
|
|
780
|
+
};
|
|
781
|
+
}
|
|
722
782
|
|
|
723
783
|
// src/premint/premint-client.ts
|
|
724
784
|
var defaultTokenConfigV1MintArguments = () => ({
|
|
@@ -746,7 +806,7 @@ var makeTokenConfigWithDefaults = ({
|
|
|
746
806
|
chainId,
|
|
747
807
|
premintConfigVersion,
|
|
748
808
|
tokenCreationConfig,
|
|
749
|
-
|
|
809
|
+
payoutRecipient
|
|
750
810
|
}) => {
|
|
751
811
|
if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
|
|
752
812
|
throw new Error("PremintV3 not supported in SDK");
|
|
@@ -756,15 +816,15 @@ var makeTokenConfigWithDefaults = ({
|
|
|
756
816
|
return {
|
|
757
817
|
fixedPriceMinter,
|
|
758
818
|
...defaultTokenConfigV1MintArguments(),
|
|
759
|
-
royaltyRecipient:
|
|
819
|
+
royaltyRecipient: payoutRecipient,
|
|
760
820
|
...tokenCreationConfig
|
|
761
821
|
};
|
|
762
822
|
} else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
|
|
763
823
|
return {
|
|
764
824
|
fixedPriceMinter,
|
|
765
825
|
...defaultTokenConfigV2MintArguments(),
|
|
766
|
-
payoutRecipient
|
|
767
|
-
createReferral:
|
|
826
|
+
payoutRecipient,
|
|
827
|
+
createReferral: import_viem5.zeroAddress,
|
|
768
828
|
...tokenCreationConfig
|
|
769
829
|
};
|
|
770
830
|
} else {
|
|
@@ -774,7 +834,7 @@ var makeTokenConfigWithDefaults = ({
|
|
|
774
834
|
function getPremintedLogFromReceipt(receipt) {
|
|
775
835
|
for (const data of receipt.logs) {
|
|
776
836
|
try {
|
|
777
|
-
const decodedLog = (0,
|
|
837
|
+
const decodedLog = (0, import_viem5.decodeEventLog)({
|
|
778
838
|
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
779
839
|
eventName: "PremintedV2",
|
|
780
840
|
...data
|
|
@@ -790,7 +850,7 @@ var PremintClient = class {
|
|
|
790
850
|
constructor(chain, publicClient, httpClient2) {
|
|
791
851
|
this.chain = chain;
|
|
792
852
|
this.apiClient = new PremintAPIClient(chain.id, httpClient2);
|
|
793
|
-
this.publicClient = publicClient
|
|
853
|
+
this.publicClient = publicClient;
|
|
794
854
|
}
|
|
795
855
|
getDataFromPremintReceipt(receipt) {
|
|
796
856
|
const premintedLog = getPremintedLogFromReceipt(receipt);
|
|
@@ -803,174 +863,45 @@ var PremintClient = class {
|
|
|
803
863
|
};
|
|
804
864
|
}
|
|
805
865
|
/**
|
|
806
|
-
*
|
|
807
|
-
*
|
|
808
|
-
* 1. Loads existing premint token
|
|
809
|
-
* 2. Updates with settings passed into function
|
|
810
|
-
* 3. Increments the version field
|
|
811
|
-
* 4. Re-signs the premint
|
|
812
|
-
* 5. Uploads the premint to the ZORA API
|
|
813
|
-
*
|
|
814
|
-
* Updates existing premint
|
|
815
|
-
* @param settings Settings for the new premint
|
|
816
|
-
* @param settings.account Account to sign the premint update from. Taken from walletClient if none passed in.
|
|
817
|
-
* @param settings.collection Collection information for the mint
|
|
818
|
-
* @param settings.walletClient viem wallet client to use to sign
|
|
819
|
-
* @param settings.uid UID
|
|
820
|
-
* @param settings.token Mint argument settings, optional settings are overridden with sensible defaults.
|
|
821
|
-
*
|
|
822
|
-
*/
|
|
823
|
-
async updatePremint({
|
|
824
|
-
walletClient,
|
|
825
|
-
uid,
|
|
826
|
-
collection,
|
|
827
|
-
account,
|
|
828
|
-
tokenConfigUpdates
|
|
829
|
-
}) {
|
|
830
|
-
const {
|
|
831
|
-
premintConfig,
|
|
832
|
-
collection: collectionCreationConfig,
|
|
833
|
-
premintConfigVersion
|
|
834
|
-
} = await this.apiClient.getSignature({
|
|
835
|
-
collectionAddress: collection,
|
|
836
|
-
uid
|
|
837
|
-
});
|
|
838
|
-
const updatedPremint = applyUpdateToPremint({
|
|
839
|
-
uid: premintConfig.uid,
|
|
840
|
-
version: premintConfig.version,
|
|
841
|
-
tokenConfig: premintConfig.tokenConfig,
|
|
842
|
-
tokenConfigUpdates
|
|
843
|
-
});
|
|
844
|
-
return await this.signAndSubmitPremint({
|
|
845
|
-
walletClient,
|
|
846
|
-
account,
|
|
847
|
-
checkSignature: true,
|
|
848
|
-
verifyingContract: collection,
|
|
849
|
-
collection: collectionCreationConfig,
|
|
850
|
-
premintConfig: updatedPremint,
|
|
851
|
-
premintConfigVersion
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
/**
|
|
855
|
-
* Delete premint.
|
|
856
|
-
*
|
|
857
|
-
* 1. Loads current premint from collection address with UID
|
|
858
|
-
* 2. Increments version and marks as deleted
|
|
859
|
-
* 3. Signs new premint version
|
|
860
|
-
* 4. Sends to ZORA Premint API
|
|
861
|
-
*
|
|
862
|
-
* Deletes existing premint
|
|
863
|
-
* @param settings.collection collection address
|
|
864
|
-
* @param settings.uid UID
|
|
865
|
-
* @param settings.walletClient viem wallet client to use to sign
|
|
866
|
+
* Prepares data for updating a premint
|
|
866
867
|
*
|
|
868
|
+
* @param parameters - Parameters for updating the premint {@link UpdatePremintParams}
|
|
869
|
+
* @returns A PremintReturn. {@link PremintReturn}
|
|
867
870
|
*/
|
|
868
|
-
async
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
const {
|
|
875
|
-
premintConfig,
|
|
876
|
-
premintConfigVersion,
|
|
877
|
-
collection: collectionCreationConfig
|
|
878
|
-
} = await this.apiClient.getSignature({
|
|
879
|
-
collectionAddress: collection,
|
|
880
|
-
uid
|
|
881
|
-
});
|
|
882
|
-
const deletedPremint = {
|
|
883
|
-
...premintConfig,
|
|
884
|
-
version: premintConfig.version + 1,
|
|
885
|
-
deleted: true
|
|
886
|
-
};
|
|
887
|
-
return await this.signAndSubmitPremint({
|
|
888
|
-
walletClient,
|
|
889
|
-
account,
|
|
890
|
-
checkSignature: false,
|
|
891
|
-
verifyingContract: collection,
|
|
892
|
-
collection: collectionCreationConfig,
|
|
893
|
-
premintConfig: deletedPremint,
|
|
894
|
-
premintConfigVersion
|
|
871
|
+
async updatePremint(args) {
|
|
872
|
+
return await updatePremint({
|
|
873
|
+
...args,
|
|
874
|
+
apiClient: this.apiClient,
|
|
875
|
+
publicClient: this.publicClient,
|
|
876
|
+
chainId: this.chain.id
|
|
895
877
|
});
|
|
896
878
|
}
|
|
897
879
|
/**
|
|
898
|
-
*
|
|
880
|
+
* Prepares data for deleting a premint
|
|
899
881
|
*
|
|
900
|
-
* @param
|
|
901
|
-
* @returns
|
|
882
|
+
* @param parameters - Parameters for deleting the premint {@link DeletePremintParams}
|
|
883
|
+
* @returns A PremintReturn. {@link PremintReturn}
|
|
902
884
|
*/
|
|
903
|
-
async
|
|
904
|
-
|
|
885
|
+
async deletePremint(params) {
|
|
886
|
+
return deletePremint({
|
|
905
887
|
...params,
|
|
906
|
-
chainId: this.chain.id,
|
|
907
888
|
apiClient: this.apiClient,
|
|
908
|
-
publicClient: this.publicClient
|
|
889
|
+
publicClient: this.publicClient,
|
|
890
|
+
chainId: this.chain.id
|
|
909
891
|
});
|
|
910
|
-
const uid = params.premintConfig.uid;
|
|
911
|
-
return {
|
|
912
|
-
urls: this.makeUrls({ address: verifyingContract, uid }),
|
|
913
|
-
uid,
|
|
914
|
-
verifyingContract
|
|
915
|
-
};
|
|
916
892
|
}
|
|
917
893
|
/**
|
|
918
|
-
*
|
|
894
|
+
* Prepares data for creating a premint
|
|
919
895
|
*
|
|
920
|
-
* @param
|
|
921
|
-
* @
|
|
922
|
-
* @param settings.collection Collection information for the mint
|
|
923
|
-
* @param settings.tokenCreationConfig Mint argument settings, optional settings are overridden with sensible defaults.
|
|
924
|
-
* @param setings.premintConfigVersion Premint config version to use, defaults to V2
|
|
925
|
-
* @param settings.uid the UID to use – optional and retrieved as a fresh UID from ZORA by default.
|
|
926
|
-
* @param settings.checkSignature if the signature should have a pre-flight check. Not required but helpful for debugging.
|
|
927
|
-
* @returns premint url, uid, newContractAddress, and premint object
|
|
896
|
+
* @param parameters - Parameters for creating the premint {@link CreatePremintParameters}
|
|
897
|
+
* @returns A PremintReturn. {@link PremintReturn}
|
|
928
898
|
*/
|
|
929
|
-
async createPremint({
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
tokenCreationConfig,
|
|
933
|
-
premintConfigVersion,
|
|
934
|
-
walletClient,
|
|
935
|
-
uid,
|
|
936
|
-
checkSignature = false
|
|
937
|
-
}) {
|
|
938
|
-
const newContractAddress = await getPremintCollectionAddress({
|
|
939
|
-
publicClient: this.publicClient,
|
|
940
|
-
collection
|
|
941
|
-
});
|
|
942
|
-
let uidToUse = uid;
|
|
943
|
-
if (typeof uidToUse !== "number") {
|
|
944
|
-
uidToUse = await this.apiClient.getNextUID(newContractAddress);
|
|
945
|
-
}
|
|
946
|
-
const actualVersion = premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1;
|
|
947
|
-
if (!await supportsPremintVersion({
|
|
948
|
-
version: actualVersion,
|
|
899
|
+
async createPremint(parameters) {
|
|
900
|
+
return createPremint({
|
|
901
|
+
...parameters,
|
|
949
902
|
publicClient: this.publicClient,
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
throw new Error(
|
|
953
|
-
`Premint version ${actualVersion} not supported by contract`
|
|
954
|
-
);
|
|
955
|
-
}
|
|
956
|
-
const premintConfig = makeNewPremint({
|
|
957
|
-
tokenConfig: makeTokenConfigWithDefaults({
|
|
958
|
-
// @ts-ignore
|
|
959
|
-
premintConfigVersion: actualVersion,
|
|
960
|
-
tokenCreationConfig,
|
|
961
|
-
creatorAccount: typeof creatorAccount === "string" ? creatorAccount : creatorAccount.address,
|
|
962
|
-
chainId: this.chain.id
|
|
963
|
-
}),
|
|
964
|
-
uid: uidToUse
|
|
965
|
-
});
|
|
966
|
-
return await this.signAndSubmitPremint({
|
|
967
|
-
verifyingContract: newContractAddress,
|
|
968
|
-
premintConfig,
|
|
969
|
-
premintConfigVersion: actualVersion,
|
|
970
|
-
checkSignature,
|
|
971
|
-
account: creatorAccount,
|
|
972
|
-
walletClient,
|
|
973
|
-
collection
|
|
903
|
+
apiClient: this.apiClient,
|
|
904
|
+
chainId: this.chain.id
|
|
974
905
|
});
|
|
975
906
|
}
|
|
976
907
|
/**
|
|
@@ -1047,91 +978,342 @@ var PremintClient = class {
|
|
|
1047
978
|
});
|
|
1048
979
|
}
|
|
1049
980
|
/**
|
|
1050
|
-
*
|
|
981
|
+
* Prepares the parameters to collect a premint; it brings the contract and token onchain, then collects
|
|
982
|
+
* tokens on that contract for the mint recipient.
|
|
1051
983
|
*
|
|
1052
|
-
* @param
|
|
1053
|
-
* @param settings.account Optional account (if omitted taken from wallet client) for the account executing the premint.
|
|
1054
|
-
* @param settings.walletClient WalletClient to send execution from.
|
|
1055
|
-
* @param settings.mintArguments User minting arguments.
|
|
1056
|
-
* @param settings.mintArguments.quantityToMint Quantity to mint, optional, defaults to 1.
|
|
1057
|
-
* @param settings.mintArguments.mintComment Optional mint comment, optional, omits when not included.
|
|
1058
|
-
* @param settings.publicClient Optional public client for preflight checks.
|
|
984
|
+
* @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
|
|
1059
985
|
* @returns receipt, log, zoraURL
|
|
1060
986
|
*/
|
|
1061
|
-
async makeMintParameters({
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
}) {
|
|
1067
|
-
if (mintArguments && mintArguments?.quantityToMint < 1) {
|
|
1068
|
-
throw new Error("Quantity to mint cannot be below 1");
|
|
1069
|
-
}
|
|
1070
|
-
if (!minterAccount) {
|
|
1071
|
-
throw new Error("Wallet not passed in");
|
|
1072
|
-
}
|
|
1073
|
-
const { premintConfig, premintConfigVersion, collection, signature } = await this.getPremintSignature({
|
|
1074
|
-
address: tokenContract,
|
|
1075
|
-
uid
|
|
987
|
+
async makeMintParameters(parameters) {
|
|
988
|
+
return await makeMintParameters({
|
|
989
|
+
...parameters,
|
|
990
|
+
apiClient: this.apiClient,
|
|
991
|
+
publicClient: this.publicClient
|
|
1076
992
|
});
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
function createPremintClient(clientConfig) {
|
|
996
|
+
const { chain, httpClient: httpClient2, publicClient } = setupClient(clientConfig);
|
|
997
|
+
return new PremintClient(chain, publicClient, httpClient2);
|
|
998
|
+
}
|
|
999
|
+
function makePremintReturn({
|
|
1000
|
+
premintConfig,
|
|
1001
|
+
premintConfigVersion,
|
|
1002
|
+
collectionAddress,
|
|
1003
|
+
collection,
|
|
1004
|
+
publicClient,
|
|
1005
|
+
apiClient,
|
|
1006
|
+
chainId
|
|
1007
|
+
}) {
|
|
1008
|
+
const typedDataDefinition = (0, import_protocol_deployments4.premintTypedDataDefinition)({
|
|
1009
|
+
verifyingContract: collectionAddress,
|
|
1010
|
+
premintConfig,
|
|
1011
|
+
premintConfigVersion,
|
|
1012
|
+
chainId
|
|
1013
|
+
});
|
|
1014
|
+
const signAndSubmit = async ({
|
|
1015
|
+
walletClient,
|
|
1016
|
+
account,
|
|
1017
|
+
checkSignature
|
|
1018
|
+
}) => {
|
|
1019
|
+
const { signature, signerAccount } = await signPremint({
|
|
1020
|
+
account,
|
|
1021
|
+
walletClient,
|
|
1022
|
+
typedDataDefinition
|
|
1023
|
+
});
|
|
1024
|
+
await submit({
|
|
1025
|
+
signature,
|
|
1026
|
+
checkSignature,
|
|
1027
|
+
signerAccount
|
|
1028
|
+
});
|
|
1029
|
+
return {
|
|
1030
|
+
signature,
|
|
1031
|
+
signerAccount
|
|
1094
1032
|
};
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
});
|
|
1110
|
-
} else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
|
|
1111
|
-
return makeSimulateContractParamaters({
|
|
1112
|
-
account: minterAccount,
|
|
1113
|
-
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1114
|
-
functionName: "premintV2",
|
|
1115
|
-
value,
|
|
1116
|
-
address: getPremintExecutorAddress(),
|
|
1117
|
-
args: [
|
|
1118
|
-
collection,
|
|
1119
|
-
premintConfig,
|
|
1120
|
-
signature,
|
|
1121
|
-
numberToMint,
|
|
1122
|
-
mintArgumentsContract
|
|
1123
|
-
]
|
|
1033
|
+
};
|
|
1034
|
+
const submit = async ({
|
|
1035
|
+
signature,
|
|
1036
|
+
checkSignature,
|
|
1037
|
+
signerAccount
|
|
1038
|
+
}) => {
|
|
1039
|
+
if (checkSignature) {
|
|
1040
|
+
await validateSignature({
|
|
1041
|
+
collection: {
|
|
1042
|
+
...collection,
|
|
1043
|
+
additionalAdmins: []
|
|
1044
|
+
},
|
|
1045
|
+
publicClient,
|
|
1046
|
+
signerAccount
|
|
1124
1047
|
});
|
|
1125
1048
|
}
|
|
1126
|
-
|
|
1049
|
+
await apiClient.postSignature({
|
|
1050
|
+
collection: {
|
|
1051
|
+
...collection,
|
|
1052
|
+
additionalAdmins: []
|
|
1053
|
+
},
|
|
1054
|
+
signature,
|
|
1055
|
+
premintConfig,
|
|
1056
|
+
premintConfigVersion
|
|
1057
|
+
});
|
|
1058
|
+
};
|
|
1059
|
+
return {
|
|
1060
|
+
premintConfig,
|
|
1061
|
+
premintConfigVersion,
|
|
1062
|
+
typedDataDefinition,
|
|
1063
|
+
collectionAddress,
|
|
1064
|
+
signAndSubmit,
|
|
1065
|
+
submit
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
async function signPremint({
|
|
1069
|
+
account,
|
|
1070
|
+
walletClient,
|
|
1071
|
+
typedDataDefinition
|
|
1072
|
+
}) {
|
|
1073
|
+
if (!account) {
|
|
1074
|
+
account = walletClient.account;
|
|
1075
|
+
}
|
|
1076
|
+
if (!account) {
|
|
1077
|
+
throw new Error("No account provided");
|
|
1078
|
+
}
|
|
1079
|
+
const signature = await walletClient.signTypedData({
|
|
1080
|
+
account,
|
|
1081
|
+
...typedDataDefinition
|
|
1082
|
+
});
|
|
1083
|
+
return {
|
|
1084
|
+
signature,
|
|
1085
|
+
signerAccount: account
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
var validateSignature = async ({
|
|
1089
|
+
collection,
|
|
1090
|
+
publicClient,
|
|
1091
|
+
signerAccount
|
|
1092
|
+
}) => {
|
|
1093
|
+
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
1094
|
+
collection,
|
|
1095
|
+
publicClient,
|
|
1096
|
+
signer: typeof signerAccount === "string" ? signerAccount : signerAccount.address,
|
|
1097
|
+
collectionAddress: await getPremintCollectionAddress({
|
|
1098
|
+
collection,
|
|
1099
|
+
publicClient
|
|
1100
|
+
})
|
|
1101
|
+
});
|
|
1102
|
+
if (!isAuthorized) {
|
|
1103
|
+
throw new Error("Not authorized to create premint");
|
|
1127
1104
|
}
|
|
1128
1105
|
};
|
|
1129
|
-
function
|
|
1130
|
-
|
|
1131
|
-
|
|
1106
|
+
async function createPremint({
|
|
1107
|
+
payoutRecipient: creatorAccount,
|
|
1108
|
+
collection,
|
|
1109
|
+
tokenCreationConfig,
|
|
1110
|
+
premintConfigVersion,
|
|
1111
|
+
uid,
|
|
1112
|
+
publicClient,
|
|
1113
|
+
apiClient,
|
|
1114
|
+
chainId
|
|
1115
|
+
}) {
|
|
1116
|
+
const {
|
|
1117
|
+
premintConfig,
|
|
1118
|
+
premintConfigVersion: actualVersion,
|
|
1119
|
+
collectionAddress
|
|
1120
|
+
} = await prepareCreatePremintConfig({
|
|
1121
|
+
payoutRecipient: creatorAccount,
|
|
1122
|
+
collection,
|
|
1123
|
+
tokenCreationConfig,
|
|
1124
|
+
premintConfigVersion,
|
|
1125
|
+
uid,
|
|
1126
|
+
publicClient,
|
|
1127
|
+
apiClient,
|
|
1128
|
+
chainId
|
|
1129
|
+
});
|
|
1130
|
+
return makePremintReturn({
|
|
1131
|
+
premintConfig,
|
|
1132
|
+
premintConfigVersion: actualVersion,
|
|
1133
|
+
collectionAddress,
|
|
1134
|
+
collection,
|
|
1135
|
+
publicClient,
|
|
1136
|
+
apiClient,
|
|
1137
|
+
chainId
|
|
1138
|
+
});
|
|
1139
|
+
}
|
|
1140
|
+
async function prepareCreatePremintConfig({
|
|
1141
|
+
payoutRecipient,
|
|
1142
|
+
collection,
|
|
1143
|
+
tokenCreationConfig,
|
|
1144
|
+
premintConfigVersion,
|
|
1145
|
+
uid,
|
|
1146
|
+
publicClient,
|
|
1147
|
+
apiClient,
|
|
1148
|
+
chainId
|
|
1149
|
+
}) {
|
|
1150
|
+
const collectionWithAdditionalAdmins = {
|
|
1151
|
+
...collection,
|
|
1152
|
+
additionalAdmins: collection.additionalAdmins || []
|
|
1153
|
+
};
|
|
1154
|
+
const newContractAddress = await getPremintCollectionAddress({
|
|
1155
|
+
publicClient,
|
|
1156
|
+
collection: collectionWithAdditionalAdmins
|
|
1157
|
+
});
|
|
1158
|
+
let uidToUse = uid;
|
|
1159
|
+
if (typeof uidToUse !== "number") {
|
|
1160
|
+
uidToUse = await apiClient.getNextUID(newContractAddress);
|
|
1161
|
+
}
|
|
1162
|
+
const actualVersion = premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1;
|
|
1163
|
+
if (!await supportsPremintVersion({
|
|
1164
|
+
version: actualVersion,
|
|
1165
|
+
publicClient,
|
|
1166
|
+
tokenContract: newContractAddress
|
|
1167
|
+
})) {
|
|
1168
|
+
throw new Error(
|
|
1169
|
+
`Premint version ${actualVersion} not supported by contract`
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
const premintConfig = makeNewPremint({
|
|
1173
|
+
tokenConfig: makeTokenConfigWithDefaults({
|
|
1174
|
+
// @ts-ignore
|
|
1175
|
+
premintConfigVersion: actualVersion,
|
|
1176
|
+
tokenCreationConfig,
|
|
1177
|
+
payoutRecipient: typeof payoutRecipient === "string" ? payoutRecipient : payoutRecipient.address,
|
|
1178
|
+
chainId
|
|
1179
|
+
}),
|
|
1180
|
+
uid: uidToUse
|
|
1181
|
+
});
|
|
1182
|
+
return {
|
|
1183
|
+
premintConfig,
|
|
1184
|
+
premintConfigVersion: actualVersion,
|
|
1185
|
+
collectionAddress: newContractAddress
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
async function updatePremint({
|
|
1189
|
+
uid,
|
|
1190
|
+
collection,
|
|
1191
|
+
tokenConfigUpdates,
|
|
1192
|
+
apiClient,
|
|
1193
|
+
publicClient,
|
|
1194
|
+
chainId
|
|
1195
|
+
}) {
|
|
1196
|
+
const {
|
|
1197
|
+
premintConfig,
|
|
1198
|
+
collection: collectionCreationConfig,
|
|
1199
|
+
premintConfigVersion
|
|
1200
|
+
} = await apiClient.getSignature({
|
|
1201
|
+
collectionAddress: collection,
|
|
1202
|
+
uid
|
|
1203
|
+
});
|
|
1204
|
+
const updatedPremint = applyUpdateToPremint({
|
|
1205
|
+
uid: premintConfig.uid,
|
|
1206
|
+
version: premintConfig.version,
|
|
1207
|
+
tokenConfig: premintConfig.tokenConfig,
|
|
1208
|
+
tokenConfigUpdates
|
|
1209
|
+
});
|
|
1210
|
+
return makePremintReturn({
|
|
1211
|
+
premintConfig: updatedPremint,
|
|
1212
|
+
premintConfigVersion,
|
|
1213
|
+
collectionAddress: collection,
|
|
1214
|
+
collection: collectionCreationConfig,
|
|
1215
|
+
publicClient,
|
|
1216
|
+
apiClient,
|
|
1217
|
+
chainId
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
async function deletePremint({
|
|
1221
|
+
uid,
|
|
1222
|
+
collection,
|
|
1223
|
+
publicClient,
|
|
1224
|
+
apiClient,
|
|
1225
|
+
chainId
|
|
1226
|
+
}) {
|
|
1227
|
+
const {
|
|
1228
|
+
premintConfig,
|
|
1229
|
+
premintConfigVersion,
|
|
1230
|
+
collection: collectionCreationConfig
|
|
1231
|
+
} = await apiClient.getSignature({
|
|
1232
|
+
collectionAddress: collection,
|
|
1233
|
+
uid
|
|
1234
|
+
});
|
|
1235
|
+
const deletedPremint = {
|
|
1236
|
+
...premintConfig,
|
|
1237
|
+
version: premintConfig.version + 1,
|
|
1238
|
+
deleted: true
|
|
1239
|
+
};
|
|
1240
|
+
return makePremintReturn({
|
|
1241
|
+
premintConfig: deletedPremint,
|
|
1242
|
+
premintConfigVersion,
|
|
1243
|
+
collectionAddress: collection,
|
|
1244
|
+
collection: collectionCreationConfig,
|
|
1245
|
+
publicClient,
|
|
1246
|
+
apiClient,
|
|
1247
|
+
chainId
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
async function makeMintParameters({
|
|
1251
|
+
uid,
|
|
1252
|
+
tokenContract,
|
|
1253
|
+
minterAccount,
|
|
1254
|
+
mintArguments,
|
|
1255
|
+
apiClient,
|
|
1132
1256
|
publicClient
|
|
1133
1257
|
}) {
|
|
1134
|
-
|
|
1258
|
+
if (mintArguments && mintArguments?.quantityToMint < 1) {
|
|
1259
|
+
throw new Error("Quantity to mint cannot be below 1");
|
|
1260
|
+
}
|
|
1261
|
+
if (!minterAccount) {
|
|
1262
|
+
throw new Error("Wallet not passed in");
|
|
1263
|
+
}
|
|
1264
|
+
const { premintConfig, premintConfigVersion, collection, signature } = await apiClient.getSignature({
|
|
1265
|
+
collectionAddress: tokenContract,
|
|
1266
|
+
uid
|
|
1267
|
+
});
|
|
1268
|
+
const numberToMint = BigInt(mintArguments?.quantityToMint || 1);
|
|
1269
|
+
if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
|
|
1270
|
+
throw new Error("PremintV3 not supported in premint SDK");
|
|
1271
|
+
}
|
|
1272
|
+
const value = (await getPremintMintCosts({
|
|
1273
|
+
tokenContract,
|
|
1274
|
+
quantityToMint: numberToMint,
|
|
1275
|
+
publicClient,
|
|
1276
|
+
tokenPrice: premintConfig.tokenConfig.pricePerToken
|
|
1277
|
+
})).totalCost;
|
|
1278
|
+
const mintArgumentsContract = {
|
|
1279
|
+
mintComment: mintArguments?.mintComment || "",
|
|
1280
|
+
mintRecipient: mintArguments?.mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address),
|
|
1281
|
+
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
1282
|
+
mintReferral: mintArguments?.mintReferral
|
|
1283
|
+
})
|
|
1284
|
+
};
|
|
1285
|
+
if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V1) {
|
|
1286
|
+
return makeSimulateContractParamaters({
|
|
1287
|
+
account: minterAccount,
|
|
1288
|
+
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1289
|
+
functionName: "premintV1",
|
|
1290
|
+
value,
|
|
1291
|
+
address: getPremintExecutorAddress(),
|
|
1292
|
+
args: [
|
|
1293
|
+
collection,
|
|
1294
|
+
premintConfig,
|
|
1295
|
+
signature,
|
|
1296
|
+
numberToMint,
|
|
1297
|
+
mintArgumentsContract
|
|
1298
|
+
]
|
|
1299
|
+
});
|
|
1300
|
+
} else if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V2) {
|
|
1301
|
+
return makeSimulateContractParamaters({
|
|
1302
|
+
account: minterAccount,
|
|
1303
|
+
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1304
|
+
functionName: "premintV2",
|
|
1305
|
+
value,
|
|
1306
|
+
address: getPremintExecutorAddress(),
|
|
1307
|
+
args: [
|
|
1308
|
+
collection,
|
|
1309
|
+
premintConfig,
|
|
1310
|
+
signature,
|
|
1311
|
+
numberToMint,
|
|
1312
|
+
mintArgumentsContract
|
|
1313
|
+
]
|
|
1314
|
+
});
|
|
1315
|
+
}
|
|
1316
|
+
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
1135
1317
|
}
|
|
1136
1318
|
function makeUrls({
|
|
1137
1319
|
uid,
|
|
@@ -1150,52 +1332,6 @@ function makeUrls({
|
|
|
1150
1332
|
zoraManage: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`
|
|
1151
1333
|
};
|
|
1152
1334
|
}
|
|
1153
|
-
async function signAndSubmitPremint({
|
|
1154
|
-
walletClient,
|
|
1155
|
-
verifyingContract,
|
|
1156
|
-
account,
|
|
1157
|
-
checkSignature,
|
|
1158
|
-
collection,
|
|
1159
|
-
chainId,
|
|
1160
|
-
publicClient,
|
|
1161
|
-
apiClient,
|
|
1162
|
-
...premintConfigAndVersion
|
|
1163
|
-
}) {
|
|
1164
|
-
if (!account) {
|
|
1165
|
-
account = walletClient.account;
|
|
1166
|
-
}
|
|
1167
|
-
if (!account) {
|
|
1168
|
-
throw new Error("No account provided");
|
|
1169
|
-
}
|
|
1170
|
-
const signature = await walletClient.signTypedData({
|
|
1171
|
-
account,
|
|
1172
|
-
...(0, import_protocol_deployments4.premintTypedDataDefinition)({
|
|
1173
|
-
verifyingContract,
|
|
1174
|
-
...premintConfigAndVersion,
|
|
1175
|
-
chainId
|
|
1176
|
-
})
|
|
1177
|
-
});
|
|
1178
|
-
if (checkSignature) {
|
|
1179
|
-
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
1180
|
-
collection,
|
|
1181
|
-
publicClient,
|
|
1182
|
-
signer: typeof account === "string" ? account : account.address,
|
|
1183
|
-
collectionAddress: await getPremintCollectionAddress({
|
|
1184
|
-
collection,
|
|
1185
|
-
publicClient
|
|
1186
|
-
})
|
|
1187
|
-
});
|
|
1188
|
-
if (!isAuthorized) {
|
|
1189
|
-
throw new Error("Not authorized to create premint");
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
const premint = await apiClient.postSignature({
|
|
1193
|
-
collection,
|
|
1194
|
-
signature,
|
|
1195
|
-
...premintConfigAndVersion
|
|
1196
|
-
});
|
|
1197
|
-
return { premint, verifyingContract };
|
|
1198
|
-
}
|
|
1199
1335
|
|
|
1200
1336
|
// src/premint/contract-types.ts
|
|
1201
1337
|
var import_protocol_deployments5 = require("@zoralabs/protocol-deployments");
|
|
@@ -1207,7 +1343,7 @@ var PremintConfigVersion3 = ((PremintConfigVersion4) => {
|
|
|
1207
1343
|
})(PremintConfigVersion3 || {});
|
|
1208
1344
|
|
|
1209
1345
|
// src/mint/mint-client.ts
|
|
1210
|
-
var
|
|
1346
|
+
var import_viem6 = require("viem");
|
|
1211
1347
|
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1212
1348
|
var MintError = class extends Error {
|
|
1213
1349
|
};
|
|
@@ -1220,30 +1356,24 @@ var Errors = {
|
|
|
1220
1356
|
var MintClient = class {
|
|
1221
1357
|
constructor(chain, publicClient, httpClient2) {
|
|
1222
1358
|
this.apiClient = new MintAPIClient(chain.id, httpClient2);
|
|
1223
|
-
this.publicClient = publicClient
|
|
1359
|
+
this.publicClient = publicClient;
|
|
1224
1360
|
}
|
|
1225
1361
|
/**
|
|
1226
1362
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
1227
|
-
*
|
|
1228
|
-
* @param
|
|
1229
|
-
* @
|
|
1230
|
-
* @returns
|
|
1363
|
+
*
|
|
1364
|
+
* @param parameters - Parameters for collecting the token {@link MintTokenParams}
|
|
1365
|
+
* @returns Parameters for simulating/executing the mint transaction
|
|
1231
1366
|
*/
|
|
1232
|
-
async makePrepareMintTokenParams({
|
|
1233
|
-
...rest
|
|
1234
|
-
}) {
|
|
1367
|
+
async makePrepareMintTokenParams(parameters) {
|
|
1235
1368
|
return makePrepareMintTokenParams({
|
|
1236
|
-
...
|
|
1369
|
+
...parameters,
|
|
1237
1370
|
apiClient: this.apiClient,
|
|
1238
1371
|
publicClient: this.publicClient
|
|
1239
1372
|
});
|
|
1240
1373
|
}
|
|
1241
1374
|
};
|
|
1242
|
-
function createMintClient({
|
|
1243
|
-
chain,
|
|
1244
|
-
publicClient,
|
|
1245
|
-
httpClient: httpClient2
|
|
1246
|
-
}) {
|
|
1375
|
+
function createMintClient(clientConfig) {
|
|
1376
|
+
const { chain, publicClient, httpClient: httpClient2 } = setupClient(clientConfig);
|
|
1247
1377
|
return new MintClient(chain, publicClient, httpClient2);
|
|
1248
1378
|
}
|
|
1249
1379
|
async function makePrepareMintTokenParams({
|
|
@@ -1251,16 +1381,19 @@ async function makePrepareMintTokenParams({
|
|
|
1251
1381
|
apiClient,
|
|
1252
1382
|
tokenId,
|
|
1253
1383
|
tokenAddress,
|
|
1384
|
+
mintArguments,
|
|
1254
1385
|
...rest
|
|
1255
1386
|
}) {
|
|
1256
1387
|
const salesConfigAndTokenInfo = await apiClient.getSalesConfigAndTokenInfo({
|
|
1257
1388
|
tokenId,
|
|
1258
|
-
tokenAddress
|
|
1389
|
+
tokenAddress,
|
|
1390
|
+
saleType: mintArguments.saleType
|
|
1259
1391
|
});
|
|
1260
1392
|
if (tokenId === void 0) {
|
|
1261
1393
|
return makePrepareMint721TokenParams({
|
|
1262
1394
|
salesConfigAndTokenInfo,
|
|
1263
1395
|
tokenAddress,
|
|
1396
|
+
mintArguments,
|
|
1264
1397
|
...rest
|
|
1265
1398
|
});
|
|
1266
1399
|
}
|
|
@@ -1268,6 +1401,7 @@ async function makePrepareMintTokenParams({
|
|
|
1268
1401
|
salesConfigAndTokenInfo,
|
|
1269
1402
|
tokenAddress,
|
|
1270
1403
|
tokenId,
|
|
1404
|
+
mintArguments,
|
|
1271
1405
|
...rest
|
|
1272
1406
|
});
|
|
1273
1407
|
}
|
|
@@ -1291,7 +1425,7 @@ async function makePrepareMint721TokenParams({
|
|
|
1291
1425
|
mintArguments.mintToAddress,
|
|
1292
1426
|
BigInt(mintArguments.quantityToMint),
|
|
1293
1427
|
mintArguments.mintComment || "",
|
|
1294
|
-
mintArguments.mintReferral ||
|
|
1428
|
+
mintArguments.mintReferral || import_viem6.zeroAddress
|
|
1295
1429
|
]
|
|
1296
1430
|
});
|
|
1297
1431
|
}
|
|
@@ -1300,7 +1434,7 @@ function getMintCosts({
|
|
|
1300
1434
|
quantityToMint
|
|
1301
1435
|
}) {
|
|
1302
1436
|
const mintFeeForTokens = salesConfigAndTokenInfo.mintFeePerQuantity * quantityToMint;
|
|
1303
|
-
const tokenPurchaseCost = BigInt(salesConfigAndTokenInfo.
|
|
1437
|
+
const tokenPurchaseCost = BigInt(salesConfigAndTokenInfo.salesConfig.pricePerToken) * quantityToMint;
|
|
1304
1438
|
return {
|
|
1305
1439
|
mintFee: mintFeeForTokens,
|
|
1306
1440
|
tokenPurchaseCost,
|
|
@@ -1319,33 +1453,58 @@ async function makePrepareMint1155TokenParams({
|
|
|
1319
1453
|
salesConfigAndTokenInfo,
|
|
1320
1454
|
quantityToMint: mintQuantity
|
|
1321
1455
|
}).totalCost;
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1456
|
+
switch (salesConfigAndTokenInfo.salesConfig.saleType) {
|
|
1457
|
+
case "fixedPrice":
|
|
1458
|
+
const fixedPriceArgs = mintArguments;
|
|
1459
|
+
return makeSimulateContractParamaters({
|
|
1460
|
+
abi: import_protocol_deployments6.zoraCreator1155ImplABI,
|
|
1461
|
+
functionName: "mintWithRewards",
|
|
1462
|
+
account: minterAccount,
|
|
1463
|
+
value: mintValue,
|
|
1464
|
+
address: tokenAddress,
|
|
1465
|
+
/* args: minter, tokenId, quantity, minterArguments, mintReferral */
|
|
1466
|
+
args: [
|
|
1467
|
+
salesConfigAndTokenInfo.salesConfig.address || import_protocol_deployments6.zoraCreatorFixedPriceSaleStrategyAddress[999999999],
|
|
1468
|
+
BigInt(tokenId),
|
|
1469
|
+
mintQuantity,
|
|
1470
|
+
(0, import_viem6.encodeAbiParameters)((0, import_viem6.parseAbiParameters)("address, string"), [
|
|
1471
|
+
fixedPriceArgs.mintToAddress,
|
|
1472
|
+
fixedPriceArgs.mintComment || ""
|
|
1473
|
+
]),
|
|
1474
|
+
fixedPriceArgs.mintReferral || import_viem6.zeroAddress
|
|
1475
|
+
]
|
|
1476
|
+
});
|
|
1477
|
+
case "erc20":
|
|
1478
|
+
const erc20Args = mintArguments;
|
|
1479
|
+
return makeSimulateContractParamaters({
|
|
1480
|
+
abi: import_protocol_deployments6.erc20MinterABI,
|
|
1481
|
+
functionName: "mint",
|
|
1482
|
+
account: minterAccount,
|
|
1483
|
+
address: salesConfigAndTokenInfo?.salesConfig.address || import_protocol_deployments6.erc20MinterAddress[999999999],
|
|
1484
|
+
/* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
|
|
1485
|
+
args: [
|
|
1486
|
+
mintArguments.mintToAddress,
|
|
1487
|
+
mintQuantity,
|
|
1488
|
+
tokenAddress,
|
|
1489
|
+
BigInt(tokenId),
|
|
1490
|
+
salesConfigAndTokenInfo.salesConfig.pricePerToken,
|
|
1491
|
+
salesConfigAndTokenInfo.salesConfig.currency,
|
|
1492
|
+
erc20Args.mintReferral || import_viem6.zeroAddress,
|
|
1493
|
+
erc20Args.mintComment || ""
|
|
1494
|
+
]
|
|
1495
|
+
});
|
|
1496
|
+
default:
|
|
1497
|
+
throw new MintError("Unsupported sale type");
|
|
1498
|
+
}
|
|
1340
1499
|
}
|
|
1341
1500
|
|
|
1342
1501
|
// src/create/1155-create-helper.ts
|
|
1343
1502
|
var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
|
|
1344
|
-
var
|
|
1503
|
+
var import_viem7 = require("viem");
|
|
1345
1504
|
var SALE_END_FOREVER = 18446744073709551615n;
|
|
1346
1505
|
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
1347
1506
|
var DEFAULT_SALE_SETTINGS = {
|
|
1348
|
-
fundsRecipient:
|
|
1507
|
+
fundsRecipient: import_viem7.zeroAddress,
|
|
1349
1508
|
// Free Mint
|
|
1350
1509
|
pricePerToken: 0n,
|
|
1351
1510
|
// Sale start time – defaults to beginning of unix time
|
|
@@ -1384,32 +1543,32 @@ function create1155TokenSetupArgs({
|
|
|
1384
1543
|
...salesConfig
|
|
1385
1544
|
};
|
|
1386
1545
|
const setupActions = [
|
|
1387
|
-
(0,
|
|
1546
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1388
1547
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1389
1548
|
functionName: "assumeLastTokenIdMatches",
|
|
1390
1549
|
args: [nextTokenId - 1n]
|
|
1391
1550
|
}),
|
|
1392
|
-
createReferral ? (0,
|
|
1551
|
+
createReferral ? (0, import_viem7.encodeFunctionData)({
|
|
1393
1552
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1394
1553
|
functionName: "setupNewTokenWithCreateReferral",
|
|
1395
1554
|
args: [tokenMetadataURI, maxSupply, createReferral]
|
|
1396
|
-
}) : (0,
|
|
1555
|
+
}) : (0, import_viem7.encodeFunctionData)({
|
|
1397
1556
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1398
1557
|
functionName: "setupNewToken",
|
|
1399
1558
|
args: [tokenMetadataURI, maxSupply]
|
|
1400
1559
|
}),
|
|
1401
|
-
(0,
|
|
1560
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1402
1561
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1403
1562
|
functionName: "addPermission",
|
|
1404
1563
|
args: [0n, fixedPriceMinterAddress, PERMISSION_BIT_MINTER]
|
|
1405
1564
|
}),
|
|
1406
|
-
(0,
|
|
1565
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1407
1566
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1408
1567
|
functionName: "callSale",
|
|
1409
1568
|
args: [
|
|
1410
1569
|
nextTokenId,
|
|
1411
1570
|
fixedPriceMinterAddress,
|
|
1412
|
-
(0,
|
|
1571
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1413
1572
|
abi: import_protocol_deployments7.zoraCreatorFixedPriceSaleStrategyABI,
|
|
1414
1573
|
functionName: "setSale",
|
|
1415
1574
|
args: [nextTokenId, salesConfigWithDefaults]
|
|
@@ -1419,7 +1578,7 @@ function create1155TokenSetupArgs({
|
|
|
1419
1578
|
];
|
|
1420
1579
|
if (mintToCreatorCount) {
|
|
1421
1580
|
setupActions.push(
|
|
1422
|
-
(0,
|
|
1581
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1423
1582
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1424
1583
|
functionName: "adminMint",
|
|
1425
1584
|
args: [account, nextTokenId, mintToCreatorCount, "0x"]
|
|
@@ -1428,7 +1587,7 @@ function create1155TokenSetupArgs({
|
|
|
1428
1587
|
}
|
|
1429
1588
|
if (royaltySettings) {
|
|
1430
1589
|
setupActions.push(
|
|
1431
|
-
(0,
|
|
1590
|
+
(0, import_viem7.encodeFunctionData)({
|
|
1432
1591
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1433
1592
|
functionName: "updateRoyaltiesForToken",
|
|
1434
1593
|
args: [
|
|
@@ -1447,7 +1606,7 @@ function create1155TokenSetupArgs({
|
|
|
1447
1606
|
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
1448
1607
|
for (const data of receipt.logs) {
|
|
1449
1608
|
try {
|
|
1450
|
-
const decodedLog = (0,
|
|
1609
|
+
const decodedLog = (0, import_viem7.decodeEventLog)({
|
|
1451
1610
|
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1452
1611
|
eventName: "SetupNewToken",
|
|
1453
1612
|
...data
|
|
@@ -1491,9 +1650,8 @@ async function getContractExists(publicClient, contract, account) {
|
|
|
1491
1650
|
contractAddress: contract
|
|
1492
1651
|
};
|
|
1493
1652
|
}
|
|
1494
|
-
function create1155CreatorClient({
|
|
1495
|
-
publicClient
|
|
1496
|
-
}) {
|
|
1653
|
+
function create1155CreatorClient(clientConfig) {
|
|
1654
|
+
const { publicClient } = setupClient(clientConfig);
|
|
1497
1655
|
async function createNew1155Token({
|
|
1498
1656
|
contract,
|
|
1499
1657
|
tokenMetadataURI,
|
|
@@ -1646,7 +1804,7 @@ var sumBalances = (mintAccountBalances) => {
|
|
|
1646
1804
|
|
|
1647
1805
|
// src/mints/mints-contracts.ts
|
|
1648
1806
|
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
1649
|
-
var
|
|
1807
|
+
var import_viem8 = require("viem");
|
|
1650
1808
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
1651
1809
|
var mintWithEthParams = ({
|
|
1652
1810
|
quantity,
|
|
@@ -1681,7 +1839,7 @@ var encodeCollectOnManager = ({
|
|
|
1681
1839
|
minter,
|
|
1682
1840
|
zoraCreator1155TokenId,
|
|
1683
1841
|
mintArguments
|
|
1684
|
-
}) => (0,
|
|
1842
|
+
}) => (0, import_viem8.encodeFunctionData)({
|
|
1685
1843
|
abi: import_protocol_deployments8.zoraMintsManagerImplConfig.abi,
|
|
1686
1844
|
functionName: "collect",
|
|
1687
1845
|
args: [
|
|
@@ -1801,8 +1959,8 @@ var encodePremintOnManager = ({
|
|
|
1801
1959
|
premintConfig,
|
|
1802
1960
|
premintSignature,
|
|
1803
1961
|
mintArguments,
|
|
1804
|
-
signerContract =
|
|
1805
|
-
}) => (0,
|
|
1962
|
+
signerContract = import_viem8.zeroAddress
|
|
1963
|
+
}) => (0, import_viem8.encodeFunctionData)({
|
|
1806
1964
|
abi: import_protocol_deployments8.zoraMintsManagerImplConfig.abi,
|
|
1807
1965
|
functionName: "collectPremintV2",
|
|
1808
1966
|
args: [
|
|
@@ -1869,7 +2027,7 @@ function decodeCallFailedError(error) {
|
|
|
1869
2027
|
if (error.data?.errorName !== "CallFailed")
|
|
1870
2028
|
throw new Error("Not a CallFailed error");
|
|
1871
2029
|
const internalErrorData = error.data?.args?.[0];
|
|
1872
|
-
return (0,
|
|
2030
|
+
return (0, import_viem8.decodeErrorResult)({
|
|
1873
2031
|
abi: import_protocol_deployments8.zoraMintsManagerImplABI,
|
|
1874
2032
|
data: internalErrorData
|
|
1875
2033
|
});
|
|
@@ -1877,12 +2035,12 @@ function decodeCallFailedError(error) {
|
|
|
1877
2035
|
|
|
1878
2036
|
// src/mints/mints-eth-unwrapper-and-caller.ts
|
|
1879
2037
|
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
1880
|
-
var
|
|
2038
|
+
var import_viem9 = require("viem");
|
|
1881
2039
|
var makeCallWithEthSafeTransferData = ({
|
|
1882
2040
|
address: addressToCall,
|
|
1883
2041
|
call: functionToCall,
|
|
1884
2042
|
value: valueToSend
|
|
1885
|
-
}) => (0,
|
|
2043
|
+
}) => (0, import_viem9.encodeFunctionData)({
|
|
1886
2044
|
abi: import_protocol_deployments9.iUnwrapAndForwardActionABI,
|
|
1887
2045
|
functionName: "callWithEth",
|
|
1888
2046
|
args: [addressToCall, functionToCall, valueToSend]
|
|
@@ -1949,6 +2107,7 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
1949
2107
|
makePermitToCollectPremintOrNonPremint,
|
|
1950
2108
|
makePermitTransferBatchAndTypeData,
|
|
1951
2109
|
makePermitTransferTypeData,
|
|
2110
|
+
makeUrls,
|
|
1952
2111
|
migratePremintConfigToV2,
|
|
1953
2112
|
mintWithEthParams,
|
|
1954
2113
|
mintsBalanceOfAccountParams,
|