@zoralabs/protocol-sdk 0.7.1 → 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 +6 -6
- package/CHANGELOG.md +6 -0
- package/dist/constants.d.ts +27 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.cjs +88 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +88 -18
- package/dist/index.js.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 +1 -0
- package/dist/mint/subgraph-queries.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 -1
- package/src/constants.ts +36 -0
- package/src/mint/mint-transactions.ts +2 -2
- package/src/mint/subgraph-mint-getter.ts +38 -5
- package/src/mint/subgraph-queries.ts +19 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -7,9 +7,9 @@ $ tsup
|
|
|
7
7
|
[34mCLI[39m Cleaning output folder
|
|
8
8
|
[34mCJS[39m Build start
|
|
9
9
|
[34mESM[39m Build start
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m111.58 KB[39m
|
|
11
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m249.54 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 180ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m118.42 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m249.74 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 226ms
|
package/CHANGELOG.md
CHANGED
package/dist/constants.d.ts
CHANGED
|
@@ -33,4 +33,31 @@ export declare const zora721Abi: readonly [{
|
|
|
33
33
|
readonly type: "uint256";
|
|
34
34
|
}];
|
|
35
35
|
}];
|
|
36
|
+
export declare const zora1155LegacyAbi: readonly [{
|
|
37
|
+
readonly type: "function";
|
|
38
|
+
readonly name: "mintWithRewards";
|
|
39
|
+
readonly inputs: readonly [{
|
|
40
|
+
readonly name: "minter";
|
|
41
|
+
readonly type: "address";
|
|
42
|
+
readonly internalType: "contract IMinter1155";
|
|
43
|
+
}, {
|
|
44
|
+
readonly name: "tokenId";
|
|
45
|
+
readonly type: "uint256";
|
|
46
|
+
readonly internalType: "uint256";
|
|
47
|
+
}, {
|
|
48
|
+
readonly name: "quantity";
|
|
49
|
+
readonly type: "uint256";
|
|
50
|
+
readonly internalType: "uint256";
|
|
51
|
+
}, {
|
|
52
|
+
readonly name: "minterArguments";
|
|
53
|
+
readonly type: "bytes";
|
|
54
|
+
readonly internalType: "bytes";
|
|
55
|
+
}, {
|
|
56
|
+
readonly name: "mintReferral";
|
|
57
|
+
readonly type: "address";
|
|
58
|
+
readonly internalType: "address";
|
|
59
|
+
}];
|
|
60
|
+
readonly outputs: readonly [];
|
|
61
|
+
readonly stateMutability: "payable";
|
|
62
|
+
}];
|
|
36
63
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,yBAAyB,CAAC;AACpD,eAAO,MAAM,sBAAsB,QAAiC,CAAC;AAMrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGZ,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,yBAAyB,CAAC;AACpD,eAAO,MAAM,sBAAsB,QAAiC,CAAC;AAMrE,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGZ,CAAC;AAEZ,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCpB,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -125,6 +125,41 @@ var zora721Abi = (0, import_viem.parseAbi)([
|
|
|
125
125
|
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
126
126
|
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
127
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
|
+
];
|
|
128
163
|
|
|
129
164
|
// src/apis/chain-constants.ts
|
|
130
165
|
var REWARD_PER_TOKEN = (0, import_viem2.parseEther)("0.000777");
|
|
@@ -793,6 +828,19 @@ query ($id: ID!) {
|
|
|
793
828
|
parseResponseData: (responseData) => responseData?.zoraCreateToken
|
|
794
829
|
};
|
|
795
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
|
+
}
|
|
796
844
|
function buildContractTokensQuery({
|
|
797
845
|
tokenAddress
|
|
798
846
|
}) {
|
|
@@ -833,6 +881,7 @@ function buildPremintsOfContractQuery({
|
|
|
833
881
|
}
|
|
834
882
|
|
|
835
883
|
// src/mint/subgraph-mint-getter.ts
|
|
884
|
+
var semver = __toESM(require("semver"), 1);
|
|
836
885
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
837
886
|
if (!networkConfigByChain[chainId]) {
|
|
838
887
|
throw new Error(`chain id ${chainId} network not configured `);
|
|
@@ -913,8 +962,10 @@ var SubgraphMintGetter = class {
|
|
|
913
962
|
if (!token) {
|
|
914
963
|
throw new Error("Cannot find token");
|
|
915
964
|
}
|
|
965
|
+
const defaultMintFee = await this.getContractMintFee(token.contract);
|
|
916
966
|
return parseTokenQueryResult({
|
|
917
967
|
token,
|
|
968
|
+
defaultMintFee,
|
|
918
969
|
tokenId,
|
|
919
970
|
preferredSaleType: saleType
|
|
920
971
|
});
|
|
@@ -922,6 +973,16 @@ var SubgraphMintGetter = class {
|
|
|
922
973
|
this.httpClient = httpClient2 || httpClient;
|
|
923
974
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
924
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
|
+
}
|
|
925
986
|
async querySubgraphWithRetries({
|
|
926
987
|
query,
|
|
927
988
|
variables,
|
|
@@ -944,13 +1005,15 @@ var SubgraphMintGetter = class {
|
|
|
944
1005
|
tokenAddress
|
|
945
1006
|
})
|
|
946
1007
|
);
|
|
947
|
-
if (!tokens)
|
|
1008
|
+
if (!tokens || tokens.length === 0)
|
|
948
1009
|
return [];
|
|
1010
|
+
const defaultMintFee = await this.getContractMintFee(tokens[0].contract);
|
|
949
1011
|
return tokens.filter((x) => x.tokenId !== "0").map(
|
|
950
1012
|
(token) => parseTokenQueryResult({
|
|
951
1013
|
token,
|
|
952
1014
|
tokenId: token.tokenId,
|
|
953
|
-
preferredSaleType
|
|
1015
|
+
preferredSaleType,
|
|
1016
|
+
defaultMintFee
|
|
954
1017
|
})
|
|
955
1018
|
);
|
|
956
1019
|
}
|
|
@@ -971,14 +1034,15 @@ var SubgraphMintGetter = class {
|
|
|
971
1034
|
function parseTokenQueryResult({
|
|
972
1035
|
token,
|
|
973
1036
|
tokenId,
|
|
974
|
-
preferredSaleType
|
|
1037
|
+
preferredSaleType,
|
|
1038
|
+
defaultMintFee
|
|
975
1039
|
}) {
|
|
976
1040
|
const targetStrategy = getTargetStrategy({
|
|
977
1041
|
tokenId,
|
|
978
1042
|
preferredSaleType,
|
|
979
1043
|
token
|
|
980
1044
|
});
|
|
981
|
-
const tokenInfo = parseTokenInfo(token);
|
|
1045
|
+
const tokenInfo = parseTokenInfo(token, defaultMintFee);
|
|
982
1046
|
const salesConfig = parseSalesConfig(targetStrategy);
|
|
983
1047
|
if (isErc20SaleStrategy(salesConfig)) {
|
|
984
1048
|
tokenInfo.mintFeePerQuantity = 0n;
|
|
@@ -988,7 +1052,13 @@ function parseTokenQueryResult({
|
|
|
988
1052
|
salesConfig
|
|
989
1053
|
};
|
|
990
1054
|
}
|
|
991
|
-
|
|
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) {
|
|
992
1062
|
return {
|
|
993
1063
|
contract: {
|
|
994
1064
|
address: token.contract.address,
|
|
@@ -1001,7 +1071,7 @@ function parseTokenInfo(token) {
|
|
|
1001
1071
|
creator: token.creator,
|
|
1002
1072
|
totalMinted: BigInt(token.totalMinted),
|
|
1003
1073
|
maxSupply: BigInt(token.maxSupply),
|
|
1004
|
-
mintFeePerQuantity:
|
|
1074
|
+
mintFeePerQuantity: defaultMintFee,
|
|
1005
1075
|
contractVersion: token.contract.contractVersion
|
|
1006
1076
|
};
|
|
1007
1077
|
}
|
|
@@ -1656,15 +1726,15 @@ var import_viem5 = require("viem");
|
|
|
1656
1726
|
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1657
1727
|
|
|
1658
1728
|
// src/mint/utils.ts
|
|
1659
|
-
var
|
|
1729
|
+
var semver2 = __toESM(require("semver"), 1);
|
|
1660
1730
|
var contractSupportsNewMintFunction = (contractVersion) => {
|
|
1661
1731
|
if (!contractVersion) {
|
|
1662
1732
|
return false;
|
|
1663
1733
|
}
|
|
1664
|
-
const semVerContractVersion =
|
|
1734
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
1665
1735
|
if (!semVerContractVersion)
|
|
1666
1736
|
return false;
|
|
1667
|
-
return
|
|
1737
|
+
return semver2.gte(semVerContractVersion, "2.9.0");
|
|
1668
1738
|
};
|
|
1669
1739
|
|
|
1670
1740
|
// src/mint/mint-transactions.ts
|
|
@@ -1797,7 +1867,7 @@ function makeEthMintCall({
|
|
|
1797
1867
|
});
|
|
1798
1868
|
}
|
|
1799
1869
|
return makeContractParameters({
|
|
1800
|
-
abi:
|
|
1870
|
+
abi: zora1155LegacyAbi,
|
|
1801
1871
|
functionName: "mintWithRewards",
|
|
1802
1872
|
account: minterAccount,
|
|
1803
1873
|
value: mintValue,
|
|
@@ -2213,7 +2283,7 @@ async function getContractInfo({
|
|
|
2213
2283
|
// src/create/token-setup.ts
|
|
2214
2284
|
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
2215
2285
|
var import_viem7 = require("viem");
|
|
2216
|
-
var
|
|
2286
|
+
var semver3 = __toESM(require("semver"), 1);
|
|
2217
2287
|
var PERMISSION_BITS = {
|
|
2218
2288
|
MINTER: 2n ** 2n
|
|
2219
2289
|
};
|
|
@@ -2464,13 +2534,13 @@ var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
|
2464
2534
|
if (!contractStandard || !contractVersion) {
|
|
2465
2535
|
return false;
|
|
2466
2536
|
}
|
|
2467
|
-
const semVerContractVersion =
|
|
2537
|
+
const semVerContractVersion = semver3.coerce(contractVersion)?.raw;
|
|
2468
2538
|
if (!semVerContractVersion)
|
|
2469
2539
|
return false;
|
|
2470
2540
|
if (contractStandard === "ERC1155") {
|
|
2471
|
-
return
|
|
2541
|
+
return semver3.gte(semVerContractVersion, "1.3.5");
|
|
2472
2542
|
} else {
|
|
2473
|
-
return
|
|
2543
|
+
return semver3.gte(semVerContractVersion, "14.0.0");
|
|
2474
2544
|
}
|
|
2475
2545
|
};
|
|
2476
2546
|
|
|
@@ -3056,7 +3126,7 @@ var equals = (aa, bb) => {
|
|
|
3056
3126
|
}
|
|
3057
3127
|
return true;
|
|
3058
3128
|
};
|
|
3059
|
-
var
|
|
3129
|
+
var coerce4 = (o) => {
|
|
3060
3130
|
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
3061
3131
|
return o;
|
|
3062
3132
|
if (o instanceof ArrayBuffer)
|
|
@@ -3079,7 +3149,7 @@ var create = (code, digest) => {
|
|
|
3079
3149
|
return new Digest(code, size, digest, bytes);
|
|
3080
3150
|
};
|
|
3081
3151
|
var decode3 = (multihash) => {
|
|
3082
|
-
const bytes =
|
|
3152
|
+
const bytes = coerce4(multihash);
|
|
3083
3153
|
const [code, sizeOffset] = decode2(bytes);
|
|
3084
3154
|
const [size, digestOffset] = decode2(bytes.subarray(sizeOffset));
|
|
3085
3155
|
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
@@ -3323,7 +3393,7 @@ var baseX = ({ prefix, name, alphabet }) => {
|
|
|
3323
3393
|
prefix,
|
|
3324
3394
|
name,
|
|
3325
3395
|
encode: encode3,
|
|
3326
|
-
decode: (text) =>
|
|
3396
|
+
decode: (text) => coerce4(decode5(text))
|
|
3327
3397
|
});
|
|
3328
3398
|
};
|
|
3329
3399
|
var decode4 = (string, alphabet, bitsPerChar, name) => {
|
|
@@ -3610,7 +3680,7 @@ var CID = class _CID {
|
|
|
3610
3680
|
static decodeFirst(bytes) {
|
|
3611
3681
|
const specs = _CID.inspectBytes(bytes);
|
|
3612
3682
|
const prefixSize = specs.size - specs.multihashSize;
|
|
3613
|
-
const multihashBytes =
|
|
3683
|
+
const multihashBytes = coerce4(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
3614
3684
|
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
3615
3685
|
throw new Error("Incorrect length");
|
|
3616
3686
|
}
|