@zoralabs/protocol-sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +6 -0
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.cjs +845 -407
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +829 -391
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +28 -4071
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +38 -0
- package/dist/mint/mint-queries.d.ts.map +1 -0
- package/dist/mint/mint-transactions.d.ts +20 -0
- package/dist/mint/mint-transactions.d.ts.map +1 -0
- package/dist/mint/subgraph-mint-getter.d.ts +14 -7
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +55 -0
- package/dist/mint/subgraph-queries.d.ts.map +1 -0
- package/dist/mint/types.d.ts +117 -19
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/mint/utils.d.ts +2 -0
- package/dist/mint/utils.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +3 -4494
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +12 -15
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +14 -11
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +15 -5
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +1 -1
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +4 -2
- package/dist/sdk.d.ts.map +1 -1
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +10 -2
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/constants.ts +0 -36
- package/src/create/1155-create-helper.test.ts +9 -7
- package/src/mint/mint-client.test.ts +96 -47
- package/src/mint/mint-client.ts +75 -343
- package/src/mint/mint-queries.ts +320 -0
- package/src/mint/mint-transactions.ts +253 -0
- package/src/mint/subgraph-mint-getter.ts +216 -123
- package/src/mint/subgraph-queries.ts +170 -0
- package/src/mint/types.ts +140 -23
- package/src/mint/utils.ts +14 -0
- package/src/premint/conversions.ts +26 -2
- package/src/premint/premint-api-client.ts +48 -16
- package/src/premint/premint-client.test.ts +29 -23
- package/src/premint/premint-client.ts +64 -36
- package/src/premint/preminter.ts +2 -3
- package/src/sdk.ts +7 -4
- package/src/types.ts +18 -0
- package/src/utils.ts +29 -28
- package/test-integration/setup-test-contracts.ts +96 -0
- package/test-integration/premint-client.test.ts +0 -148
package/dist/index.js
CHANGED
|
@@ -49,41 +49,6 @@ var zora721Abi = parseAbi([
|
|
|
49
49
|
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
50
50
|
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
51
51
|
]);
|
|
52
|
-
var NFT_SALE_QUERY = `
|
|
53
|
-
fragment SaleStrategy on SalesStrategyConfig {
|
|
54
|
-
type
|
|
55
|
-
fixedPrice {
|
|
56
|
-
address
|
|
57
|
-
pricePerToken
|
|
58
|
-
saleEnd
|
|
59
|
-
saleStart
|
|
60
|
-
maxTokensPerAddress
|
|
61
|
-
}
|
|
62
|
-
erc20Minter {
|
|
63
|
-
address
|
|
64
|
-
pricePerToken
|
|
65
|
-
currency
|
|
66
|
-
saleEnd
|
|
67
|
-
saleStart
|
|
68
|
-
maxTokensPerAddress
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
query ($id: ID!) {
|
|
73
|
-
zoraCreateToken(id: $id) {
|
|
74
|
-
id
|
|
75
|
-
contract {
|
|
76
|
-
mintFeePerQuantity
|
|
77
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
78
|
-
...SaleStrategy
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
82
|
-
...SaleStrategy
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
`;
|
|
87
52
|
|
|
88
53
|
// src/apis/chain-constants.ts
|
|
89
54
|
var REWARD_PER_TOKEN = parseEther("0.000777");
|
|
@@ -212,10 +177,22 @@ var convertPremintFromApi = (premint) => {
|
|
|
212
177
|
}
|
|
213
178
|
};
|
|
214
179
|
var convertGetPremintApiResponse = (response) => ({
|
|
215
|
-
...convertPremintFromApi(response.premint),
|
|
216
180
|
collection: convertCollectionFromApi(response.collection),
|
|
217
181
|
collectionAddress: response.collection_address,
|
|
218
|
-
signature: response.signature
|
|
182
|
+
signature: response.signature,
|
|
183
|
+
signer: response.signer,
|
|
184
|
+
premint: convertPremintFromApi(response.premint)
|
|
185
|
+
});
|
|
186
|
+
var convertGetPremintOfCollectionApiResponse = (response) => ({
|
|
187
|
+
collection: convertCollectionFromApi({
|
|
188
|
+
contractAdmin: response.contract_admin,
|
|
189
|
+
contractName: response.contract_name,
|
|
190
|
+
contractURI: response.contract_uri
|
|
191
|
+
}),
|
|
192
|
+
premints: response.premints.map((premint) => ({
|
|
193
|
+
premint: convertPremintFromApi(premint),
|
|
194
|
+
signature: premint.signature
|
|
195
|
+
}))
|
|
219
196
|
});
|
|
220
197
|
var encodePremintV1ForAPI = ({
|
|
221
198
|
tokenConfig,
|
|
@@ -504,7 +481,7 @@ async function getPremintPricePerToken({
|
|
|
504
481
|
uid,
|
|
505
482
|
premintGetter
|
|
506
483
|
}) {
|
|
507
|
-
const premintConfigWithVersion = await premintGetter.
|
|
484
|
+
const { premint: premintConfigWithVersion } = await premintGetter.get({
|
|
508
485
|
collectionAddress: collection,
|
|
509
486
|
uid
|
|
510
487
|
});
|
|
@@ -646,6 +623,144 @@ var httpClient = {
|
|
|
646
623
|
retries
|
|
647
624
|
};
|
|
648
625
|
|
|
626
|
+
// src/mint/types.ts
|
|
627
|
+
var isOnChainMint = (mint2) => mint2.mintType !== "premint";
|
|
628
|
+
var is1155Mint = (mint2) => mint2.mintType === "1155";
|
|
629
|
+
function isErc20SaleStrategy(salesConfig) {
|
|
630
|
+
return salesConfig.saleType === "erc20";
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
// src/utils.ts
|
|
634
|
+
var makeContractParameters = (args) => args;
|
|
635
|
+
function mintRecipientOrAccount({
|
|
636
|
+
mintRecipient,
|
|
637
|
+
minterAccount
|
|
638
|
+
}) {
|
|
639
|
+
return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
640
|
+
}
|
|
641
|
+
async function querySubgraphWithRetries({
|
|
642
|
+
httpClient: httpClient2,
|
|
643
|
+
subgraphUrl,
|
|
644
|
+
query,
|
|
645
|
+
variables
|
|
646
|
+
}) {
|
|
647
|
+
const { retries: retries2, post: post2 } = httpClient2;
|
|
648
|
+
const result = await retries2(async () => {
|
|
649
|
+
return await post2(subgraphUrl, {
|
|
650
|
+
query,
|
|
651
|
+
variables
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
return result?.data;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// src/mint/subgraph-queries.ts
|
|
658
|
+
var NFT_SALE_STRATEGY_FRAGMENT = `
|
|
659
|
+
fragment SaleStrategy on SalesStrategyConfig {
|
|
660
|
+
type
|
|
661
|
+
fixedPrice {
|
|
662
|
+
address
|
|
663
|
+
pricePerToken
|
|
664
|
+
saleEnd
|
|
665
|
+
saleStart
|
|
666
|
+
maxTokensPerAddress
|
|
667
|
+
}
|
|
668
|
+
erc20Minter {
|
|
669
|
+
address
|
|
670
|
+
pricePerToken
|
|
671
|
+
currency
|
|
672
|
+
saleEnd
|
|
673
|
+
saleStart
|
|
674
|
+
maxTokensPerAddress
|
|
675
|
+
}
|
|
676
|
+
}`;
|
|
677
|
+
var TOKEN_FRAGMENT = `
|
|
678
|
+
fragment Token on ZoraCreateToken {
|
|
679
|
+
creator
|
|
680
|
+
tokenId
|
|
681
|
+
uri
|
|
682
|
+
totalMinted
|
|
683
|
+
maxSupply
|
|
684
|
+
tokenStandard
|
|
685
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
686
|
+
...SaleStrategy
|
|
687
|
+
}
|
|
688
|
+
contract {
|
|
689
|
+
address
|
|
690
|
+
mintFeePerQuantity
|
|
691
|
+
contractVersion
|
|
692
|
+
contractURI
|
|
693
|
+
name
|
|
694
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
695
|
+
...SaleStrategy
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}`;
|
|
699
|
+
var FRAGMENTS = `
|
|
700
|
+
${NFT_SALE_STRATEGY_FRAGMENT}
|
|
701
|
+
${TOKEN_FRAGMENT}
|
|
702
|
+
`;
|
|
703
|
+
function buildNftTokenSalesQuery({
|
|
704
|
+
tokenId,
|
|
705
|
+
tokenAddress
|
|
706
|
+
}) {
|
|
707
|
+
return {
|
|
708
|
+
query: `
|
|
709
|
+
${FRAGMENTS}
|
|
710
|
+
query ($id: ID!) {
|
|
711
|
+
zoraCreateToken(id: $id) {
|
|
712
|
+
...Token
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
`,
|
|
716
|
+
variables: {
|
|
717
|
+
id: tokenId !== void 0 ? (
|
|
718
|
+
// Generic Token ID types all stringify down to the base numeric equivalent.
|
|
719
|
+
`${tokenAddress.toLowerCase()}-${tokenId}`
|
|
720
|
+
) : `${tokenAddress.toLowerCase()}-0`
|
|
721
|
+
},
|
|
722
|
+
parseResponseData: (responseData) => responseData?.zoraCreateToken
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
function buildContractTokensQuery({
|
|
726
|
+
tokenAddress
|
|
727
|
+
}) {
|
|
728
|
+
return {
|
|
729
|
+
query: `
|
|
730
|
+
${FRAGMENTS}
|
|
731
|
+
query ($contract: Bytes!) {
|
|
732
|
+
zoraCreateTokens(
|
|
733
|
+
where: {address: $contract}
|
|
734
|
+
) {
|
|
735
|
+
...Token
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
`,
|
|
739
|
+
variables: {
|
|
740
|
+
contract: tokenAddress.toLowerCase()
|
|
741
|
+
},
|
|
742
|
+
parseResponseData: (responseData) => responseData?.zoraCreateTokens
|
|
743
|
+
};
|
|
744
|
+
}
|
|
745
|
+
function buildPremintsOfContractQuery({
|
|
746
|
+
tokenAddress
|
|
747
|
+
}) {
|
|
748
|
+
return {
|
|
749
|
+
query: `
|
|
750
|
+
query ($contractAddress: Bytes!) {
|
|
751
|
+
premints(where:{contractAddress:$contractAddress}) {
|
|
752
|
+
uid
|
|
753
|
+
tokenId
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
`,
|
|
757
|
+
variables: {
|
|
758
|
+
contractAddress: tokenAddress.toLowerCase()
|
|
759
|
+
},
|
|
760
|
+
parseResponseData: (responseData) => responseData?.premints
|
|
761
|
+
};
|
|
762
|
+
}
|
|
763
|
+
|
|
649
764
|
// src/mint/subgraph-mint-getter.ts
|
|
650
765
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
651
766
|
if (!networkConfigByChain[chainId]) {
|
|
@@ -653,92 +768,171 @@ var getApiNetworkConfigForChain = (chainId) => {
|
|
|
653
768
|
}
|
|
654
769
|
return networkConfigByChain[chainId];
|
|
655
770
|
};
|
|
771
|
+
function parseSalesConfig(targetStrategy) {
|
|
772
|
+
if (targetStrategy.type === "FIXED_PRICE")
|
|
773
|
+
return {
|
|
774
|
+
saleType: "fixedPrice",
|
|
775
|
+
...targetStrategy.fixedPrice,
|
|
776
|
+
maxTokensPerAddress: BigInt(
|
|
777
|
+
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
778
|
+
),
|
|
779
|
+
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
780
|
+
};
|
|
781
|
+
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
782
|
+
return {
|
|
783
|
+
saleType: "erc20",
|
|
784
|
+
...targetStrategy.erc20Minter,
|
|
785
|
+
maxTokensPerAddress: BigInt(
|
|
786
|
+
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
787
|
+
),
|
|
788
|
+
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
789
|
+
};
|
|
790
|
+
}
|
|
791
|
+
throw new Error("Unknown saleType");
|
|
792
|
+
}
|
|
793
|
+
function getSaleEnd(a) {
|
|
794
|
+
return BigInt(
|
|
795
|
+
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
796
|
+
);
|
|
797
|
+
}
|
|
798
|
+
function getTargetStrategy({
|
|
799
|
+
tokenId,
|
|
800
|
+
preferredSaleType,
|
|
801
|
+
token
|
|
802
|
+
}) {
|
|
803
|
+
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
804
|
+
const saleStrategies = allStrategies.sort(
|
|
805
|
+
(a, b) => getSaleEnd(a) > getSaleEnd(b) ? 1 : -1
|
|
806
|
+
);
|
|
807
|
+
let targetStrategy;
|
|
808
|
+
if (!preferredSaleType) {
|
|
809
|
+
targetStrategy = saleStrategies[0];
|
|
810
|
+
if (!targetStrategy) {
|
|
811
|
+
throw new Error("Cannot find sale strategy");
|
|
812
|
+
}
|
|
813
|
+
} else {
|
|
814
|
+
const mappedSaleType = preferredSaleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
815
|
+
targetStrategy = saleStrategies.find(
|
|
816
|
+
(strategy) => strategy.type === mappedSaleType
|
|
817
|
+
);
|
|
818
|
+
if (!targetStrategy) {
|
|
819
|
+
const targetStrategy2 = saleStrategies.find(
|
|
820
|
+
(strategy) => strategy.type === "FIXED_PRICE" || strategy.type === "ERC_20_MINTER"
|
|
821
|
+
);
|
|
822
|
+
if (!targetStrategy2)
|
|
823
|
+
throw new Error("Cannot find valid sale strategy");
|
|
824
|
+
return targetStrategy2;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
return targetStrategy;
|
|
828
|
+
}
|
|
656
829
|
var SubgraphMintGetter = class {
|
|
657
830
|
constructor(chainId, httpClient2) {
|
|
831
|
+
this.getMintable = async ({
|
|
832
|
+
tokenAddress,
|
|
833
|
+
tokenId,
|
|
834
|
+
preferredSaleType: saleType
|
|
835
|
+
}) => {
|
|
836
|
+
const token = await this.querySubgraphWithRetries(
|
|
837
|
+
buildNftTokenSalesQuery({
|
|
838
|
+
tokenId,
|
|
839
|
+
tokenAddress
|
|
840
|
+
})
|
|
841
|
+
);
|
|
842
|
+
if (!token) {
|
|
843
|
+
throw new Error("Cannot find token");
|
|
844
|
+
}
|
|
845
|
+
return parseTokenQueryResult({
|
|
846
|
+
token,
|
|
847
|
+
tokenId,
|
|
848
|
+
preferredSaleType: saleType
|
|
849
|
+
});
|
|
850
|
+
};
|
|
658
851
|
this.httpClient = httpClient2 || httpClient;
|
|
659
852
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
660
853
|
}
|
|
661
|
-
async
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
854
|
+
async querySubgraphWithRetries({
|
|
855
|
+
query,
|
|
856
|
+
variables,
|
|
857
|
+
parseResponseData
|
|
665
858
|
}) {
|
|
666
|
-
const
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
id: tokenId !== void 0 ? (
|
|
672
|
-
// Generic Token ID types all stringify down to the base numeric equivalent.
|
|
673
|
-
`${tokenAddress.toLowerCase()}-${tokenId}`
|
|
674
|
-
) : `${tokenAddress.toLowerCase()}-0`
|
|
675
|
-
}
|
|
676
|
-
});
|
|
677
|
-
const token = response.data?.zoraCreateToken;
|
|
678
|
-
if (!token) {
|
|
679
|
-
throw new Error("Cannot find a token to mint");
|
|
680
|
-
}
|
|
681
|
-
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
682
|
-
const saleStrategies = allStrategies.sort(
|
|
683
|
-
(a, b) => BigInt(
|
|
684
|
-
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
685
|
-
) > BigInt(
|
|
686
|
-
b.type === "FIXED_PRICE" ? b.fixedPrice.saleEnd : b.erc20Minter.saleEnd
|
|
687
|
-
) ? 1 : -1
|
|
688
|
-
);
|
|
689
|
-
let targetStrategy;
|
|
690
|
-
if (!saleType) {
|
|
691
|
-
targetStrategy = saleStrategies[0];
|
|
692
|
-
if (!targetStrategy) {
|
|
693
|
-
throw new Error("Cannot find sale strategy");
|
|
694
|
-
}
|
|
695
|
-
} else {
|
|
696
|
-
const mappedSaleType = saleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
697
|
-
targetStrategy = saleStrategies.find(
|
|
698
|
-
(strategy) => strategy.type === mappedSaleType
|
|
699
|
-
);
|
|
700
|
-
if (!targetStrategy) {
|
|
701
|
-
throw new Error(`Cannot find sale strategy for ${mappedSaleType}`);
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
if (targetStrategy.type === "FIXED_PRICE") {
|
|
705
|
-
return {
|
|
706
|
-
salesConfig: {
|
|
707
|
-
saleType: "fixedPrice",
|
|
708
|
-
...targetStrategy.fixedPrice,
|
|
709
|
-
maxTokensPerAddress: BigInt(
|
|
710
|
-
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
711
|
-
),
|
|
712
|
-
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
713
|
-
},
|
|
714
|
-
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
715
|
-
};
|
|
716
|
-
}
|
|
717
|
-
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
718
|
-
return {
|
|
719
|
-
salesConfig: {
|
|
720
|
-
saleType: "erc20",
|
|
721
|
-
...targetStrategy.erc20Minter,
|
|
722
|
-
maxTokensPerAddress: BigInt(
|
|
723
|
-
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
724
|
-
),
|
|
725
|
-
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
726
|
-
},
|
|
727
|
-
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
728
|
-
};
|
|
729
|
-
}
|
|
730
|
-
throw new Error("Invalid saleType");
|
|
859
|
+
const responseData = await querySubgraphWithRetries({
|
|
860
|
+
httpClient: this.httpClient,
|
|
861
|
+
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
862
|
+
query,
|
|
863
|
+
variables
|
|
731
864
|
});
|
|
865
|
+
return parseResponseData(responseData);
|
|
866
|
+
}
|
|
867
|
+
async getContractMintable({
|
|
868
|
+
tokenAddress,
|
|
869
|
+
preferredSaleType
|
|
870
|
+
}) {
|
|
871
|
+
const tokens = await this.querySubgraphWithRetries(
|
|
872
|
+
buildContractTokensQuery({
|
|
873
|
+
tokenAddress
|
|
874
|
+
})
|
|
875
|
+
);
|
|
876
|
+
if (!tokens)
|
|
877
|
+
return [];
|
|
878
|
+
return tokens.filter((x) => x.tokenId !== "0").map(
|
|
879
|
+
(token) => parseTokenQueryResult({
|
|
880
|
+
token,
|
|
881
|
+
tokenId: token.tokenId,
|
|
882
|
+
preferredSaleType
|
|
883
|
+
})
|
|
884
|
+
);
|
|
885
|
+
}
|
|
886
|
+
async getContractPremintTokenIds({
|
|
887
|
+
tokenAddress
|
|
888
|
+
}) {
|
|
889
|
+
const premints = await this.querySubgraphWithRetries(
|
|
890
|
+
buildPremintsOfContractQuery({
|
|
891
|
+
tokenAddress
|
|
892
|
+
})
|
|
893
|
+
);
|
|
894
|
+
return premints?.map((premint) => ({
|
|
895
|
+
tokenId: BigInt(premint.tokenId),
|
|
896
|
+
uid: +premint.uid
|
|
897
|
+
})) || [];
|
|
732
898
|
}
|
|
733
899
|
};
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
mintRecipient,
|
|
739
|
-
minterAccount
|
|
900
|
+
function parseTokenQueryResult({
|
|
901
|
+
token,
|
|
902
|
+
tokenId,
|
|
903
|
+
preferredSaleType
|
|
740
904
|
}) {
|
|
741
|
-
|
|
905
|
+
const targetStrategy = getTargetStrategy({
|
|
906
|
+
tokenId,
|
|
907
|
+
preferredSaleType,
|
|
908
|
+
token
|
|
909
|
+
});
|
|
910
|
+
const tokenInfo = parseTokenInfo(token);
|
|
911
|
+
const salesConfig = parseSalesConfig(targetStrategy);
|
|
912
|
+
if (isErc20SaleStrategy(salesConfig)) {
|
|
913
|
+
tokenInfo.mintFeePerQuantity = 0n;
|
|
914
|
+
}
|
|
915
|
+
return {
|
|
916
|
+
...tokenInfo,
|
|
917
|
+
salesConfig
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
function parseTokenInfo(token) {
|
|
921
|
+
return {
|
|
922
|
+
contract: {
|
|
923
|
+
address: token.contract.address,
|
|
924
|
+
name: token.contract.name,
|
|
925
|
+
URI: token.contract.contractURI
|
|
926
|
+
},
|
|
927
|
+
tokenURI: token.uri,
|
|
928
|
+
tokenId: token.tokenId ? BigInt(token.tokenId) : void 0,
|
|
929
|
+
mintType: token.tokenStandard === "ERC721" ? "721" : "1155",
|
|
930
|
+
creator: token.creator,
|
|
931
|
+
totalMinted: BigInt(token.totalMinted),
|
|
932
|
+
maxSupply: BigInt(token.maxSupply),
|
|
933
|
+
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity),
|
|
934
|
+
contractVersion: token.contract.contractVersion
|
|
935
|
+
};
|
|
742
936
|
}
|
|
743
937
|
|
|
744
938
|
// src/premint/premint-client.ts
|
|
@@ -896,7 +1090,7 @@ var PremintClient = class {
|
|
|
896
1090
|
* @returns PremintSignatureGetResponse of premint data from the API
|
|
897
1091
|
*/
|
|
898
1092
|
async getPremint({ address, uid }) {
|
|
899
|
-
return await this.apiClient.
|
|
1093
|
+
return await this.apiClient.get({
|
|
900
1094
|
collectionAddress: address,
|
|
901
1095
|
uid
|
|
902
1096
|
});
|
|
@@ -1131,10 +1325,9 @@ async function updatePremint({
|
|
|
1131
1325
|
chainId
|
|
1132
1326
|
}) {
|
|
1133
1327
|
const {
|
|
1134
|
-
premintConfig,
|
|
1135
|
-
collection: collectionCreationConfig
|
|
1136
|
-
|
|
1137
|
-
} = await apiClient.getSignature({
|
|
1328
|
+
premint: { premintConfig, premintConfigVersion },
|
|
1329
|
+
collection: collectionCreationConfig
|
|
1330
|
+
} = await apiClient.get({
|
|
1138
1331
|
collectionAddress: collection,
|
|
1139
1332
|
uid
|
|
1140
1333
|
});
|
|
@@ -1162,11 +1355,10 @@ async function deletePremint({
|
|
|
1162
1355
|
chainId
|
|
1163
1356
|
}) {
|
|
1164
1357
|
const {
|
|
1165
|
-
premintConfig,
|
|
1166
|
-
premintConfigVersion,
|
|
1358
|
+
premint: { premintConfig, premintConfigVersion },
|
|
1167
1359
|
collection: collectionCreationConfig,
|
|
1168
1360
|
collectionAddress
|
|
1169
|
-
} = await apiClient.
|
|
1361
|
+
} = await apiClient.get({
|
|
1170
1362
|
collectionAddress: collection,
|
|
1171
1363
|
uid
|
|
1172
1364
|
});
|
|
@@ -1200,26 +1392,39 @@ async function collectPremint({
|
|
|
1200
1392
|
if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
|
|
1201
1393
|
throw new Error("Quantity to mint cannot be below 1");
|
|
1202
1394
|
}
|
|
1203
|
-
const {
|
|
1204
|
-
premintConfig,
|
|
1205
|
-
premintConfigVersion,
|
|
1206
|
-
collection,
|
|
1207
|
-
collectionAddress,
|
|
1208
|
-
signature
|
|
1209
|
-
} = await premintGetter.getSignature({
|
|
1395
|
+
const premint = await premintGetter.get({
|
|
1210
1396
|
collectionAddress: tokenContract,
|
|
1211
1397
|
uid
|
|
1212
1398
|
});
|
|
1213
|
-
const
|
|
1214
|
-
if (premintConfigVersion === PremintConfigVersion2.V3) {
|
|
1215
|
-
throw new Error("PremintV3 not supported in premint SDK");
|
|
1216
|
-
}
|
|
1217
|
-
const value = (await getPremintMintCosts({
|
|
1399
|
+
const mintFee = await getPremintMintFee({
|
|
1218
1400
|
tokenContract,
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1401
|
+
publicClient
|
|
1402
|
+
});
|
|
1403
|
+
return buildPremintMintCall({
|
|
1404
|
+
mintArguments: {
|
|
1405
|
+
minterAccount,
|
|
1406
|
+
quantityToMint,
|
|
1407
|
+
firstMinter,
|
|
1408
|
+
mintComment,
|
|
1409
|
+
mintRecipient,
|
|
1410
|
+
mintReferral
|
|
1411
|
+
},
|
|
1412
|
+
mintFee,
|
|
1413
|
+
premint
|
|
1414
|
+
});
|
|
1415
|
+
}
|
|
1416
|
+
var buildPremintMintCall = ({
|
|
1417
|
+
mintArguments: {
|
|
1418
|
+
minterAccount,
|
|
1419
|
+
mintComment = "",
|
|
1420
|
+
mintRecipient,
|
|
1421
|
+
mintReferral,
|
|
1422
|
+
firstMinter,
|
|
1423
|
+
quantityToMint
|
|
1424
|
+
},
|
|
1425
|
+
premint: { collection, collectionAddress, premint, signature },
|
|
1426
|
+
mintFee
|
|
1427
|
+
}) => {
|
|
1223
1428
|
const mintArgumentsContract = {
|
|
1224
1429
|
mintComment,
|
|
1225
1430
|
mintRecipient: mintRecipientOrAccount({
|
|
@@ -1233,6 +1438,10 @@ async function collectPremint({
|
|
|
1233
1438
|
const collectionOrEmpty = collection ? defaultAdditionalAdmins(collection) : emptyContractCreationConfig();
|
|
1234
1439
|
const collectionAddressToSubmit = collection ? zeroAddress2 : collectionAddress;
|
|
1235
1440
|
const firstMinterToSubmit = firstMinter || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
1441
|
+
if (premint.premintConfigVersion === PremintConfigVersion2.V3) {
|
|
1442
|
+
throw new Error("PremintV3 not supported in premint SDK");
|
|
1443
|
+
}
|
|
1444
|
+
const value = (mintFee + premint.premintConfig.tokenConfig.pricePerToken) * BigInt(quantityToMint);
|
|
1236
1445
|
return makeContractParameters({
|
|
1237
1446
|
account: minterAccount,
|
|
1238
1447
|
abi: zoraCreator1155PremintExecutorImplABI2,
|
|
@@ -1242,18 +1451,15 @@ async function collectPremint({
|
|
|
1242
1451
|
args: [
|
|
1243
1452
|
collectionOrEmpty,
|
|
1244
1453
|
collectionAddressToSubmit,
|
|
1245
|
-
encodePremintConfig(
|
|
1246
|
-
premintConfig,
|
|
1247
|
-
premintConfigVersion
|
|
1248
|
-
}),
|
|
1454
|
+
encodePremintConfig(premint),
|
|
1249
1455
|
signature,
|
|
1250
|
-
|
|
1456
|
+
BigInt(quantityToMint),
|
|
1251
1457
|
mintArgumentsContract,
|
|
1252
1458
|
firstMinterToSubmit,
|
|
1253
1459
|
zeroAddress2
|
|
1254
1460
|
]
|
|
1255
1461
|
});
|
|
1256
|
-
}
|
|
1462
|
+
};
|
|
1257
1463
|
function makeUrls({
|
|
1258
1464
|
uid,
|
|
1259
1465
|
address,
|
|
@@ -1314,6 +1520,19 @@ var getSignature = async ({
|
|
|
1314
1520
|
);
|
|
1315
1521
|
return convertGetPremintApiResponse(result);
|
|
1316
1522
|
};
|
|
1523
|
+
var getOfCollection = async ({
|
|
1524
|
+
collectionAddress,
|
|
1525
|
+
chainId,
|
|
1526
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
1527
|
+
}) => {
|
|
1528
|
+
const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
|
|
1529
|
+
const result = await retries2(
|
|
1530
|
+
() => get2(
|
|
1531
|
+
`${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}`
|
|
1532
|
+
)
|
|
1533
|
+
);
|
|
1534
|
+
return convertGetPremintOfCollectionApiResponse(result);
|
|
1535
|
+
};
|
|
1317
1536
|
var PremintAPIClient = class {
|
|
1318
1537
|
constructor(chainId, httpClient2) {
|
|
1319
1538
|
this.postSignature = ({
|
|
@@ -1335,10 +1554,7 @@ var PremintAPIClient = class {
|
|
|
1335
1554
|
chainId: this.chainId,
|
|
1336
1555
|
httpClient: this.httpClient
|
|
1337
1556
|
})).next_uid;
|
|
1338
|
-
this.
|
|
1339
|
-
collectionAddress,
|
|
1340
|
-
uid
|
|
1341
|
-
}) => {
|
|
1557
|
+
this.get = async ({ collectionAddress, uid }) => {
|
|
1342
1558
|
return getSignature({
|
|
1343
1559
|
collectionAddress,
|
|
1344
1560
|
uid,
|
|
@@ -1346,180 +1562,109 @@ var PremintAPIClient = class {
|
|
|
1346
1562
|
httpClient: this.httpClient
|
|
1347
1563
|
});
|
|
1348
1564
|
};
|
|
1565
|
+
this.getOfCollection = async ({
|
|
1566
|
+
collectionAddress
|
|
1567
|
+
}) => {
|
|
1568
|
+
return getOfCollection({
|
|
1569
|
+
collectionAddress,
|
|
1570
|
+
chainId: this.chainId,
|
|
1571
|
+
httpClient: this.httpClient
|
|
1572
|
+
});
|
|
1573
|
+
};
|
|
1349
1574
|
this.chainId = chainId;
|
|
1350
1575
|
this.httpClient = httpClient2 || httpClient;
|
|
1351
1576
|
}
|
|
1352
1577
|
};
|
|
1353
1578
|
|
|
1354
|
-
// src/mint/mint-
|
|
1579
|
+
// src/mint/mint-transactions.ts
|
|
1355
1580
|
import {
|
|
1356
1581
|
encodeAbiParameters,
|
|
1357
1582
|
parseAbiParameters,
|
|
1358
|
-
zeroAddress as zeroAddress3
|
|
1359
|
-
erc20Abi
|
|
1583
|
+
zeroAddress as zeroAddress3
|
|
1360
1584
|
} from "viem";
|
|
1361
1585
|
import {
|
|
1362
1586
|
erc20MinterABI,
|
|
1363
|
-
|
|
1364
|
-
zoraCreator1155ImplABI as zoraCreator1155ImplABI2,
|
|
1365
|
-
zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress2
|
|
1587
|
+
zoraCreator1155ImplABI as zoraCreator1155ImplABI2
|
|
1366
1588
|
} from "@zoralabs/protocol-deployments";
|
|
1367
1589
|
|
|
1368
|
-
// src/mint/
|
|
1369
|
-
|
|
1370
|
-
var
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
}
|
|
1374
|
-
|
|
1375
|
-
// src/mint/mint-client.ts
|
|
1376
|
-
var MintError = class extends Error {
|
|
1377
|
-
};
|
|
1378
|
-
var MintInactiveError = class extends Error {
|
|
1379
|
-
};
|
|
1380
|
-
var Errors = {
|
|
1381
|
-
MintError,
|
|
1382
|
-
MintInactiveError
|
|
1383
|
-
};
|
|
1384
|
-
var MintClient = class {
|
|
1385
|
-
constructor({
|
|
1386
|
-
chainId,
|
|
1387
|
-
publicClient,
|
|
1388
|
-
premintGetter,
|
|
1389
|
-
mintGetter
|
|
1390
|
-
}) {
|
|
1391
|
-
this.chainId = chainId;
|
|
1392
|
-
this.publicClient = publicClient;
|
|
1393
|
-
this.mintGetter = mintGetter;
|
|
1394
|
-
this.premintGetter = premintGetter;
|
|
1395
|
-
}
|
|
1396
|
-
/**
|
|
1397
|
-
* Returns the parameters needed to prepare a transaction mint a token.
|
|
1398
|
-
* Works with premint, onchain 1155, and onchain 721.
|
|
1399
|
-
*
|
|
1400
|
-
* @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
|
|
1401
|
-
* @returns Parameters for simulating/executing the mint transaction
|
|
1402
|
-
*/
|
|
1403
|
-
async mint(parameters) {
|
|
1404
|
-
return mint({
|
|
1405
|
-
parameters,
|
|
1406
|
-
chainId: this.chainId,
|
|
1407
|
-
publicClient: this.publicClient,
|
|
1408
|
-
mintGetter: this.mintGetter,
|
|
1409
|
-
premintGetter: this.premintGetter
|
|
1410
|
-
});
|
|
1411
|
-
}
|
|
1412
|
-
/**
|
|
1413
|
-
* Gets the costs to mint the quantity of tokens specified for a mint.
|
|
1414
|
-
* @param parameters - Parameters for the mint {@link GetMintCostsParameters}
|
|
1415
|
-
* @returns Costs to mint the quantity of tokens specified
|
|
1416
|
-
*/
|
|
1417
|
-
async getMintCosts(parameters) {
|
|
1418
|
-
return getMintCosts({
|
|
1419
|
-
...parameters,
|
|
1420
|
-
mintGetter: this.mintGetter,
|
|
1421
|
-
premintGetter: this.premintGetter,
|
|
1422
|
-
publicClient: this.publicClient
|
|
1423
|
-
});
|
|
1590
|
+
// src/mint/utils.ts
|
|
1591
|
+
import * as semver from "semver";
|
|
1592
|
+
var contractSupportsNewMintFunction = (contractVersion) => {
|
|
1593
|
+
if (!contractVersion) {
|
|
1594
|
+
return false;
|
|
1424
1595
|
}
|
|
1596
|
+
const semVerContractVersion = semver.coerce(contractVersion)?.raw;
|
|
1597
|
+
if (!semVerContractVersion)
|
|
1598
|
+
return false;
|
|
1599
|
+
return semver.gte(semVerContractVersion, "2.9.0");
|
|
1425
1600
|
};
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
}
|
|
1432
|
-
async function mint({
|
|
1433
|
-
parameters,
|
|
1434
|
-
chainId,
|
|
1435
|
-
publicClient,
|
|
1436
|
-
mintGetter,
|
|
1437
|
-
premintGetter
|
|
1601
|
+
|
|
1602
|
+
// src/mint/mint-transactions.ts
|
|
1603
|
+
function makeOnchainMintCall({
|
|
1604
|
+
token,
|
|
1605
|
+
mintParams
|
|
1438
1606
|
}) {
|
|
1439
|
-
if (
|
|
1440
|
-
return {
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
})
|
|
1446
|
-
};
|
|
1607
|
+
if (token.mintType === "721") {
|
|
1608
|
+
return makePrepareMint721TokenParams({
|
|
1609
|
+
salesConfigAndTokenInfo: token,
|
|
1610
|
+
tokenContract: token.contract.address,
|
|
1611
|
+
...mintParams
|
|
1612
|
+
});
|
|
1447
1613
|
}
|
|
1448
|
-
return {
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
})
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
function requestErc20ApprovalForMint({
|
|
1457
|
-
account,
|
|
1458
|
-
tokenAddress,
|
|
1459
|
-
quantityErc20,
|
|
1460
|
-
erc20MinterAddress: erc20MinterAddress2
|
|
1461
|
-
}) {
|
|
1462
|
-
return makeContractParameters({
|
|
1463
|
-
abi: erc20Abi,
|
|
1464
|
-
address: tokenAddress,
|
|
1465
|
-
account,
|
|
1466
|
-
functionName: "approve",
|
|
1467
|
-
args: [erc20MinterAddress2, quantityErc20]
|
|
1614
|
+
return makePrepareMint1155TokenParams({
|
|
1615
|
+
salesConfigAndTokenInfo: token,
|
|
1616
|
+
tokenContract: token.contract.address,
|
|
1617
|
+
tokenId: token.tokenId,
|
|
1618
|
+
...mintParams
|
|
1468
1619
|
});
|
|
1469
1620
|
}
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1621
|
+
function makePrepareMint1155TokenParams({
|
|
1622
|
+
tokenContract,
|
|
1623
|
+
tokenId,
|
|
1624
|
+
salesConfigAndTokenInfo,
|
|
1625
|
+
minterAccount,
|
|
1626
|
+
mintComment,
|
|
1627
|
+
mintReferral,
|
|
1628
|
+
mintRecipient,
|
|
1629
|
+
quantityToMint
|
|
1476
1630
|
}) {
|
|
1477
|
-
const
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
erc20MinterAddress: destination,
|
|
1491
|
-
account,
|
|
1492
|
-
tokenAddress,
|
|
1493
|
-
quantityErc20: quantityErc20 - allowance
|
|
1631
|
+
const mintQuantity = BigInt(quantityToMint || 1);
|
|
1632
|
+
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
1633
|
+
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
1634
|
+
if (saleType === "fixedPrice") {
|
|
1635
|
+
return makeEthMintCall({
|
|
1636
|
+
mintComment,
|
|
1637
|
+
minterAccount,
|
|
1638
|
+
mintQuantity,
|
|
1639
|
+
mintReferral,
|
|
1640
|
+
mintTo,
|
|
1641
|
+
salesConfigAndTokenInfo,
|
|
1642
|
+
tokenContract,
|
|
1643
|
+
tokenId
|
|
1494
1644
|
});
|
|
1495
1645
|
}
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
...parameters
|
|
1646
|
+
if (saleType === "erc20") {
|
|
1647
|
+
return makeContractParameters({
|
|
1648
|
+
abi: erc20MinterABI,
|
|
1649
|
+
functionName: "mint",
|
|
1650
|
+
account: minterAccount,
|
|
1651
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
1652
|
+
/* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
|
|
1653
|
+
args: [
|
|
1654
|
+
mintTo,
|
|
1655
|
+
mintQuantity,
|
|
1656
|
+
tokenContract,
|
|
1657
|
+
BigInt(tokenId),
|
|
1658
|
+
salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
|
|
1659
|
+
salesConfigAndTokenInfo.salesConfig.currency,
|
|
1660
|
+
mintReferral || zeroAddress3,
|
|
1661
|
+
mintComment || ""
|
|
1662
|
+
]
|
|
1514
1663
|
});
|
|
1515
1664
|
}
|
|
1516
|
-
|
|
1517
|
-
salesConfigAndTokenInfo,
|
|
1518
|
-
chainId,
|
|
1519
|
-
...parameters
|
|
1520
|
-
});
|
|
1665
|
+
throw new Error("Unsupported sale type");
|
|
1521
1666
|
}
|
|
1522
|
-
|
|
1667
|
+
function makePrepareMint721TokenParams({
|
|
1523
1668
|
salesConfigAndTokenInfo,
|
|
1524
1669
|
minterAccount,
|
|
1525
1670
|
tokenContract,
|
|
@@ -1530,7 +1675,8 @@ async function makePrepareMint721TokenParams({
|
|
|
1530
1675
|
}) {
|
|
1531
1676
|
const actualQuantityToMint = BigInt(quantityToMint || 1);
|
|
1532
1677
|
const mintValue = parseMintCosts({
|
|
1533
|
-
salesConfigAndTokenInfo,
|
|
1678
|
+
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1679
|
+
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1534
1680
|
quantityToMint: actualQuantityToMint
|
|
1535
1681
|
}).totalCostEth;
|
|
1536
1682
|
return makeContractParameters({
|
|
@@ -1547,15 +1693,65 @@ async function makePrepareMint721TokenParams({
|
|
|
1547
1693
|
]
|
|
1548
1694
|
});
|
|
1549
1695
|
}
|
|
1550
|
-
function
|
|
1696
|
+
function makeEthMintCall({
|
|
1697
|
+
tokenContract,
|
|
1698
|
+
tokenId,
|
|
1551
1699
|
salesConfigAndTokenInfo,
|
|
1700
|
+
minterAccount,
|
|
1701
|
+
mintComment,
|
|
1702
|
+
mintReferral,
|
|
1703
|
+
mintQuantity,
|
|
1704
|
+
mintTo
|
|
1705
|
+
}) {
|
|
1706
|
+
const mintValue = parseMintCosts({
|
|
1707
|
+
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1708
|
+
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1709
|
+
quantityToMint: mintQuantity
|
|
1710
|
+
}).totalCostEth;
|
|
1711
|
+
const minterArguments = encodeAbiParameters(
|
|
1712
|
+
parseAbiParameters("address, string"),
|
|
1713
|
+
[mintTo, mintComment || ""]
|
|
1714
|
+
);
|
|
1715
|
+
if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
|
|
1716
|
+
return makeContractParameters({
|
|
1717
|
+
abi: zoraCreator1155ImplABI2,
|
|
1718
|
+
functionName: "mint",
|
|
1719
|
+
account: minterAccount,
|
|
1720
|
+
value: mintValue,
|
|
1721
|
+
address: tokenContract,
|
|
1722
|
+
args: [
|
|
1723
|
+
salesConfigAndTokenInfo.salesConfig.address,
|
|
1724
|
+
BigInt(tokenId),
|
|
1725
|
+
mintQuantity,
|
|
1726
|
+
mintReferral ? [mintReferral] : [],
|
|
1727
|
+
minterArguments
|
|
1728
|
+
]
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1731
|
+
return makeContractParameters({
|
|
1732
|
+
abi: zoraCreator1155ImplABI2,
|
|
1733
|
+
functionName: "mintWithRewards",
|
|
1734
|
+
account: minterAccount,
|
|
1735
|
+
value: mintValue,
|
|
1736
|
+
address: tokenContract,
|
|
1737
|
+
/* args: minter, tokenId, quantity, minterArguments, mintReferral */
|
|
1738
|
+
args: [
|
|
1739
|
+
salesConfigAndTokenInfo.salesConfig.address,
|
|
1740
|
+
BigInt(tokenId),
|
|
1741
|
+
mintQuantity,
|
|
1742
|
+
minterArguments,
|
|
1743
|
+
mintReferral || zeroAddress3
|
|
1744
|
+
]
|
|
1745
|
+
});
|
|
1746
|
+
}
|
|
1747
|
+
function parseMintCosts({
|
|
1748
|
+
salesConfig,
|
|
1749
|
+
mintFeePerQuantity,
|
|
1552
1750
|
quantityToMint
|
|
1553
1751
|
}) {
|
|
1554
|
-
const mintFeeForTokens =
|
|
1555
|
-
const tokenPurchaseCost = BigInt(
|
|
1556
|
-
const totalPurchaseCostCurrency = isErc20SaleStrategy(
|
|
1557
|
-
salesConfigAndTokenInfo.salesConfig
|
|
1558
|
-
) ? salesConfigAndTokenInfo.salesConfig.currency : void 0;
|
|
1752
|
+
const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
|
|
1753
|
+
const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
|
|
1754
|
+
const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
|
|
1559
1755
|
const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
|
|
1560
1756
|
return {
|
|
1561
1757
|
mintFee: mintFeeForTokens,
|
|
@@ -1564,85 +1760,329 @@ function parseMintCosts({
|
|
|
1564
1760
|
totalCostEth: mintFeeForTokens + totalPurchaseCostEth
|
|
1565
1761
|
};
|
|
1566
1762
|
}
|
|
1567
|
-
|
|
1568
|
-
|
|
1763
|
+
|
|
1764
|
+
// src/mint/mint-queries.ts
|
|
1765
|
+
import { zeroAddress as zeroAddress4 } from "viem";
|
|
1766
|
+
async function getMint({
|
|
1767
|
+
params,
|
|
1768
|
+
mintGetter,
|
|
1769
|
+
premintGetter,
|
|
1770
|
+
publicClient
|
|
1771
|
+
}) {
|
|
1772
|
+
const { tokenContract } = params;
|
|
1569
1773
|
if (isOnChainMint(params)) {
|
|
1570
1774
|
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
1571
|
-
const
|
|
1775
|
+
const result = await mintGetter.getMintable({
|
|
1776
|
+
tokenId,
|
|
1777
|
+
tokenAddress: tokenContract,
|
|
1778
|
+
preferredSaleType: params.preferredSaleType
|
|
1779
|
+
});
|
|
1780
|
+
return toMintableReturn(result);
|
|
1781
|
+
}
|
|
1782
|
+
const premint = await premintGetter.get({
|
|
1783
|
+
collectionAddress: tokenContract,
|
|
1784
|
+
uid: params.uid
|
|
1785
|
+
});
|
|
1786
|
+
const mintFee = await getPremintMintFee({
|
|
1787
|
+
publicClient,
|
|
1788
|
+
tokenContract
|
|
1789
|
+
});
|
|
1790
|
+
return toPremintMintReturn({ premint, mintFee });
|
|
1791
|
+
}
|
|
1792
|
+
async function getPremintsOfCollectionWithTokenIds({
|
|
1793
|
+
premintGetter,
|
|
1794
|
+
mintGetter,
|
|
1795
|
+
tokenContract
|
|
1796
|
+
}) {
|
|
1797
|
+
const { collection, premints } = await premintGetter.getOfCollection({
|
|
1798
|
+
collectionAddress: tokenContract
|
|
1799
|
+
});
|
|
1800
|
+
const premintUidsAndTokenIds = await mintGetter.getContractPremintTokenIds({
|
|
1801
|
+
tokenAddress: tokenContract
|
|
1802
|
+
});
|
|
1803
|
+
const premintsWithTokenId = premints.map((premint) => ({
|
|
1804
|
+
...premint,
|
|
1805
|
+
tokenId: premintUidsAndTokenIds.find(
|
|
1806
|
+
({ uid }) => uid === premint.premint.premintConfig.uid
|
|
1807
|
+
)?.tokenId
|
|
1808
|
+
}));
|
|
1809
|
+
return {
|
|
1810
|
+
collection,
|
|
1811
|
+
premints: premintsWithTokenId
|
|
1812
|
+
};
|
|
1813
|
+
}
|
|
1814
|
+
async function getMintsOfContract({
|
|
1815
|
+
params,
|
|
1816
|
+
mintGetter,
|
|
1817
|
+
premintGetter,
|
|
1818
|
+
publicClient
|
|
1819
|
+
}) {
|
|
1820
|
+
const onchainMints = (await mintGetter.getContractMintable({
|
|
1821
|
+
tokenAddress: params.tokenContract
|
|
1822
|
+
})).map(toMintableReturn);
|
|
1823
|
+
const offchainMints = await getPremintsOfContractMintable({
|
|
1824
|
+
mintGetter,
|
|
1825
|
+
premintGetter,
|
|
1826
|
+
publicClient,
|
|
1827
|
+
params: {
|
|
1828
|
+
tokenContract: params.tokenContract
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1831
|
+
const tokens = [...onchainMints, ...offchainMints];
|
|
1832
|
+
return {
|
|
1833
|
+
tokens,
|
|
1834
|
+
contract: tokens[0]?.token.contract
|
|
1835
|
+
};
|
|
1836
|
+
}
|
|
1837
|
+
async function getMintCosts({
|
|
1838
|
+
params,
|
|
1839
|
+
mintGetter,
|
|
1840
|
+
premintGetter,
|
|
1841
|
+
publicClient
|
|
1842
|
+
}) {
|
|
1843
|
+
const { quantityMinted: quantityToMint, collection } = params;
|
|
1844
|
+
if (isOnChainMint(params)) {
|
|
1845
|
+
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
1846
|
+
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
1572
1847
|
tokenId,
|
|
1573
1848
|
tokenAddress: collection
|
|
1574
1849
|
});
|
|
1575
1850
|
return parseMintCosts({
|
|
1576
|
-
salesConfigAndTokenInfo,
|
|
1851
|
+
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1852
|
+
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1577
1853
|
quantityToMint: BigInt(quantityToMint)
|
|
1578
1854
|
});
|
|
1579
1855
|
}
|
|
1580
1856
|
return getPremintMintCostsWithUnknownTokenPrice({
|
|
1581
|
-
premintGetter
|
|
1857
|
+
premintGetter,
|
|
1582
1858
|
publicClient,
|
|
1583
1859
|
quantityToMint: BigInt(quantityToMint),
|
|
1584
1860
|
uid: params.uid,
|
|
1585
1861
|
tokenContract: collection
|
|
1586
1862
|
});
|
|
1587
1863
|
}
|
|
1588
|
-
function
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
mintComment,
|
|
1594
|
-
mintReferral,
|
|
1595
|
-
mintRecipient,
|
|
1596
|
-
quantityToMint,
|
|
1597
|
-
chainId
|
|
1864
|
+
async function getPremintsOfContractMintable({
|
|
1865
|
+
mintGetter,
|
|
1866
|
+
premintGetter,
|
|
1867
|
+
publicClient,
|
|
1868
|
+
params
|
|
1598
1869
|
}) {
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1870
|
+
const { premints, collection } = await getPremintsOfCollectionWithTokenIds({
|
|
1871
|
+
mintGetter,
|
|
1872
|
+
premintGetter,
|
|
1873
|
+
tokenContract: params.tokenContract
|
|
1874
|
+
});
|
|
1875
|
+
const offChainPremints = premints.filter(
|
|
1876
|
+
(premint) => (
|
|
1877
|
+
// if premint's uid is not in the list of uids from the subgraph, it is offchain
|
|
1878
|
+
typeof premint.tokenId === "undefined"
|
|
1879
|
+
)
|
|
1880
|
+
);
|
|
1881
|
+
if (offChainPremints.length === 0)
|
|
1882
|
+
return [];
|
|
1883
|
+
const mintFee = await getPremintMintFee({
|
|
1884
|
+
publicClient,
|
|
1885
|
+
tokenContract: params.tokenContract
|
|
1886
|
+
});
|
|
1887
|
+
return offChainPremints.map((premint) => {
|
|
1888
|
+
return toPremintMintReturn({
|
|
1889
|
+
premint: {
|
|
1890
|
+
premint: premint.premint,
|
|
1891
|
+
// todo: fix when api returns signer
|
|
1892
|
+
signer: zeroAddress4,
|
|
1893
|
+
collection,
|
|
1894
|
+
collectionAddress: params.tokenContract,
|
|
1895
|
+
signature: premint.signature
|
|
1896
|
+
},
|
|
1897
|
+
mintFee
|
|
1624
1898
|
});
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
function parsePremint({
|
|
1902
|
+
premint,
|
|
1903
|
+
mintFee
|
|
1904
|
+
}) {
|
|
1905
|
+
if (isPremintConfigV1(premint.premint) || isPremintConfigV2(premint.premint)) {
|
|
1906
|
+
return {
|
|
1907
|
+
creator: premint.signer,
|
|
1908
|
+
maxSupply: premint.premint.premintConfig.tokenConfig.maxSupply,
|
|
1909
|
+
mintFeePerQuantity: mintFee,
|
|
1910
|
+
mintType: "premint",
|
|
1911
|
+
uid: premint.premint.premintConfig.uid,
|
|
1912
|
+
contract: {
|
|
1913
|
+
address: premint.collectionAddress,
|
|
1914
|
+
name: premint.collection.contractName,
|
|
1915
|
+
URI: premint.collection.contractURI
|
|
1916
|
+
},
|
|
1917
|
+
tokenURI: premint.premint.premintConfig.tokenConfig.tokenURI,
|
|
1918
|
+
totalMinted: 0n,
|
|
1919
|
+
salesConfig: {
|
|
1920
|
+
duration: premint.premint.premintConfig.tokenConfig.mintDuration,
|
|
1921
|
+
maxTokensPerAddress: premint.premint.premintConfig.tokenConfig.maxTokensPerAddress,
|
|
1922
|
+
pricePerToken: premint.premint.premintConfig.tokenConfig.pricePerToken,
|
|
1923
|
+
saleType: "premint"
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1625
1926
|
}
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1927
|
+
throw new Error("Invalid premint config version");
|
|
1928
|
+
}
|
|
1929
|
+
var makeOnchainPrepareMint = (result) => (params) => ({
|
|
1930
|
+
parameters: makeOnchainMintCall({ token: result, mintParams: params }),
|
|
1931
|
+
erc20Approval: getRequiredErc20Approvals(params, result),
|
|
1932
|
+
costs: parseMintCosts({
|
|
1933
|
+
salesConfig: result.salesConfig,
|
|
1934
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
1935
|
+
mintFeePerQuantity: result.mintFeePerQuantity
|
|
1936
|
+
})
|
|
1937
|
+
});
|
|
1938
|
+
function toMintableReturn(result) {
|
|
1939
|
+
return { token: result, prepareMint: makeOnchainPrepareMint(result) };
|
|
1940
|
+
}
|
|
1941
|
+
var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
|
|
1942
|
+
parameters: buildPremintMintCall({
|
|
1943
|
+
mintArguments: params,
|
|
1944
|
+
mintFee,
|
|
1945
|
+
premint
|
|
1946
|
+
}),
|
|
1947
|
+
costs: parseMintCosts({
|
|
1948
|
+
mintFeePerQuantity: mintFee,
|
|
1949
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
1950
|
+
salesConfig: mintable.salesConfig
|
|
1951
|
+
})
|
|
1952
|
+
});
|
|
1953
|
+
function toPremintMintReturn({
|
|
1954
|
+
premint,
|
|
1955
|
+
mintFee
|
|
1956
|
+
}) {
|
|
1957
|
+
const mintable = parsePremint({ premint, mintFee });
|
|
1958
|
+
return {
|
|
1959
|
+
token: mintable,
|
|
1960
|
+
prepareMint: makePremintPrepareMint(mintable, mintFee, premint)
|
|
1961
|
+
};
|
|
1962
|
+
}
|
|
1963
|
+
function getRequiredErc20Approvals(params, result) {
|
|
1964
|
+
if (result.salesConfig.saleType !== "erc20")
|
|
1965
|
+
return void 0;
|
|
1966
|
+
return {
|
|
1967
|
+
quantity: result.salesConfig.pricePerToken * BigInt(params.quantityToMint),
|
|
1968
|
+
approveTo: result.salesConfig.address,
|
|
1969
|
+
erc20: result.salesConfig.currency
|
|
1970
|
+
};
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
// src/mint/mint-client.ts
|
|
1974
|
+
var MintError = class extends Error {
|
|
1975
|
+
};
|
|
1976
|
+
var MintInactiveError = class extends Error {
|
|
1977
|
+
};
|
|
1978
|
+
var Errors = {
|
|
1979
|
+
MintError,
|
|
1980
|
+
MintInactiveError
|
|
1981
|
+
};
|
|
1982
|
+
var MintClient = class {
|
|
1983
|
+
constructor({
|
|
1984
|
+
publicClient,
|
|
1985
|
+
premintGetter,
|
|
1986
|
+
mintGetter
|
|
1987
|
+
}) {
|
|
1988
|
+
this.publicClient = publicClient;
|
|
1989
|
+
this.mintGetter = mintGetter;
|
|
1990
|
+
this.premintGetter = premintGetter;
|
|
1991
|
+
}
|
|
1992
|
+
/**
|
|
1993
|
+
* Returns the parameters needed to prepare a transaction mint a token.
|
|
1994
|
+
* Works with premint, onchain 1155, and onchain 721.
|
|
1995
|
+
*
|
|
1996
|
+
* @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
|
|
1997
|
+
* @returns Parameters for simulating/executing the mint transaction, any necessary erc20 approval, and costs to mint
|
|
1998
|
+
*/
|
|
1999
|
+
async mint(parameters) {
|
|
2000
|
+
return mint({
|
|
2001
|
+
parameters,
|
|
2002
|
+
publicClient: this.publicClient,
|
|
2003
|
+
mintGetter: this.mintGetter,
|
|
2004
|
+
premintGetter: this.premintGetter
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
/**
|
|
2008
|
+
* Gets an 1155, 721, or premint, and returns both information about it, and a function
|
|
2009
|
+
* that can be used to build a mint transaction for a quantity of items to mint.
|
|
2010
|
+
* @param parameters - Token to get {@link GetMintParameters}
|
|
2011
|
+
* @Returns Information about the mint and a function to build a mint transaction {@link MintableReturn}
|
|
2012
|
+
*/
|
|
2013
|
+
async get(parameters) {
|
|
2014
|
+
return getMint({
|
|
2015
|
+
params: parameters,
|
|
2016
|
+
mintGetter: this.mintGetter,
|
|
2017
|
+
premintGetter: this.premintGetter,
|
|
2018
|
+
publicClient: this.publicClient
|
|
2019
|
+
});
|
|
2020
|
+
}
|
|
2021
|
+
/**
|
|
2022
|
+
* Gets onchain and premint tokens of an 1155 contract. For each token returns both information about it, and a function
|
|
2023
|
+
* that can be used to build a mint transaction for a quantity of items to mint.
|
|
2024
|
+
* @param parameters - Contract address to get tokens for {@link GetMintsOfContractParameters}
|
|
2025
|
+
* @Returns Array of tokens, each containing information about the token and a function to build a mint transaction.
|
|
2026
|
+
*/
|
|
2027
|
+
async getOfContract(params) {
|
|
2028
|
+
return getMintsOfContract({
|
|
2029
|
+
params,
|
|
2030
|
+
mintGetter: this.mintGetter,
|
|
2031
|
+
premintGetter: this.premintGetter,
|
|
2032
|
+
publicClient: this.publicClient
|
|
1643
2033
|
});
|
|
1644
2034
|
}
|
|
1645
|
-
|
|
2035
|
+
/**
|
|
2036
|
+
* Gets the costs to mint the quantity of tokens specified for a mint.
|
|
2037
|
+
* @param parameters - Parameters for the mint {@link GetMintCostsParameters}
|
|
2038
|
+
* @returns Costs to mint the quantity of tokens specified
|
|
2039
|
+
*/
|
|
2040
|
+
async getMintCosts(parameters) {
|
|
2041
|
+
return getMintCosts({
|
|
2042
|
+
params: parameters,
|
|
2043
|
+
mintGetter: this.mintGetter,
|
|
2044
|
+
premintGetter: this.premintGetter,
|
|
2045
|
+
publicClient: this.publicClient
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
};
|
|
2049
|
+
async function mint({
|
|
2050
|
+
parameters,
|
|
2051
|
+
publicClient,
|
|
2052
|
+
mintGetter,
|
|
2053
|
+
premintGetter
|
|
2054
|
+
}) {
|
|
2055
|
+
const { prepareMint } = await getMint({
|
|
2056
|
+
params: parameters,
|
|
2057
|
+
mintGetter,
|
|
2058
|
+
premintGetter,
|
|
2059
|
+
publicClient
|
|
2060
|
+
});
|
|
2061
|
+
return prepareMint({
|
|
2062
|
+
minterAccount: parameters.minterAccount,
|
|
2063
|
+
quantityToMint: parameters.quantityToMint,
|
|
2064
|
+
firstMinter: parameters.firstMinter,
|
|
2065
|
+
mintComment: parameters.mintComment,
|
|
2066
|
+
mintRecipient: parameters.mintRecipient,
|
|
2067
|
+
mintReferral: parameters.mintReferral
|
|
2068
|
+
});
|
|
2069
|
+
}
|
|
2070
|
+
async function collectOnchain({
|
|
2071
|
+
chainId,
|
|
2072
|
+
mintGetter,
|
|
2073
|
+
...parameters
|
|
2074
|
+
}) {
|
|
2075
|
+
const { tokenContract, preferredSaleType: saleType } = parameters;
|
|
2076
|
+
const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
|
|
2077
|
+
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
2078
|
+
tokenId,
|
|
2079
|
+
tokenAddress: tokenContract,
|
|
2080
|
+
preferredSaleType: saleType
|
|
2081
|
+
});
|
|
2082
|
+
return makeOnchainMintCall({
|
|
2083
|
+
mintParams: parameters,
|
|
2084
|
+
token: salesConfigAndTokenInfo
|
|
2085
|
+
});
|
|
1646
2086
|
}
|
|
1647
2087
|
|
|
1648
2088
|
// src/create/1155-create-helper.ts
|
|
@@ -1717,17 +2157,17 @@ import {
|
|
|
1717
2157
|
erc20MinterAddress as erc20MinterAddresses,
|
|
1718
2158
|
zoraCreator1155ImplABI as zoraCreator1155ImplABI4,
|
|
1719
2159
|
zoraCreatorFixedPriceSaleStrategyABI,
|
|
1720
|
-
zoraCreatorFixedPriceSaleStrategyAddress as
|
|
2160
|
+
zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress2
|
|
1721
2161
|
} from "@zoralabs/protocol-deployments";
|
|
1722
|
-
import { encodeFunctionData, zeroAddress as
|
|
1723
|
-
import * as
|
|
2162
|
+
import { encodeFunctionData, zeroAddress as zeroAddress5 } from "viem";
|
|
2163
|
+
import * as semver2 from "semver";
|
|
1724
2164
|
var PERMISSION_BITS = {
|
|
1725
2165
|
MINTER: 2n ** 2n
|
|
1726
2166
|
};
|
|
1727
2167
|
var saleSettingsOrDefault = (saleSettings) => {
|
|
1728
2168
|
const SALE_END_FOREVER = 18446744073709551615n;
|
|
1729
2169
|
const DEFAULT_SALE_SETTINGS = {
|
|
1730
|
-
currency:
|
|
2170
|
+
currency: zeroAddress5,
|
|
1731
2171
|
// Free Mint
|
|
1732
2172
|
pricePerToken: 0n,
|
|
1733
2173
|
// Sale start time – defaults to beginning of unix time
|
|
@@ -1744,10 +2184,10 @@ var saleSettingsOrDefault = (saleSettings) => {
|
|
|
1744
2184
|
};
|
|
1745
2185
|
function applyNew1155Defaults(props, ownerAddress) {
|
|
1746
2186
|
const { payoutRecipient: fundsRecipient } = props;
|
|
1747
|
-
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !==
|
|
2187
|
+
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== zeroAddress5 ? fundsRecipient : ownerAddress;
|
|
1748
2188
|
return {
|
|
1749
2189
|
payoutRecipient: fundsRecipientOrOwner,
|
|
1750
|
-
createReferral: props.createReferral ||
|
|
2190
|
+
createReferral: props.createReferral || zeroAddress5,
|
|
1751
2191
|
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
1752
2192
|
royaltyBPS: props.royaltyBPS || 1e3,
|
|
1753
2193
|
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
@@ -1764,13 +2204,13 @@ function setupErc20Minter({
|
|
|
1764
2204
|
maxTokensPerAddress: mintLimit,
|
|
1765
2205
|
fundsRecipient
|
|
1766
2206
|
}) {
|
|
1767
|
-
const
|
|
1768
|
-
if (!
|
|
2207
|
+
const erc20MinterAddress = erc20MinterAddresses[chainId];
|
|
2208
|
+
if (!erc20MinterAddress)
|
|
1769
2209
|
throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
|
|
1770
2210
|
const erc20MinterApproval = encodeFunctionData({
|
|
1771
2211
|
abi: zoraCreator1155ImplABI4,
|
|
1772
2212
|
functionName: "addPermission",
|
|
1773
|
-
args: [BigInt(nextTokenId),
|
|
2213
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
|
|
1774
2214
|
});
|
|
1775
2215
|
const saleData = encodeFunctionData({
|
|
1776
2216
|
abi: erc20MinterABI2,
|
|
@@ -1790,10 +2230,10 @@ function setupErc20Minter({
|
|
|
1790
2230
|
const callSale = encodeFunctionData({
|
|
1791
2231
|
abi: zoraCreator1155ImplABI4,
|
|
1792
2232
|
functionName: "callSale",
|
|
1793
|
-
args: [BigInt(nextTokenId),
|
|
2233
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
|
|
1794
2234
|
});
|
|
1795
2235
|
return {
|
|
1796
|
-
minter:
|
|
2236
|
+
minter: erc20MinterAddress,
|
|
1797
2237
|
setupActions: [erc20MinterApproval, callSale]
|
|
1798
2238
|
};
|
|
1799
2239
|
}
|
|
@@ -1806,7 +2246,7 @@ function setupFixedPriceMinter({
|
|
|
1806
2246
|
maxTokensPerAddress: mintLimit,
|
|
1807
2247
|
fundsRecipient
|
|
1808
2248
|
}) {
|
|
1809
|
-
const fixedPriceStrategyAddress =
|
|
2249
|
+
const fixedPriceStrategyAddress = zoraCreatorFixedPriceSaleStrategyAddress2[chainId];
|
|
1810
2250
|
const fixedPriceApproval = encodeFunctionData({
|
|
1811
2251
|
abi: zoraCreator1155ImplABI4,
|
|
1812
2252
|
functionName: "addPermission",
|
|
@@ -1844,7 +2284,7 @@ function setupMinters({ salesConfig, ...rest }) {
|
|
|
1844
2284
|
if (!salesConfig)
|
|
1845
2285
|
throw new Error("No sales config for token");
|
|
1846
2286
|
const { currency: currencyAddress } = salesConfig;
|
|
1847
|
-
if (currencyAddress ===
|
|
2287
|
+
if (currencyAddress === zeroAddress5) {
|
|
1848
2288
|
return setupFixedPriceMinter({
|
|
1849
2289
|
...salesConfig,
|
|
1850
2290
|
...rest
|
|
@@ -1859,7 +2299,7 @@ function setupMinters({ salesConfig, ...rest }) {
|
|
|
1859
2299
|
function buildSetupNewToken({
|
|
1860
2300
|
tokenURI,
|
|
1861
2301
|
maxSupply = OPEN_EDITION_MINT_SIZE,
|
|
1862
|
-
createReferral =
|
|
2302
|
+
createReferral = zeroAddress5,
|
|
1863
2303
|
contractVersion
|
|
1864
2304
|
}) {
|
|
1865
2305
|
if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
|
|
@@ -1869,7 +2309,7 @@ function buildSetupNewToken({
|
|
|
1869
2309
|
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
1870
2310
|
});
|
|
1871
2311
|
}
|
|
1872
|
-
if (createReferral !==
|
|
2312
|
+
if (createReferral !== zeroAddress5) {
|
|
1873
2313
|
throw new Error(
|
|
1874
2314
|
"Contract does not support create referral, but one was provided"
|
|
1875
2315
|
);
|
|
@@ -1885,7 +2325,7 @@ function setupRoyaltyConfig({
|
|
|
1885
2325
|
royaltyRecipient,
|
|
1886
2326
|
nextTokenId
|
|
1887
2327
|
}) {
|
|
1888
|
-
if (royaltyBPS > 0 && royaltyRecipient !=
|
|
2328
|
+
if (royaltyBPS > 0 && royaltyRecipient != zeroAddress5) {
|
|
1889
2329
|
return encodeFunctionData({
|
|
1890
2330
|
abi: zoraCreator1155ImplABI4,
|
|
1891
2331
|
functionName: "updateRoyaltiesForToken",
|
|
@@ -1912,7 +2352,7 @@ function makeAdminMintCall({
|
|
|
1912
2352
|
return encodeFunctionData({
|
|
1913
2353
|
abi: zoraCreator1155ImplABI4,
|
|
1914
2354
|
functionName: "adminMint",
|
|
1915
|
-
args: [ownerAddress, nextTokenId, BigInt(mintQuantity),
|
|
2355
|
+
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), zeroAddress5]
|
|
1916
2356
|
});
|
|
1917
2357
|
}
|
|
1918
2358
|
function constructCreate1155TokenCalls(props) {
|
|
@@ -1971,13 +2411,13 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
|
1971
2411
|
if (!contractStandard || !contractVersion) {
|
|
1972
2412
|
return false;
|
|
1973
2413
|
}
|
|
1974
|
-
const semVerContractVersion =
|
|
2414
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
1975
2415
|
if (!semVerContractVersion)
|
|
1976
2416
|
return false;
|
|
1977
2417
|
if (contractStandard === "ERC1155") {
|
|
1978
|
-
return
|
|
2418
|
+
return semver2.gte(semVerContractVersion, "1.3.5");
|
|
1979
2419
|
} else {
|
|
1980
|
-
return
|
|
2420
|
+
return semver2.gte(semVerContractVersion, "14.0.0");
|
|
1981
2421
|
}
|
|
1982
2422
|
};
|
|
1983
2423
|
|
|
@@ -2178,7 +2618,7 @@ import {
|
|
|
2178
2618
|
import {
|
|
2179
2619
|
decodeErrorResult,
|
|
2180
2620
|
encodeFunctionData as encodeFunctionData2,
|
|
2181
|
-
zeroAddress as
|
|
2621
|
+
zeroAddress as zeroAddress6
|
|
2182
2622
|
} from "viem";
|
|
2183
2623
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
2184
2624
|
var mintWithEthParams = ({
|
|
@@ -2334,7 +2774,7 @@ var encodePremintOnManager = ({
|
|
|
2334
2774
|
premintConfig,
|
|
2335
2775
|
premintSignature,
|
|
2336
2776
|
mintArguments,
|
|
2337
|
-
signerContract =
|
|
2777
|
+
signerContract = zeroAddress6
|
|
2338
2778
|
}) => encodeFunctionData2({
|
|
2339
2779
|
abi: zoraMintsManagerImplConfig.abi,
|
|
2340
2780
|
functionName: "collectPremintV2",
|
|
@@ -2465,17 +2905,18 @@ function createCollectorClient(params) {
|
|
|
2465
2905
|
const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
|
|
2466
2906
|
const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
|
|
2467
2907
|
const mintClient = new MintClient({
|
|
2468
|
-
chainId: params.chainId,
|
|
2469
2908
|
publicClient: params.publicClient,
|
|
2470
2909
|
premintGetter: premintGetterToUse,
|
|
2471
2910
|
mintGetter: mintGetterToUse
|
|
2472
2911
|
});
|
|
2473
2912
|
return {
|
|
2474
|
-
getPremint: (p) => premintGetterToUse.
|
|
2913
|
+
getPremint: (p) => premintGetterToUse.get({
|
|
2475
2914
|
collectionAddress: p.address,
|
|
2476
2915
|
uid: p.uid
|
|
2477
2916
|
}),
|
|
2478
2917
|
getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
|
|
2918
|
+
getToken: (p) => mintClient.get(p),
|
|
2919
|
+
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
2479
2920
|
mint: (p) => mintClient.mint(p),
|
|
2480
2921
|
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
2481
2922
|
};
|
|
@@ -2490,12 +2931,14 @@ export {
|
|
|
2490
2931
|
SubgraphMintGetter,
|
|
2491
2932
|
ZORA_API_BASE,
|
|
2492
2933
|
applyUpdateToPremint,
|
|
2934
|
+
buildPremintMintCall,
|
|
2493
2935
|
collectOnchain,
|
|
2494
2936
|
collectPremint,
|
|
2495
2937
|
collectPremintV2WithMintsParams,
|
|
2496
2938
|
collectWithMintsParams,
|
|
2497
2939
|
convertCollectionFromApi,
|
|
2498
2940
|
convertGetPremintApiResponse,
|
|
2941
|
+
convertGetPremintOfCollectionApiResponse,
|
|
2499
2942
|
convertPremintFromApi,
|
|
2500
2943
|
createCollectorClient,
|
|
2501
2944
|
createCreatorClient,
|
|
@@ -2510,10 +2953,8 @@ export {
|
|
|
2510
2953
|
getApiNetworkConfigForChain,
|
|
2511
2954
|
getDataFromPremintReceipt,
|
|
2512
2955
|
getDefaultFixedPriceMinterAddress,
|
|
2513
|
-
getMintCosts,
|
|
2514
2956
|
getMintsAccountBalanceWithPriceQuery,
|
|
2515
2957
|
getMintsEthPrice,
|
|
2516
|
-
getNecessaryErc20Approval,
|
|
2517
2958
|
getPremintCollectionAddress,
|
|
2518
2959
|
getPremintExecutorAddress,
|
|
2519
2960
|
getPremintMintCosts,
|
|
@@ -2533,15 +2974,12 @@ export {
|
|
|
2533
2974
|
makePermitToCollectPremintOrNonPremint,
|
|
2534
2975
|
makePermitTransferBatchAndTypeData,
|
|
2535
2976
|
makePermitTransferTypeData,
|
|
2536
|
-
makePrepareMint1155TokenParams,
|
|
2537
2977
|
makeUrls,
|
|
2538
2978
|
migratePremintConfigToV2,
|
|
2539
2979
|
mintWithEthParams,
|
|
2540
2980
|
mintsBalanceOfAccountParams,
|
|
2541
|
-
parseMintCosts,
|
|
2542
2981
|
recoverCreatorFromCreatorAttribution,
|
|
2543
2982
|
recoverPremintSigner,
|
|
2544
|
-
requestErc20ApprovalForMint,
|
|
2545
2983
|
selectMintsToCollectWithFromQueryResult,
|
|
2546
2984
|
sumBalances,
|
|
2547
2985
|
supportedPremintVersions,
|