@zoralabs/protocol-sdk 0.7.2-ALLOWLIST.0 → 0.7.3-SPARKS.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/CHANGELOG.md +10 -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 +128 -238
- 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 +130 -240
- 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 +14 -14
- package/dist/mints/mints-relay-example.d.ts +4 -4
- package/dist/mints/mints-relay-example.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 +2 -3
- package/src/apis/http-api-base.ts +0 -12
- package/src/constants.ts +36 -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-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-eth-unwrapper-and-caller.ts +2 -2
- package/src/mints/mints-relay-example.ts +10 -10
- 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/dist/index.js
CHANGED
|
@@ -49,6 +49,41 @@ 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 zora1155LegacyAbi = [
|
|
53
|
+
{
|
|
54
|
+
type: "function",
|
|
55
|
+
name: "mintWithRewards",
|
|
56
|
+
inputs: [
|
|
57
|
+
{
|
|
58
|
+
name: "minter",
|
|
59
|
+
type: "address",
|
|
60
|
+
internalType: "contract IMinter1155"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "tokenId",
|
|
64
|
+
type: "uint256",
|
|
65
|
+
internalType: "uint256"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: "quantity",
|
|
69
|
+
type: "uint256",
|
|
70
|
+
internalType: "uint256"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "minterArguments",
|
|
74
|
+
type: "bytes",
|
|
75
|
+
internalType: "bytes"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "mintReferral",
|
|
79
|
+
type: "address",
|
|
80
|
+
internalType: "address"
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
outputs: [],
|
|
84
|
+
stateMutability: "payable"
|
|
85
|
+
}
|
|
86
|
+
];
|
|
52
87
|
|
|
53
88
|
// src/apis/chain-constants.ts
|
|
54
89
|
var REWARD_PER_TOKEN = parseEther("0.000777");
|
|
@@ -580,20 +615,14 @@ var get = async (url) => {
|
|
|
580
615
|
return await response.json();
|
|
581
616
|
};
|
|
582
617
|
var post = async (url, data) => {
|
|
583
|
-
const controller = new AbortController();
|
|
584
|
-
const { signal } = controller;
|
|
585
|
-
const timeout = 30 * 60 * 1e3;
|
|
586
|
-
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
587
618
|
const response = await fetch(url, {
|
|
588
619
|
method: "POST",
|
|
589
620
|
headers: {
|
|
590
621
|
"content-type": "application/json",
|
|
591
622
|
accept: "application/json"
|
|
592
623
|
},
|
|
593
|
-
body: JSON.stringify(data)
|
|
594
|
-
signal
|
|
624
|
+
body: JSON.stringify(data)
|
|
595
625
|
});
|
|
596
|
-
clearTimeout(timeoutId);
|
|
597
626
|
if (response.status !== 200) {
|
|
598
627
|
let json;
|
|
599
628
|
try {
|
|
@@ -679,12 +708,6 @@ fragment SaleStrategy on SalesStrategyConfig {
|
|
|
679
708
|
saleStart
|
|
680
709
|
maxTokensPerAddress
|
|
681
710
|
}
|
|
682
|
-
presale {
|
|
683
|
-
address
|
|
684
|
-
presaleStart
|
|
685
|
-
presaleEnd
|
|
686
|
-
merkleRoot
|
|
687
|
-
}
|
|
688
711
|
}`;
|
|
689
712
|
var TOKEN_FRAGMENT = `
|
|
690
713
|
fragment Token on ZoraCreateToken {
|
|
@@ -694,7 +717,7 @@ fragment Token on ZoraCreateToken {
|
|
|
694
717
|
totalMinted
|
|
695
718
|
maxSupply
|
|
696
719
|
tokenStandard
|
|
697
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"
|
|
720
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
698
721
|
...SaleStrategy
|
|
699
722
|
}
|
|
700
723
|
contract {
|
|
@@ -703,7 +726,7 @@ fragment Token on ZoraCreateToken {
|
|
|
703
726
|
contractVersion
|
|
704
727
|
contractURI
|
|
705
728
|
name
|
|
706
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"
|
|
729
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
707
730
|
...SaleStrategy
|
|
708
731
|
}
|
|
709
732
|
}
|
|
@@ -734,6 +757,19 @@ query ($id: ID!) {
|
|
|
734
757
|
parseResponseData: (responseData) => responseData?.zoraCreateToken
|
|
735
758
|
};
|
|
736
759
|
}
|
|
760
|
+
function buildGetDefaultMintPriceQuery({}) {
|
|
761
|
+
return {
|
|
762
|
+
query: `
|
|
763
|
+
{
|
|
764
|
+
defaultMintPrice(id: "0x0000000000000000000000000000000000000000") {
|
|
765
|
+
pricePerToken
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
`,
|
|
769
|
+
variables: {},
|
|
770
|
+
parseResponseData: (responseData) => responseData?.defaultMintPrice?.pricePerToken ? BigInt(responseData?.defaultMintPrice?.pricePerToken) : void 0
|
|
771
|
+
};
|
|
772
|
+
}
|
|
737
773
|
function buildContractTokensQuery({
|
|
738
774
|
tokenAddress
|
|
739
775
|
}) {
|
|
@@ -774,6 +810,7 @@ function buildPremintsOfContractQuery({
|
|
|
774
810
|
}
|
|
775
811
|
|
|
776
812
|
// src/mint/subgraph-mint-getter.ts
|
|
813
|
+
import * as semver from "semver";
|
|
777
814
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
778
815
|
if (!networkConfigByChain[chainId]) {
|
|
779
816
|
throw new Error(`chain id ${chainId} network not configured `);
|
|
@@ -800,23 +837,12 @@ function parseSalesConfig(targetStrategy) {
|
|
|
800
837
|
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
801
838
|
};
|
|
802
839
|
}
|
|
803
|
-
if (targetStrategy.type === "PRESALE") {
|
|
804
|
-
return {
|
|
805
|
-
saleType: "allowlist",
|
|
806
|
-
address: targetStrategy.presale.address,
|
|
807
|
-
merkleRoot: targetStrategy.presale.merkleRoot,
|
|
808
|
-
saleStart: targetStrategy.presale.presaleStart,
|
|
809
|
-
saleEnd: targetStrategy.presale.presaleEnd
|
|
810
|
-
};
|
|
811
|
-
}
|
|
812
840
|
throw new Error("Unknown saleType");
|
|
813
841
|
}
|
|
814
842
|
function getSaleEnd(a) {
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
return BigInt(a.erc20Minter.saleEnd);
|
|
819
|
-
return BigInt(a.presale.presaleEnd);
|
|
843
|
+
return BigInt(
|
|
844
|
+
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
845
|
+
);
|
|
820
846
|
}
|
|
821
847
|
function getTargetStrategy({
|
|
822
848
|
tokenId,
|
|
@@ -865,8 +891,10 @@ var SubgraphMintGetter = class {
|
|
|
865
891
|
if (!token) {
|
|
866
892
|
throw new Error("Cannot find token");
|
|
867
893
|
}
|
|
894
|
+
const defaultMintFee = await this.getContractMintFee(token.contract);
|
|
868
895
|
return parseTokenQueryResult({
|
|
869
896
|
token,
|
|
897
|
+
defaultMintFee,
|
|
870
898
|
tokenId,
|
|
871
899
|
preferredSaleType: saleType
|
|
872
900
|
});
|
|
@@ -874,6 +902,16 @@ var SubgraphMintGetter = class {
|
|
|
874
902
|
this.httpClient = httpClient2 || httpClient;
|
|
875
903
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
876
904
|
}
|
|
905
|
+
async getContractMintFee(contract) {
|
|
906
|
+
const storedMintFee = BigInt(contract.mintFeePerQuantity);
|
|
907
|
+
if (!contractUsesMintCardsForMintFee(contract.contractVersion)) {
|
|
908
|
+
return storedMintFee;
|
|
909
|
+
}
|
|
910
|
+
const defaultMintFee = await this.querySubgraphWithRetries(
|
|
911
|
+
buildGetDefaultMintPriceQuery({})
|
|
912
|
+
);
|
|
913
|
+
return defaultMintFee || storedMintFee;
|
|
914
|
+
}
|
|
877
915
|
async querySubgraphWithRetries({
|
|
878
916
|
query,
|
|
879
917
|
variables,
|
|
@@ -896,13 +934,15 @@ var SubgraphMintGetter = class {
|
|
|
896
934
|
tokenAddress
|
|
897
935
|
})
|
|
898
936
|
);
|
|
899
|
-
if (!tokens)
|
|
937
|
+
if (!tokens || tokens.length === 0)
|
|
900
938
|
return [];
|
|
939
|
+
const defaultMintFee = await this.getContractMintFee(tokens[0].contract);
|
|
901
940
|
return tokens.filter((x) => x.tokenId !== "0").map(
|
|
902
941
|
(token) => parseTokenQueryResult({
|
|
903
942
|
token,
|
|
904
943
|
tokenId: token.tokenId,
|
|
905
|
-
preferredSaleType
|
|
944
|
+
preferredSaleType,
|
|
945
|
+
defaultMintFee
|
|
906
946
|
})
|
|
907
947
|
);
|
|
908
948
|
}
|
|
@@ -923,14 +963,15 @@ var SubgraphMintGetter = class {
|
|
|
923
963
|
function parseTokenQueryResult({
|
|
924
964
|
token,
|
|
925
965
|
tokenId,
|
|
926
|
-
preferredSaleType
|
|
966
|
+
preferredSaleType,
|
|
967
|
+
defaultMintFee
|
|
927
968
|
}) {
|
|
928
969
|
const targetStrategy = getTargetStrategy({
|
|
929
970
|
tokenId,
|
|
930
971
|
preferredSaleType,
|
|
931
972
|
token
|
|
932
973
|
});
|
|
933
|
-
const tokenInfo = parseTokenInfo(token);
|
|
974
|
+
const tokenInfo = parseTokenInfo(token, defaultMintFee);
|
|
934
975
|
const salesConfig = parseSalesConfig(targetStrategy);
|
|
935
976
|
if (isErc20SaleStrategy(salesConfig)) {
|
|
936
977
|
tokenInfo.mintFeePerQuantity = 0n;
|
|
@@ -940,7 +981,13 @@ function parseTokenQueryResult({
|
|
|
940
981
|
salesConfig
|
|
941
982
|
};
|
|
942
983
|
}
|
|
943
|
-
|
|
984
|
+
var contractUsesMintCardsForMintFee = (contractVersion) => {
|
|
985
|
+
const semVerContractVersion = semver.coerce(contractVersion)?.raw;
|
|
986
|
+
if (!semVerContractVersion)
|
|
987
|
+
return false;
|
|
988
|
+
return semver.gte(semVerContractVersion, "2.9.0");
|
|
989
|
+
};
|
|
990
|
+
function parseTokenInfo(token, defaultMintFee) {
|
|
944
991
|
return {
|
|
945
992
|
contract: {
|
|
946
993
|
address: token.contract.address,
|
|
@@ -953,7 +1000,7 @@ function parseTokenInfo(token) {
|
|
|
953
1000
|
creator: token.creator,
|
|
954
1001
|
totalMinted: BigInt(token.totalMinted),
|
|
955
1002
|
maxSupply: BigInt(token.maxSupply),
|
|
956
|
-
mintFeePerQuantity:
|
|
1003
|
+
mintFeePerQuantity: defaultMintFee,
|
|
957
1004
|
contractVersion: token.contract.contractVersion
|
|
958
1005
|
};
|
|
959
1006
|
}
|
|
@@ -1617,15 +1664,15 @@ import {
|
|
|
1617
1664
|
} from "@zoralabs/protocol-deployments";
|
|
1618
1665
|
|
|
1619
1666
|
// src/mint/utils.ts
|
|
1620
|
-
import * as
|
|
1667
|
+
import * as semver2 from "semver";
|
|
1621
1668
|
var contractSupportsNewMintFunction = (contractVersion) => {
|
|
1622
1669
|
if (!contractVersion) {
|
|
1623
1670
|
return false;
|
|
1624
1671
|
}
|
|
1625
|
-
const semVerContractVersion =
|
|
1672
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
1626
1673
|
if (!semVerContractVersion)
|
|
1627
1674
|
return false;
|
|
1628
|
-
return
|
|
1675
|
+
return semver2.gte(semVerContractVersion, "2.9.0");
|
|
1629
1676
|
};
|
|
1630
1677
|
|
|
1631
1678
|
// src/mint/mint-transactions.ts
|
|
@@ -1655,13 +1702,12 @@ function makePrepareMint1155TokenParams({
|
|
|
1655
1702
|
mintComment,
|
|
1656
1703
|
mintReferral,
|
|
1657
1704
|
mintRecipient,
|
|
1658
|
-
quantityToMint
|
|
1659
|
-
allowListEntry
|
|
1705
|
+
quantityToMint
|
|
1660
1706
|
}) {
|
|
1661
1707
|
const mintQuantity = BigInt(quantityToMint || 1);
|
|
1662
1708
|
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
1663
1709
|
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
1664
|
-
if (saleType === "fixedPrice"
|
|
1710
|
+
if (saleType === "fixedPrice") {
|
|
1665
1711
|
return makeEthMintCall({
|
|
1666
1712
|
mintComment,
|
|
1667
1713
|
minterAccount,
|
|
@@ -1670,8 +1716,7 @@ function makePrepareMint1155TokenParams({
|
|
|
1670
1716
|
mintTo,
|
|
1671
1717
|
salesConfigAndTokenInfo,
|
|
1672
1718
|
tokenContract,
|
|
1673
|
-
tokenId
|
|
1674
|
-
allowListEntry
|
|
1719
|
+
tokenId
|
|
1675
1720
|
});
|
|
1676
1721
|
}
|
|
1677
1722
|
if (saleType === "erc20") {
|
|
@@ -1708,8 +1753,7 @@ function makePrepareMint721TokenParams({
|
|
|
1708
1753
|
const mintValue = parseMintCosts({
|
|
1709
1754
|
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1710
1755
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1711
|
-
quantityToMint: actualQuantityToMint
|
|
1712
|
-
allowListEntry: void 0
|
|
1756
|
+
quantityToMint: actualQuantityToMint
|
|
1713
1757
|
}).totalCostEth;
|
|
1714
1758
|
return makeContractParameters({
|
|
1715
1759
|
abi: zora721Abi,
|
|
@@ -1725,29 +1769,6 @@ function makePrepareMint721TokenParams({
|
|
|
1725
1769
|
]
|
|
1726
1770
|
});
|
|
1727
1771
|
}
|
|
1728
|
-
function makeFixedPriceMinterArguments({
|
|
1729
|
-
mintTo,
|
|
1730
|
-
mintComment
|
|
1731
|
-
}) {
|
|
1732
|
-
return encodeAbiParameters(parseAbiParameters("address, string"), [
|
|
1733
|
-
mintTo,
|
|
1734
|
-
mintComment || ""
|
|
1735
|
-
]);
|
|
1736
|
-
}
|
|
1737
|
-
function makeAllowListMinterArguments({
|
|
1738
|
-
mintTo,
|
|
1739
|
-
allowListEntry
|
|
1740
|
-
}) {
|
|
1741
|
-
return encodeAbiParameters(
|
|
1742
|
-
parseAbiParameters("address, uint256, uint256, bytes32[]"),
|
|
1743
|
-
[
|
|
1744
|
-
mintTo,
|
|
1745
|
-
BigInt(allowListEntry.maxCanMint),
|
|
1746
|
-
allowListEntry.price,
|
|
1747
|
-
allowListEntry.proof
|
|
1748
|
-
]
|
|
1749
|
-
);
|
|
1750
|
-
}
|
|
1751
1772
|
function makeEthMintCall({
|
|
1752
1773
|
tokenContract,
|
|
1753
1774
|
tokenId,
|
|
@@ -1756,26 +1777,17 @@ function makeEthMintCall({
|
|
|
1756
1777
|
mintComment,
|
|
1757
1778
|
mintReferral,
|
|
1758
1779
|
mintQuantity,
|
|
1759
|
-
mintTo
|
|
1760
|
-
allowListEntry
|
|
1780
|
+
mintTo
|
|
1761
1781
|
}) {
|
|
1762
1782
|
const mintValue = parseMintCosts({
|
|
1763
1783
|
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1764
1784
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1765
|
-
quantityToMint: mintQuantity
|
|
1766
|
-
allowListEntry
|
|
1785
|
+
quantityToMint: mintQuantity
|
|
1767
1786
|
}).totalCostEth;
|
|
1768
|
-
const
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
} else if (saleType === "allowlist") {
|
|
1773
|
-
if (!allowListEntry)
|
|
1774
|
-
throw new Error("Missing allowListEntry");
|
|
1775
|
-
minterArguments = makeAllowListMinterArguments({ mintTo, allowListEntry });
|
|
1776
|
-
} else {
|
|
1777
|
-
throw new Error("Unsupported sale type");
|
|
1778
|
-
}
|
|
1787
|
+
const minterArguments = encodeAbiParameters(
|
|
1788
|
+
parseAbiParameters("address, string"),
|
|
1789
|
+
[mintTo, mintComment || ""]
|
|
1790
|
+
);
|
|
1779
1791
|
if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
|
|
1780
1792
|
return makeContractParameters({
|
|
1781
1793
|
abi: zoraCreator1155ImplABI2,
|
|
@@ -1793,7 +1805,7 @@ function makeEthMintCall({
|
|
|
1793
1805
|
});
|
|
1794
1806
|
}
|
|
1795
1807
|
return makeContractParameters({
|
|
1796
|
-
abi:
|
|
1808
|
+
abi: zora1155LegacyAbi,
|
|
1797
1809
|
functionName: "mintWithRewards",
|
|
1798
1810
|
account: minterAccount,
|
|
1799
1811
|
value: mintValue,
|
|
@@ -1808,22 +1820,13 @@ function makeEthMintCall({
|
|
|
1808
1820
|
]
|
|
1809
1821
|
});
|
|
1810
1822
|
}
|
|
1811
|
-
function paidMintCost(salesConfig, allowListEntry) {
|
|
1812
|
-
if (salesConfig.saleType === "erc20" || salesConfig.saleType === "fixedPrice") {
|
|
1813
|
-
return salesConfig.pricePerToken;
|
|
1814
|
-
}
|
|
1815
|
-
if (allowListEntry)
|
|
1816
|
-
return allowListEntry.price;
|
|
1817
|
-
return 0n;
|
|
1818
|
-
}
|
|
1819
1823
|
function parseMintCosts({
|
|
1820
1824
|
salesConfig,
|
|
1821
1825
|
mintFeePerQuantity,
|
|
1822
|
-
quantityToMint
|
|
1823
|
-
allowListEntry
|
|
1826
|
+
quantityToMint
|
|
1824
1827
|
}) {
|
|
1825
1828
|
const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
|
|
1826
|
-
const tokenPurchaseCost =
|
|
1829
|
+
const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
|
|
1827
1830
|
const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
|
|
1828
1831
|
const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
|
|
1829
1832
|
return {
|
|
@@ -1909,7 +1912,6 @@ async function getMintsOfContract({
|
|
|
1909
1912
|
}
|
|
1910
1913
|
async function getMintCosts({
|
|
1911
1914
|
params,
|
|
1912
|
-
allowListEntry,
|
|
1913
1915
|
mintGetter,
|
|
1914
1916
|
premintGetter,
|
|
1915
1917
|
publicClient
|
|
@@ -1924,8 +1926,7 @@ async function getMintCosts({
|
|
|
1924
1926
|
return parseMintCosts({
|
|
1925
1927
|
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1926
1928
|
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1927
|
-
quantityToMint: BigInt(quantityToMint)
|
|
1928
|
-
allowListEntry
|
|
1929
|
+
quantityToMint: BigInt(quantityToMint)
|
|
1929
1930
|
});
|
|
1930
1931
|
}
|
|
1931
1932
|
return getPremintMintCostsWithUnknownTokenPrice({
|
|
@@ -2007,8 +2008,7 @@ var makeOnchainPrepareMint = (result) => (params) => ({
|
|
|
2007
2008
|
costs: parseMintCosts({
|
|
2008
2009
|
salesConfig: result.salesConfig,
|
|
2009
2010
|
quantityToMint: BigInt(params.quantityToMint),
|
|
2010
|
-
mintFeePerQuantity: result.mintFeePerQuantity
|
|
2011
|
-
allowListEntry: params.allowListEntry
|
|
2011
|
+
mintFeePerQuantity: result.mintFeePerQuantity
|
|
2012
2012
|
})
|
|
2013
2013
|
});
|
|
2014
2014
|
function toMintableReturn(result) {
|
|
@@ -2023,8 +2023,7 @@ var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
|
|
|
2023
2023
|
costs: parseMintCosts({
|
|
2024
2024
|
mintFeePerQuantity: mintFee,
|
|
2025
2025
|
quantityToMint: BigInt(params.quantityToMint),
|
|
2026
|
-
salesConfig: mintable.salesConfig
|
|
2027
|
-
allowListEntry: params.allowListEntry
|
|
2026
|
+
salesConfig: mintable.salesConfig
|
|
2028
2027
|
})
|
|
2029
2028
|
});
|
|
2030
2029
|
function toPremintMintReturn({
|
|
@@ -2234,17 +2233,15 @@ import {
|
|
|
2234
2233
|
erc20MinterAddress as erc20MinterAddresses,
|
|
2235
2234
|
zoraCreator1155ImplABI as zoraCreator1155ImplABI4,
|
|
2236
2235
|
zoraCreatorFixedPriceSaleStrategyABI,
|
|
2237
|
-
zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress2
|
|
2238
|
-
zoraCreatorMerkleMinterStrategyABI,
|
|
2239
|
-
zoraCreatorMerkleMinterStrategyAddress
|
|
2236
|
+
zoraCreatorFixedPriceSaleStrategyAddress as zoraCreatorFixedPriceSaleStrategyAddress2
|
|
2240
2237
|
} from "@zoralabs/protocol-deployments";
|
|
2241
2238
|
import { encodeFunctionData, zeroAddress as zeroAddress5 } from "viem";
|
|
2242
|
-
import * as
|
|
2239
|
+
import * as semver3 from "semver";
|
|
2243
2240
|
var PERMISSION_BITS = {
|
|
2244
2241
|
MINTER: 2n ** 2n
|
|
2245
2242
|
};
|
|
2246
|
-
var SALE_END_FOREVER = 18446744073709551615n;
|
|
2247
2243
|
var saleSettingsOrDefault = (saleSettings) => {
|
|
2244
|
+
const SALE_END_FOREVER = 18446744073709551615n;
|
|
2248
2245
|
const DEFAULT_SALE_SETTINGS = {
|
|
2249
2246
|
currency: zeroAddress5,
|
|
2250
2247
|
// Free Mint
|
|
@@ -2261,31 +2258,6 @@ var saleSettingsOrDefault = (saleSettings) => {
|
|
|
2261
2258
|
...saleSettings
|
|
2262
2259
|
};
|
|
2263
2260
|
};
|
|
2264
|
-
var allowListWithDefaults = (allowlist) => {
|
|
2265
|
-
const defaultAllowListSettings = {
|
|
2266
|
-
// Sale start time – defaults to beginning of unix time
|
|
2267
|
-
saleStart: 0n,
|
|
2268
|
-
// This is the end of uint64, plenty of time
|
|
2269
|
-
saleEnd: SALE_END_FOREVER
|
|
2270
|
-
};
|
|
2271
|
-
return {
|
|
2272
|
-
...defaultAllowListSettings,
|
|
2273
|
-
...allowlist
|
|
2274
|
-
};
|
|
2275
|
-
};
|
|
2276
|
-
var getSalesConfigOrAllowListWithDefaults = ({
|
|
2277
|
-
salesConfig,
|
|
2278
|
-
allowlist
|
|
2279
|
-
}) => {
|
|
2280
|
-
if (!allowlist) {
|
|
2281
|
-
return {
|
|
2282
|
-
salesConfig: saleSettingsOrDefault(salesConfig)
|
|
2283
|
-
};
|
|
2284
|
-
}
|
|
2285
|
-
return {
|
|
2286
|
-
allowlist: allowListWithDefaults(allowlist)
|
|
2287
|
-
};
|
|
2288
|
-
};
|
|
2289
2261
|
function applyNew1155Defaults(props, ownerAddress) {
|
|
2290
2262
|
const { payoutRecipient: fundsRecipient } = props;
|
|
2291
2263
|
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== zeroAddress5 ? fundsRecipient : ownerAddress;
|
|
@@ -2294,11 +2266,8 @@ function applyNew1155Defaults(props, ownerAddress) {
|
|
|
2294
2266
|
createReferral: props.createReferral || zeroAddress5,
|
|
2295
2267
|
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
2296
2268
|
royaltyBPS: props.royaltyBPS || 1e3,
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
salesConfig: props.salesConfig,
|
|
2300
|
-
allowlist: props.allowlist
|
|
2301
|
-
})
|
|
2269
|
+
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
2270
|
+
tokenMetadataURI: props.tokenMetadataURI
|
|
2302
2271
|
};
|
|
2303
2272
|
}
|
|
2304
2273
|
function setupErc20Minter({
|
|
@@ -2387,64 +2356,21 @@ function setupFixedPriceMinter({
|
|
|
2387
2356
|
setupActions: [fixedPriceApproval, callSale]
|
|
2388
2357
|
};
|
|
2389
2358
|
}
|
|
2390
|
-
function
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
abi: zoraCreatorMerkleMinterStrategyABI,
|
|
2405
|
-
functionName: "setSale",
|
|
2406
|
-
args: [
|
|
2407
|
-
BigInt(nextTokenId),
|
|
2408
|
-
{
|
|
2409
|
-
presaleStart: allowlist.saleStart,
|
|
2410
|
-
presaleEnd: allowlist.saleEnd,
|
|
2411
|
-
merkleRoot,
|
|
2412
|
-
fundsRecipient
|
|
2413
|
-
}
|
|
2414
|
-
]
|
|
2415
|
-
});
|
|
2416
|
-
const callSaleMerkle = encodeFunctionData({
|
|
2417
|
-
abi: zoraCreator1155ImplABI4,
|
|
2418
|
-
functionName: "callSale",
|
|
2419
|
-
args: [BigInt(nextTokenId), merkleSaleStrategyAddress, saleData]
|
|
2420
|
-
});
|
|
2421
|
-
return {
|
|
2422
|
-
minter: merkleSaleStrategyAddress,
|
|
2423
|
-
setupActions: [merkleApproval, callSaleMerkle]
|
|
2424
|
-
};
|
|
2425
|
-
}
|
|
2426
|
-
function setupMinters({
|
|
2427
|
-
salesConfigOrAllowList: { salesConfig, allowlist },
|
|
2428
|
-
...rest
|
|
2429
|
-
}) {
|
|
2430
|
-
if (salesConfig) {
|
|
2431
|
-
const { currency: currencyAddress } = salesConfig;
|
|
2432
|
-
if (currencyAddress === zeroAddress5) {
|
|
2433
|
-
return setupFixedPriceMinter({
|
|
2434
|
-
...salesConfig,
|
|
2435
|
-
...rest
|
|
2436
|
-
});
|
|
2437
|
-
} else {
|
|
2438
|
-
return setupErc20Minter({
|
|
2439
|
-
...salesConfig,
|
|
2440
|
-
...rest
|
|
2441
|
-
});
|
|
2442
|
-
}
|
|
2359
|
+
function setupMinters({ salesConfig, ...rest }) {
|
|
2360
|
+
if (!salesConfig)
|
|
2361
|
+
throw new Error("No sales config for token");
|
|
2362
|
+
const { currency: currencyAddress } = salesConfig;
|
|
2363
|
+
if (currencyAddress === zeroAddress5) {
|
|
2364
|
+
return setupFixedPriceMinter({
|
|
2365
|
+
...salesConfig,
|
|
2366
|
+
...rest
|
|
2367
|
+
});
|
|
2368
|
+
} else {
|
|
2369
|
+
return setupErc20Minter({
|
|
2370
|
+
...salesConfig,
|
|
2371
|
+
...rest
|
|
2372
|
+
});
|
|
2443
2373
|
}
|
|
2444
|
-
return setupAllowListMinter({
|
|
2445
|
-
allowlist,
|
|
2446
|
-
...rest
|
|
2447
|
-
});
|
|
2448
2374
|
}
|
|
2449
2375
|
function buildSetupNewToken({
|
|
2450
2376
|
tokenURI,
|
|
@@ -2537,7 +2463,7 @@ function constructCreate1155TokenCalls(props) {
|
|
|
2537
2463
|
tokenId: nextTokenId,
|
|
2538
2464
|
chainId,
|
|
2539
2465
|
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
2540
|
-
|
|
2466
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
2541
2467
|
});
|
|
2542
2468
|
const adminMintCall = makeAdminMintCall({
|
|
2543
2469
|
ownerAddress,
|
|
@@ -2561,13 +2487,13 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
|
2561
2487
|
if (!contractStandard || !contractVersion) {
|
|
2562
2488
|
return false;
|
|
2563
2489
|
}
|
|
2564
|
-
const semVerContractVersion =
|
|
2490
|
+
const semVerContractVersion = semver3.coerce(contractVersion)?.raw;
|
|
2565
2491
|
if (!semVerContractVersion)
|
|
2566
2492
|
return false;
|
|
2567
2493
|
if (contractStandard === "ERC1155") {
|
|
2568
|
-
return
|
|
2494
|
+
return semver3.gte(semVerContractVersion, "1.3.5");
|
|
2569
2495
|
} else {
|
|
2570
|
-
return
|
|
2496
|
+
return semver3.gte(semVerContractVersion, "14.0.0");
|
|
2571
2497
|
}
|
|
2572
2498
|
};
|
|
2573
2499
|
|
|
@@ -2588,21 +2514,6 @@ var getTokenIdFromCreateReceipt = (receipt) => {
|
|
|
2588
2514
|
}
|
|
2589
2515
|
}
|
|
2590
2516
|
};
|
|
2591
|
-
var getContractAddressFromCreateReceipt = (receipt) => {
|
|
2592
|
-
for (const data of receipt.logs) {
|
|
2593
|
-
try {
|
|
2594
|
-
const decodedLog = decodeEventLog2({
|
|
2595
|
-
abi: zoraCreator1155FactoryImplABI2,
|
|
2596
|
-
eventName: "SetupNewContract",
|
|
2597
|
-
...data
|
|
2598
|
-
});
|
|
2599
|
-
if (decodedLog && decodedLog.eventName === "SetupNewContract") {
|
|
2600
|
-
return decodedLog.args.newContract;
|
|
2601
|
-
}
|
|
2602
|
-
} catch (err) {
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
};
|
|
2606
2517
|
function makeCreateContractAndTokenCall({
|
|
2607
2518
|
contractExists,
|
|
2608
2519
|
contractAddress,
|
|
@@ -3016,7 +2927,7 @@ function decodeCallFailedError(error) {
|
|
|
3016
2927
|
// src/mints/mints-eth-unwrapper-and-caller.ts
|
|
3017
2928
|
import {
|
|
3018
2929
|
iUnwrapAndForwardActionABI,
|
|
3019
|
-
|
|
2930
|
+
sparksEthUnwrapperAndCallerAddress
|
|
3020
2931
|
} from "@zoralabs/protocol-deployments";
|
|
3021
2932
|
import { encodeFunctionData as encodeFunctionData3 } from "viem";
|
|
3022
2933
|
var makeCallWithEthSafeTransferData = ({
|
|
@@ -3044,7 +2955,7 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
3044
2955
|
tokenIds,
|
|
3045
2956
|
quantities,
|
|
3046
2957
|
safeTransferData: safeTransferData || makeCallWithEthSafeTransferData(callWithEth),
|
|
3047
|
-
to:
|
|
2958
|
+
to: sparksEthUnwrapperAndCallerAddress[chainId],
|
|
3048
2959
|
nonce
|
|
3049
2960
|
});
|
|
3050
2961
|
|
|
@@ -3182,7 +3093,7 @@ var equals = (aa, bb) => {
|
|
|
3182
3093
|
}
|
|
3183
3094
|
return true;
|
|
3184
3095
|
};
|
|
3185
|
-
var
|
|
3096
|
+
var coerce4 = (o) => {
|
|
3186
3097
|
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
3187
3098
|
return o;
|
|
3188
3099
|
if (o instanceof ArrayBuffer)
|
|
@@ -3205,7 +3116,7 @@ var create = (code, digest) => {
|
|
|
3205
3116
|
return new Digest(code, size, digest, bytes);
|
|
3206
3117
|
};
|
|
3207
3118
|
var decode3 = (multihash) => {
|
|
3208
|
-
const bytes =
|
|
3119
|
+
const bytes = coerce4(multihash);
|
|
3209
3120
|
const [code, sizeOffset] = decode2(bytes);
|
|
3210
3121
|
const [size, digestOffset] = decode2(bytes.subarray(sizeOffset));
|
|
3211
3122
|
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
@@ -3449,7 +3360,7 @@ var baseX = ({ prefix, name, alphabet }) => {
|
|
|
3449
3360
|
prefix,
|
|
3450
3361
|
name,
|
|
3451
3362
|
encode: encode3,
|
|
3452
|
-
decode: (text) =>
|
|
3363
|
+
decode: (text) => coerce4(decode5(text))
|
|
3453
3364
|
});
|
|
3454
3365
|
};
|
|
3455
3366
|
var decode4 = (string, alphabet, bitsPerChar, name) => {
|
|
@@ -3736,7 +3647,7 @@ var CID = class _CID {
|
|
|
3736
3647
|
static decodeFirst(bytes) {
|
|
3737
3648
|
const specs = _CID.inspectBytes(bytes);
|
|
3738
3649
|
const prefixSize = specs.size - specs.multihashSize;
|
|
3739
|
-
const multihashBytes =
|
|
3650
|
+
const multihashBytes = coerce4(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
3740
3651
|
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
3741
3652
|
throw new Error("Incorrect length");
|
|
3742
3653
|
}
|
|
@@ -4228,25 +4139,6 @@ async function generateTextNftMetadataFiles(text) {
|
|
|
4228
4139
|
thumbnailFile
|
|
4229
4140
|
};
|
|
4230
4141
|
}
|
|
4231
|
-
|
|
4232
|
-
// src/allow-list/allow-list-client.ts
|
|
4233
|
-
var ALLOW_LIST_API_BASE = "http://allowlist.zora.co/";
|
|
4234
|
-
var createAllowList = async ({
|
|
4235
|
-
allowList,
|
|
4236
|
-
httpClient: httpClient2 = httpClient
|
|
4237
|
-
}) => {
|
|
4238
|
-
const { post: post2, retries: retries2 } = httpClient2;
|
|
4239
|
-
const data = {
|
|
4240
|
-
entries: allowList.entries.map((entry) => ({
|
|
4241
|
-
user: entry.user,
|
|
4242
|
-
maxCanMint: entry.maxCanMint,
|
|
4243
|
-
price: entry.price.toString()
|
|
4244
|
-
}))
|
|
4245
|
-
};
|
|
4246
|
-
return (await retries2(
|
|
4247
|
-
() => post2(`${ALLOW_LIST_API_BASE}allowlist`, data)
|
|
4248
|
-
)).root;
|
|
4249
|
-
};
|
|
4250
4142
|
export {
|
|
4251
4143
|
Create1155Client,
|
|
4252
4144
|
Errors,
|
|
@@ -4266,7 +4158,6 @@ export {
|
|
|
4266
4158
|
convertGetPremintApiResponse,
|
|
4267
4159
|
convertGetPremintOfCollectionApiResponse,
|
|
4268
4160
|
convertPremintFromApi,
|
|
4269
|
-
createAllowList,
|
|
4270
4161
|
createCollectorClient,
|
|
4271
4162
|
createCreatorClient,
|
|
4272
4163
|
decodeCallFailedError,
|
|
@@ -4279,7 +4170,6 @@ export {
|
|
|
4279
4170
|
encodePremintForAPI,
|
|
4280
4171
|
generateTextNftMetadataFiles,
|
|
4281
4172
|
getApiNetworkConfigForChain,
|
|
4282
|
-
getContractAddressFromCreateReceipt,
|
|
4283
4173
|
getDataFromPremintReceipt,
|
|
4284
4174
|
getDefaultFixedPriceMinterAddress,
|
|
4285
4175
|
getMintsAccountBalanceWithPriceQuery,
|