@zoralabs/protocol-sdk 0.5.3-mints.0 → 0.5.4-MINT.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 -7
- package/CHANGELOG.md +11 -2
- package/dist/apis/chain-constants.d.ts +1 -0
- package/dist/apis/chain-constants.d.ts.map +1 -1
- package/dist/index.cjs +120 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +88 -9
- package/dist/index.js.map +1 -1
- package/dist/mints/mints-queries.d.ts +44 -0
- package/dist/mints/mints-queries.d.ts.map +1 -0
- package/dist/premint/contract-types.d.ts +1 -1
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +2 -2
- 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/preminter.d.ts +2 -2
- package/dist/preminter.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/apis/chain-constants.ts +10 -0
- package/src/create/1155-create-helper.ts +1 -1
- package/src/index.ts +2 -0
- package/src/mint/mint-client.test.ts +1 -1
- package/src/mint/mint-client.ts +1 -1
- package/src/mints/mints-queries.test.ts +78 -0
- package/src/mints/mints-queries.ts +121 -0
- package/src/premint/contract-types.ts +1 -1
- package/src/premint/premint-client.ts +6 -3
- package/src/premint/preminter.test.ts +1 -1
- package/src/premint/preminter.ts +1 -1
- package/src/preminter.ts +2 -2
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
warning package.json: "dependencies" has dependency "vite" with range "4.5.0" that collides with a dependency in "devDependencies" of the same name with version "^4.5.0"
|
|
2
1
|
$ tsup
|
|
3
2
|
[34mCLI[39m Building entry: src/index.ts
|
|
4
3
|
[34mCLI[39m Using tsconfig: tsconfig.build.json
|
|
@@ -8,9 +7,9 @@ $ tsup
|
|
|
8
7
|
[34mCLI[39m Cleaning output folder
|
|
9
8
|
[34mCJS[39m Build start
|
|
10
9
|
[34mESM[39m Build start
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
10
|
+
[32mESM[39m [1mdist/index.js [22m[32m48.29 KB[39m
|
|
11
|
+
[32mESM[39m [1mdist/index.js.map [22m[32m101.92 KB[39m
|
|
12
|
+
[32mESM[39m ⚡️ Build success in 118ms
|
|
13
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m52.47 KB[39m
|
|
14
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m101.90 KB[39m
|
|
15
|
+
[32mCJS[39m ⚡️ Build success in 119ms
|
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
# @zoralabs/protocol-sdk
|
|
2
2
|
|
|
3
|
-
## 0.5.
|
|
3
|
+
## 0.5.4-MINT.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- b07a4729: Added functionality to be able to query for MINTs to use when collecting from an account
|
|
8
|
+
- Updated dependencies [a4d2d3d2]
|
|
9
|
+
- Updated dependencies [3401be26]
|
|
10
|
+
- @zoralabs/protocol-deployments@0.1.1-MINT.0
|
|
11
|
+
|
|
12
|
+
## 0.5.3
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- a07499d: Allows an `Account` object to be passed for `signTypedData` compatiblity with Local Accounts
|
|
8
17
|
|
|
9
18
|
## 0.5.2
|
|
10
19
|
|
|
@@ -9,5 +9,6 @@ export type NetworkConfig = {
|
|
|
9
9
|
};
|
|
10
10
|
export declare const REWARD_PER_TOKEN: bigint;
|
|
11
11
|
export declare const networkConfigByChain: Record<number, NetworkConfig>;
|
|
12
|
+
export declare const getSubgraphUrl: (chainId: number) => string;
|
|
12
13
|
export {};
|
|
13
14
|
//# sourceMappingURL=chain-constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-constants.d.ts","sourceRoot":"","sources":["../../src/apis/chain-constants.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,KAAK,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB,EAAE,MAAM,CAAC;IACjC,oBAAoB,EAAE,gBAAgB,CAAC;IACvC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAyB,CAAC;AAEvD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAuE9D,CAAC"}
|
|
1
|
+
{"version":3,"file":"chain-constants.d.ts","sourceRoot":"","sources":["../../src/apis/chain-constants.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAIhE,KAAK,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,wBAAwB,EAAE,MAAM,CAAC;IACjC,oBAAoB,EAAE,gBAAgB,CAAC;IACvC,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAyB,CAAC;AAEvD,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAuE9D,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,MAQhD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,9 @@ __export(src_exports, {
|
|
|
41
41
|
encodePremintForAPI: () => encodePremintForAPI,
|
|
42
42
|
getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
|
|
43
43
|
getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
|
|
44
|
+
getMINTsToCollectWith: () => getMINTsToCollectWith,
|
|
44
45
|
getMintCosts: () => getMintCosts,
|
|
46
|
+
getMintsAccountBalanceQuery: () => getMintsAccountBalanceQuery,
|
|
45
47
|
getPremintCollectionAddress: () => getPremintCollectionAddress,
|
|
46
48
|
getPremintExecutorAddress: () => getPremintExecutorAddress,
|
|
47
49
|
getPremintMintCosts: () => getPremintMintCosts,
|
|
@@ -57,6 +59,7 @@ __export(src_exports, {
|
|
|
57
59
|
premintTypedDataDefinition: () => premintTypedDataDefinition,
|
|
58
60
|
recoverCreatorFromCreatorAttribution: () => recoverCreatorFromCreatorAttribution,
|
|
59
61
|
recoverPremintSigner: () => recoverPremintSigner,
|
|
62
|
+
selectMintsToCollectWithFromQueryResult: () => selectMintsToCollectWithFromQueryResult,
|
|
60
63
|
supportedPremintVersions: () => supportedPremintVersions,
|
|
61
64
|
supportsPremintVersion: () => supportsPremintVersion,
|
|
62
65
|
tryRecoverPremintSigner: () => tryRecoverPremintSigner,
|
|
@@ -67,10 +70,10 @@ module.exports = __toCommonJS(src_exports);
|
|
|
67
70
|
|
|
68
71
|
// src/premint/premint-client.ts
|
|
69
72
|
var import_viem4 = require("viem");
|
|
70
|
-
var
|
|
73
|
+
var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
|
|
71
74
|
|
|
72
75
|
// src/premint/preminter.ts
|
|
73
|
-
var
|
|
76
|
+
var import_protocol_deployments = require("@zoralabs/protocol-deployments");
|
|
74
77
|
var import_viem = require("viem");
|
|
75
78
|
|
|
76
79
|
// src/premint/contract-types.ts
|
|
@@ -130,7 +133,7 @@ var PremintConfigVersion = /* @__PURE__ */ ((PremintConfigVersion2) => {
|
|
|
130
133
|
})(PremintConfigVersion || {});
|
|
131
134
|
|
|
132
135
|
// src/premint/preminter.ts
|
|
133
|
-
var getPremintExecutorAddress = () =>
|
|
136
|
+
var getPremintExecutorAddress = () => import_protocol_deployments.zoraCreator1155PremintExecutorImplAddress[999];
|
|
134
137
|
var premintTypedDataDefinition = ({
|
|
135
138
|
verifyingContract,
|
|
136
139
|
chainId,
|
|
@@ -167,7 +170,7 @@ async function isAuthorizedToCreatePremint({
|
|
|
167
170
|
signer
|
|
168
171
|
}) {
|
|
169
172
|
return await publicClient.readContract({
|
|
170
|
-
abi:
|
|
173
|
+
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
171
174
|
address: getPremintExecutorAddress(),
|
|
172
175
|
functionName: "isAuthorizedToCreatePremint",
|
|
173
176
|
args: [signer, collection.contractAdmin, collectionAddress]
|
|
@@ -283,7 +286,7 @@ var supportedPremintVersions = async ({
|
|
|
283
286
|
publicClient
|
|
284
287
|
}) => {
|
|
285
288
|
return await publicClient.readContract({
|
|
286
|
-
abi:
|
|
289
|
+
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
287
290
|
address: getPremintExecutorAddress(),
|
|
288
291
|
functionName: "supportedPremintSignatureVersions",
|
|
289
292
|
args: [tokenContract]
|
|
@@ -302,7 +305,7 @@ async function getPremintCollectionAddress({
|
|
|
302
305
|
}) {
|
|
303
306
|
return publicClient.readContract({
|
|
304
307
|
address: getPremintExecutorAddress(),
|
|
305
|
-
abi:
|
|
308
|
+
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
306
309
|
functionName: "getContractAddress",
|
|
307
310
|
args: [collection]
|
|
308
311
|
});
|
|
@@ -350,7 +353,7 @@ async function getPremintMintFee({
|
|
|
350
353
|
try {
|
|
351
354
|
return await publicClient.readContract({
|
|
352
355
|
address: getPremintExecutorAddress(),
|
|
353
|
-
abi:
|
|
356
|
+
abi: import_protocol_deployments.zoraCreator1155PremintExecutorImplABI,
|
|
354
357
|
functionName: "mintFee",
|
|
355
358
|
args: [tokenContract]
|
|
356
359
|
});
|
|
@@ -379,7 +382,7 @@ function makeMintRewardsRecipient({
|
|
|
379
382
|
return [mintReferral, platformReferral];
|
|
380
383
|
}
|
|
381
384
|
function getDefaultFixedPriceMinterAddress(chainId) {
|
|
382
|
-
return
|
|
385
|
+
return import_protocol_deployments.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
383
386
|
}
|
|
384
387
|
|
|
385
388
|
// src/apis/http-api-base.ts
|
|
@@ -545,6 +548,13 @@ var networkConfigByChain = {
|
|
|
545
548
|
subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable")
|
|
546
549
|
}
|
|
547
550
|
};
|
|
551
|
+
var getSubgraphUrl = (chainId) => {
|
|
552
|
+
const networkConfig = networkConfigByChain[chainId];
|
|
553
|
+
if (!networkConfig) {
|
|
554
|
+
throw new Error(`Network not configured for chain id ${chainId}`);
|
|
555
|
+
}
|
|
556
|
+
return networkConfig.subgraphUrl;
|
|
557
|
+
};
|
|
548
558
|
|
|
549
559
|
// src/mint/mint-api-client.ts
|
|
550
560
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
@@ -851,7 +861,7 @@ function getPremintedLogFromReceipt(receipt) {
|
|
|
851
861
|
for (const data of receipt.logs) {
|
|
852
862
|
try {
|
|
853
863
|
const decodedLog = (0, import_viem4.decodeEventLog)({
|
|
854
|
-
abi:
|
|
864
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
855
865
|
eventName: "PremintedV2",
|
|
856
866
|
...data
|
|
857
867
|
});
|
|
@@ -1029,7 +1039,7 @@ var PremintClient = class {
|
|
|
1029
1039
|
tokenConfig: makeTokenConfigWithDefaults({
|
|
1030
1040
|
premintConfigVersion: actualVersion,
|
|
1031
1041
|
tokenCreationConfig,
|
|
1032
|
-
creatorAccount,
|
|
1042
|
+
creatorAccount: typeof creatorAccount === "string" ? creatorAccount : creatorAccount.address,
|
|
1033
1043
|
chainId: this.chain.id
|
|
1034
1044
|
}),
|
|
1035
1045
|
uid: uidToUse
|
|
@@ -1163,7 +1173,7 @@ var PremintClient = class {
|
|
|
1163
1173
|
if (premintConfigVersion === "1" /* V1 */) {
|
|
1164
1174
|
return {
|
|
1165
1175
|
account: minterAccount,
|
|
1166
|
-
abi:
|
|
1176
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
1167
1177
|
functionName: "premintV1",
|
|
1168
1178
|
value,
|
|
1169
1179
|
address: getPremintExecutorAddress(),
|
|
@@ -1178,7 +1188,7 @@ var PremintClient = class {
|
|
|
1178
1188
|
} else if (premintConfigVersion === "2" /* V2 */) {
|
|
1179
1189
|
return {
|
|
1180
1190
|
account: minterAccount,
|
|
1181
|
-
abi:
|
|
1191
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
1182
1192
|
functionName: "premintV2",
|
|
1183
1193
|
value,
|
|
1184
1194
|
address: getPremintExecutorAddress(),
|
|
@@ -1267,7 +1277,7 @@ async function signAndSubmitPremint({
|
|
|
1267
1277
|
|
|
1268
1278
|
// src/mint/mint-client.ts
|
|
1269
1279
|
var import_viem5 = require("viem");
|
|
1270
|
-
var
|
|
1280
|
+
var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
|
|
1271
1281
|
var MintError = class extends Error {
|
|
1272
1282
|
};
|
|
1273
1283
|
var MintInactiveError = class extends Error {
|
|
@@ -1380,14 +1390,14 @@ async function makePrepareMint1155TokenParams({
|
|
|
1380
1390
|
quantityToMint: mintQuantity
|
|
1381
1391
|
}).totalCost;
|
|
1382
1392
|
const result = {
|
|
1383
|
-
abi:
|
|
1393
|
+
abi: import_protocol_deployments3.zoraCreator1155ImplABI,
|
|
1384
1394
|
functionName: "mintWithRewards",
|
|
1385
1395
|
account: minterAccount,
|
|
1386
1396
|
value: mintValue,
|
|
1387
1397
|
address: tokenAddress,
|
|
1388
1398
|
/* args: minter, tokenId, quantity, minterArguments, mintReferral */
|
|
1389
1399
|
args: [
|
|
1390
|
-
salesConfigAndTokenInfo?.fixedPrice.address ||
|
|
1400
|
+
salesConfigAndTokenInfo?.fixedPrice.address || import_protocol_deployments3.zoraCreatorFixedPriceSaleStrategyAddress[999],
|
|
1391
1401
|
BigInt(tokenId),
|
|
1392
1402
|
mintQuantity,
|
|
1393
1403
|
(0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
|
|
@@ -1401,7 +1411,7 @@ async function makePrepareMint1155TokenParams({
|
|
|
1401
1411
|
}
|
|
1402
1412
|
|
|
1403
1413
|
// src/create/1155-create-helper.ts
|
|
1404
|
-
var
|
|
1414
|
+
var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
|
|
1405
1415
|
var import_viem6 = require("viem");
|
|
1406
1416
|
var SALE_END_FOREVER = 18446744073709551615n;
|
|
1407
1417
|
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
@@ -1446,32 +1456,32 @@ function create1155TokenSetupArgs({
|
|
|
1446
1456
|
};
|
|
1447
1457
|
const setupActions = [
|
|
1448
1458
|
(0, import_viem6.encodeFunctionData)({
|
|
1449
|
-
abi:
|
|
1459
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1450
1460
|
functionName: "assumeLastTokenIdMatches",
|
|
1451
1461
|
args: [nextTokenId - 1n]
|
|
1452
1462
|
}),
|
|
1453
1463
|
createReferral ? (0, import_viem6.encodeFunctionData)({
|
|
1454
|
-
abi:
|
|
1464
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1455
1465
|
functionName: "setupNewTokenWithCreateReferral",
|
|
1456
1466
|
args: [tokenMetadataURI, maxSupply, createReferral]
|
|
1457
1467
|
}) : (0, import_viem6.encodeFunctionData)({
|
|
1458
|
-
abi:
|
|
1468
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1459
1469
|
functionName: "setupNewToken",
|
|
1460
1470
|
args: [tokenMetadataURI, maxSupply]
|
|
1461
1471
|
}),
|
|
1462
1472
|
(0, import_viem6.encodeFunctionData)({
|
|
1463
|
-
abi:
|
|
1473
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1464
1474
|
functionName: "addPermission",
|
|
1465
1475
|
args: [0n, fixedPriceMinterAddress, PERMISSION_BIT_MINTER]
|
|
1466
1476
|
}),
|
|
1467
1477
|
(0, import_viem6.encodeFunctionData)({
|
|
1468
|
-
abi:
|
|
1478
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1469
1479
|
functionName: "callSale",
|
|
1470
1480
|
args: [
|
|
1471
1481
|
nextTokenId,
|
|
1472
1482
|
fixedPriceMinterAddress,
|
|
1473
1483
|
(0, import_viem6.encodeFunctionData)({
|
|
1474
|
-
abi:
|
|
1484
|
+
abi: import_protocol_deployments4.zoraCreatorFixedPriceSaleStrategyABI,
|
|
1475
1485
|
functionName: "setSale",
|
|
1476
1486
|
args: [nextTokenId, salesConfigWithDefaults]
|
|
1477
1487
|
})
|
|
@@ -1481,7 +1491,7 @@ function create1155TokenSetupArgs({
|
|
|
1481
1491
|
if (mintToCreatorCount) {
|
|
1482
1492
|
setupActions.push(
|
|
1483
1493
|
(0, import_viem6.encodeFunctionData)({
|
|
1484
|
-
abi:
|
|
1494
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1485
1495
|
functionName: "adminMint",
|
|
1486
1496
|
args: [account, nextTokenId, mintToCreatorCount, "0x"]
|
|
1487
1497
|
})
|
|
@@ -1490,7 +1500,7 @@ function create1155TokenSetupArgs({
|
|
|
1490
1500
|
if (royaltySettings) {
|
|
1491
1501
|
setupActions.push(
|
|
1492
1502
|
(0, import_viem6.encodeFunctionData)({
|
|
1493
|
-
abi:
|
|
1503
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1494
1504
|
functionName: "updateRoyaltiesForToken",
|
|
1495
1505
|
args: [
|
|
1496
1506
|
nextTokenId,
|
|
@@ -1509,7 +1519,7 @@ var getTokenIdFromCreateReceipt = (receipt) => {
|
|
|
1509
1519
|
for (const data of receipt.logs) {
|
|
1510
1520
|
try {
|
|
1511
1521
|
const decodedLog = (0, import_viem6.decodeEventLog)({
|
|
1512
|
-
abi:
|
|
1522
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1513
1523
|
eventName: "SetupNewToken",
|
|
1514
1524
|
...data
|
|
1515
1525
|
});
|
|
@@ -1525,9 +1535,9 @@ async function getContractExists(publicClient, contract, account) {
|
|
|
1525
1535
|
let contractExists = false;
|
|
1526
1536
|
if (typeof contract !== "string") {
|
|
1527
1537
|
contractAddress = await publicClient.readContract({
|
|
1528
|
-
abi:
|
|
1538
|
+
abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
|
|
1529
1539
|
// Since this address is deterministic we can hardcode a chain id safely here.
|
|
1530
|
-
address:
|
|
1540
|
+
address: import_protocol_deployments4.zoraCreator1155FactoryImplAddress[999],
|
|
1531
1541
|
functionName: "deterministicContractAddress",
|
|
1532
1542
|
args: [
|
|
1533
1543
|
account,
|
|
@@ -1538,7 +1548,7 @@ async function getContractExists(publicClient, contract, account) {
|
|
|
1538
1548
|
});
|
|
1539
1549
|
try {
|
|
1540
1550
|
await publicClient.readContract({
|
|
1541
|
-
abi:
|
|
1551
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1542
1552
|
address: contractAddress,
|
|
1543
1553
|
functionName: "contractVersion"
|
|
1544
1554
|
});
|
|
@@ -1573,14 +1583,14 @@ function create1155CreatorClient({
|
|
|
1573
1583
|
let nextTokenId = 1n;
|
|
1574
1584
|
if (contractExists) {
|
|
1575
1585
|
nextTokenId = await publicClient.readContract({
|
|
1576
|
-
abi:
|
|
1586
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1577
1587
|
functionName: "nextTokenId",
|
|
1578
1588
|
address: contractAddress
|
|
1579
1589
|
});
|
|
1580
1590
|
}
|
|
1581
1591
|
const fixedPriceMinterAddress = await publicClient.readContract({
|
|
1582
|
-
abi:
|
|
1583
|
-
address:
|
|
1592
|
+
abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
|
|
1593
|
+
address: import_protocol_deployments4.zoraCreator1155FactoryImplAddress[999],
|
|
1584
1594
|
functionName: "fixedPriceMinter"
|
|
1585
1595
|
});
|
|
1586
1596
|
let tokenSetupActions = create1155TokenSetupArgs({
|
|
@@ -1603,11 +1613,11 @@ function create1155CreatorClient({
|
|
|
1603
1613
|
throw new Error("Invariant: contract cannot be missing and an address");
|
|
1604
1614
|
}
|
|
1605
1615
|
if (!contractExists && typeof contract !== "string") {
|
|
1606
|
-
const
|
|
1607
|
-
abi:
|
|
1616
|
+
const request2 = {
|
|
1617
|
+
abi: import_protocol_deployments4.zoraCreator1155FactoryImplABI,
|
|
1608
1618
|
functionName: "createContractDeterministic",
|
|
1609
1619
|
account,
|
|
1610
|
-
address:
|
|
1620
|
+
address: import_protocol_deployments4.zoraCreator1155FactoryImplAddress[999],
|
|
1611
1621
|
args: [
|
|
1612
1622
|
contract.uri,
|
|
1613
1623
|
contract.name,
|
|
@@ -1622,21 +1632,21 @@ function create1155CreatorClient({
|
|
|
1622
1632
|
]
|
|
1623
1633
|
};
|
|
1624
1634
|
return {
|
|
1625
|
-
request,
|
|
1635
|
+
request: request2,
|
|
1626
1636
|
tokenSetupActions,
|
|
1627
1637
|
contractAddress,
|
|
1628
1638
|
contractExists
|
|
1629
1639
|
};
|
|
1630
1640
|
} else if (contractExists) {
|
|
1631
|
-
const
|
|
1632
|
-
abi:
|
|
1641
|
+
const request2 = {
|
|
1642
|
+
abi: import_protocol_deployments4.zoraCreator1155ImplABI,
|
|
1633
1643
|
functionName: "multicall",
|
|
1634
1644
|
account,
|
|
1635
1645
|
address: contractAddress,
|
|
1636
1646
|
args: [tokenSetupActions]
|
|
1637
1647
|
};
|
|
1638
1648
|
return {
|
|
1639
|
-
request,
|
|
1649
|
+
request: request2,
|
|
1640
1650
|
tokenSetupActions,
|
|
1641
1651
|
contractAddress,
|
|
1642
1652
|
contractExists
|
|
@@ -1646,6 +1656,75 @@ function create1155CreatorClient({
|
|
|
1646
1656
|
}
|
|
1647
1657
|
return { createNew1155Token };
|
|
1648
1658
|
}
|
|
1659
|
+
|
|
1660
|
+
// src/mints/mints-queries.ts
|
|
1661
|
+
var import_graphql_request = require("graphql-request");
|
|
1662
|
+
var getMintsAccountBalanceQuery = (account) => {
|
|
1663
|
+
const query = import_graphql_request.gql`
|
|
1664
|
+
query GetMintAccountBalances($account: String!) {
|
|
1665
|
+
mintTokenBalances(where: { account: $account }) {
|
|
1666
|
+
balance
|
|
1667
|
+
mintToken {
|
|
1668
|
+
id
|
|
1669
|
+
pricePerToken
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
`;
|
|
1674
|
+
return {
|
|
1675
|
+
query,
|
|
1676
|
+
variables: { account }
|
|
1677
|
+
};
|
|
1678
|
+
};
|
|
1679
|
+
var selectMintsToCollectWithFromQueryResult = (mintAccountBalances, quantityToCollect) => {
|
|
1680
|
+
const parsed = mintAccountBalances.map((r) => {
|
|
1681
|
+
return {
|
|
1682
|
+
tokenId: BigInt(r.mintToken.id),
|
|
1683
|
+
quantity: BigInt(r.balance),
|
|
1684
|
+
pricePerToken: BigInt(r.mintToken.pricePerToken)
|
|
1685
|
+
};
|
|
1686
|
+
});
|
|
1687
|
+
const sorted = parsed.sort((a, b) => {
|
|
1688
|
+
if (a.pricePerToken < b.pricePerToken) {
|
|
1689
|
+
return -1;
|
|
1690
|
+
}
|
|
1691
|
+
return 1;
|
|
1692
|
+
});
|
|
1693
|
+
let remainingQuantity = quantityToCollect;
|
|
1694
|
+
const tokenIds = [];
|
|
1695
|
+
const quantities = [];
|
|
1696
|
+
while (remainingQuantity > 0) {
|
|
1697
|
+
const next = sorted.shift();
|
|
1698
|
+
if (!next) {
|
|
1699
|
+
throw new Error("Not enough MINTs to collect with");
|
|
1700
|
+
}
|
|
1701
|
+
const quantityToUse = remainingQuantity > next.quantity ? next.quantity : remainingQuantity;
|
|
1702
|
+
tokenIds.push(next.tokenId);
|
|
1703
|
+
quantities.push(quantityToUse);
|
|
1704
|
+
remainingQuantity -= quantityToUse;
|
|
1705
|
+
}
|
|
1706
|
+
return {
|
|
1707
|
+
tokenIds,
|
|
1708
|
+
quantities
|
|
1709
|
+
};
|
|
1710
|
+
};
|
|
1711
|
+
var getMINTsToCollectWith = async ({
|
|
1712
|
+
account,
|
|
1713
|
+
chainId,
|
|
1714
|
+
quantityToCollect
|
|
1715
|
+
}) => {
|
|
1716
|
+
const subgraphUrl = getSubgraphUrl(chainId);
|
|
1717
|
+
const { query, variables } = getMintsAccountBalanceQuery(account);
|
|
1718
|
+
const result = await (0, import_graphql_request.request)(
|
|
1719
|
+
subgraphUrl,
|
|
1720
|
+
query,
|
|
1721
|
+
variables
|
|
1722
|
+
);
|
|
1723
|
+
return selectMintsToCollectWithFromQueryResult(
|
|
1724
|
+
result.mintTokenBalances,
|
|
1725
|
+
quantityToCollect
|
|
1726
|
+
);
|
|
1727
|
+
};
|
|
1649
1728
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1650
1729
|
0 && (module.exports = {
|
|
1651
1730
|
DEFAULT_SALE_SETTINGS,
|
|
@@ -1669,7 +1748,9 @@ function create1155CreatorClient({
|
|
|
1669
1748
|
encodePremintForAPI,
|
|
1670
1749
|
getApiNetworkConfigForChain,
|
|
1671
1750
|
getDefaultFixedPriceMinterAddress,
|
|
1751
|
+
getMINTsToCollectWith,
|
|
1672
1752
|
getMintCosts,
|
|
1753
|
+
getMintsAccountBalanceQuery,
|
|
1673
1754
|
getPremintCollectionAddress,
|
|
1674
1755
|
getPremintExecutorAddress,
|
|
1675
1756
|
getPremintMintCosts,
|
|
@@ -1685,6 +1766,7 @@ function create1155CreatorClient({
|
|
|
1685
1766
|
premintTypedDataDefinition,
|
|
1686
1767
|
recoverCreatorFromCreatorAttribution,
|
|
1687
1768
|
recoverPremintSigner,
|
|
1769
|
+
selectMintsToCollectWithFromQueryResult,
|
|
1688
1770
|
supportedPremintVersions,
|
|
1689
1771
|
supportsPremintVersion,
|
|
1690
1772
|
tryRecoverPremintSigner,
|