@zoralabs/protocol-sdk 0.7.2-ALLOWLIST.0 → 0.7.2
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 +15 -0
- package/CHANGELOG.md +2 -2
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/constants.d.ts +27 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +0 -1
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/token-setup.d.ts +4 -3
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/create/types.d.ts +4 -24
- package/dist/create/types.d.ts.map +1 -1
- package/dist/index.cjs +127 -237
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +128 -238
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-queries.d.ts +1 -3
- package/dist/mint/mint-queries.d.ts.map +1 -1
- package/dist/mint/mint-transactions.d.ts +3 -5
- package/dist/mint/mint-transactions.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +2 -1
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +14 -27
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/mint/types.d.ts +11 -22
- package/dist/mint/types.d.ts.map +1 -1
- package/dist/mints/mints-contracts.d.ts +16 -0
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +8 -0
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/apis/http-api-base.ts +0 -12
- package/src/constants.ts +36 -0
- package/src/create/1155-create-helper.test.ts +325 -0
- package/src/create/1155-create-helper.ts +0 -17
- package/src/create/token-setup.ts +19 -116
- package/src/create/types.ts +4 -32
- package/src/index.ts +0 -4
- package/src/mint/mint-client.test.ts +263 -0
- package/src/mint/mint-queries.ts +0 -6
- package/src/mint/mint-transactions.ts +8 -74
- package/src/mint/subgraph-mint-getter.ts +41 -17
- package/src/mint/subgraph-queries.ts +36 -39
- package/src/mint/types.ts +12 -38
- package/src/mints/mints-contracts.test.ts +529 -0
- package/src/mints/mints-eth-unwrapper-and-caller.test.ts +467 -0
- package/src/mints/mints-queries.test.ts +105 -0
- package/src/premint/premint-client.test.ts +290 -0
- package/src/premint/preminter.test.ts +866 -0
- package/test-integration/setup-test-contracts.ts +96 -0
- package/tsconfig.build.json +10 -0
- package/tsup.config.ts +12 -0
- package/dist/allow-list/allow-list-client.d.ts +0 -25
- package/dist/allow-list/allow-list-client.d.ts.map +0 -1
- package/dist/allow-list/types.d.ts +0 -14
- package/dist/allow-list/types.d.ts.map +0 -1
- package/dist/apis/generated/allow-list-api-types.d.ts +0 -288
- package/dist/apis/generated/allow-list-api-types.d.ts.map +0 -1
- package/src/allow-list/allow-list-client.ts +0 -102
- package/src/allow-list/types.ts +0 -15
- package/src/apis/generated/allow-list-api-types.ts +0 -288
- package/yarn-error.log +0 -8602
package/dist/index.cjs
CHANGED
|
@@ -48,7 +48,6 @@ __export(src_exports, {
|
|
|
48
48
|
convertGetPremintApiResponse: () => convertGetPremintApiResponse,
|
|
49
49
|
convertGetPremintOfCollectionApiResponse: () => convertGetPremintOfCollectionApiResponse,
|
|
50
50
|
convertPremintFromApi: () => convertPremintFromApi,
|
|
51
|
-
createAllowList: () => createAllowList,
|
|
52
51
|
createCollectorClient: () => createCollectorClient,
|
|
53
52
|
createCreatorClient: () => createCreatorClient,
|
|
54
53
|
decodeCallFailedError: () => decodeCallFailedError,
|
|
@@ -61,7 +60,6 @@ __export(src_exports, {
|
|
|
61
60
|
encodePremintForAPI: () => encodePremintForAPI,
|
|
62
61
|
generateTextNftMetadataFiles: () => generateTextNftMetadataFiles,
|
|
63
62
|
getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
|
|
64
|
-
getContractAddressFromCreateReceipt: () => getContractAddressFromCreateReceipt,
|
|
65
63
|
getDataFromPremintReceipt: () => getDataFromPremintReceipt,
|
|
66
64
|
getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
|
|
67
65
|
getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
|
|
@@ -127,6 +125,41 @@ var zora721Abi = (0, import_viem.parseAbi)([
|
|
|
127
125
|
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
128
126
|
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
129
127
|
]);
|
|
128
|
+
var zora1155LegacyAbi = [
|
|
129
|
+
{
|
|
130
|
+
type: "function",
|
|
131
|
+
name: "mintWithRewards",
|
|
132
|
+
inputs: [
|
|
133
|
+
{
|
|
134
|
+
name: "minter",
|
|
135
|
+
type: "address",
|
|
136
|
+
internalType: "contract IMinter1155"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
name: "tokenId",
|
|
140
|
+
type: "uint256",
|
|
141
|
+
internalType: "uint256"
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: "quantity",
|
|
145
|
+
type: "uint256",
|
|
146
|
+
internalType: "uint256"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: "minterArguments",
|
|
150
|
+
type: "bytes",
|
|
151
|
+
internalType: "bytes"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: "mintReferral",
|
|
155
|
+
type: "address",
|
|
156
|
+
internalType: "address"
|
|
157
|
+
}
|
|
158
|
+
],
|
|
159
|
+
outputs: [],
|
|
160
|
+
stateMutability: "payable"
|
|
161
|
+
}
|
|
162
|
+
];
|
|
130
163
|
|
|
131
164
|
// src/apis/chain-constants.ts
|
|
132
165
|
var REWARD_PER_TOKEN = (0, import_viem2.parseEther)("0.000777");
|
|
@@ -653,20 +686,14 @@ var get = async (url) => {
|
|
|
653
686
|
return await response.json();
|
|
654
687
|
};
|
|
655
688
|
var post = async (url, data) => {
|
|
656
|
-
const controller = new AbortController();
|
|
657
|
-
const { signal } = controller;
|
|
658
|
-
const timeout = 30 * 60 * 1e3;
|
|
659
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
660
689
|
const response = await fetch(url, {
|
|
661
690
|
method: "POST",
|
|
662
691
|
headers: {
|
|
663
692
|
"content-type": "application/json",
|
|
664
693
|
accept: "application/json"
|
|
665
694
|
},
|
|
666
|
-
body: JSON.stringify(data)
|
|
667
|
-
signal
|
|
695
|
+
body: JSON.stringify(data)
|
|
668
696
|
});
|
|
669
|
-
clearTimeout(timeoutId);
|
|
670
697
|
if (response.status !== 200) {
|
|
671
698
|
let json;
|
|
672
699
|
try {
|
|
@@ -752,12 +779,6 @@ fragment SaleStrategy on SalesStrategyConfig {
|
|
|
752
779
|
saleStart
|
|
753
780
|
maxTokensPerAddress
|
|
754
781
|
}
|
|
755
|
-
presale {
|
|
756
|
-
address
|
|
757
|
-
presaleStart
|
|
758
|
-
presaleEnd
|
|
759
|
-
merkleRoot
|
|
760
|
-
}
|
|
761
782
|
}`;
|
|
762
783
|
var TOKEN_FRAGMENT = `
|
|
763
784
|
fragment Token on ZoraCreateToken {
|
|
@@ -767,7 +788,7 @@ fragment Token on ZoraCreateToken {
|
|
|
767
788
|
totalMinted
|
|
768
789
|
maxSupply
|
|
769
790
|
tokenStandard
|
|
770
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"
|
|
791
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
771
792
|
...SaleStrategy
|
|
772
793
|
}
|
|
773
794
|
contract {
|
|
@@ -776,7 +797,7 @@ fragment Token on ZoraCreateToken {
|
|
|
776
797
|
contractVersion
|
|
777
798
|
contractURI
|
|
778
799
|
name
|
|
779
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"
|
|
800
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
780
801
|
...SaleStrategy
|
|
781
802
|
}
|
|
782
803
|
}
|
|
@@ -807,6 +828,19 @@ query ($id: ID!) {
|
|
|
807
828
|
parseResponseData: (responseData) => responseData?.zoraCreateToken
|
|
808
829
|
};
|
|
809
830
|
}
|
|
831
|
+
function buildGetDefaultMintPriceQuery({}) {
|
|
832
|
+
return {
|
|
833
|
+
query: `
|
|
834
|
+
{
|
|
835
|
+
defaultMintPrice(id: "0x0000000000000000000000000000000000000000") {
|
|
836
|
+
pricePerToken
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
`,
|
|
840
|
+
variables: {},
|
|
841
|
+
parseResponseData: (responseData) => responseData?.defaultMintPrice?.pricePerToken ? BigInt(responseData?.defaultMintPrice?.pricePerToken) : void 0
|
|
842
|
+
};
|
|
843
|
+
}
|
|
810
844
|
function buildContractTokensQuery({
|
|
811
845
|
tokenAddress
|
|
812
846
|
}) {
|
|
@@ -847,6 +881,7 @@ function buildPremintsOfContractQuery({
|
|
|
847
881
|
}
|
|
848
882
|
|
|
849
883
|
// src/mint/subgraph-mint-getter.ts
|
|
884
|
+
var semver = __toESM(require("semver"), 1);
|
|
850
885
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
851
886
|
if (!networkConfigByChain[chainId]) {
|
|
852
887
|
throw new Error(`chain id ${chainId} network not configured `);
|
|
@@ -873,23 +908,12 @@ function parseSalesConfig(targetStrategy) {
|
|
|
873
908
|
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
874
909
|
};
|
|
875
910
|
}
|
|
876
|
-
if (targetStrategy.type === "PRESALE") {
|
|
877
|
-
return {
|
|
878
|
-
saleType: "allowlist",
|
|
879
|
-
address: targetStrategy.presale.address,
|
|
880
|
-
merkleRoot: targetStrategy.presale.merkleRoot,
|
|
881
|
-
saleStart: targetStrategy.presale.presaleStart,
|
|
882
|
-
saleEnd: targetStrategy.presale.presaleEnd
|
|
883
|
-
};
|
|
884
|
-
}
|
|
885
911
|
throw new Error("Unknown saleType");
|
|
886
912
|
}
|
|
887
913
|
function getSaleEnd(a) {
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return BigInt(a.erc20Minter.saleEnd);
|
|
892
|
-
return BigInt(a.presale.presaleEnd);
|
|
914
|
+
return BigInt(
|
|
915
|
+
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
916
|
+
);
|
|
893
917
|
}
|
|
894
918
|
function getTargetStrategy({
|
|
895
919
|
tokenId,
|
|
@@ -938,8 +962,10 @@ var SubgraphMintGetter = class {
|
|
|
938
962
|
if (!token) {
|
|
939
963
|
throw new Error("Cannot find token");
|
|
940
964
|
}
|
|
965
|
+
const defaultMintFee = await this.getContractMintFee(token.contract);
|
|
941
966
|
return parseTokenQueryResult({
|
|
942
967
|
token,
|
|
968
|
+
defaultMintFee,
|
|
943
969
|
tokenId,
|
|
944
970
|
preferredSaleType: saleType
|
|
945
971
|
});
|
|
@@ -947,6 +973,16 @@ var SubgraphMintGetter = class {
|
|
|
947
973
|
this.httpClient = httpClient2 || httpClient;
|
|
948
974
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
949
975
|
}
|
|
976
|
+
async getContractMintFee(contract) {
|
|
977
|
+
const storedMintFee = BigInt(contract.mintFeePerQuantity);
|
|
978
|
+
if (!contractUsesMintCardsForMintFee(contract.contractVersion)) {
|
|
979
|
+
return storedMintFee;
|
|
980
|
+
}
|
|
981
|
+
const defaultMintFee = await this.querySubgraphWithRetries(
|
|
982
|
+
buildGetDefaultMintPriceQuery({})
|
|
983
|
+
);
|
|
984
|
+
return defaultMintFee || storedMintFee;
|
|
985
|
+
}
|
|
950
986
|
async querySubgraphWithRetries({
|
|
951
987
|
query,
|
|
952
988
|
variables,
|
|
@@ -969,13 +1005,15 @@ var SubgraphMintGetter = class {
|
|
|
969
1005
|
tokenAddress
|
|
970
1006
|
})
|
|
971
1007
|
);
|
|
972
|
-
if (!tokens)
|
|
1008
|
+
if (!tokens || tokens.length === 0)
|
|
973
1009
|
return [];
|
|
1010
|
+
const defaultMintFee = await this.getContractMintFee(tokens[0].contract);
|
|
974
1011
|
return tokens.filter((x) => x.tokenId !== "0").map(
|
|
975
1012
|
(token) => parseTokenQueryResult({
|
|
976
1013
|
token,
|
|
977
1014
|
tokenId: token.tokenId,
|
|
978
|
-
preferredSaleType
|
|
1015
|
+
preferredSaleType,
|
|
1016
|
+
defaultMintFee
|
|
979
1017
|
})
|
|
980
1018
|
);
|
|
981
1019
|
}
|
|
@@ -996,14 +1034,15 @@ var SubgraphMintGetter = class {
|
|
|
996
1034
|
function parseTokenQueryResult({
|
|
997
1035
|
token,
|
|
998
1036
|
tokenId,
|
|
999
|
-
preferredSaleType
|
|
1037
|
+
preferredSaleType,
|
|
1038
|
+
defaultMintFee
|
|
1000
1039
|
}) {
|
|
1001
1040
|
const targetStrategy = getTargetStrategy({
|
|
1002
1041
|
tokenId,
|
|
1003
1042
|
preferredSaleType,
|
|
1004
1043
|
token
|
|
1005
1044
|
});
|
|
1006
|
-
const tokenInfo = parseTokenInfo(token);
|
|
1045
|
+
const tokenInfo = parseTokenInfo(token, defaultMintFee);
|
|
1007
1046
|
const salesConfig = parseSalesConfig(targetStrategy);
|
|
1008
1047
|
if (isErc20SaleStrategy(salesConfig)) {
|
|
1009
1048
|
tokenInfo.mintFeePerQuantity = 0n;
|
|
@@ -1013,7 +1052,13 @@ function parseTokenQueryResult({
|
|
|
1013
1052
|
salesConfig
|
|
1014
1053
|
};
|
|
1015
1054
|
}
|
|
1016
|
-
|
|
1055
|
+
var contractUsesMintCardsForMintFee = (contractVersion) => {
|
|
1056
|
+
const semVerContractVersion = semver.coerce(contractVersion)?.raw;
|
|
1057
|
+
if (!semVerContractVersion)
|
|
1058
|
+
return false;
|
|
1059
|
+
return semver.gte(semVerContractVersion, "2.9.0");
|
|
1060
|
+
};
|
|
1061
|
+
function parseTokenInfo(token, defaultMintFee) {
|
|
1017
1062
|
return {
|
|
1018
1063
|
contract: {
|
|
1019
1064
|
address: token.contract.address,
|
|
@@ -1026,7 +1071,7 @@ function parseTokenInfo(token) {
|
|
|
1026
1071
|
creator: token.creator,
|
|
1027
1072
|
totalMinted: BigInt(token.totalMinted),
|
|
1028
1073
|
maxSupply: BigInt(token.maxSupply),
|
|
1029
|
-
mintFeePerQuantity:
|
|
1074
|
+
mintFeePerQuantity: defaultMintFee,
|
|
1030
1075
|
contractVersion: token.contract.contractVersion
|
|
1031
1076
|
};
|
|
1032
1077
|
}
|
|
@@ -1681,15 +1726,15 @@ var import_viem5 = require("viem");
|
|
|
1681
1726
|
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1682
1727
|
|
|
1683
1728
|
// src/mint/utils.ts
|
|
1684
|
-
var
|
|
1729
|
+
var semver2 = __toESM(require("semver"), 1);
|
|
1685
1730
|
var contractSupportsNewMintFunction = (contractVersion) => {
|
|
1686
1731
|
if (!contractVersion) {
|
|
1687
1732
|
return false;
|
|
1688
1733
|
}
|
|
1689
|
-
const semVerContractVersion =
|
|
1734
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
1690
1735
|
if (!semVerContractVersion)
|
|
1691
1736
|
return false;
|
|
1692
|
-
return
|
|
1737
|
+
return semver2.gte(semVerContractVersion, "2.9.0");
|
|
1693
1738
|
};
|
|
1694
1739
|
|
|
1695
1740
|
// src/mint/mint-transactions.ts
|
|
@@ -1719,13 +1764,12 @@ function makePrepareMint1155TokenParams({
|
|
|
1719
1764
|
mintComment,
|
|
1720
1765
|
mintReferral,
|
|
1721
1766
|
mintRecipient,
|
|
1722
|
-
quantityToMint
|
|
1723
|
-
allowListEntry
|
|
1767
|
+
quantityToMint
|
|
1724
1768
|
}) {
|
|
1725
1769
|
const mintQuantity = BigInt(quantityToMint || 1);
|
|
1726
1770
|
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
1727
1771
|
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
1728
|
-
if (saleType === "fixedPrice"
|
|
1772
|
+
if (saleType === "fixedPrice") {
|
|
1729
1773
|
return makeEthMintCall({
|
|
1730
1774
|
mintComment,
|
|
1731
1775
|
minterAccount,
|
|
@@ -1734,8 +1778,7 @@ function makePrepareMint1155TokenParams({
|
|
|
1734
1778
|
mintTo,
|
|
1735
1779
|
salesConfigAndTokenInfo,
|
|
1736
1780
|
tokenContract,
|
|
1737
|
-
tokenId
|
|
1738
|
-
allowListEntry
|
|
1781
|
+
tokenId
|
|
1739
1782
|
});
|
|
1740
1783
|
}
|
|
1741
1784
|
if (saleType === "erc20") {
|
|
@@ -1772,8 +1815,7 @@ function makePrepareMint721TokenParams({
|
|
|
1772
1815
|
const mintValue = parseMintCosts({
|
|
1773
1816
|
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1774
1817
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1775
|
-
quantityToMint: actualQuantityToMint
|
|
1776
|
-
allowListEntry: void 0
|
|
1818
|
+
quantityToMint: actualQuantityToMint
|
|
1777
1819
|
}).totalCostEth;
|
|
1778
1820
|
return makeContractParameters({
|
|
1779
1821
|
abi: zora721Abi,
|
|
@@ -1789,29 +1831,6 @@ function makePrepareMint721TokenParams({
|
|
|
1789
1831
|
]
|
|
1790
1832
|
});
|
|
1791
1833
|
}
|
|
1792
|
-
function makeFixedPriceMinterArguments({
|
|
1793
|
-
mintTo,
|
|
1794
|
-
mintComment
|
|
1795
|
-
}) {
|
|
1796
|
-
return (0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
|
|
1797
|
-
mintTo,
|
|
1798
|
-
mintComment || ""
|
|
1799
|
-
]);
|
|
1800
|
-
}
|
|
1801
|
-
function makeAllowListMinterArguments({
|
|
1802
|
-
mintTo,
|
|
1803
|
-
allowListEntry
|
|
1804
|
-
}) {
|
|
1805
|
-
return (0, import_viem5.encodeAbiParameters)(
|
|
1806
|
-
(0, import_viem5.parseAbiParameters)("address, uint256, uint256, bytes32[]"),
|
|
1807
|
-
[
|
|
1808
|
-
mintTo,
|
|
1809
|
-
BigInt(allowListEntry.maxCanMint),
|
|
1810
|
-
allowListEntry.price,
|
|
1811
|
-
allowListEntry.proof
|
|
1812
|
-
]
|
|
1813
|
-
);
|
|
1814
|
-
}
|
|
1815
1834
|
function makeEthMintCall({
|
|
1816
1835
|
tokenContract,
|
|
1817
1836
|
tokenId,
|
|
@@ -1820,26 +1839,17 @@ function makeEthMintCall({
|
|
|
1820
1839
|
mintComment,
|
|
1821
1840
|
mintReferral,
|
|
1822
1841
|
mintQuantity,
|
|
1823
|
-
mintTo
|
|
1824
|
-
allowListEntry
|
|
1842
|
+
mintTo
|
|
1825
1843
|
}) {
|
|
1826
1844
|
const mintValue = parseMintCosts({
|
|
1827
1845
|
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1828
1846
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1829
|
-
quantityToMint: mintQuantity
|
|
1830
|
-
allowListEntry
|
|
1847
|
+
quantityToMint: mintQuantity
|
|
1831
1848
|
}).totalCostEth;
|
|
1832
|
-
const
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
} else if (saleType === "allowlist") {
|
|
1837
|
-
if (!allowListEntry)
|
|
1838
|
-
throw new Error("Missing allowListEntry");
|
|
1839
|
-
minterArguments = makeAllowListMinterArguments({ mintTo, allowListEntry });
|
|
1840
|
-
} else {
|
|
1841
|
-
throw new Error("Unsupported sale type");
|
|
1842
|
-
}
|
|
1849
|
+
const minterArguments = (0, import_viem5.encodeAbiParameters)(
|
|
1850
|
+
(0, import_viem5.parseAbiParameters)("address, string"),
|
|
1851
|
+
[mintTo, mintComment || ""]
|
|
1852
|
+
);
|
|
1843
1853
|
if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
|
|
1844
1854
|
return makeContractParameters({
|
|
1845
1855
|
abi: import_protocol_deployments6.zoraCreator1155ImplABI,
|
|
@@ -1857,7 +1867,7 @@ function makeEthMintCall({
|
|
|
1857
1867
|
});
|
|
1858
1868
|
}
|
|
1859
1869
|
return makeContractParameters({
|
|
1860
|
-
abi:
|
|
1870
|
+
abi: zora1155LegacyAbi,
|
|
1861
1871
|
functionName: "mintWithRewards",
|
|
1862
1872
|
account: minterAccount,
|
|
1863
1873
|
value: mintValue,
|
|
@@ -1872,22 +1882,13 @@ function makeEthMintCall({
|
|
|
1872
1882
|
]
|
|
1873
1883
|
});
|
|
1874
1884
|
}
|
|
1875
|
-
function paidMintCost(salesConfig, allowListEntry) {
|
|
1876
|
-
if (salesConfig.saleType === "erc20" || salesConfig.saleType === "fixedPrice") {
|
|
1877
|
-
return salesConfig.pricePerToken;
|
|
1878
|
-
}
|
|
1879
|
-
if (allowListEntry)
|
|
1880
|
-
return allowListEntry.price;
|
|
1881
|
-
return 0n;
|
|
1882
|
-
}
|
|
1883
1885
|
function parseMintCosts({
|
|
1884
1886
|
salesConfig,
|
|
1885
1887
|
mintFeePerQuantity,
|
|
1886
|
-
quantityToMint
|
|
1887
|
-
allowListEntry
|
|
1888
|
+
quantityToMint
|
|
1888
1889
|
}) {
|
|
1889
1890
|
const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
|
|
1890
|
-
const tokenPurchaseCost =
|
|
1891
|
+
const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
|
|
1891
1892
|
const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
|
|
1892
1893
|
const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
|
|
1893
1894
|
return {
|
|
@@ -1973,7 +1974,6 @@ async function getMintsOfContract({
|
|
|
1973
1974
|
}
|
|
1974
1975
|
async function getMintCosts({
|
|
1975
1976
|
params,
|
|
1976
|
-
allowListEntry,
|
|
1977
1977
|
mintGetter,
|
|
1978
1978
|
premintGetter,
|
|
1979
1979
|
publicClient
|
|
@@ -1988,8 +1988,7 @@ async function getMintCosts({
|
|
|
1988
1988
|
return parseMintCosts({
|
|
1989
1989
|
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1990
1990
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1991
|
-
quantityToMint: BigInt(quantityToMint)
|
|
1992
|
-
allowListEntry
|
|
1991
|
+
quantityToMint: BigInt(quantityToMint)
|
|
1993
1992
|
});
|
|
1994
1993
|
}
|
|
1995
1994
|
return getPremintMintCostsWithUnknownTokenPrice({
|
|
@@ -2071,8 +2070,7 @@ var makeOnchainPrepareMint = (result) => (params) => ({
|
|
|
2071
2070
|
costs: parseMintCosts({
|
|
2072
2071
|
salesConfig: result.salesConfig,
|
|
2073
2072
|
quantityToMint: BigInt(params.quantityToMint),
|
|
2074
|
-
mintFeePerQuantity: result.mintFeePerQuantity
|
|
2075
|
-
allowListEntry: params.allowListEntry
|
|
2073
|
+
mintFeePerQuantity: result.mintFeePerQuantity
|
|
2076
2074
|
})
|
|
2077
2075
|
});
|
|
2078
2076
|
function toMintableReturn(result) {
|
|
@@ -2087,8 +2085,7 @@ var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
|
|
|
2087
2085
|
costs: parseMintCosts({
|
|
2088
2086
|
mintFeePerQuantity: mintFee,
|
|
2089
2087
|
quantityToMint: BigInt(params.quantityToMint),
|
|
2090
|
-
salesConfig: mintable.salesConfig
|
|
2091
|
-
allowListEntry: params.allowListEntry
|
|
2088
|
+
salesConfig: mintable.salesConfig
|
|
2092
2089
|
})
|
|
2093
2090
|
});
|
|
2094
2091
|
function toPremintMintReturn({
|
|
@@ -2286,12 +2283,12 @@ async function getContractInfo({
|
|
|
2286
2283
|
// src/create/token-setup.ts
|
|
2287
2284
|
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
2288
2285
|
var import_viem7 = require("viem");
|
|
2289
|
-
var
|
|
2286
|
+
var semver3 = __toESM(require("semver"), 1);
|
|
2290
2287
|
var PERMISSION_BITS = {
|
|
2291
2288
|
MINTER: 2n ** 2n
|
|
2292
2289
|
};
|
|
2293
|
-
var SALE_END_FOREVER = 18446744073709551615n;
|
|
2294
2290
|
var saleSettingsOrDefault = (saleSettings) => {
|
|
2291
|
+
const SALE_END_FOREVER = 18446744073709551615n;
|
|
2295
2292
|
const DEFAULT_SALE_SETTINGS = {
|
|
2296
2293
|
currency: import_viem7.zeroAddress,
|
|
2297
2294
|
// Free Mint
|
|
@@ -2308,31 +2305,6 @@ var saleSettingsOrDefault = (saleSettings) => {
|
|
|
2308
2305
|
...saleSettings
|
|
2309
2306
|
};
|
|
2310
2307
|
};
|
|
2311
|
-
var allowListWithDefaults = (allowlist) => {
|
|
2312
|
-
const defaultAllowListSettings = {
|
|
2313
|
-
// Sale start time – defaults to beginning of unix time
|
|
2314
|
-
saleStart: 0n,
|
|
2315
|
-
// This is the end of uint64, plenty of time
|
|
2316
|
-
saleEnd: SALE_END_FOREVER
|
|
2317
|
-
};
|
|
2318
|
-
return {
|
|
2319
|
-
...defaultAllowListSettings,
|
|
2320
|
-
...allowlist
|
|
2321
|
-
};
|
|
2322
|
-
};
|
|
2323
|
-
var getSalesConfigOrAllowListWithDefaults = ({
|
|
2324
|
-
salesConfig,
|
|
2325
|
-
allowlist
|
|
2326
|
-
}) => {
|
|
2327
|
-
if (!allowlist) {
|
|
2328
|
-
return {
|
|
2329
|
-
salesConfig: saleSettingsOrDefault(salesConfig)
|
|
2330
|
-
};
|
|
2331
|
-
}
|
|
2332
|
-
return {
|
|
2333
|
-
allowlist: allowListWithDefaults(allowlist)
|
|
2334
|
-
};
|
|
2335
|
-
};
|
|
2336
2308
|
function applyNew1155Defaults(props, ownerAddress) {
|
|
2337
2309
|
const { payoutRecipient: fundsRecipient } = props;
|
|
2338
2310
|
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem7.zeroAddress ? fundsRecipient : ownerAddress;
|
|
@@ -2341,11 +2313,8 @@ function applyNew1155Defaults(props, ownerAddress) {
|
|
|
2341
2313
|
createReferral: props.createReferral || import_viem7.zeroAddress,
|
|
2342
2314
|
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
2343
2315
|
royaltyBPS: props.royaltyBPS || 1e3,
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
salesConfig: props.salesConfig,
|
|
2347
|
-
allowlist: props.allowlist
|
|
2348
|
-
})
|
|
2316
|
+
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
2317
|
+
tokenMetadataURI: props.tokenMetadataURI
|
|
2349
2318
|
};
|
|
2350
2319
|
}
|
|
2351
2320
|
function setupErc20Minter({
|
|
@@ -2434,64 +2403,21 @@ function setupFixedPriceMinter({
|
|
|
2434
2403
|
setupActions: [fixedPriceApproval, callSale]
|
|
2435
2404
|
};
|
|
2436
2405
|
}
|
|
2437
|
-
function
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
abi: import_protocol_deployments8.zoraCreatorMerkleMinterStrategyABI,
|
|
2452
|
-
functionName: "setSale",
|
|
2453
|
-
args: [
|
|
2454
|
-
BigInt(nextTokenId),
|
|
2455
|
-
{
|
|
2456
|
-
presaleStart: allowlist.saleStart,
|
|
2457
|
-
presaleEnd: allowlist.saleEnd,
|
|
2458
|
-
merkleRoot,
|
|
2459
|
-
fundsRecipient
|
|
2460
|
-
}
|
|
2461
|
-
]
|
|
2462
|
-
});
|
|
2463
|
-
const callSaleMerkle = (0, import_viem7.encodeFunctionData)({
|
|
2464
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2465
|
-
functionName: "callSale",
|
|
2466
|
-
args: [BigInt(nextTokenId), merkleSaleStrategyAddress, saleData]
|
|
2467
|
-
});
|
|
2468
|
-
return {
|
|
2469
|
-
minter: merkleSaleStrategyAddress,
|
|
2470
|
-
setupActions: [merkleApproval, callSaleMerkle]
|
|
2471
|
-
};
|
|
2472
|
-
}
|
|
2473
|
-
function setupMinters({
|
|
2474
|
-
salesConfigOrAllowList: { salesConfig, allowlist },
|
|
2475
|
-
...rest
|
|
2476
|
-
}) {
|
|
2477
|
-
if (salesConfig) {
|
|
2478
|
-
const { currency: currencyAddress } = salesConfig;
|
|
2479
|
-
if (currencyAddress === import_viem7.zeroAddress) {
|
|
2480
|
-
return setupFixedPriceMinter({
|
|
2481
|
-
...salesConfig,
|
|
2482
|
-
...rest
|
|
2483
|
-
});
|
|
2484
|
-
} else {
|
|
2485
|
-
return setupErc20Minter({
|
|
2486
|
-
...salesConfig,
|
|
2487
|
-
...rest
|
|
2488
|
-
});
|
|
2489
|
-
}
|
|
2406
|
+
function setupMinters({ salesConfig, ...rest }) {
|
|
2407
|
+
if (!salesConfig)
|
|
2408
|
+
throw new Error("No sales config for token");
|
|
2409
|
+
const { currency: currencyAddress } = salesConfig;
|
|
2410
|
+
if (currencyAddress === import_viem7.zeroAddress) {
|
|
2411
|
+
return setupFixedPriceMinter({
|
|
2412
|
+
...salesConfig,
|
|
2413
|
+
...rest
|
|
2414
|
+
});
|
|
2415
|
+
} else {
|
|
2416
|
+
return setupErc20Minter({
|
|
2417
|
+
...salesConfig,
|
|
2418
|
+
...rest
|
|
2419
|
+
});
|
|
2490
2420
|
}
|
|
2491
|
-
return setupAllowListMinter({
|
|
2492
|
-
allowlist,
|
|
2493
|
-
...rest
|
|
2494
|
-
});
|
|
2495
2421
|
}
|
|
2496
2422
|
function buildSetupNewToken({
|
|
2497
2423
|
tokenURI,
|
|
@@ -2584,7 +2510,7 @@ function constructCreate1155TokenCalls(props) {
|
|
|
2584
2510
|
tokenId: nextTokenId,
|
|
2585
2511
|
chainId,
|
|
2586
2512
|
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
2587
|
-
|
|
2513
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
2588
2514
|
});
|
|
2589
2515
|
const adminMintCall = makeAdminMintCall({
|
|
2590
2516
|
ownerAddress,
|
|
@@ -2608,13 +2534,13 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
|
2608
2534
|
if (!contractStandard || !contractVersion) {
|
|
2609
2535
|
return false;
|
|
2610
2536
|
}
|
|
2611
|
-
const semVerContractVersion =
|
|
2537
|
+
const semVerContractVersion = semver3.coerce(contractVersion)?.raw;
|
|
2612
2538
|
if (!semVerContractVersion)
|
|
2613
2539
|
return false;
|
|
2614
2540
|
if (contractStandard === "ERC1155") {
|
|
2615
|
-
return
|
|
2541
|
+
return semver3.gte(semVerContractVersion, "1.3.5");
|
|
2616
2542
|
} else {
|
|
2617
|
-
return
|
|
2543
|
+
return semver3.gte(semVerContractVersion, "14.0.0");
|
|
2618
2544
|
}
|
|
2619
2545
|
};
|
|
2620
2546
|
|
|
@@ -2635,21 +2561,6 @@ var getTokenIdFromCreateReceipt = (receipt) => {
|
|
|
2635
2561
|
}
|
|
2636
2562
|
}
|
|
2637
2563
|
};
|
|
2638
|
-
var getContractAddressFromCreateReceipt = (receipt) => {
|
|
2639
|
-
for (const data of receipt.logs) {
|
|
2640
|
-
try {
|
|
2641
|
-
const decodedLog = (0, import_viem8.decodeEventLog)({
|
|
2642
|
-
abi: import_protocol_deployments9.zoraCreator1155FactoryImplABI,
|
|
2643
|
-
eventName: "SetupNewContract",
|
|
2644
|
-
...data
|
|
2645
|
-
});
|
|
2646
|
-
if (decodedLog && decodedLog.eventName === "SetupNewContract") {
|
|
2647
|
-
return decodedLog.args.newContract;
|
|
2648
|
-
}
|
|
2649
|
-
} catch (err) {
|
|
2650
|
-
}
|
|
2651
|
-
}
|
|
2652
|
-
};
|
|
2653
2564
|
function makeCreateContractAndTokenCall({
|
|
2654
2565
|
contractExists,
|
|
2655
2566
|
contractAddress,
|
|
@@ -3215,7 +3126,7 @@ var equals = (aa, bb) => {
|
|
|
3215
3126
|
}
|
|
3216
3127
|
return true;
|
|
3217
3128
|
};
|
|
3218
|
-
var
|
|
3129
|
+
var coerce4 = (o) => {
|
|
3219
3130
|
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
3220
3131
|
return o;
|
|
3221
3132
|
if (o instanceof ArrayBuffer)
|
|
@@ -3238,7 +3149,7 @@ var create = (code, digest) => {
|
|
|
3238
3149
|
return new Digest(code, size, digest, bytes);
|
|
3239
3150
|
};
|
|
3240
3151
|
var decode3 = (multihash) => {
|
|
3241
|
-
const bytes =
|
|
3152
|
+
const bytes = coerce4(multihash);
|
|
3242
3153
|
const [code, sizeOffset] = decode2(bytes);
|
|
3243
3154
|
const [size, digestOffset] = decode2(bytes.subarray(sizeOffset));
|
|
3244
3155
|
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
@@ -3482,7 +3393,7 @@ var baseX = ({ prefix, name, alphabet }) => {
|
|
|
3482
3393
|
prefix,
|
|
3483
3394
|
name,
|
|
3484
3395
|
encode: encode3,
|
|
3485
|
-
decode: (text) =>
|
|
3396
|
+
decode: (text) => coerce4(decode5(text))
|
|
3486
3397
|
});
|
|
3487
3398
|
};
|
|
3488
3399
|
var decode4 = (string, alphabet, bitsPerChar, name) => {
|
|
@@ -3769,7 +3680,7 @@ var CID = class _CID {
|
|
|
3769
3680
|
static decodeFirst(bytes) {
|
|
3770
3681
|
const specs = _CID.inspectBytes(bytes);
|
|
3771
3682
|
const prefixSize = specs.size - specs.multihashSize;
|
|
3772
|
-
const multihashBytes =
|
|
3683
|
+
const multihashBytes = coerce4(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
3773
3684
|
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
3774
3685
|
throw new Error("Incorrect length");
|
|
3775
3686
|
}
|
|
@@ -4261,25 +4172,6 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
4261
4172
|
thumbnailFile
|
|
4262
4173
|
};
|
|
4263
4174
|
}
|
|
4264
|
-
|
|
4265
|
-
// src/allow-list/allow-list-client.ts
|
|
4266
|
-
var ALLOW_LIST_API_BASE = "http://allowlist.zora.co/";
|
|
4267
|
-
var createAllowList = async ({
|
|
4268
|
-
allowList,
|
|
4269
|
-
httpClient: httpClient2 = httpClient
|
|
4270
|
-
}) => {
|
|
4271
|
-
const { post: post2, retries: retries2 } = httpClient2;
|
|
4272
|
-
const data = {
|
|
4273
|
-
entries: allowList.entries.map((entry) => ({
|
|
4274
|
-
user: entry.user,
|
|
4275
|
-
maxCanMint: entry.maxCanMint,
|
|
4276
|
-
price: entry.price.toString()
|
|
4277
|
-
}))
|
|
4278
|
-
};
|
|
4279
|
-
return (await retries2(
|
|
4280
|
-
() => post2(`${ALLOW_LIST_API_BASE}allowlist`, data)
|
|
4281
|
-
)).root;
|
|
4282
|
-
};
|
|
4283
4175
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4284
4176
|
0 && (module.exports = {
|
|
4285
4177
|
Create1155Client,
|
|
@@ -4300,7 +4192,6 @@ var createAllowList = async ({
|
|
|
4300
4192
|
convertGetPremintApiResponse,
|
|
4301
4193
|
convertGetPremintOfCollectionApiResponse,
|
|
4302
4194
|
convertPremintFromApi,
|
|
4303
|
-
createAllowList,
|
|
4304
4195
|
createCollectorClient,
|
|
4305
4196
|
createCreatorClient,
|
|
4306
4197
|
decodeCallFailedError,
|
|
@@ -4313,7 +4204,6 @@ var createAllowList = async ({
|
|
|
4313
4204
|
encodePremintForAPI,
|
|
4314
4205
|
generateTextNftMetadataFiles,
|
|
4315
4206
|
getApiNetworkConfigForChain,
|
|
4316
|
-
getContractAddressFromCreateReceipt,
|
|
4317
4207
|
getDataFromPremintReceipt,
|
|
4318
4208
|
getDefaultFixedPriceMinterAddress,
|
|
4319
4209
|
getMintsAccountBalanceWithPriceQuery,
|