@zoralabs/protocol-sdk 0.5.17 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +6 -6
- package/CHANGELOG.md +19 -0
- package/README.md +1 -416
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +16 -55
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-setup.d.ts +14 -0
- package/dist/create/contract-setup.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +27 -0
- package/dist/create/token-setup.d.ts.map +1 -0
- package/dist/create/types.d.ts +45 -0
- package/dist/create/types.d.ts.map +1 -0
- package/dist/index.cjs +1745 -891
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1698 -858
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +48 -51
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/mint-queries.d.ts +38 -0
- package/dist/mint/mint-queries.d.ts.map +1 -0
- package/dist/mint/mint-transactions.d.ts +20 -0
- package/dist/mint/mint-transactions.d.ts.map +1 -0
- package/dist/mint/subgraph-mint-getter.d.ts +24 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- package/dist/mint/subgraph-queries.d.ts +55 -0
- package/dist/mint/subgraph-queries.d.ts.map +1 -0
- package/dist/mint/types.d.ts +177 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mint/utils.d.ts +2 -0
- package/dist/mint/utils.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +27 -4518
- package/dist/mints/mints-contracts.d.ts.map +1 -1
- package/dist/premint/contract-types.d.ts +4 -4
- package/dist/premint/contract-types.d.ts.map +1 -1
- package/dist/premint/conversions.d.ts +15 -16
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +32 -16
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +76 -50
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +20 -8
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +45 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +24 -6869
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/constants.ts +0 -36
- package/src/create/1155-create-helper.test.ts +236 -55
- package/src/create/1155-create-helper.ts +141 -309
- package/src/create/contract-setup.ts +88 -0
- package/src/create/token-setup.ts +379 -0
- package/src/create/types.ts +57 -0
- package/src/index.ts +5 -1
- package/src/mint/mint-client.test.ts +116 -78
- package/src/mint/mint-client.ts +130 -234
- package/src/mint/mint-queries.ts +320 -0
- package/src/mint/mint-transactions.ts +253 -0
- package/src/mint/subgraph-mint-getter.ts +247 -0
- package/src/mint/subgraph-queries.ts +170 -0
- package/src/mint/types.ts +239 -0
- package/src/mint/utils.ts +14 -0
- package/src/mints/mints-contracts.test.ts +1 -1
- package/src/mints/mints-contracts.ts +4 -4
- package/src/premint/contract-types.ts +4 -4
- package/src/premint/conversions.ts +38 -4
- package/src/premint/premint-api-client.ts +92 -48
- package/src/premint/premint-client.test.ts +100 -84
- package/src/premint/premint-client.ts +186 -185
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -14
- package/src/sdk.ts +101 -0
- package/src/types.ts +18 -0
- package/src/utils.ts +54 -46
- package/test-integration/setup-test-contracts.ts +96 -0
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
- package/src/mint/mint-api-client.ts +0 -177
- package/test-integration/premint-client.test.ts +0 -148
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,27 +17,39 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var src_exports = {};
|
|
22
32
|
__export(src_exports, {
|
|
23
|
-
|
|
33
|
+
Create1155Client: () => Create1155Client,
|
|
24
34
|
Errors: () => Errors,
|
|
25
|
-
|
|
35
|
+
MintClient: () => MintClient,
|
|
26
36
|
PremintAPIClient: () => PremintAPIClient,
|
|
37
|
+
PremintClient: () => PremintClient,
|
|
27
38
|
PremintConfigVersion: () => PremintConfigVersion3,
|
|
39
|
+
SubgraphMintGetter: () => SubgraphMintGetter,
|
|
28
40
|
ZORA_API_BASE: () => ZORA_API_BASE,
|
|
29
41
|
applyUpdateToPremint: () => applyUpdateToPremint,
|
|
42
|
+
buildPremintMintCall: () => buildPremintMintCall,
|
|
43
|
+
collectOnchain: () => collectOnchain,
|
|
44
|
+
collectPremint: () => collectPremint,
|
|
30
45
|
collectPremintV2WithMintsParams: () => collectPremintV2WithMintsParams,
|
|
31
46
|
collectWithMintsParams: () => collectWithMintsParams,
|
|
32
47
|
convertCollectionFromApi: () => convertCollectionFromApi,
|
|
33
48
|
convertGetPremintApiResponse: () => convertGetPremintApiResponse,
|
|
49
|
+
convertGetPremintOfCollectionApiResponse: () => convertGetPremintOfCollectionApiResponse,
|
|
34
50
|
convertPremintFromApi: () => convertPremintFromApi,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
createMintClient: () => createMintClient,
|
|
38
|
-
createPremintClient: () => createPremintClient,
|
|
51
|
+
createCollectorClient: () => createCollectorClient,
|
|
52
|
+
createCreatorClient: () => createCreatorClient,
|
|
39
53
|
decodeCallFailedError: () => decodeCallFailedError,
|
|
40
54
|
defaultAdditionalAdmins: () => defaultAdditionalAdmins,
|
|
41
55
|
defaultTokenConfigV1MintArguments: () => defaultTokenConfigV1MintArguments,
|
|
@@ -45,17 +59,22 @@ __export(src_exports, {
|
|
|
45
59
|
encodePostSignatureInput: () => encodePostSignatureInput,
|
|
46
60
|
encodePremintForAPI: () => encodePremintForAPI,
|
|
47
61
|
getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
|
|
62
|
+
getDataFromPremintReceipt: () => getDataFromPremintReceipt,
|
|
48
63
|
getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
|
|
49
|
-
getMintCosts: () => getMintCosts,
|
|
50
64
|
getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
|
|
51
65
|
getMintsEthPrice: () => getMintsEthPrice,
|
|
52
66
|
getPremintCollectionAddress: () => getPremintCollectionAddress,
|
|
53
67
|
getPremintExecutorAddress: () => getPremintExecutorAddress,
|
|
54
68
|
getPremintMintCosts: () => getPremintMintCosts,
|
|
69
|
+
getPremintMintCostsWithUnknownTokenPrice: () => getPremintMintCostsWithUnknownTokenPrice,
|
|
55
70
|
getPremintMintFee: () => getPremintMintFee,
|
|
71
|
+
getPremintPricePerToken: () => getPremintPricePerToken,
|
|
56
72
|
getPremintedLogFromReceipt: () => getPremintedLogFromReceipt,
|
|
73
|
+
getSignature: () => getSignature,
|
|
57
74
|
getTokenIdFromCreateReceipt: () => getTokenIdFromCreateReceipt,
|
|
58
75
|
isAuthorizedToCreatePremint: () => isAuthorizedToCreatePremint,
|
|
76
|
+
isPremintConfigV1: () => isPremintConfigV1,
|
|
77
|
+
isPremintConfigV2: () => isPremintConfigV2,
|
|
59
78
|
isValidSignature: () => isValidSignature,
|
|
60
79
|
makeCallWithEthSafeTransferData: () => makeCallWithEthSafeTransferData,
|
|
61
80
|
makeMintRewardsRecipient: () => makeMintRewardsRecipient,
|
|
@@ -80,22 +99,245 @@ __export(src_exports, {
|
|
|
80
99
|
module.exports = __toCommonJS(src_exports);
|
|
81
100
|
|
|
82
101
|
// src/premint/premint-client.ts
|
|
83
|
-
var
|
|
102
|
+
var import_viem4 = require("viem");
|
|
84
103
|
var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
|
|
85
104
|
|
|
86
105
|
// src/premint/preminter.ts
|
|
87
|
-
var
|
|
106
|
+
var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
|
|
107
|
+
var import_viem3 = require("viem");
|
|
108
|
+
|
|
109
|
+
// src/apis/chain-constants.ts
|
|
110
|
+
var import_chains = require("viem/chains");
|
|
111
|
+
var import_viem2 = require("viem");
|
|
112
|
+
|
|
113
|
+
// src/constants.ts
|
|
88
114
|
var import_viem = require("viem");
|
|
89
|
-
var
|
|
115
|
+
var ZORA_API_BASE = "https://api.zora.co/";
|
|
116
|
+
var OPEN_EDITION_MINT_SIZE = BigInt("18446744073709551615");
|
|
117
|
+
var SUBGRAPH_CONFIG_BASE = "https://api.goldsky.com/api/public/project_clhk16b61ay9t49vm6ntn4mkz/subgraphs";
|
|
118
|
+
function getSubgraph(name, version) {
|
|
119
|
+
return `${SUBGRAPH_CONFIG_BASE}/${name}/${version}/gn`;
|
|
120
|
+
}
|
|
121
|
+
var zora721Abi = (0, import_viem.parseAbi)([
|
|
122
|
+
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
123
|
+
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
124
|
+
]);
|
|
125
|
+
|
|
126
|
+
// src/apis/chain-constants.ts
|
|
127
|
+
var REWARD_PER_TOKEN = (0, import_viem2.parseEther)("0.000777");
|
|
128
|
+
var networkConfigByChain = {
|
|
129
|
+
[import_chains.mainnet.id]: {
|
|
130
|
+
chainId: import_chains.mainnet.id,
|
|
131
|
+
isTestnet: false,
|
|
132
|
+
zoraCollectPathChainName: "eth",
|
|
133
|
+
zoraBackendChainName: "ETHEREUM-MAINNET",
|
|
134
|
+
subgraphUrl: getSubgraph("zora-create-mainnet", "stable")
|
|
135
|
+
},
|
|
136
|
+
[import_chains.sepolia.id]: {
|
|
137
|
+
chainId: import_chains.sepolia.id,
|
|
138
|
+
isTestnet: true,
|
|
139
|
+
zoraCollectPathChainName: "sep",
|
|
140
|
+
zoraBackendChainName: "ETHEREUM-SEPOLIA",
|
|
141
|
+
subgraphUrl: getSubgraph("zora-create-sepolia", "stable")
|
|
142
|
+
},
|
|
143
|
+
[import_chains.zora.id]: {
|
|
144
|
+
chainId: import_chains.zora.id,
|
|
145
|
+
isTestnet: false,
|
|
146
|
+
zoraCollectPathChainName: "zora",
|
|
147
|
+
zoraBackendChainName: "ZORA-MAINNET",
|
|
148
|
+
subgraphUrl: getSubgraph("zora-create-zora-mainnet", "stable")
|
|
149
|
+
},
|
|
150
|
+
[import_chains.zoraSepolia.id]: {
|
|
151
|
+
chainId: import_chains.zoraSepolia.id,
|
|
152
|
+
isTestnet: true,
|
|
153
|
+
zoraCollectPathChainName: "zsep",
|
|
154
|
+
zoraBackendChainName: "ZORA-SEPOLIA",
|
|
155
|
+
subgraphUrl: getSubgraph("zora-create-zora-sepolia", "stable")
|
|
156
|
+
},
|
|
157
|
+
[import_chains.optimism.id]: {
|
|
158
|
+
chainId: import_chains.optimism.id,
|
|
159
|
+
isTestnet: false,
|
|
160
|
+
zoraCollectPathChainName: "oeth",
|
|
161
|
+
zoraBackendChainName: "OPTIMISM-MAINNET",
|
|
162
|
+
subgraphUrl: getSubgraph("zora-create-optimism", "stable")
|
|
163
|
+
},
|
|
164
|
+
[import_chains.arbitrum.id]: {
|
|
165
|
+
chainId: import_chains.arbitrum.id,
|
|
166
|
+
isTestnet: true,
|
|
167
|
+
zoraCollectPathChainName: "arb",
|
|
168
|
+
zoraBackendChainName: "ARBITRUM-MAINNET",
|
|
169
|
+
subgraphUrl: getSubgraph("zora-create-arbitrum-one", "stable")
|
|
170
|
+
},
|
|
171
|
+
[import_chains.base.id]: {
|
|
172
|
+
chainId: import_chains.base.id,
|
|
173
|
+
isTestnet: false,
|
|
174
|
+
zoraCollectPathChainName: "base",
|
|
175
|
+
zoraBackendChainName: "BASE-MAINNET",
|
|
176
|
+
subgraphUrl: getSubgraph("zora-create-base-mainnet", "stable")
|
|
177
|
+
},
|
|
178
|
+
[import_chains.baseSepolia.id]: {
|
|
179
|
+
chainId: import_chains.baseSepolia.id,
|
|
180
|
+
isTestnet: true,
|
|
181
|
+
zoraCollectPathChainName: "bsep",
|
|
182
|
+
zoraBackendChainName: "BASE-SEPOLIA",
|
|
183
|
+
subgraphUrl: getSubgraph("zora-create-base-sepolia", "stable")
|
|
184
|
+
},
|
|
185
|
+
[import_chains.foundry.id]: {
|
|
186
|
+
chainId: import_chains.foundry.id,
|
|
187
|
+
isTestnet: true,
|
|
188
|
+
zoraCollectPathChainName: "zgor",
|
|
189
|
+
zoraBackendChainName: "ZORA-GOERLI",
|
|
190
|
+
subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable")
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
// src/premint/conversions.ts
|
|
195
|
+
var import_protocol_deployments = require("@zoralabs/protocol-deployments");
|
|
196
|
+
var convertCollectionFromApi = (collection) => {
|
|
197
|
+
if (!collection)
|
|
198
|
+
return void 0;
|
|
199
|
+
return {
|
|
200
|
+
additionalAdmins: collection.additionalAdmins || [],
|
|
201
|
+
contractAdmin: collection.contractAdmin,
|
|
202
|
+
contractName: collection.contractName,
|
|
203
|
+
contractURI: collection.contractURI
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
var convertPremintFromApi = (premint) => {
|
|
207
|
+
if (premint.config_version === import_protocol_deployments.PremintConfigVersion.V1 || !premint.config_version) {
|
|
208
|
+
const tokenConfig = premint.tokenConfig;
|
|
209
|
+
return {
|
|
210
|
+
premintConfigVersion: import_protocol_deployments.PremintConfigVersion.V1,
|
|
211
|
+
premintConfig: {
|
|
212
|
+
deleted: premint.deleted,
|
|
213
|
+
uid: premint.uid,
|
|
214
|
+
version: premint.version,
|
|
215
|
+
tokenConfig: {
|
|
216
|
+
...tokenConfig,
|
|
217
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
218
|
+
royaltyRecipient: tokenConfig.royaltyRecipient,
|
|
219
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
220
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
221
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
222
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
223
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
} else {
|
|
228
|
+
const tokenConfig = premint.tokenConfig;
|
|
229
|
+
return {
|
|
230
|
+
premintConfigVersion: import_protocol_deployments.PremintConfigVersion.V2,
|
|
231
|
+
premintConfig: {
|
|
232
|
+
deleted: premint.deleted,
|
|
233
|
+
uid: premint.uid,
|
|
234
|
+
version: premint.version,
|
|
235
|
+
tokenConfig: {
|
|
236
|
+
...tokenConfig,
|
|
237
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
238
|
+
payoutRecipient: tokenConfig.payoutRecipient,
|
|
239
|
+
createReferral: tokenConfig.createReferral,
|
|
240
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
241
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
242
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
243
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
244
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var convertGetPremintApiResponse = (response) => ({
|
|
251
|
+
collection: convertCollectionFromApi(response.collection),
|
|
252
|
+
collectionAddress: response.collection_address,
|
|
253
|
+
signature: response.signature,
|
|
254
|
+
signer: response.signer,
|
|
255
|
+
premint: convertPremintFromApi(response.premint)
|
|
256
|
+
});
|
|
257
|
+
var convertGetPremintOfCollectionApiResponse = (response) => ({
|
|
258
|
+
collection: convertCollectionFromApi({
|
|
259
|
+
contractAdmin: response.contract_admin,
|
|
260
|
+
contractName: response.contract_name,
|
|
261
|
+
contractURI: response.contract_uri
|
|
262
|
+
}),
|
|
263
|
+
premints: response.premints.map((premint) => ({
|
|
264
|
+
premint: convertPremintFromApi(premint),
|
|
265
|
+
signature: premint.signature
|
|
266
|
+
}))
|
|
267
|
+
});
|
|
268
|
+
var encodePremintV1ForAPI = ({
|
|
269
|
+
tokenConfig,
|
|
270
|
+
...premint
|
|
271
|
+
}) => ({
|
|
272
|
+
...premint,
|
|
273
|
+
config_version: "1",
|
|
274
|
+
tokenConfig: {
|
|
275
|
+
...tokenConfig,
|
|
276
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
277
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
278
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
279
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
280
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
var encodePremintV2ForAPI = ({
|
|
284
|
+
tokenConfig,
|
|
285
|
+
...premint
|
|
286
|
+
}) => ({
|
|
287
|
+
...premint,
|
|
288
|
+
config_version: "2",
|
|
289
|
+
tokenConfig: {
|
|
290
|
+
...tokenConfig,
|
|
291
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
292
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
293
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
294
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
295
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
var encodePremintForAPI = ({
|
|
299
|
+
premintConfig,
|
|
300
|
+
premintConfigVersion
|
|
301
|
+
}) => {
|
|
302
|
+
if (premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V1) {
|
|
303
|
+
return encodePremintV1ForAPI(premintConfig);
|
|
304
|
+
}
|
|
305
|
+
if (premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V2) {
|
|
306
|
+
return encodePremintV2ForAPI(premintConfig);
|
|
307
|
+
}
|
|
308
|
+
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
309
|
+
};
|
|
310
|
+
var encodePostSignatureInput = ({
|
|
311
|
+
contract: collection,
|
|
312
|
+
contractAddress: collectionAddress,
|
|
313
|
+
premintConfigVersion,
|
|
314
|
+
premintConfig,
|
|
315
|
+
signature,
|
|
316
|
+
chainId
|
|
317
|
+
}) => ({
|
|
318
|
+
premint: encodePremintForAPI({
|
|
319
|
+
premintConfig,
|
|
320
|
+
premintConfigVersion
|
|
321
|
+
}),
|
|
322
|
+
signature,
|
|
323
|
+
collection,
|
|
324
|
+
collection_address: collectionAddress,
|
|
325
|
+
chain_name: networkConfigByChain[chainId].zoraBackendChainName
|
|
326
|
+
});
|
|
327
|
+
var isPremintConfigV1 = (premintConfigAndVersion) => premintConfigAndVersion.premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V1;
|
|
328
|
+
var isPremintConfigV2 = (premintConfigAndVersion) => premintConfigAndVersion.premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V2;
|
|
329
|
+
|
|
330
|
+
// src/premint/preminter.ts
|
|
331
|
+
var getPremintExecutorAddress = () => import_protocol_deployments2.zoraCreator1155PremintExecutorImplAddress[999];
|
|
90
332
|
async function isAuthorizedToCreatePremint({
|
|
91
|
-
contractAdmin =
|
|
333
|
+
contractAdmin = import_viem3.zeroAddress,
|
|
92
334
|
additionalAdmins = [],
|
|
93
335
|
collectionAddress,
|
|
94
336
|
publicClient,
|
|
95
337
|
signer
|
|
96
338
|
}) {
|
|
97
339
|
return await publicClient.readContract({
|
|
98
|
-
abi:
|
|
340
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
99
341
|
address: getPremintExecutorAddress(),
|
|
100
342
|
functionName: "isAuthorizedToCreatePremintWithAdditionalAdmins",
|
|
101
343
|
args: [
|
|
@@ -110,8 +352,8 @@ async function recoverPremintSigner({
|
|
|
110
352
|
signature,
|
|
111
353
|
...rest
|
|
112
354
|
}) {
|
|
113
|
-
return await (0,
|
|
114
|
-
...(0,
|
|
355
|
+
return await (0, import_viem3.recoverTypedDataAddress)({
|
|
356
|
+
...(0, import_protocol_deployments2.premintTypedDataDefinition)(rest),
|
|
115
357
|
signature
|
|
116
358
|
});
|
|
117
359
|
}
|
|
@@ -137,7 +379,7 @@ async function isValidSignature({
|
|
|
137
379
|
verifyingContract: collectionAddress,
|
|
138
380
|
chainId
|
|
139
381
|
});
|
|
140
|
-
if (!
|
|
382
|
+
if (!import_viem3.recoverAddress) {
|
|
141
383
|
return {
|
|
142
384
|
isAuthorized: false
|
|
143
385
|
};
|
|
@@ -156,7 +398,7 @@ async function isValidSignature({
|
|
|
156
398
|
}
|
|
157
399
|
function migratePremintConfigToV2({
|
|
158
400
|
premintConfig,
|
|
159
|
-
createReferral =
|
|
401
|
+
createReferral = import_viem3.zeroAddress
|
|
160
402
|
}) {
|
|
161
403
|
return {
|
|
162
404
|
...premintConfig,
|
|
@@ -179,7 +421,7 @@ var recoverCreatorFromCreatorAttribution = async ({
|
|
|
179
421
|
chainId,
|
|
180
422
|
tokenContract
|
|
181
423
|
}) => {
|
|
182
|
-
const hashedDomain = (0,
|
|
424
|
+
const hashedDomain = (0, import_viem3.hashDomain)({
|
|
183
425
|
domain: {
|
|
184
426
|
chainId,
|
|
185
427
|
name: domainName,
|
|
@@ -202,8 +444,8 @@ var recoverCreatorFromCreatorAttribution = async ({
|
|
|
202
444
|
}
|
|
203
445
|
});
|
|
204
446
|
const parts = ["0x1901", hashedDomain, structHash];
|
|
205
|
-
const hashedTypedData = (0,
|
|
206
|
-
return await (0,
|
|
447
|
+
const hashedTypedData = (0, import_viem3.keccak256)((0, import_viem3.concat)(parts));
|
|
448
|
+
return await (0, import_viem3.recoverAddress)({
|
|
207
449
|
hash: hashedTypedData,
|
|
208
450
|
signature
|
|
209
451
|
});
|
|
@@ -213,7 +455,7 @@ var supportedPremintVersions = async ({
|
|
|
213
455
|
publicClient
|
|
214
456
|
}) => {
|
|
215
457
|
return await publicClient.readContract({
|
|
216
|
-
abi:
|
|
458
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
217
459
|
address: getPremintExecutorAddress(),
|
|
218
460
|
functionName: "supportedPremintSignatureVersions",
|
|
219
461
|
args: [tokenContract]
|
|
@@ -228,13 +470,13 @@ var supportsPremintVersion = async ({
|
|
|
228
470
|
};
|
|
229
471
|
async function getPremintCollectionAddress({
|
|
230
472
|
publicClient,
|
|
231
|
-
collection,
|
|
232
|
-
collectionAddress
|
|
473
|
+
contract: collection,
|
|
474
|
+
contractAddress: collectionAddress
|
|
233
475
|
}) {
|
|
234
476
|
if (typeof collection !== "undefined") {
|
|
235
477
|
return publicClient.readContract({
|
|
236
478
|
address: getPremintExecutorAddress(),
|
|
237
|
-
abi:
|
|
479
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
238
480
|
functionName: "getContractWithAdditionalAdminsAddress",
|
|
239
481
|
args: [
|
|
240
482
|
{
|
|
@@ -282,13 +524,13 @@ async function getPremintMintFee({
|
|
|
282
524
|
try {
|
|
283
525
|
return await publicClient.readContract({
|
|
284
526
|
address: getPremintExecutorAddress(),
|
|
285
|
-
abi:
|
|
527
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
286
528
|
functionName: "mintFee",
|
|
287
529
|
args: [tokenContract]
|
|
288
530
|
});
|
|
289
531
|
} catch (e) {
|
|
290
532
|
console.error(e);
|
|
291
|
-
return (0,
|
|
533
|
+
return (0, import_viem3.parseEther)("0.000777");
|
|
292
534
|
}
|
|
293
535
|
}
|
|
294
536
|
async function getPremintMintCosts({
|
|
@@ -298,23 +540,53 @@ async function getPremintMintCosts({
|
|
|
298
540
|
quantityToMint
|
|
299
541
|
}) {
|
|
300
542
|
const mintFee = await getPremintMintFee({ tokenContract, publicClient });
|
|
543
|
+
const quantityToMintBigInt = BigInt(quantityToMint);
|
|
301
544
|
return {
|
|
302
|
-
mintFee: mintFee *
|
|
303
|
-
|
|
304
|
-
|
|
545
|
+
mintFee: mintFee * quantityToMintBigInt,
|
|
546
|
+
totalPurchaseCost: tokenPrice * quantityToMintBigInt,
|
|
547
|
+
totalCostEth: (mintFee + tokenPrice) * quantityToMintBigInt
|
|
305
548
|
};
|
|
306
549
|
}
|
|
550
|
+
async function getPremintPricePerToken({
|
|
551
|
+
collection,
|
|
552
|
+
uid,
|
|
553
|
+
premintGetter
|
|
554
|
+
}) {
|
|
555
|
+
const { premint: premintConfigWithVersion } = await premintGetter.get({
|
|
556
|
+
collectionAddress: collection,
|
|
557
|
+
uid
|
|
558
|
+
});
|
|
559
|
+
if (isPremintConfigV1(premintConfigWithVersion) || isPremintConfigV2(premintConfigWithVersion)) {
|
|
560
|
+
return premintConfigWithVersion.premintConfig.tokenConfig.pricePerToken;
|
|
561
|
+
}
|
|
562
|
+
throw new Error("Premint version not supported to get price");
|
|
563
|
+
}
|
|
564
|
+
async function getPremintMintCostsWithUnknownTokenPrice({
|
|
565
|
+
premintGetter,
|
|
566
|
+
uid,
|
|
567
|
+
...rest
|
|
568
|
+
}) {
|
|
569
|
+
const pricePerToken = await getPremintPricePerToken({
|
|
570
|
+
uid,
|
|
571
|
+
premintGetter,
|
|
572
|
+
collection: rest.tokenContract
|
|
573
|
+
});
|
|
574
|
+
return await getPremintMintCosts({
|
|
575
|
+
...rest,
|
|
576
|
+
tokenPrice: pricePerToken
|
|
577
|
+
});
|
|
578
|
+
}
|
|
307
579
|
function makeMintRewardsRecipient({
|
|
308
|
-
mintReferral =
|
|
309
|
-
platformReferral =
|
|
580
|
+
mintReferral = import_viem3.zeroAddress,
|
|
581
|
+
platformReferral = import_viem3.zeroAddress
|
|
310
582
|
}) {
|
|
311
583
|
return [mintReferral, platformReferral];
|
|
312
584
|
}
|
|
313
585
|
function getDefaultFixedPriceMinterAddress(chainId) {
|
|
314
|
-
return
|
|
586
|
+
return import_protocol_deployments2.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
315
587
|
}
|
|
316
588
|
var emptyContractCreationConfig = () => ({
|
|
317
|
-
contractAdmin:
|
|
589
|
+
contractAdmin: import_viem3.zeroAddress,
|
|
318
590
|
contractURI: "",
|
|
319
591
|
contractName: "",
|
|
320
592
|
additionalAdmins: []
|
|
@@ -331,12 +603,12 @@ var toContractCreationConfigOrAddress = ({
|
|
|
331
603
|
}) => {
|
|
332
604
|
if (typeof collection !== "undefined") {
|
|
333
605
|
return {
|
|
334
|
-
collection
|
|
606
|
+
contract: collection
|
|
335
607
|
};
|
|
336
608
|
}
|
|
337
609
|
if (typeof collectionAddress !== "undefined") {
|
|
338
610
|
return {
|
|
339
|
-
collectionAddress
|
|
611
|
+
contractAddress: collectionAddress
|
|
340
612
|
};
|
|
341
613
|
}
|
|
342
614
|
throw new Error("Must provide either a collection or a collection address");
|
|
@@ -419,19 +691,39 @@ var httpClient = {
|
|
|
419
691
|
retries
|
|
420
692
|
};
|
|
421
693
|
|
|
422
|
-
// src/
|
|
423
|
-
var
|
|
424
|
-
var
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
function getSubgraph(name, version) {
|
|
428
|
-
return `${SUBGRAPH_CONFIG_BASE}/${name}/${version}/gn`;
|
|
694
|
+
// src/mint/types.ts
|
|
695
|
+
var isOnChainMint = (mint2) => mint2.mintType !== "premint";
|
|
696
|
+
var is1155Mint = (mint2) => mint2.mintType === "1155";
|
|
697
|
+
function isErc20SaleStrategy(salesConfig) {
|
|
698
|
+
return salesConfig.saleType === "erc20";
|
|
429
699
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
700
|
+
|
|
701
|
+
// src/utils.ts
|
|
702
|
+
var makeContractParameters = (args) => args;
|
|
703
|
+
function mintRecipientOrAccount({
|
|
704
|
+
mintRecipient,
|
|
705
|
+
minterAccount
|
|
706
|
+
}) {
|
|
707
|
+
return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
708
|
+
}
|
|
709
|
+
async function querySubgraphWithRetries({
|
|
710
|
+
httpClient: httpClient2,
|
|
711
|
+
subgraphUrl,
|
|
712
|
+
query,
|
|
713
|
+
variables
|
|
714
|
+
}) {
|
|
715
|
+
const { retries: retries2, post: post2 } = httpClient2;
|
|
716
|
+
const result = await retries2(async () => {
|
|
717
|
+
return await post2(subgraphUrl, {
|
|
718
|
+
query,
|
|
719
|
+
variables
|
|
720
|
+
});
|
|
721
|
+
});
|
|
722
|
+
return result?.data;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// src/mint/subgraph-queries.ts
|
|
726
|
+
var NFT_SALE_STRATEGY_FRAGMENT = `
|
|
435
727
|
fragment SaleStrategy on SalesStrategyConfig {
|
|
436
728
|
type
|
|
437
729
|
fixedPrice {
|
|
@@ -449,377 +741,265 @@ fragment SaleStrategy on SalesStrategyConfig {
|
|
|
449
741
|
saleStart
|
|
450
742
|
maxTokensPerAddress
|
|
451
743
|
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
744
|
+
}`;
|
|
745
|
+
var TOKEN_FRAGMENT = `
|
|
746
|
+
fragment Token on ZoraCreateToken {
|
|
747
|
+
creator
|
|
748
|
+
tokenId
|
|
749
|
+
uri
|
|
750
|
+
totalMinted
|
|
751
|
+
maxSupply
|
|
752
|
+
tokenStandard
|
|
753
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
754
|
+
...SaleStrategy
|
|
755
|
+
}
|
|
457
756
|
contract {
|
|
757
|
+
address
|
|
458
758
|
mintFeePerQuantity
|
|
759
|
+
contractVersion
|
|
760
|
+
contractURI
|
|
761
|
+
name
|
|
459
762
|
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
460
763
|
...SaleStrategy
|
|
461
764
|
}
|
|
462
765
|
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}
|
|
766
|
+
}`;
|
|
767
|
+
var FRAGMENTS = `
|
|
768
|
+
${NFT_SALE_STRATEGY_FRAGMENT}
|
|
769
|
+
${TOKEN_FRAGMENT}
|
|
468
770
|
`;
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
zoraBackendChainName: "ETHEREUM-MAINNET",
|
|
480
|
-
subgraphUrl: getSubgraph("zora-create-mainnet", "stable")
|
|
481
|
-
},
|
|
482
|
-
[import_chains.sepolia.id]: {
|
|
483
|
-
chainId: import_chains.sepolia.id,
|
|
484
|
-
isTestnet: true,
|
|
485
|
-
zoraCollectPathChainName: "sep",
|
|
486
|
-
zoraBackendChainName: "ETHEREUM-SEPOLIA",
|
|
487
|
-
subgraphUrl: getSubgraph("zora-create-sepolia", "stable")
|
|
488
|
-
},
|
|
489
|
-
[import_chains.zora.id]: {
|
|
490
|
-
chainId: import_chains.zora.id,
|
|
491
|
-
isTestnet: false,
|
|
492
|
-
zoraCollectPathChainName: "zora",
|
|
493
|
-
zoraBackendChainName: "ZORA-MAINNET",
|
|
494
|
-
subgraphUrl: getSubgraph("zora-create-zora-mainnet", "stable")
|
|
495
|
-
},
|
|
496
|
-
[import_chains.zoraSepolia.id]: {
|
|
497
|
-
chainId: import_chains.zoraSepolia.id,
|
|
498
|
-
isTestnet: true,
|
|
499
|
-
zoraCollectPathChainName: "zsep",
|
|
500
|
-
zoraBackendChainName: "ZORA-SEPOLIA",
|
|
501
|
-
subgraphUrl: getSubgraph("zora-create-zora-sepolia", "stable")
|
|
502
|
-
},
|
|
503
|
-
[import_chains.optimism.id]: {
|
|
504
|
-
chainId: import_chains.optimism.id,
|
|
505
|
-
isTestnet: false,
|
|
506
|
-
zoraCollectPathChainName: "oeth",
|
|
507
|
-
zoraBackendChainName: "OPTIMISM-MAINNET",
|
|
508
|
-
subgraphUrl: getSubgraph("zora-create-optimism", "stable")
|
|
509
|
-
},
|
|
510
|
-
[import_chains.arbitrum.id]: {
|
|
511
|
-
chainId: import_chains.arbitrum.id,
|
|
512
|
-
isTestnet: true,
|
|
513
|
-
zoraCollectPathChainName: "arb",
|
|
514
|
-
zoraBackendChainName: "ARBITRUM-MAINNET",
|
|
515
|
-
subgraphUrl: getSubgraph("zora-create-arbitrum-one", "stable")
|
|
516
|
-
},
|
|
517
|
-
[import_chains.base.id]: {
|
|
518
|
-
chainId: import_chains.base.id,
|
|
519
|
-
isTestnet: false,
|
|
520
|
-
zoraCollectPathChainName: "base",
|
|
521
|
-
zoraBackendChainName: "BASE-MAINNET",
|
|
522
|
-
subgraphUrl: getSubgraph("zora-create-base-mainnet", "stable")
|
|
523
|
-
},
|
|
524
|
-
[import_chains.baseSepolia.id]: {
|
|
525
|
-
chainId: import_chains.baseSepolia.id,
|
|
526
|
-
isTestnet: true,
|
|
527
|
-
zoraCollectPathChainName: "bsep",
|
|
528
|
-
zoraBackendChainName: "BASE-SEPOLIA",
|
|
529
|
-
subgraphUrl: getSubgraph("zora-create-base-sepolia", "stable")
|
|
530
|
-
},
|
|
531
|
-
[import_chains.foundry.id]: {
|
|
532
|
-
chainId: import_chains.foundry.id,
|
|
533
|
-
isTestnet: true,
|
|
534
|
-
zoraCollectPathChainName: "zgor",
|
|
535
|
-
zoraBackendChainName: "ZORA-GOERLI",
|
|
536
|
-
subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable")
|
|
771
|
+
function buildNftTokenSalesQuery({
|
|
772
|
+
tokenId,
|
|
773
|
+
tokenAddress
|
|
774
|
+
}) {
|
|
775
|
+
return {
|
|
776
|
+
query: `
|
|
777
|
+
${FRAGMENTS}
|
|
778
|
+
query ($id: ID!) {
|
|
779
|
+
zoraCreateToken(id: $id) {
|
|
780
|
+
...Token
|
|
537
781
|
}
|
|
538
|
-
}
|
|
782
|
+
}
|
|
783
|
+
`,
|
|
784
|
+
variables: {
|
|
785
|
+
id: tokenId !== void 0 ? (
|
|
786
|
+
// Generic Token ID types all stringify down to the base numeric equivalent.
|
|
787
|
+
`${tokenAddress.toLowerCase()}-${tokenId}`
|
|
788
|
+
) : `${tokenAddress.toLowerCase()}-0`
|
|
789
|
+
},
|
|
790
|
+
parseResponseData: (responseData) => responseData?.zoraCreateToken
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function buildContractTokensQuery({
|
|
794
|
+
tokenAddress
|
|
795
|
+
}) {
|
|
796
|
+
return {
|
|
797
|
+
query: `
|
|
798
|
+
${FRAGMENTS}
|
|
799
|
+
query ($contract: Bytes!) {
|
|
800
|
+
zoraCreateTokens(
|
|
801
|
+
where: {address: $contract}
|
|
802
|
+
) {
|
|
803
|
+
...Token
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
`,
|
|
807
|
+
variables: {
|
|
808
|
+
contract: tokenAddress.toLowerCase()
|
|
809
|
+
},
|
|
810
|
+
parseResponseData: (responseData) => responseData?.zoraCreateTokens
|
|
811
|
+
};
|
|
812
|
+
}
|
|
813
|
+
function buildPremintsOfContractQuery({
|
|
814
|
+
tokenAddress
|
|
815
|
+
}) {
|
|
816
|
+
return {
|
|
817
|
+
query: `
|
|
818
|
+
query ($contractAddress: Bytes!) {
|
|
819
|
+
premints(where:{contractAddress:$contractAddress}) {
|
|
820
|
+
uid
|
|
821
|
+
tokenId
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
`,
|
|
825
|
+
variables: {
|
|
826
|
+
contractAddress: tokenAddress.toLowerCase()
|
|
827
|
+
},
|
|
828
|
+
parseResponseData: (responseData) => responseData?.premints
|
|
829
|
+
};
|
|
830
|
+
}
|
|
539
831
|
|
|
540
|
-
// src/mint/mint-
|
|
832
|
+
// src/mint/subgraph-mint-getter.ts
|
|
541
833
|
var getApiNetworkConfigForChain = (chainId) => {
|
|
542
834
|
if (!networkConfigByChain[chainId]) {
|
|
543
835
|
throw new Error(`chain id ${chainId} network not configured `);
|
|
544
836
|
}
|
|
545
837
|
return networkConfigByChain[chainId];
|
|
546
838
|
};
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
this.httpClient = httpClient2 || httpClient;
|
|
550
|
-
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
551
|
-
}
|
|
552
|
-
async getSalesConfigAndTokenInfo({
|
|
553
|
-
tokenAddress,
|
|
554
|
-
tokenId,
|
|
555
|
-
saleType
|
|
556
|
-
}) {
|
|
557
|
-
const { retries: retries2, post: post2 } = this.httpClient;
|
|
558
|
-
return retries2(async () => {
|
|
559
|
-
const response = await post2(this.networkConfig.subgraphUrl, {
|
|
560
|
-
query: NFT_SALE_QUERY,
|
|
561
|
-
variables: {
|
|
562
|
-
id: tokenId !== void 0 ? (
|
|
563
|
-
// Generic Token ID types all stringify down to the base numeric equivalent.
|
|
564
|
-
`${tokenAddress.toLowerCase()}-${tokenId}`
|
|
565
|
-
) : `${tokenAddress.toLowerCase()}-0`
|
|
566
|
-
}
|
|
567
|
-
});
|
|
568
|
-
const token = response.data?.zoraCreateToken;
|
|
569
|
-
if (!token) {
|
|
570
|
-
throw new Error("Cannot find a token to mint");
|
|
571
|
-
}
|
|
572
|
-
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
573
|
-
const saleStrategies = allStrategies.sort(
|
|
574
|
-
(a, b) => BigInt(
|
|
575
|
-
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
576
|
-
) > BigInt(
|
|
577
|
-
b.type === "FIXED_PRICE" ? b.fixedPrice.saleEnd : b.erc20Minter.saleEnd
|
|
578
|
-
) ? 1 : -1
|
|
579
|
-
);
|
|
580
|
-
let targetStrategy;
|
|
581
|
-
if (!saleType) {
|
|
582
|
-
targetStrategy = saleStrategies[0];
|
|
583
|
-
if (!targetStrategy) {
|
|
584
|
-
throw new Error("Cannot find sale strategy");
|
|
585
|
-
}
|
|
586
|
-
} else {
|
|
587
|
-
const mappedSaleType = saleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
588
|
-
targetStrategy = saleStrategies.find(
|
|
589
|
-
(strategy) => strategy.type === mappedSaleType
|
|
590
|
-
);
|
|
591
|
-
if (!targetStrategy) {
|
|
592
|
-
throw new Error(`Cannot find sale strategy for ${mappedSaleType}`);
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
if (targetStrategy.type === "FIXED_PRICE") {
|
|
596
|
-
return {
|
|
597
|
-
salesConfig: {
|
|
598
|
-
saleType: "fixedPrice",
|
|
599
|
-
...targetStrategy.fixedPrice,
|
|
600
|
-
maxTokensPerAddress: BigInt(
|
|
601
|
-
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
602
|
-
),
|
|
603
|
-
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
604
|
-
},
|
|
605
|
-
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
609
|
-
return {
|
|
610
|
-
salesConfig: {
|
|
611
|
-
saleType: "erc20",
|
|
612
|
-
...targetStrategy.erc20Minter,
|
|
613
|
-
maxTokensPerAddress: BigInt(
|
|
614
|
-
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
615
|
-
),
|
|
616
|
-
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
617
|
-
},
|
|
618
|
-
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
throw new Error("Invalid saleType");
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
};
|
|
625
|
-
|
|
626
|
-
// src/premint/conversions.ts
|
|
627
|
-
var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
|
|
628
|
-
var convertCollectionFromApi = (collection) => {
|
|
629
|
-
if (!collection)
|
|
630
|
-
return void 0;
|
|
631
|
-
return {
|
|
632
|
-
additionalAdmins: collection.additionalAdmins || [],
|
|
633
|
-
contractAdmin: collection.contractAdmin,
|
|
634
|
-
contractName: collection.contractName,
|
|
635
|
-
contractURI: collection.contractURI
|
|
636
|
-
};
|
|
637
|
-
};
|
|
638
|
-
var convertPremintFromApi = (premint) => {
|
|
639
|
-
if (premint.config_version === import_protocol_deployments2.PremintConfigVersion.V1 || !premint.config_version) {
|
|
640
|
-
const tokenConfig = premint.tokenConfig;
|
|
839
|
+
function parseSalesConfig(targetStrategy) {
|
|
840
|
+
if (targetStrategy.type === "FIXED_PRICE")
|
|
641
841
|
return {
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
...tokenConfig,
|
|
649
|
-
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
650
|
-
royaltyRecipient: tokenConfig.royaltyRecipient,
|
|
651
|
-
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
652
|
-
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
653
|
-
mintStart: BigInt(tokenConfig.mintStart),
|
|
654
|
-
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
655
|
-
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
656
|
-
}
|
|
657
|
-
}
|
|
842
|
+
saleType: "fixedPrice",
|
|
843
|
+
...targetStrategy.fixedPrice,
|
|
844
|
+
maxTokensPerAddress: BigInt(
|
|
845
|
+
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
846
|
+
),
|
|
847
|
+
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
658
848
|
};
|
|
659
|
-
|
|
660
|
-
const tokenConfig = premint.tokenConfig;
|
|
849
|
+
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
661
850
|
return {
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
...tokenConfig,
|
|
669
|
-
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
670
|
-
payoutRecipient: tokenConfig.payoutRecipient,
|
|
671
|
-
createReferral: tokenConfig.createReferral,
|
|
672
|
-
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
673
|
-
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
674
|
-
mintStart: BigInt(tokenConfig.mintStart),
|
|
675
|
-
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
676
|
-
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
677
|
-
}
|
|
678
|
-
}
|
|
851
|
+
saleType: "erc20",
|
|
852
|
+
...targetStrategy.erc20Minter,
|
|
853
|
+
maxTokensPerAddress: BigInt(
|
|
854
|
+
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
855
|
+
),
|
|
856
|
+
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
679
857
|
};
|
|
680
858
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
signature: response.signature
|
|
687
|
-
});
|
|
688
|
-
var encodePremintV1ForAPI = ({
|
|
689
|
-
tokenConfig,
|
|
690
|
-
...premint
|
|
691
|
-
}) => ({
|
|
692
|
-
...premint,
|
|
693
|
-
config_version: "1",
|
|
694
|
-
tokenConfig: {
|
|
695
|
-
...tokenConfig,
|
|
696
|
-
maxSupply: tokenConfig.maxSupply.toString(),
|
|
697
|
-
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
698
|
-
mintStart: tokenConfig.mintStart.toString(),
|
|
699
|
-
mintDuration: tokenConfig.mintDuration.toString(),
|
|
700
|
-
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
|
|
701
|
-
}
|
|
702
|
-
});
|
|
703
|
-
var encodePremintV2ForAPI = ({
|
|
704
|
-
tokenConfig,
|
|
705
|
-
...premint
|
|
706
|
-
}) => ({
|
|
707
|
-
...premint,
|
|
708
|
-
config_version: "2",
|
|
709
|
-
tokenConfig: {
|
|
710
|
-
...tokenConfig,
|
|
711
|
-
maxSupply: tokenConfig.maxSupply.toString(),
|
|
712
|
-
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
713
|
-
mintStart: tokenConfig.mintStart.toString(),
|
|
714
|
-
mintDuration: tokenConfig.mintDuration.toString(),
|
|
715
|
-
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
|
|
716
|
-
}
|
|
717
|
-
});
|
|
718
|
-
var encodePremintForAPI = ({
|
|
719
|
-
premintConfig,
|
|
720
|
-
premintConfigVersion
|
|
721
|
-
}) => {
|
|
722
|
-
if (premintConfigVersion === import_protocol_deployments2.PremintConfigVersion.V1) {
|
|
723
|
-
return encodePremintV1ForAPI(premintConfig);
|
|
724
|
-
}
|
|
725
|
-
if (premintConfigVersion === import_protocol_deployments2.PremintConfigVersion.V2) {
|
|
726
|
-
return encodePremintV2ForAPI(premintConfig);
|
|
727
|
-
}
|
|
728
|
-
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
729
|
-
};
|
|
730
|
-
var encodePostSignatureInput = ({
|
|
731
|
-
collection,
|
|
732
|
-
collectionAddress,
|
|
733
|
-
premintConfigVersion,
|
|
734
|
-
premintConfig,
|
|
735
|
-
signature,
|
|
736
|
-
chainId
|
|
737
|
-
}) => ({
|
|
738
|
-
premint: encodePremintForAPI({
|
|
739
|
-
premintConfig,
|
|
740
|
-
premintConfigVersion
|
|
741
|
-
}),
|
|
742
|
-
signature,
|
|
743
|
-
collection,
|
|
744
|
-
collection_address: collectionAddress,
|
|
745
|
-
chain_name: networkConfigByChain[chainId].zoraBackendChainName
|
|
746
|
-
});
|
|
747
|
-
|
|
748
|
-
// src/premint/premint-api-client.ts
|
|
749
|
-
var postSignature = async ({
|
|
750
|
-
httpClient: { post: post2, retries: retries2 } = httpClient,
|
|
751
|
-
...data
|
|
752
|
-
}) => retries2(
|
|
753
|
-
() => post2(`${ZORA_API_BASE}premint/signature`, data)
|
|
754
|
-
);
|
|
755
|
-
var getNextUID = async ({
|
|
756
|
-
chain_name,
|
|
757
|
-
collection_address,
|
|
758
|
-
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
759
|
-
}) => retries2(
|
|
760
|
-
() => get2(
|
|
761
|
-
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/next_uid`
|
|
762
|
-
)
|
|
763
|
-
);
|
|
764
|
-
var getSignature = async ({
|
|
765
|
-
collection_address,
|
|
766
|
-
uid,
|
|
767
|
-
chain_name,
|
|
768
|
-
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
769
|
-
}) => {
|
|
770
|
-
const result = await retries2(
|
|
771
|
-
() => get2(
|
|
772
|
-
`${ZORA_API_BASE}premint/signature/${chain_name}/${collection_address}/${uid}`
|
|
773
|
-
)
|
|
859
|
+
throw new Error("Unknown saleType");
|
|
860
|
+
}
|
|
861
|
+
function getSaleEnd(a) {
|
|
862
|
+
return BigInt(
|
|
863
|
+
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
774
864
|
);
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
865
|
+
}
|
|
866
|
+
function getTargetStrategy({
|
|
867
|
+
tokenId,
|
|
868
|
+
preferredSaleType,
|
|
869
|
+
token
|
|
870
|
+
}) {
|
|
871
|
+
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
872
|
+
const saleStrategies = allStrategies.sort(
|
|
873
|
+
(a, b) => getSaleEnd(a) > getSaleEnd(b) ? 1 : -1
|
|
874
|
+
);
|
|
875
|
+
let targetStrategy;
|
|
876
|
+
if (!preferredSaleType) {
|
|
877
|
+
targetStrategy = saleStrategies[0];
|
|
878
|
+
if (!targetStrategy) {
|
|
879
|
+
throw new Error("Cannot find sale strategy");
|
|
880
|
+
}
|
|
881
|
+
} else {
|
|
882
|
+
const mappedSaleType = preferredSaleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
883
|
+
targetStrategy = saleStrategies.find(
|
|
884
|
+
(strategy) => strategy.type === mappedSaleType
|
|
885
|
+
);
|
|
886
|
+
if (!targetStrategy) {
|
|
887
|
+
const targetStrategy2 = saleStrategies.find(
|
|
888
|
+
(strategy) => strategy.type === "FIXED_PRICE" || strategy.type === "ERC_20_MINTER"
|
|
889
|
+
);
|
|
890
|
+
if (!targetStrategy2)
|
|
891
|
+
throw new Error("Cannot find valid sale strategy");
|
|
892
|
+
return targetStrategy2;
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
return targetStrategy;
|
|
896
|
+
}
|
|
897
|
+
var SubgraphMintGetter = class {
|
|
778
898
|
constructor(chainId, httpClient2) {
|
|
779
|
-
this.
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
const data = encodePostSignatureInput({
|
|
784
|
-
...rest,
|
|
785
|
-
chainId: this.networkConfig.chainId,
|
|
786
|
-
signature
|
|
787
|
-
});
|
|
788
|
-
return postSignature({
|
|
789
|
-
...data,
|
|
790
|
-
httpClient: this.httpClient
|
|
791
|
-
});
|
|
792
|
-
};
|
|
793
|
-
this.getNextUID = async (collectionAddress) => (await getNextUID({
|
|
794
|
-
collection_address: collectionAddress.toLowerCase(),
|
|
795
|
-
chain_name: this.networkConfig.zoraBackendChainName,
|
|
796
|
-
httpClient: this.httpClient
|
|
797
|
-
})).next_uid;
|
|
798
|
-
this.getSignature = async ({
|
|
799
|
-
collectionAddress,
|
|
800
|
-
uid
|
|
899
|
+
this.getMintable = async ({
|
|
900
|
+
tokenAddress,
|
|
901
|
+
tokenId,
|
|
902
|
+
preferredSaleType: saleType
|
|
801
903
|
}) => {
|
|
802
|
-
const
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
904
|
+
const token = await this.querySubgraphWithRetries(
|
|
905
|
+
buildNftTokenSalesQuery({
|
|
906
|
+
tokenId,
|
|
907
|
+
tokenAddress
|
|
908
|
+
})
|
|
909
|
+
);
|
|
910
|
+
if (!token) {
|
|
911
|
+
throw new Error("Cannot find token");
|
|
912
|
+
}
|
|
913
|
+
return parseTokenQueryResult({
|
|
914
|
+
token,
|
|
915
|
+
tokenId,
|
|
916
|
+
preferredSaleType: saleType
|
|
807
917
|
});
|
|
808
|
-
return convertGetPremintApiResponse(response);
|
|
809
918
|
};
|
|
810
919
|
this.httpClient = httpClient2 || httpClient;
|
|
811
920
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
812
921
|
}
|
|
922
|
+
async querySubgraphWithRetries({
|
|
923
|
+
query,
|
|
924
|
+
variables,
|
|
925
|
+
parseResponseData
|
|
926
|
+
}) {
|
|
927
|
+
const responseData = await querySubgraphWithRetries({
|
|
928
|
+
httpClient: this.httpClient,
|
|
929
|
+
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
930
|
+
query,
|
|
931
|
+
variables
|
|
932
|
+
});
|
|
933
|
+
return parseResponseData(responseData);
|
|
934
|
+
}
|
|
935
|
+
async getContractMintable({
|
|
936
|
+
tokenAddress,
|
|
937
|
+
preferredSaleType
|
|
938
|
+
}) {
|
|
939
|
+
const tokens = await this.querySubgraphWithRetries(
|
|
940
|
+
buildContractTokensQuery({
|
|
941
|
+
tokenAddress
|
|
942
|
+
})
|
|
943
|
+
);
|
|
944
|
+
if (!tokens)
|
|
945
|
+
return [];
|
|
946
|
+
return tokens.filter((x) => x.tokenId !== "0").map(
|
|
947
|
+
(token) => parseTokenQueryResult({
|
|
948
|
+
token,
|
|
949
|
+
tokenId: token.tokenId,
|
|
950
|
+
preferredSaleType
|
|
951
|
+
})
|
|
952
|
+
);
|
|
953
|
+
}
|
|
954
|
+
async getContractPremintTokenIds({
|
|
955
|
+
tokenAddress
|
|
956
|
+
}) {
|
|
957
|
+
const premints = await this.querySubgraphWithRetries(
|
|
958
|
+
buildPremintsOfContractQuery({
|
|
959
|
+
tokenAddress
|
|
960
|
+
})
|
|
961
|
+
);
|
|
962
|
+
return premints?.map((premint) => ({
|
|
963
|
+
tokenId: BigInt(premint.tokenId),
|
|
964
|
+
uid: +premint.uid
|
|
965
|
+
})) || [];
|
|
966
|
+
}
|
|
813
967
|
};
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
968
|
+
function parseTokenQueryResult({
|
|
969
|
+
token,
|
|
970
|
+
tokenId,
|
|
971
|
+
preferredSaleType
|
|
972
|
+
}) {
|
|
973
|
+
const targetStrategy = getTargetStrategy({
|
|
974
|
+
tokenId,
|
|
975
|
+
preferredSaleType,
|
|
976
|
+
token
|
|
977
|
+
});
|
|
978
|
+
const tokenInfo = parseTokenInfo(token);
|
|
979
|
+
const salesConfig = parseSalesConfig(targetStrategy);
|
|
980
|
+
if (isErc20SaleStrategy(salesConfig)) {
|
|
981
|
+
tokenInfo.mintFeePerQuantity = 0n;
|
|
982
|
+
}
|
|
819
983
|
return {
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
984
|
+
...tokenInfo,
|
|
985
|
+
salesConfig
|
|
986
|
+
};
|
|
987
|
+
}
|
|
988
|
+
function parseTokenInfo(token) {
|
|
989
|
+
return {
|
|
990
|
+
contract: {
|
|
991
|
+
address: token.contract.address,
|
|
992
|
+
name: token.contract.name,
|
|
993
|
+
URI: token.contract.contractURI
|
|
994
|
+
},
|
|
995
|
+
tokenURI: token.uri,
|
|
996
|
+
tokenId: token.tokenId ? BigInt(token.tokenId) : void 0,
|
|
997
|
+
mintType: token.tokenStandard === "ERC721" ? "721" : "1155",
|
|
998
|
+
creator: token.creator,
|
|
999
|
+
totalMinted: BigInt(token.totalMinted),
|
|
1000
|
+
maxSupply: BigInt(token.maxSupply),
|
|
1001
|
+
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity),
|
|
1002
|
+
contractVersion: token.contract.contractVersion
|
|
823
1003
|
};
|
|
824
1004
|
}
|
|
825
1005
|
|
|
@@ -828,8 +1008,7 @@ var defaultTokenConfigV1MintArguments = () => ({
|
|
|
828
1008
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
829
1009
|
maxTokensPerAddress: 0n,
|
|
830
1010
|
pricePerToken: 0n,
|
|
831
|
-
mintDuration:
|
|
832
|
-
// 1 week
|
|
1011
|
+
mintDuration: 0n,
|
|
833
1012
|
mintStart: 0n,
|
|
834
1013
|
royaltyMintSchedule: 0,
|
|
835
1014
|
royaltyBPS: 1e3
|
|
@@ -854,7 +1033,7 @@ var pickTokenConfigV2 = (tokenConfig) => ({
|
|
|
854
1033
|
royaltyBPS: tokenConfig.royaltyBPS,
|
|
855
1034
|
tokenURI: tokenConfig.tokenURI,
|
|
856
1035
|
payoutRecipient: tokenConfig.payoutRecipient,
|
|
857
|
-
createReferral: tokenConfig.createReferral ||
|
|
1036
|
+
createReferral: tokenConfig.createReferral || import_viem4.zeroAddress
|
|
858
1037
|
});
|
|
859
1038
|
var tokenConfigV1WithDefault = (tokenConfig, fixedPriceMinter) => ({
|
|
860
1039
|
...pickTokenConfigV1(tokenConfig),
|
|
@@ -870,8 +1049,7 @@ var defaultTokenConfigV2MintArguments = () => ({
|
|
|
870
1049
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
871
1050
|
maxTokensPerAddress: 0n,
|
|
872
1051
|
pricePerToken: 0n,
|
|
873
|
-
mintDuration:
|
|
874
|
-
// 1 week
|
|
1052
|
+
mintDuration: 0n,
|
|
875
1053
|
mintStart: 0n,
|
|
876
1054
|
royaltyBPS: 1e3
|
|
877
1055
|
// 10%,
|
|
@@ -905,7 +1083,7 @@ var makeTokenConfigWithDefaults = ({
|
|
|
905
1083
|
function getPremintedLogFromReceipt(receipt) {
|
|
906
1084
|
for (const data of receipt.logs) {
|
|
907
1085
|
try {
|
|
908
|
-
const decodedLog = (0,
|
|
1086
|
+
const decodedLog = (0, import_viem4.decodeEventLog)({
|
|
909
1087
|
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
910
1088
|
eventName: "PremintedV2",
|
|
911
1089
|
...data
|
|
@@ -918,20 +1096,17 @@ function getPremintedLogFromReceipt(receipt) {
|
|
|
918
1096
|
}
|
|
919
1097
|
}
|
|
920
1098
|
var PremintClient = class {
|
|
921
|
-
constructor(
|
|
922
|
-
|
|
923
|
-
|
|
1099
|
+
constructor({
|
|
1100
|
+
chainId,
|
|
1101
|
+
publicClient,
|
|
1102
|
+
premintApi
|
|
1103
|
+
}) {
|
|
1104
|
+
this.chainId = chainId;
|
|
1105
|
+
this.apiClient = premintApi;
|
|
924
1106
|
this.publicClient = publicClient;
|
|
925
1107
|
}
|
|
926
|
-
getDataFromPremintReceipt(receipt) {
|
|
927
|
-
|
|
928
|
-
return {
|
|
929
|
-
premintedLog,
|
|
930
|
-
urls: this.makeUrls({
|
|
931
|
-
address: premintedLog?.contractAddress,
|
|
932
|
-
tokenId: premintedLog?.tokenId
|
|
933
|
-
})
|
|
934
|
-
};
|
|
1108
|
+
getDataFromPremintReceipt(receipt, blockExplorerUrl) {
|
|
1109
|
+
return getDataFromPremintReceipt(receipt, this.chainId, blockExplorerUrl);
|
|
935
1110
|
}
|
|
936
1111
|
/**
|
|
937
1112
|
* Prepares data for updating a premint
|
|
@@ -944,7 +1119,7 @@ var PremintClient = class {
|
|
|
944
1119
|
...args,
|
|
945
1120
|
apiClient: this.apiClient,
|
|
946
1121
|
publicClient: this.publicClient,
|
|
947
|
-
chainId: this.
|
|
1122
|
+
chainId: this.chainId
|
|
948
1123
|
});
|
|
949
1124
|
}
|
|
950
1125
|
/**
|
|
@@ -958,7 +1133,7 @@ var PremintClient = class {
|
|
|
958
1133
|
...params,
|
|
959
1134
|
apiClient: this.apiClient,
|
|
960
1135
|
publicClient: this.publicClient,
|
|
961
|
-
chainId: this.
|
|
1136
|
+
chainId: this.chainId
|
|
962
1137
|
});
|
|
963
1138
|
}
|
|
964
1139
|
/**
|
|
@@ -972,7 +1147,7 @@ var PremintClient = class {
|
|
|
972
1147
|
...parameters,
|
|
973
1148
|
publicClient: this.publicClient,
|
|
974
1149
|
apiClient: this.apiClient,
|
|
975
|
-
chainId: this.
|
|
1150
|
+
chainId: this.chainId
|
|
976
1151
|
});
|
|
977
1152
|
}
|
|
978
1153
|
/**
|
|
@@ -982,63 +1157,21 @@ var PremintClient = class {
|
|
|
982
1157
|
* @param uid UID for the desired premint
|
|
983
1158
|
* @returns PremintSignatureGetResponse of premint data from the API
|
|
984
1159
|
*/
|
|
985
|
-
async
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
return await this.apiClient.getSignature({
|
|
990
|
-
collectionAddress: address,
|
|
991
|
-
uid
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
/**
|
|
995
|
-
* Gets the deterministic contract address for a premint collection
|
|
996
|
-
* @param collection Collection to get the address for
|
|
997
|
-
* @returns deterministic contract address
|
|
998
|
-
*/
|
|
999
|
-
async getCollectionAddress(collection) {
|
|
1000
|
-
return await getPremintCollectionAddress({
|
|
1001
|
-
collection,
|
|
1002
|
-
publicClient: this.publicClient
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
/**
|
|
1006
|
-
* Check user signature for v1
|
|
1007
|
-
*
|
|
1008
|
-
* @param data Signature data from the API
|
|
1009
|
-
* @returns isValid = signature is valid or not, recoveredSigner = signer from contract
|
|
1010
|
-
*/
|
|
1011
|
-
async isValidSignature({
|
|
1012
|
-
signature,
|
|
1013
|
-
premintConfig,
|
|
1014
|
-
premintConfigVersion,
|
|
1015
|
-
...collectionAndOrAddress
|
|
1016
|
-
}) {
|
|
1017
|
-
const collectionAddressToUse = await getPremintCollectionAddress({
|
|
1018
|
-
...collectionAndOrAddress,
|
|
1019
|
-
publicClient: this.publicClient
|
|
1020
|
-
});
|
|
1021
|
-
const { isAuthorized, recoveredAddress } = await isValidSignature({
|
|
1022
|
-
chainId: this.chain.id,
|
|
1023
|
-
signature,
|
|
1024
|
-
publicClient: this.publicClient,
|
|
1025
|
-
premintConfig,
|
|
1026
|
-
premintConfigVersion: premintConfigVersion || import_protocol_deployments4.PremintConfigVersion.V1,
|
|
1027
|
-
collectionAddress: collectionAddressToUse,
|
|
1028
|
-
collection: collectionAndOrAddress.collection
|
|
1160
|
+
async getPremint({ address, uid }) {
|
|
1161
|
+
return await this.apiClient.get({
|
|
1162
|
+
collectionAddress: address,
|
|
1163
|
+
uid
|
|
1029
1164
|
});
|
|
1030
|
-
return { isValid: isAuthorized, recoveredSigner: recoveredAddress };
|
|
1031
1165
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
chain: this.chain
|
|
1166
|
+
/**
|
|
1167
|
+
* Gets the deterministic contract address for a premint collection
|
|
1168
|
+
* @param collection Collection to get the address for
|
|
1169
|
+
* @returns deterministic contract address
|
|
1170
|
+
*/
|
|
1171
|
+
async getCollectionAddress(collection) {
|
|
1172
|
+
return await getPremintCollectionAddress({
|
|
1173
|
+
contract: collection,
|
|
1174
|
+
publicClient: this.publicClient
|
|
1042
1175
|
});
|
|
1043
1176
|
}
|
|
1044
1177
|
async getMintCosts({
|
|
@@ -1060,17 +1193,40 @@ var PremintClient = class {
|
|
|
1060
1193
|
* @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
|
|
1061
1194
|
* @returns receipt, log, zoraURL
|
|
1062
1195
|
*/
|
|
1063
|
-
async makeMintParameters(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1196
|
+
async makeMintParameters({
|
|
1197
|
+
minterAccount,
|
|
1198
|
+
tokenContract,
|
|
1199
|
+
uid,
|
|
1200
|
+
mintArguments,
|
|
1201
|
+
firstMinter
|
|
1202
|
+
}) {
|
|
1203
|
+
return await collectPremint({
|
|
1204
|
+
uid,
|
|
1205
|
+
tokenContract,
|
|
1206
|
+
minterAccount,
|
|
1207
|
+
quantityToMint: mintArguments?.quantityToMint || 1n,
|
|
1208
|
+
mintComment: mintArguments?.mintComment,
|
|
1209
|
+
mintReferral: mintArguments?.mintReferral,
|
|
1210
|
+
mintRecipient: mintArguments?.mintRecipient,
|
|
1211
|
+
firstMinter,
|
|
1212
|
+
premintGetter: this.apiClient,
|
|
1067
1213
|
publicClient: this.publicClient
|
|
1068
1214
|
});
|
|
1069
1215
|
}
|
|
1070
1216
|
};
|
|
1071
|
-
function
|
|
1072
|
-
const
|
|
1073
|
-
return
|
|
1217
|
+
function getDataFromPremintReceipt(receipt, chainId, blockExplorerUrl) {
|
|
1218
|
+
const premintedLog = getPremintedLogFromReceipt(receipt);
|
|
1219
|
+
return {
|
|
1220
|
+
tokenId: premintedLog?.tokenId,
|
|
1221
|
+
collectionAddres: premintedLog?.contractAddress,
|
|
1222
|
+
premintedLog,
|
|
1223
|
+
urls: makeUrls({
|
|
1224
|
+
address: premintedLog?.contractAddress,
|
|
1225
|
+
tokenId: premintedLog?.tokenId,
|
|
1226
|
+
chainId,
|
|
1227
|
+
blockExplorerUrl
|
|
1228
|
+
})
|
|
1229
|
+
};
|
|
1074
1230
|
}
|
|
1075
1231
|
function makePremintReturn({
|
|
1076
1232
|
premintConfig,
|
|
@@ -1100,7 +1256,7 @@ function makePremintReturn({
|
|
|
1100
1256
|
await submit({
|
|
1101
1257
|
signature,
|
|
1102
1258
|
checkSignature,
|
|
1103
|
-
signerAccount
|
|
1259
|
+
account: signerAccount
|
|
1104
1260
|
});
|
|
1105
1261
|
return {
|
|
1106
1262
|
signature,
|
|
@@ -1110,7 +1266,7 @@ function makePremintReturn({
|
|
|
1110
1266
|
const submit = async ({
|
|
1111
1267
|
signature,
|
|
1112
1268
|
checkSignature,
|
|
1113
|
-
|
|
1269
|
+
account
|
|
1114
1270
|
}) => {
|
|
1115
1271
|
if (checkSignature) {
|
|
1116
1272
|
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
@@ -1118,7 +1274,7 @@ function makePremintReturn({
|
|
|
1118
1274
|
additionalAdmins: collection?.additionalAdmins,
|
|
1119
1275
|
contractAdmin: collection?.contractAdmin,
|
|
1120
1276
|
publicClient,
|
|
1121
|
-
signer:
|
|
1277
|
+
signer: account
|
|
1122
1278
|
});
|
|
1123
1279
|
if (!isAuthorized) {
|
|
1124
1280
|
throw new Error("Not authorized to create premint");
|
|
@@ -1161,7 +1317,7 @@ async function signPremint({
|
|
|
1161
1317
|
};
|
|
1162
1318
|
}
|
|
1163
1319
|
async function createPremint({
|
|
1164
|
-
tokenCreationConfig,
|
|
1320
|
+
token: tokenCreationConfig,
|
|
1165
1321
|
uid,
|
|
1166
1322
|
publicClient,
|
|
1167
1323
|
apiClient,
|
|
@@ -1184,7 +1340,7 @@ async function createPremint({
|
|
|
1184
1340
|
premintConfig,
|
|
1185
1341
|
premintConfigVersion,
|
|
1186
1342
|
collectionAddress: collectionAddressToUse,
|
|
1187
|
-
collection: collectionOrAddress.
|
|
1343
|
+
collection: collectionOrAddress.contract,
|
|
1188
1344
|
publicClient,
|
|
1189
1345
|
apiClient,
|
|
1190
1346
|
chainId
|
|
@@ -1237,10 +1393,9 @@ async function updatePremint({
|
|
|
1237
1393
|
chainId
|
|
1238
1394
|
}) {
|
|
1239
1395
|
const {
|
|
1240
|
-
premintConfig,
|
|
1241
|
-
collection: collectionCreationConfig
|
|
1242
|
-
|
|
1243
|
-
} = await apiClient.getSignature({
|
|
1396
|
+
premint: { premintConfig, premintConfigVersion },
|
|
1397
|
+
collection: collectionCreationConfig
|
|
1398
|
+
} = await apiClient.get({
|
|
1244
1399
|
collectionAddress: collection,
|
|
1245
1400
|
uid
|
|
1246
1401
|
});
|
|
@@ -1268,11 +1423,10 @@ async function deletePremint({
|
|
|
1268
1423
|
chainId
|
|
1269
1424
|
}) {
|
|
1270
1425
|
const {
|
|
1271
|
-
premintConfig,
|
|
1272
|
-
premintConfigVersion,
|
|
1426
|
+
premint: { premintConfig, premintConfigVersion },
|
|
1273
1427
|
collection: collectionCreationConfig,
|
|
1274
1428
|
collectionAddress
|
|
1275
|
-
} = await apiClient.
|
|
1429
|
+
} = await apiClient.get({
|
|
1276
1430
|
collectionAddress: collection,
|
|
1277
1431
|
uid
|
|
1278
1432
|
});
|
|
@@ -1291,52 +1445,72 @@ async function deletePremint({
|
|
|
1291
1445
|
chainId
|
|
1292
1446
|
});
|
|
1293
1447
|
}
|
|
1294
|
-
async function
|
|
1448
|
+
async function collectPremint({
|
|
1295
1449
|
uid,
|
|
1296
1450
|
tokenContract,
|
|
1297
1451
|
minterAccount,
|
|
1298
|
-
|
|
1452
|
+
quantityToMint,
|
|
1453
|
+
mintComment = "",
|
|
1454
|
+
mintReferral,
|
|
1455
|
+
mintRecipient,
|
|
1299
1456
|
firstMinter,
|
|
1300
|
-
|
|
1457
|
+
premintGetter,
|
|
1301
1458
|
publicClient
|
|
1302
1459
|
}) {
|
|
1303
|
-
if (
|
|
1460
|
+
if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
|
|
1304
1461
|
throw new Error("Quantity to mint cannot be below 1");
|
|
1305
1462
|
}
|
|
1306
|
-
|
|
1307
|
-
throw new Error("Wallet not passed in");
|
|
1308
|
-
}
|
|
1309
|
-
const {
|
|
1310
|
-
premintConfig,
|
|
1311
|
-
premintConfigVersion,
|
|
1312
|
-
collection,
|
|
1313
|
-
collectionAddress,
|
|
1314
|
-
signature
|
|
1315
|
-
} = await apiClient.getSignature({
|
|
1463
|
+
const premint = await premintGetter.get({
|
|
1316
1464
|
collectionAddress: tokenContract,
|
|
1317
1465
|
uid
|
|
1318
1466
|
});
|
|
1319
|
-
const
|
|
1320
|
-
if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
|
|
1321
|
-
throw new Error("PremintV3 not supported in premint SDK");
|
|
1322
|
-
}
|
|
1323
|
-
const value = (await getPremintMintCosts({
|
|
1467
|
+
const mintFee = await getPremintMintFee({
|
|
1324
1468
|
tokenContract,
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1469
|
+
publicClient
|
|
1470
|
+
});
|
|
1471
|
+
return buildPremintMintCall({
|
|
1472
|
+
mintArguments: {
|
|
1473
|
+
minterAccount,
|
|
1474
|
+
quantityToMint,
|
|
1475
|
+
firstMinter,
|
|
1476
|
+
mintComment,
|
|
1477
|
+
mintRecipient,
|
|
1478
|
+
mintReferral
|
|
1479
|
+
},
|
|
1480
|
+
mintFee,
|
|
1481
|
+
premint
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
var buildPremintMintCall = ({
|
|
1485
|
+
mintArguments: {
|
|
1486
|
+
minterAccount,
|
|
1487
|
+
mintComment = "",
|
|
1488
|
+
mintRecipient,
|
|
1489
|
+
mintReferral,
|
|
1490
|
+
firstMinter,
|
|
1491
|
+
quantityToMint
|
|
1492
|
+
},
|
|
1493
|
+
premint: { collection, collectionAddress, premint, signature },
|
|
1494
|
+
mintFee
|
|
1495
|
+
}) => {
|
|
1329
1496
|
const mintArgumentsContract = {
|
|
1330
|
-
mintComment
|
|
1331
|
-
mintRecipient:
|
|
1497
|
+
mintComment,
|
|
1498
|
+
mintRecipient: mintRecipientOrAccount({
|
|
1499
|
+
mintRecipient,
|
|
1500
|
+
minterAccount
|
|
1501
|
+
}),
|
|
1332
1502
|
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
1333
|
-
mintReferral
|
|
1503
|
+
mintReferral
|
|
1334
1504
|
})
|
|
1335
1505
|
};
|
|
1336
1506
|
const collectionOrEmpty = collection ? defaultAdditionalAdmins(collection) : emptyContractCreationConfig();
|
|
1337
|
-
const collectionAddressToSubmit = collection ?
|
|
1507
|
+
const collectionAddressToSubmit = collection ? import_viem4.zeroAddress : collectionAddress;
|
|
1338
1508
|
const firstMinterToSubmit = firstMinter || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
1339
|
-
|
|
1509
|
+
if (premint.premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
|
|
1510
|
+
throw new Error("PremintV3 not supported in premint SDK");
|
|
1511
|
+
}
|
|
1512
|
+
const value = (mintFee + premint.premintConfig.tokenConfig.pricePerToken) * BigInt(quantityToMint);
|
|
1513
|
+
return makeContractParameters({
|
|
1340
1514
|
account: minterAccount,
|
|
1341
1515
|
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1342
1516
|
functionName: "premint",
|
|
@@ -1345,31 +1519,29 @@ async function makeMintParameters({
|
|
|
1345
1519
|
args: [
|
|
1346
1520
|
collectionOrEmpty,
|
|
1347
1521
|
collectionAddressToSubmit,
|
|
1348
|
-
(0, import_protocol_deployments3.encodePremintConfig)(
|
|
1349
|
-
premintConfig,
|
|
1350
|
-
premintConfigVersion
|
|
1351
|
-
}),
|
|
1522
|
+
(0, import_protocol_deployments3.encodePremintConfig)(premint),
|
|
1352
1523
|
signature,
|
|
1353
|
-
|
|
1524
|
+
BigInt(quantityToMint),
|
|
1354
1525
|
mintArgumentsContract,
|
|
1355
1526
|
firstMinterToSubmit,
|
|
1356
|
-
|
|
1527
|
+
import_viem4.zeroAddress
|
|
1357
1528
|
]
|
|
1358
1529
|
});
|
|
1359
|
-
}
|
|
1530
|
+
};
|
|
1360
1531
|
function makeUrls({
|
|
1361
1532
|
uid,
|
|
1362
1533
|
address,
|
|
1363
1534
|
tokenId,
|
|
1364
|
-
|
|
1535
|
+
chainId,
|
|
1536
|
+
blockExplorerUrl
|
|
1365
1537
|
}) {
|
|
1366
1538
|
if ((!uid || !tokenId) && !address) {
|
|
1367
1539
|
return { explorer: null, zoraCollect: null, zoraManage: null };
|
|
1368
1540
|
}
|
|
1369
1541
|
const zoraTokenPath = uid ? `premint-${uid}` : tokenId;
|
|
1370
|
-
const network = getApiNetworkConfigForChain(
|
|
1542
|
+
const network = getApiNetworkConfigForChain(chainId);
|
|
1371
1543
|
return {
|
|
1372
|
-
explorer: tokenId ? `https://${
|
|
1544
|
+
explorer: tokenId ? `https://${blockExplorerUrl}/token/${address}/instance/${tokenId}` : null,
|
|
1373
1545
|
zoraCollect: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`,
|
|
1374
1546
|
zoraManage: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`
|
|
1375
1547
|
};
|
|
@@ -1384,9 +1556,480 @@ var PremintConfigVersion3 = ((PremintConfigVersion4) => {
|
|
|
1384
1556
|
return PremintConfigVersion4;
|
|
1385
1557
|
})(PremintConfigVersion3 || {});
|
|
1386
1558
|
|
|
1559
|
+
// src/premint/premint-api-client.ts
|
|
1560
|
+
var postSignature = async ({
|
|
1561
|
+
httpClient: { post: post2, retries: retries2 } = httpClient,
|
|
1562
|
+
...data
|
|
1563
|
+
}) => retries2(
|
|
1564
|
+
() => post2(`${ZORA_API_BASE}premint/signature`, data)
|
|
1565
|
+
);
|
|
1566
|
+
var getNextUID = async ({
|
|
1567
|
+
chainId,
|
|
1568
|
+
collection_address,
|
|
1569
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
1570
|
+
}) => retries2(
|
|
1571
|
+
() => get2(
|
|
1572
|
+
`${ZORA_API_BASE}premint/signature/${getApiNetworkConfigForChain(chainId).zoraBackendChainName}/${collection_address}/next_uid`
|
|
1573
|
+
)
|
|
1574
|
+
);
|
|
1575
|
+
var getSignature = async ({
|
|
1576
|
+
collectionAddress,
|
|
1577
|
+
uid,
|
|
1578
|
+
chainId,
|
|
1579
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
1580
|
+
}) => {
|
|
1581
|
+
const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
|
|
1582
|
+
const result = await retries2(
|
|
1583
|
+
() => get2(
|
|
1584
|
+
`${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}/${uid}`
|
|
1585
|
+
)
|
|
1586
|
+
);
|
|
1587
|
+
return convertGetPremintApiResponse(result);
|
|
1588
|
+
};
|
|
1589
|
+
var getOfCollection = async ({
|
|
1590
|
+
collectionAddress,
|
|
1591
|
+
chainId,
|
|
1592
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
1593
|
+
}) => {
|
|
1594
|
+
const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
|
|
1595
|
+
const result = await retries2(
|
|
1596
|
+
() => get2(
|
|
1597
|
+
`${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}`
|
|
1598
|
+
)
|
|
1599
|
+
);
|
|
1600
|
+
return convertGetPremintOfCollectionApiResponse(result);
|
|
1601
|
+
};
|
|
1602
|
+
var PremintAPIClient = class {
|
|
1603
|
+
constructor(chainId, httpClient2) {
|
|
1604
|
+
this.postSignature = ({
|
|
1605
|
+
signature,
|
|
1606
|
+
...rest
|
|
1607
|
+
}) => {
|
|
1608
|
+
const data = encodePostSignatureInput({
|
|
1609
|
+
...rest,
|
|
1610
|
+
chainId: this.chainId,
|
|
1611
|
+
signature
|
|
1612
|
+
});
|
|
1613
|
+
return postSignature({
|
|
1614
|
+
...data,
|
|
1615
|
+
httpClient: this.httpClient
|
|
1616
|
+
});
|
|
1617
|
+
};
|
|
1618
|
+
this.getNextUID = async (collectionAddress) => (await getNextUID({
|
|
1619
|
+
collection_address: collectionAddress.toLowerCase(),
|
|
1620
|
+
chainId: this.chainId,
|
|
1621
|
+
httpClient: this.httpClient
|
|
1622
|
+
})).next_uid;
|
|
1623
|
+
this.get = async ({ collectionAddress, uid }) => {
|
|
1624
|
+
return getSignature({
|
|
1625
|
+
collectionAddress,
|
|
1626
|
+
uid,
|
|
1627
|
+
chainId: this.chainId,
|
|
1628
|
+
httpClient: this.httpClient
|
|
1629
|
+
});
|
|
1630
|
+
};
|
|
1631
|
+
this.getOfCollection = async ({
|
|
1632
|
+
collectionAddress
|
|
1633
|
+
}) => {
|
|
1634
|
+
return getOfCollection({
|
|
1635
|
+
collectionAddress,
|
|
1636
|
+
chainId: this.chainId,
|
|
1637
|
+
httpClient: this.httpClient
|
|
1638
|
+
});
|
|
1639
|
+
};
|
|
1640
|
+
this.chainId = chainId;
|
|
1641
|
+
this.httpClient = httpClient2 || httpClient;
|
|
1642
|
+
}
|
|
1643
|
+
};
|
|
1644
|
+
|
|
1645
|
+
// src/mint/mint-transactions.ts
|
|
1646
|
+
var import_viem5 = require("viem");
|
|
1647
|
+
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1648
|
+
|
|
1649
|
+
// src/mint/utils.ts
|
|
1650
|
+
var semver = __toESM(require("semver"), 1);
|
|
1651
|
+
var contractSupportsNewMintFunction = (contractVersion) => {
|
|
1652
|
+
if (!contractVersion) {
|
|
1653
|
+
return false;
|
|
1654
|
+
}
|
|
1655
|
+
const semVerContractVersion = semver.coerce(contractVersion)?.raw;
|
|
1656
|
+
if (!semVerContractVersion)
|
|
1657
|
+
return false;
|
|
1658
|
+
return semver.gte(semVerContractVersion, "2.9.0");
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// src/mint/mint-transactions.ts
|
|
1662
|
+
function makeOnchainMintCall({
|
|
1663
|
+
token,
|
|
1664
|
+
mintParams
|
|
1665
|
+
}) {
|
|
1666
|
+
if (token.mintType === "721") {
|
|
1667
|
+
return makePrepareMint721TokenParams({
|
|
1668
|
+
salesConfigAndTokenInfo: token,
|
|
1669
|
+
tokenContract: token.contract.address,
|
|
1670
|
+
...mintParams
|
|
1671
|
+
});
|
|
1672
|
+
}
|
|
1673
|
+
return makePrepareMint1155TokenParams({
|
|
1674
|
+
salesConfigAndTokenInfo: token,
|
|
1675
|
+
tokenContract: token.contract.address,
|
|
1676
|
+
tokenId: token.tokenId,
|
|
1677
|
+
...mintParams
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
function makePrepareMint1155TokenParams({
|
|
1681
|
+
tokenContract,
|
|
1682
|
+
tokenId,
|
|
1683
|
+
salesConfigAndTokenInfo,
|
|
1684
|
+
minterAccount,
|
|
1685
|
+
mintComment,
|
|
1686
|
+
mintReferral,
|
|
1687
|
+
mintRecipient,
|
|
1688
|
+
quantityToMint
|
|
1689
|
+
}) {
|
|
1690
|
+
const mintQuantity = BigInt(quantityToMint || 1);
|
|
1691
|
+
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
1692
|
+
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
1693
|
+
if (saleType === "fixedPrice") {
|
|
1694
|
+
return makeEthMintCall({
|
|
1695
|
+
mintComment,
|
|
1696
|
+
minterAccount,
|
|
1697
|
+
mintQuantity,
|
|
1698
|
+
mintReferral,
|
|
1699
|
+
mintTo,
|
|
1700
|
+
salesConfigAndTokenInfo,
|
|
1701
|
+
tokenContract,
|
|
1702
|
+
tokenId
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
if (saleType === "erc20") {
|
|
1706
|
+
return makeContractParameters({
|
|
1707
|
+
abi: import_protocol_deployments6.erc20MinterABI,
|
|
1708
|
+
functionName: "mint",
|
|
1709
|
+
account: minterAccount,
|
|
1710
|
+
address: salesConfigAndTokenInfo.salesConfig.address,
|
|
1711
|
+
/* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
|
|
1712
|
+
args: [
|
|
1713
|
+
mintTo,
|
|
1714
|
+
mintQuantity,
|
|
1715
|
+
tokenContract,
|
|
1716
|
+
BigInt(tokenId),
|
|
1717
|
+
salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
|
|
1718
|
+
salesConfigAndTokenInfo.salesConfig.currency,
|
|
1719
|
+
mintReferral || import_viem5.zeroAddress,
|
|
1720
|
+
mintComment || ""
|
|
1721
|
+
]
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
throw new Error("Unsupported sale type");
|
|
1725
|
+
}
|
|
1726
|
+
function makePrepareMint721TokenParams({
|
|
1727
|
+
salesConfigAndTokenInfo,
|
|
1728
|
+
minterAccount,
|
|
1729
|
+
tokenContract,
|
|
1730
|
+
mintComment,
|
|
1731
|
+
mintReferral,
|
|
1732
|
+
mintRecipient,
|
|
1733
|
+
quantityToMint
|
|
1734
|
+
}) {
|
|
1735
|
+
const actualQuantityToMint = BigInt(quantityToMint || 1);
|
|
1736
|
+
const mintValue = parseMintCosts({
|
|
1737
|
+
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1738
|
+
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1739
|
+
quantityToMint: actualQuantityToMint
|
|
1740
|
+
}).totalCostEth;
|
|
1741
|
+
return makeContractParameters({
|
|
1742
|
+
abi: zora721Abi,
|
|
1743
|
+
address: tokenContract,
|
|
1744
|
+
account: minterAccount,
|
|
1745
|
+
functionName: "mintWithRewards",
|
|
1746
|
+
value: mintValue,
|
|
1747
|
+
args: [
|
|
1748
|
+
mintRecipientOrAccount({ mintRecipient, minterAccount }),
|
|
1749
|
+
actualQuantityToMint,
|
|
1750
|
+
mintComment || "",
|
|
1751
|
+
mintReferral || import_viem5.zeroAddress
|
|
1752
|
+
]
|
|
1753
|
+
});
|
|
1754
|
+
}
|
|
1755
|
+
function makeEthMintCall({
|
|
1756
|
+
tokenContract,
|
|
1757
|
+
tokenId,
|
|
1758
|
+
salesConfigAndTokenInfo,
|
|
1759
|
+
minterAccount,
|
|
1760
|
+
mintComment,
|
|
1761
|
+
mintReferral,
|
|
1762
|
+
mintQuantity,
|
|
1763
|
+
mintTo
|
|
1764
|
+
}) {
|
|
1765
|
+
const mintValue = parseMintCosts({
|
|
1766
|
+
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1767
|
+
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1768
|
+
quantityToMint: mintQuantity
|
|
1769
|
+
}).totalCostEth;
|
|
1770
|
+
const minterArguments = (0, import_viem5.encodeAbiParameters)(
|
|
1771
|
+
(0, import_viem5.parseAbiParameters)("address, string"),
|
|
1772
|
+
[mintTo, mintComment || ""]
|
|
1773
|
+
);
|
|
1774
|
+
if (contractSupportsNewMintFunction(salesConfigAndTokenInfo.contractVersion)) {
|
|
1775
|
+
return makeContractParameters({
|
|
1776
|
+
abi: import_protocol_deployments6.zoraCreator1155ImplABI,
|
|
1777
|
+
functionName: "mint",
|
|
1778
|
+
account: minterAccount,
|
|
1779
|
+
value: mintValue,
|
|
1780
|
+
address: tokenContract,
|
|
1781
|
+
args: [
|
|
1782
|
+
salesConfigAndTokenInfo.salesConfig.address,
|
|
1783
|
+
BigInt(tokenId),
|
|
1784
|
+
mintQuantity,
|
|
1785
|
+
mintReferral ? [mintReferral] : [],
|
|
1786
|
+
minterArguments
|
|
1787
|
+
]
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1790
|
+
return makeContractParameters({
|
|
1791
|
+
abi: import_protocol_deployments6.zoraCreator1155ImplABI,
|
|
1792
|
+
functionName: "mintWithRewards",
|
|
1793
|
+
account: minterAccount,
|
|
1794
|
+
value: mintValue,
|
|
1795
|
+
address: tokenContract,
|
|
1796
|
+
/* args: minter, tokenId, quantity, minterArguments, mintReferral */
|
|
1797
|
+
args: [
|
|
1798
|
+
salesConfigAndTokenInfo.salesConfig.address,
|
|
1799
|
+
BigInt(tokenId),
|
|
1800
|
+
mintQuantity,
|
|
1801
|
+
minterArguments,
|
|
1802
|
+
mintReferral || import_viem5.zeroAddress
|
|
1803
|
+
]
|
|
1804
|
+
});
|
|
1805
|
+
}
|
|
1806
|
+
function parseMintCosts({
|
|
1807
|
+
salesConfig,
|
|
1808
|
+
mintFeePerQuantity,
|
|
1809
|
+
quantityToMint
|
|
1810
|
+
}) {
|
|
1811
|
+
const mintFeeForTokens = mintFeePerQuantity * quantityToMint;
|
|
1812
|
+
const tokenPurchaseCost = BigInt(salesConfig.pricePerToken) * quantityToMint;
|
|
1813
|
+
const totalPurchaseCostCurrency = isErc20SaleStrategy(salesConfig) ? salesConfig.currency : void 0;
|
|
1814
|
+
const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
|
|
1815
|
+
return {
|
|
1816
|
+
mintFee: mintFeeForTokens,
|
|
1817
|
+
totalPurchaseCost: tokenPurchaseCost,
|
|
1818
|
+
totalPurchaseCostCurrency,
|
|
1819
|
+
totalCostEth: mintFeeForTokens + totalPurchaseCostEth
|
|
1820
|
+
};
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
// src/mint/mint-queries.ts
|
|
1824
|
+
var import_viem6 = require("viem");
|
|
1825
|
+
async function getMint({
|
|
1826
|
+
params,
|
|
1827
|
+
mintGetter,
|
|
1828
|
+
premintGetter,
|
|
1829
|
+
publicClient
|
|
1830
|
+
}) {
|
|
1831
|
+
const { tokenContract } = params;
|
|
1832
|
+
if (isOnChainMint(params)) {
|
|
1833
|
+
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
1834
|
+
const result = await mintGetter.getMintable({
|
|
1835
|
+
tokenId,
|
|
1836
|
+
tokenAddress: tokenContract,
|
|
1837
|
+
preferredSaleType: params.preferredSaleType
|
|
1838
|
+
});
|
|
1839
|
+
return toMintableReturn(result);
|
|
1840
|
+
}
|
|
1841
|
+
const premint = await premintGetter.get({
|
|
1842
|
+
collectionAddress: tokenContract,
|
|
1843
|
+
uid: params.uid
|
|
1844
|
+
});
|
|
1845
|
+
const mintFee = await getPremintMintFee({
|
|
1846
|
+
publicClient,
|
|
1847
|
+
tokenContract
|
|
1848
|
+
});
|
|
1849
|
+
return toPremintMintReturn({ premint, mintFee });
|
|
1850
|
+
}
|
|
1851
|
+
async function getPremintsOfCollectionWithTokenIds({
|
|
1852
|
+
premintGetter,
|
|
1853
|
+
mintGetter,
|
|
1854
|
+
tokenContract
|
|
1855
|
+
}) {
|
|
1856
|
+
const { collection, premints } = await premintGetter.getOfCollection({
|
|
1857
|
+
collectionAddress: tokenContract
|
|
1858
|
+
});
|
|
1859
|
+
const premintUidsAndTokenIds = await mintGetter.getContractPremintTokenIds({
|
|
1860
|
+
tokenAddress: tokenContract
|
|
1861
|
+
});
|
|
1862
|
+
const premintsWithTokenId = premints.map((premint) => ({
|
|
1863
|
+
...premint,
|
|
1864
|
+
tokenId: premintUidsAndTokenIds.find(
|
|
1865
|
+
({ uid }) => uid === premint.premint.premintConfig.uid
|
|
1866
|
+
)?.tokenId
|
|
1867
|
+
}));
|
|
1868
|
+
return {
|
|
1869
|
+
collection,
|
|
1870
|
+
premints: premintsWithTokenId
|
|
1871
|
+
};
|
|
1872
|
+
}
|
|
1873
|
+
async function getMintsOfContract({
|
|
1874
|
+
params,
|
|
1875
|
+
mintGetter,
|
|
1876
|
+
premintGetter,
|
|
1877
|
+
publicClient
|
|
1878
|
+
}) {
|
|
1879
|
+
const onchainMints = (await mintGetter.getContractMintable({
|
|
1880
|
+
tokenAddress: params.tokenContract
|
|
1881
|
+
})).map(toMintableReturn);
|
|
1882
|
+
const offchainMints = await getPremintsOfContractMintable({
|
|
1883
|
+
mintGetter,
|
|
1884
|
+
premintGetter,
|
|
1885
|
+
publicClient,
|
|
1886
|
+
params: {
|
|
1887
|
+
tokenContract: params.tokenContract
|
|
1888
|
+
}
|
|
1889
|
+
});
|
|
1890
|
+
const tokens = [...onchainMints, ...offchainMints];
|
|
1891
|
+
return {
|
|
1892
|
+
tokens,
|
|
1893
|
+
contract: tokens[0]?.token.contract
|
|
1894
|
+
};
|
|
1895
|
+
}
|
|
1896
|
+
async function getMintCosts({
|
|
1897
|
+
params,
|
|
1898
|
+
mintGetter,
|
|
1899
|
+
premintGetter,
|
|
1900
|
+
publicClient
|
|
1901
|
+
}) {
|
|
1902
|
+
const { quantityMinted: quantityToMint, collection } = params;
|
|
1903
|
+
if (isOnChainMint(params)) {
|
|
1904
|
+
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
1905
|
+
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
1906
|
+
tokenId,
|
|
1907
|
+
tokenAddress: collection
|
|
1908
|
+
});
|
|
1909
|
+
return parseMintCosts({
|
|
1910
|
+
mintFeePerQuantity: salesConfigAndTokenInfo.mintFeePerQuantity,
|
|
1911
|
+
salesConfig: salesConfigAndTokenInfo.salesConfig,
|
|
1912
|
+
quantityToMint: BigInt(quantityToMint)
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
return getPremintMintCostsWithUnknownTokenPrice({
|
|
1916
|
+
premintGetter,
|
|
1917
|
+
publicClient,
|
|
1918
|
+
quantityToMint: BigInt(quantityToMint),
|
|
1919
|
+
uid: params.uid,
|
|
1920
|
+
tokenContract: collection
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
async function getPremintsOfContractMintable({
|
|
1924
|
+
mintGetter,
|
|
1925
|
+
premintGetter,
|
|
1926
|
+
publicClient,
|
|
1927
|
+
params
|
|
1928
|
+
}) {
|
|
1929
|
+
const { premints, collection } = await getPremintsOfCollectionWithTokenIds({
|
|
1930
|
+
mintGetter,
|
|
1931
|
+
premintGetter,
|
|
1932
|
+
tokenContract: params.tokenContract
|
|
1933
|
+
});
|
|
1934
|
+
const offChainPremints = premints.filter(
|
|
1935
|
+
(premint) => (
|
|
1936
|
+
// if premint's uid is not in the list of uids from the subgraph, it is offchain
|
|
1937
|
+
typeof premint.tokenId === "undefined"
|
|
1938
|
+
)
|
|
1939
|
+
);
|
|
1940
|
+
if (offChainPremints.length === 0)
|
|
1941
|
+
return [];
|
|
1942
|
+
const mintFee = await getPremintMintFee({
|
|
1943
|
+
publicClient,
|
|
1944
|
+
tokenContract: params.tokenContract
|
|
1945
|
+
});
|
|
1946
|
+
return offChainPremints.map((premint) => {
|
|
1947
|
+
return toPremintMintReturn({
|
|
1948
|
+
premint: {
|
|
1949
|
+
premint: premint.premint,
|
|
1950
|
+
// todo: fix when api returns signer
|
|
1951
|
+
signer: import_viem6.zeroAddress,
|
|
1952
|
+
collection,
|
|
1953
|
+
collectionAddress: params.tokenContract,
|
|
1954
|
+
signature: premint.signature
|
|
1955
|
+
},
|
|
1956
|
+
mintFee
|
|
1957
|
+
});
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
function parsePremint({
|
|
1961
|
+
premint,
|
|
1962
|
+
mintFee
|
|
1963
|
+
}) {
|
|
1964
|
+
if (isPremintConfigV1(premint.premint) || isPremintConfigV2(premint.premint)) {
|
|
1965
|
+
return {
|
|
1966
|
+
creator: premint.signer,
|
|
1967
|
+
maxSupply: premint.premint.premintConfig.tokenConfig.maxSupply,
|
|
1968
|
+
mintFeePerQuantity: mintFee,
|
|
1969
|
+
mintType: "premint",
|
|
1970
|
+
uid: premint.premint.premintConfig.uid,
|
|
1971
|
+
contract: {
|
|
1972
|
+
address: premint.collectionAddress,
|
|
1973
|
+
name: premint.collection.contractName,
|
|
1974
|
+
URI: premint.collection.contractURI
|
|
1975
|
+
},
|
|
1976
|
+
tokenURI: premint.premint.premintConfig.tokenConfig.tokenURI,
|
|
1977
|
+
totalMinted: 0n,
|
|
1978
|
+
salesConfig: {
|
|
1979
|
+
duration: premint.premint.premintConfig.tokenConfig.mintDuration,
|
|
1980
|
+
maxTokensPerAddress: premint.premint.premintConfig.tokenConfig.maxTokensPerAddress,
|
|
1981
|
+
pricePerToken: premint.premint.premintConfig.tokenConfig.pricePerToken,
|
|
1982
|
+
saleType: "premint"
|
|
1983
|
+
}
|
|
1984
|
+
};
|
|
1985
|
+
}
|
|
1986
|
+
throw new Error("Invalid premint config version");
|
|
1987
|
+
}
|
|
1988
|
+
var makeOnchainPrepareMint = (result) => (params) => ({
|
|
1989
|
+
parameters: makeOnchainMintCall({ token: result, mintParams: params }),
|
|
1990
|
+
erc20Approval: getRequiredErc20Approvals(params, result),
|
|
1991
|
+
costs: parseMintCosts({
|
|
1992
|
+
salesConfig: result.salesConfig,
|
|
1993
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
1994
|
+
mintFeePerQuantity: result.mintFeePerQuantity
|
|
1995
|
+
})
|
|
1996
|
+
});
|
|
1997
|
+
function toMintableReturn(result) {
|
|
1998
|
+
return { token: result, prepareMint: makeOnchainPrepareMint(result) };
|
|
1999
|
+
}
|
|
2000
|
+
var makePremintPrepareMint = (mintable, mintFee, premint) => (params) => ({
|
|
2001
|
+
parameters: buildPremintMintCall({
|
|
2002
|
+
mintArguments: params,
|
|
2003
|
+
mintFee,
|
|
2004
|
+
premint
|
|
2005
|
+
}),
|
|
2006
|
+
costs: parseMintCosts({
|
|
2007
|
+
mintFeePerQuantity: mintFee,
|
|
2008
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
2009
|
+
salesConfig: mintable.salesConfig
|
|
2010
|
+
})
|
|
2011
|
+
});
|
|
2012
|
+
function toPremintMintReturn({
|
|
2013
|
+
premint,
|
|
2014
|
+
mintFee
|
|
2015
|
+
}) {
|
|
2016
|
+
const mintable = parsePremint({ premint, mintFee });
|
|
2017
|
+
return {
|
|
2018
|
+
token: mintable,
|
|
2019
|
+
prepareMint: makePremintPrepareMint(mintable, mintFee, premint)
|
|
2020
|
+
};
|
|
2021
|
+
}
|
|
2022
|
+
function getRequiredErc20Approvals(params, result) {
|
|
2023
|
+
if (result.salesConfig.saleType !== "erc20")
|
|
2024
|
+
return void 0;
|
|
2025
|
+
return {
|
|
2026
|
+
quantity: result.salesConfig.pricePerToken * BigInt(params.quantityToMint),
|
|
2027
|
+
approveTo: result.salesConfig.address,
|
|
2028
|
+
erc20: result.salesConfig.currency
|
|
2029
|
+
};
|
|
2030
|
+
}
|
|
2031
|
+
|
|
1387
2032
|
// src/mint/mint-client.ts
|
|
1388
|
-
var import_viem6 = require("viem");
|
|
1389
|
-
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1390
2033
|
var MintError = class extends Error {
|
|
1391
2034
|
};
|
|
1392
2035
|
var MintInactiveError = class extends Error {
|
|
@@ -1396,260 +2039,439 @@ var Errors = {
|
|
|
1396
2039
|
MintInactiveError
|
|
1397
2040
|
};
|
|
1398
2041
|
var MintClient = class {
|
|
1399
|
-
constructor(
|
|
1400
|
-
|
|
2042
|
+
constructor({
|
|
2043
|
+
publicClient,
|
|
2044
|
+
premintGetter,
|
|
2045
|
+
mintGetter
|
|
2046
|
+
}) {
|
|
1401
2047
|
this.publicClient = publicClient;
|
|
2048
|
+
this.mintGetter = mintGetter;
|
|
2049
|
+
this.premintGetter = premintGetter;
|
|
1402
2050
|
}
|
|
1403
2051
|
/**
|
|
1404
2052
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
2053
|
+
* Works with premint, onchain 1155, and onchain 721.
|
|
1405
2054
|
*
|
|
1406
|
-
* @param parameters - Parameters for collecting the token {@link
|
|
1407
|
-
* @returns Parameters for simulating/executing the mint transaction
|
|
2055
|
+
* @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
|
|
2056
|
+
* @returns Parameters for simulating/executing the mint transaction, any necessary erc20 approval, and costs to mint
|
|
1408
2057
|
*/
|
|
1409
|
-
async
|
|
1410
|
-
return
|
|
1411
|
-
|
|
1412
|
-
|
|
2058
|
+
async mint(parameters) {
|
|
2059
|
+
return mint({
|
|
2060
|
+
parameters,
|
|
2061
|
+
publicClient: this.publicClient,
|
|
2062
|
+
mintGetter: this.mintGetter,
|
|
2063
|
+
premintGetter: this.premintGetter
|
|
2064
|
+
});
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Gets an 1155, 721, or premint, and returns both information about it, and a function
|
|
2068
|
+
* that can be used to build a mint transaction for a quantity of items to mint.
|
|
2069
|
+
* @param parameters - Token to get {@link GetMintParameters}
|
|
2070
|
+
* @Returns Information about the mint and a function to build a mint transaction {@link MintableReturn}
|
|
2071
|
+
*/
|
|
2072
|
+
async get(parameters) {
|
|
2073
|
+
return getMint({
|
|
2074
|
+
params: parameters,
|
|
2075
|
+
mintGetter: this.mintGetter,
|
|
2076
|
+
premintGetter: this.premintGetter,
|
|
2077
|
+
publicClient: this.publicClient
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
/**
|
|
2081
|
+
* Gets onchain and premint tokens of an 1155 contract. For each token returns both information about it, and a function
|
|
2082
|
+
* that can be used to build a mint transaction for a quantity of items to mint.
|
|
2083
|
+
* @param parameters - Contract address to get tokens for {@link GetMintsOfContractParameters}
|
|
2084
|
+
* @Returns Array of tokens, each containing information about the token and a function to build a mint transaction.
|
|
2085
|
+
*/
|
|
2086
|
+
async getOfContract(params) {
|
|
2087
|
+
return getMintsOfContract({
|
|
2088
|
+
params,
|
|
2089
|
+
mintGetter: this.mintGetter,
|
|
2090
|
+
premintGetter: this.premintGetter,
|
|
2091
|
+
publicClient: this.publicClient
|
|
2092
|
+
});
|
|
2093
|
+
}
|
|
2094
|
+
/**
|
|
2095
|
+
* Gets the costs to mint the quantity of tokens specified for a mint.
|
|
2096
|
+
* @param parameters - Parameters for the mint {@link GetMintCostsParameters}
|
|
2097
|
+
* @returns Costs to mint the quantity of tokens specified
|
|
2098
|
+
*/
|
|
2099
|
+
async getMintCosts(parameters) {
|
|
2100
|
+
return getMintCosts({
|
|
2101
|
+
params: parameters,
|
|
2102
|
+
mintGetter: this.mintGetter,
|
|
2103
|
+
premintGetter: this.premintGetter,
|
|
1413
2104
|
publicClient: this.publicClient
|
|
1414
2105
|
});
|
|
1415
2106
|
}
|
|
1416
2107
|
};
|
|
1417
|
-
function
|
|
1418
|
-
|
|
1419
|
-
return new MintClient(chain, publicClient, httpClient2);
|
|
1420
|
-
}
|
|
1421
|
-
async function makePrepareMintTokenParams({
|
|
2108
|
+
async function mint({
|
|
2109
|
+
parameters,
|
|
1422
2110
|
publicClient,
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
tokenAddress,
|
|
1426
|
-
mintArguments,
|
|
1427
|
-
...rest
|
|
2111
|
+
mintGetter,
|
|
2112
|
+
premintGetter
|
|
1428
2113
|
}) {
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
2114
|
+
const { prepareMint } = await getMint({
|
|
2115
|
+
params: parameters,
|
|
2116
|
+
mintGetter,
|
|
2117
|
+
premintGetter,
|
|
2118
|
+
publicClient
|
|
1433
2119
|
});
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
2120
|
+
return prepareMint({
|
|
2121
|
+
minterAccount: parameters.minterAccount,
|
|
2122
|
+
quantityToMint: parameters.quantityToMint,
|
|
2123
|
+
firstMinter: parameters.firstMinter,
|
|
2124
|
+
mintComment: parameters.mintComment,
|
|
2125
|
+
mintRecipient: parameters.mintRecipient,
|
|
2126
|
+
mintReferral: parameters.mintReferral
|
|
2127
|
+
});
|
|
2128
|
+
}
|
|
2129
|
+
async function collectOnchain({
|
|
2130
|
+
chainId,
|
|
2131
|
+
mintGetter,
|
|
2132
|
+
...parameters
|
|
2133
|
+
}) {
|
|
2134
|
+
const { tokenContract, preferredSaleType: saleType } = parameters;
|
|
2135
|
+
const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
|
|
2136
|
+
const salesConfigAndTokenInfo = await mintGetter.getMintable({
|
|
1445
2137
|
tokenId,
|
|
1446
|
-
|
|
1447
|
-
|
|
2138
|
+
tokenAddress: tokenContract,
|
|
2139
|
+
preferredSaleType: saleType
|
|
2140
|
+
});
|
|
2141
|
+
return makeOnchainMintCall({
|
|
2142
|
+
mintParams: parameters,
|
|
2143
|
+
token: salesConfigAndTokenInfo
|
|
1448
2144
|
});
|
|
1449
2145
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
2146
|
+
|
|
2147
|
+
// src/create/1155-create-helper.ts
|
|
2148
|
+
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
2149
|
+
var import_viem8 = require("viem");
|
|
2150
|
+
|
|
2151
|
+
// src/create/contract-setup.ts
|
|
2152
|
+
var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
|
|
2153
|
+
function new1155ContractVersion(chainId) {
|
|
2154
|
+
const address = import_protocol_deployments7.contracts1155.addresses[chainId];
|
|
2155
|
+
if (!address) {
|
|
2156
|
+
throw new Error(`No contract address for chainId ${chainId}`);
|
|
2157
|
+
}
|
|
2158
|
+
return address.CONTRACT_1155_IMPL_VERSION;
|
|
2159
|
+
}
|
|
2160
|
+
async function getContractInfo({
|
|
2161
|
+
publicClient,
|
|
2162
|
+
chainId,
|
|
2163
|
+
contract,
|
|
2164
|
+
account
|
|
1455
2165
|
}) {
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
abi: zora721Abi,
|
|
1462
|
-
address: tokenAddress,
|
|
1463
|
-
account: minterAccount,
|
|
1464
|
-
functionName: "mintWithRewards",
|
|
1465
|
-
value: mintValue,
|
|
2166
|
+
const contractAddress = typeof contract === "string" ? contract : await publicClient.readContract({
|
|
2167
|
+
abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
|
|
2168
|
+
// Since this address is deterministic we can hardcode a chain id safely here.
|
|
2169
|
+
address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[chainId],
|
|
2170
|
+
functionName: "deterministicContractAddress",
|
|
1466
2171
|
args: [
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
2172
|
+
account,
|
|
2173
|
+
contract.uri,
|
|
2174
|
+
contract.name,
|
|
2175
|
+
contract.defaultAdmin || account
|
|
1471
2176
|
]
|
|
1472
2177
|
});
|
|
2178
|
+
let contractVersion;
|
|
2179
|
+
let contractExists;
|
|
2180
|
+
try {
|
|
2181
|
+
contractVersion = await publicClient.readContract({
|
|
2182
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
2183
|
+
address: contractAddress,
|
|
2184
|
+
functionName: "contractVersion"
|
|
2185
|
+
});
|
|
2186
|
+
contractExists = true;
|
|
2187
|
+
} catch (e) {
|
|
2188
|
+
contractVersion = new1155ContractVersion(chainId);
|
|
2189
|
+
contractExists = false;
|
|
2190
|
+
}
|
|
2191
|
+
const nextTokenId = contractExists ? await publicClient.readContract({
|
|
2192
|
+
address: contractAddress,
|
|
2193
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
2194
|
+
functionName: "nextTokenId"
|
|
2195
|
+
}) : 1n;
|
|
2196
|
+
return {
|
|
2197
|
+
contractExists,
|
|
2198
|
+
contractAddress,
|
|
2199
|
+
contractVersion,
|
|
2200
|
+
nextTokenId
|
|
2201
|
+
};
|
|
1473
2202
|
}
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
2203
|
+
|
|
2204
|
+
// src/create/token-setup.ts
|
|
2205
|
+
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
2206
|
+
var import_viem7 = require("viem");
|
|
2207
|
+
var semver2 = __toESM(require("semver"), 1);
|
|
2208
|
+
var PERMISSION_BITS = {
|
|
2209
|
+
MINTER: 2n ** 2n
|
|
2210
|
+
};
|
|
2211
|
+
var saleSettingsOrDefault = (saleSettings) => {
|
|
2212
|
+
const SALE_END_FOREVER = 18446744073709551615n;
|
|
2213
|
+
const DEFAULT_SALE_SETTINGS = {
|
|
2214
|
+
currency: import_viem7.zeroAddress,
|
|
2215
|
+
// Free Mint
|
|
2216
|
+
pricePerToken: 0n,
|
|
2217
|
+
// Sale start time – defaults to beginning of unix time
|
|
2218
|
+
saleStart: 0n,
|
|
2219
|
+
// This is the end of uint64, plenty of time
|
|
2220
|
+
saleEnd: SALE_END_FOREVER,
|
|
2221
|
+
// 0 Here means no limit
|
|
2222
|
+
maxTokensPerAddress: 0n
|
|
2223
|
+
};
|
|
2224
|
+
return {
|
|
2225
|
+
...DEFAULT_SALE_SETTINGS,
|
|
2226
|
+
...saleSettings
|
|
2227
|
+
};
|
|
2228
|
+
};
|
|
2229
|
+
function applyNew1155Defaults(props, ownerAddress) {
|
|
2230
|
+
const { payoutRecipient: fundsRecipient } = props;
|
|
2231
|
+
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem7.zeroAddress ? fundsRecipient : ownerAddress;
|
|
2232
|
+
return {
|
|
2233
|
+
payoutRecipient: fundsRecipientOrOwner,
|
|
2234
|
+
createReferral: props.createReferral || import_viem7.zeroAddress,
|
|
2235
|
+
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
2236
|
+
royaltyBPS: props.royaltyBPS || 1e3,
|
|
2237
|
+
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
2238
|
+
tokenMetadataURI: props.tokenMetadataURI
|
|
2239
|
+
};
|
|
2240
|
+
}
|
|
2241
|
+
function setupErc20Minter({
|
|
2242
|
+
pricePerToken,
|
|
2243
|
+
chainId,
|
|
2244
|
+
tokenId: nextTokenId,
|
|
2245
|
+
currency,
|
|
2246
|
+
saleStart,
|
|
2247
|
+
saleEnd,
|
|
2248
|
+
maxTokensPerAddress: mintLimit,
|
|
2249
|
+
fundsRecipient
|
|
1477
2250
|
}) {
|
|
1478
|
-
const
|
|
1479
|
-
|
|
2251
|
+
const erc20MinterAddress = import_protocol_deployments8.erc20MinterAddress[chainId];
|
|
2252
|
+
if (!erc20MinterAddress)
|
|
2253
|
+
throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
|
|
2254
|
+
const erc20MinterApproval = (0, import_viem7.encodeFunctionData)({
|
|
2255
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2256
|
+
functionName: "addPermission",
|
|
2257
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
|
|
2258
|
+
});
|
|
2259
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
2260
|
+
abi: import_protocol_deployments8.erc20MinterABI,
|
|
2261
|
+
functionName: "setSale",
|
|
2262
|
+
args: [
|
|
2263
|
+
BigInt(nextTokenId),
|
|
2264
|
+
{
|
|
2265
|
+
saleStart: saleStart || BigInt(0),
|
|
2266
|
+
saleEnd: saleEnd || BigInt(0),
|
|
2267
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
2268
|
+
pricePerToken,
|
|
2269
|
+
fundsRecipient,
|
|
2270
|
+
currency
|
|
2271
|
+
}
|
|
2272
|
+
]
|
|
2273
|
+
});
|
|
2274
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
2275
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2276
|
+
functionName: "callSale",
|
|
2277
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
|
|
2278
|
+
});
|
|
1480
2279
|
return {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
totalCost: mintFeeForTokens + tokenPurchaseCost
|
|
2280
|
+
minter: erc20MinterAddress,
|
|
2281
|
+
setupActions: [erc20MinterApproval, callSale]
|
|
1484
2282
|
};
|
|
1485
2283
|
}
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
2284
|
+
function setupFixedPriceMinter({
|
|
2285
|
+
pricePerToken: price,
|
|
2286
|
+
tokenId: nextTokenId,
|
|
2287
|
+
chainId,
|
|
2288
|
+
saleStart,
|
|
2289
|
+
saleEnd,
|
|
2290
|
+
maxTokensPerAddress: mintLimit,
|
|
2291
|
+
fundsRecipient
|
|
1492
2292
|
}) {
|
|
1493
|
-
const
|
|
1494
|
-
const
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
2293
|
+
const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
2294
|
+
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
2295
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2296
|
+
functionName: "addPermission",
|
|
2297
|
+
args: [
|
|
2298
|
+
BigInt(nextTokenId),
|
|
2299
|
+
fixedPriceStrategyAddress,
|
|
2300
|
+
PERMISSION_BITS.MINTER
|
|
2301
|
+
]
|
|
2302
|
+
});
|
|
2303
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
2304
|
+
abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
|
|
2305
|
+
functionName: "setSale",
|
|
2306
|
+
args: [
|
|
2307
|
+
BigInt(nextTokenId),
|
|
2308
|
+
{
|
|
2309
|
+
pricePerToken: price,
|
|
2310
|
+
saleStart: saleStart || BigInt(0),
|
|
2311
|
+
saleEnd: saleEnd || BigInt(0),
|
|
2312
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
2313
|
+
fundsRecipient
|
|
2314
|
+
}
|
|
2315
|
+
]
|
|
2316
|
+
});
|
|
2317
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
2318
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2319
|
+
functionName: "callSale",
|
|
2320
|
+
args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
|
|
2321
|
+
});
|
|
2322
|
+
return {
|
|
2323
|
+
minter: fixedPriceStrategyAddress,
|
|
2324
|
+
setupActions: [fixedPriceApproval, callSale]
|
|
2325
|
+
};
|
|
2326
|
+
}
|
|
2327
|
+
function setupMinters({ salesConfig, ...rest }) {
|
|
2328
|
+
if (!salesConfig)
|
|
2329
|
+
throw new Error("No sales config for token");
|
|
2330
|
+
const { currency: currencyAddress } = salesConfig;
|
|
2331
|
+
if (currencyAddress === import_viem7.zeroAddress) {
|
|
2332
|
+
return setupFixedPriceMinter({
|
|
2333
|
+
...salesConfig,
|
|
2334
|
+
...rest
|
|
2335
|
+
});
|
|
2336
|
+
} else {
|
|
2337
|
+
return setupErc20Minter({
|
|
2338
|
+
...salesConfig,
|
|
2339
|
+
...rest
|
|
2340
|
+
});
|
|
1540
2341
|
}
|
|
1541
2342
|
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
1548
|
-
var DEFAULT_SALE_SETTINGS = {
|
|
1549
|
-
fundsRecipient: import_viem7.zeroAddress,
|
|
1550
|
-
// Free Mint
|
|
1551
|
-
pricePerToken: 0n,
|
|
1552
|
-
// Sale start time – defaults to beginning of unix time
|
|
1553
|
-
saleStart: 0n,
|
|
1554
|
-
// This is the end of uint64, plenty of time
|
|
1555
|
-
saleEnd: SALE_END_FOREVER,
|
|
1556
|
-
// 0 Here means no limit
|
|
1557
|
-
maxTokensPerAddress: 0n
|
|
1558
|
-
};
|
|
1559
|
-
var PERMISSION_BIT_MINTER = 4n;
|
|
1560
|
-
function create1155TokenSetupArgs({
|
|
1561
|
-
nextTokenId,
|
|
1562
|
-
// How many NFTs upon initialization to mint to the creator
|
|
1563
|
-
mintToCreatorCount,
|
|
1564
|
-
tokenMetadataURI,
|
|
1565
|
-
// Fixed price minter address – required minter
|
|
1566
|
-
fixedPriceMinterAddress,
|
|
1567
|
-
// Address to use as the create referral, optional.
|
|
1568
|
-
createReferral,
|
|
1569
|
-
// Optional max supply of the token. Default unlimited
|
|
1570
|
-
maxSupply,
|
|
1571
|
-
// wallet sending the transaction
|
|
1572
|
-
account,
|
|
1573
|
-
salesConfig,
|
|
1574
|
-
royaltySettings
|
|
2343
|
+
function buildSetupNewToken({
|
|
2344
|
+
tokenURI,
|
|
2345
|
+
maxSupply = OPEN_EDITION_MINT_SIZE,
|
|
2346
|
+
createReferral = import_viem7.zeroAddress,
|
|
2347
|
+
contractVersion
|
|
1575
2348
|
}) {
|
|
1576
|
-
if (
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
maxSupply = BigInt(maxSupply);
|
|
1580
|
-
mintToCreatorCount = BigInt(mintToCreatorCount);
|
|
1581
|
-
const salesConfigWithDefaults = {
|
|
1582
|
-
// Set static sales default.
|
|
1583
|
-
...DEFAULT_SALE_SETTINGS,
|
|
1584
|
-
// Override with user settings.
|
|
1585
|
-
...salesConfig
|
|
1586
|
-
};
|
|
1587
|
-
const setupActions = [
|
|
1588
|
-
(0, import_viem7.encodeFunctionData)({
|
|
1589
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1590
|
-
functionName: "assumeLastTokenIdMatches",
|
|
1591
|
-
args: [nextTokenId - 1n]
|
|
1592
|
-
}),
|
|
1593
|
-
createReferral ? (0, import_viem7.encodeFunctionData)({
|
|
1594
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
2349
|
+
if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
|
|
2350
|
+
return (0, import_viem7.encodeFunctionData)({
|
|
2351
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1595
2352
|
functionName: "setupNewTokenWithCreateReferral",
|
|
1596
|
-
args: [
|
|
1597
|
-
})
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
2353
|
+
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
2354
|
+
});
|
|
2355
|
+
}
|
|
2356
|
+
if (createReferral !== import_viem7.zeroAddress) {
|
|
2357
|
+
throw new Error(
|
|
2358
|
+
"Contract does not support create referral, but one was provided"
|
|
2359
|
+
);
|
|
2360
|
+
}
|
|
2361
|
+
return (0, import_viem7.encodeFunctionData)({
|
|
2362
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2363
|
+
functionName: "setupNewToken",
|
|
2364
|
+
args: [tokenURI, BigInt(maxSupply)]
|
|
2365
|
+
});
|
|
2366
|
+
}
|
|
2367
|
+
function setupRoyaltyConfig({
|
|
2368
|
+
royaltyBPS,
|
|
2369
|
+
royaltyRecipient,
|
|
2370
|
+
nextTokenId
|
|
2371
|
+
}) {
|
|
2372
|
+
if (royaltyBPS > 0 && royaltyRecipient != import_viem7.zeroAddress) {
|
|
2373
|
+
return (0, import_viem7.encodeFunctionData)({
|
|
2374
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2375
|
+
functionName: "updateRoyaltiesForToken",
|
|
1610
2376
|
args: [
|
|
1611
2377
|
nextTokenId,
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
})
|
|
2378
|
+
{
|
|
2379
|
+
royaltyBPS,
|
|
2380
|
+
royaltyRecipient,
|
|
2381
|
+
royaltyMintSchedule: 0
|
|
2382
|
+
}
|
|
1618
2383
|
]
|
|
1619
|
-
})
|
|
1620
|
-
];
|
|
1621
|
-
if (mintToCreatorCount) {
|
|
1622
|
-
setupActions.push(
|
|
1623
|
-
(0, import_viem7.encodeFunctionData)({
|
|
1624
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1625
|
-
functionName: "adminMint",
|
|
1626
|
-
args: [account, nextTokenId, mintToCreatorCount, "0x"]
|
|
1627
|
-
})
|
|
1628
|
-
);
|
|
2384
|
+
});
|
|
1629
2385
|
}
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
royaltyBPS: royaltySettings?.royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
1640
|
-
royaltyRecipient: royaltySettings?.royaltyRecipient || account
|
|
1641
|
-
}
|
|
1642
|
-
]
|
|
1643
|
-
})
|
|
1644
|
-
);
|
|
2386
|
+
return null;
|
|
2387
|
+
}
|
|
2388
|
+
function makeAdminMintCall({
|
|
2389
|
+
ownerAddress,
|
|
2390
|
+
mintQuantity,
|
|
2391
|
+
nextTokenId
|
|
2392
|
+
}) {
|
|
2393
|
+
if (!mintQuantity || mintQuantity <= 0 || !ownerAddress) {
|
|
2394
|
+
return null;
|
|
1645
2395
|
}
|
|
1646
|
-
return
|
|
2396
|
+
return (0, import_viem7.encodeFunctionData)({
|
|
2397
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2398
|
+
functionName: "adminMint",
|
|
2399
|
+
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem7.zeroAddress]
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
function constructCreate1155TokenCalls(props) {
|
|
2403
|
+
const {
|
|
2404
|
+
chainId,
|
|
2405
|
+
nextTokenId,
|
|
2406
|
+
mintToCreatorCount,
|
|
2407
|
+
ownerAddress,
|
|
2408
|
+
contractVersion
|
|
2409
|
+
} = props;
|
|
2410
|
+
const new1155TokenPropsWithDefaults = applyNew1155Defaults(
|
|
2411
|
+
props,
|
|
2412
|
+
ownerAddress
|
|
2413
|
+
);
|
|
2414
|
+
const verifyTokenIdExpected = (0, import_viem7.encodeFunctionData)({
|
|
2415
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
2416
|
+
functionName: "assumeLastTokenIdMatches",
|
|
2417
|
+
args: [nextTokenId - 1n]
|
|
2418
|
+
});
|
|
2419
|
+
const setupNewToken = buildSetupNewToken({
|
|
2420
|
+
tokenURI: new1155TokenPropsWithDefaults.tokenMetadataURI,
|
|
2421
|
+
maxSupply: new1155TokenPropsWithDefaults.maxSupply,
|
|
2422
|
+
createReferral: new1155TokenPropsWithDefaults.createReferral,
|
|
2423
|
+
contractVersion
|
|
2424
|
+
});
|
|
2425
|
+
const royaltyConfig = setupRoyaltyConfig({
|
|
2426
|
+
royaltyBPS: new1155TokenPropsWithDefaults.royaltyBPS,
|
|
2427
|
+
royaltyRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
2428
|
+
nextTokenId
|
|
2429
|
+
});
|
|
2430
|
+
const { minter, setupActions: mintersSetup } = setupMinters({
|
|
2431
|
+
tokenId: nextTokenId,
|
|
2432
|
+
chainId,
|
|
2433
|
+
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
2434
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
2435
|
+
});
|
|
2436
|
+
const adminMintCall = makeAdminMintCall({
|
|
2437
|
+
ownerAddress,
|
|
2438
|
+
mintQuantity: mintToCreatorCount,
|
|
2439
|
+
nextTokenId
|
|
2440
|
+
});
|
|
2441
|
+
const setupActions = [
|
|
2442
|
+
verifyTokenIdExpected,
|
|
2443
|
+
setupNewToken,
|
|
2444
|
+
...mintersSetup,
|
|
2445
|
+
royaltyConfig,
|
|
2446
|
+
adminMintCall
|
|
2447
|
+
].filter((item) => item !== null);
|
|
2448
|
+
return {
|
|
2449
|
+
setupActions,
|
|
2450
|
+
minter,
|
|
2451
|
+
newToken: new1155TokenPropsWithDefaults
|
|
2452
|
+
};
|
|
1647
2453
|
}
|
|
2454
|
+
var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
2455
|
+
if (!contractStandard || !contractVersion) {
|
|
2456
|
+
return false;
|
|
2457
|
+
}
|
|
2458
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
2459
|
+
if (!semVerContractVersion)
|
|
2460
|
+
return false;
|
|
2461
|
+
if (contractStandard === "ERC1155") {
|
|
2462
|
+
return semver2.gte(semVerContractVersion, "1.3.5");
|
|
2463
|
+
} else {
|
|
2464
|
+
return semver2.gte(semVerContractVersion, "14.0.0");
|
|
2465
|
+
}
|
|
2466
|
+
};
|
|
2467
|
+
|
|
2468
|
+
// src/create/1155-create-helper.ts
|
|
2469
|
+
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
1648
2470
|
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
1649
2471
|
for (const data of receipt.logs) {
|
|
1650
2472
|
try {
|
|
1651
|
-
const decodedLog = (0,
|
|
1652
|
-
abi:
|
|
2473
|
+
const decodedLog = (0, import_viem8.decodeEventLog)({
|
|
2474
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
1653
2475
|
eventName: "SetupNewToken",
|
|
1654
2476
|
...data
|
|
1655
2477
|
});
|
|
@@ -1660,132 +2482,116 @@ var getTokenIdFromCreateReceipt = (receipt) => {
|
|
|
1660
2482
|
}
|
|
1661
2483
|
}
|
|
1662
2484
|
};
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
2485
|
+
function makeCreateContractAndTokenCall({
|
|
2486
|
+
contractExists,
|
|
2487
|
+
contractAddress,
|
|
2488
|
+
contract,
|
|
2489
|
+
account,
|
|
2490
|
+
royaltyBPS,
|
|
2491
|
+
tokenSetupActions,
|
|
2492
|
+
fundsRecipient
|
|
2493
|
+
}) {
|
|
2494
|
+
if (!contractAddress && typeof contract === "string") {
|
|
2495
|
+
throw new Error("Invariant: contract cannot be missing and an address");
|
|
2496
|
+
}
|
|
2497
|
+
if (!contractExists) {
|
|
2498
|
+
if (typeof contract === "string") {
|
|
2499
|
+
throw new Error("Invariant: expected contract object");
|
|
2500
|
+
}
|
|
2501
|
+
const accountAddress = typeof account === "string" ? account : account.address;
|
|
2502
|
+
return makeContractParameters({
|
|
2503
|
+
abi: import_protocol_deployments9.zoraCreator1155FactoryImplABI,
|
|
2504
|
+
functionName: "createContractDeterministic",
|
|
2505
|
+
account,
|
|
2506
|
+
address: import_protocol_deployments9.zoraCreator1155FactoryImplAddress[999],
|
|
1672
2507
|
args: [
|
|
1673
|
-
account,
|
|
1674
2508
|
contract.uri,
|
|
1675
2509
|
contract.name,
|
|
1676
|
-
|
|
2510
|
+
{
|
|
2511
|
+
// deprecated
|
|
2512
|
+
royaltyMintSchedule: 0,
|
|
2513
|
+
royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
2514
|
+
royaltyRecipient: fundsRecipient || accountAddress
|
|
2515
|
+
},
|
|
2516
|
+
contract.defaultAdmin || accountAddress,
|
|
2517
|
+
tokenSetupActions
|
|
1677
2518
|
]
|
|
1678
2519
|
});
|
|
1679
|
-
try {
|
|
1680
|
-
await publicClient.readContract({
|
|
1681
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1682
|
-
address: contractAddress,
|
|
1683
|
-
functionName: "contractVersion"
|
|
1684
|
-
});
|
|
1685
|
-
contractExists = true;
|
|
1686
|
-
} catch (e) {
|
|
1687
|
-
}
|
|
1688
|
-
return { contractAddress, contractExists };
|
|
1689
2520
|
}
|
|
1690
|
-
return {
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
};
|
|
1694
|
-
}
|
|
1695
|
-
function create1155CreatorClient(clientConfig) {
|
|
1696
|
-
const { publicClient } = setupClient(clientConfig);
|
|
1697
|
-
async function createNew1155Token({
|
|
1698
|
-
contract,
|
|
1699
|
-
tokenMetadataURI,
|
|
1700
|
-
mintToCreatorCount = 1,
|
|
1701
|
-
salesConfig = {},
|
|
1702
|
-
maxSupply,
|
|
2521
|
+
return makeContractParameters({
|
|
2522
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
2523
|
+
functionName: "multicall",
|
|
1703
2524
|
account,
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
2525
|
+
address: contractAddress,
|
|
2526
|
+
args: [tokenSetupActions]
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
var Create1155Client = class {
|
|
2530
|
+
constructor({
|
|
2531
|
+
chainId,
|
|
2532
|
+
publicClient
|
|
1707
2533
|
}) {
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1717
|
-
functionName: "nextTokenId",
|
|
1718
|
-
address: contractAddress
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
const fixedPriceMinterAddress = await publicClient.readContract({
|
|
1722
|
-
abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
|
|
1723
|
-
address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[999],
|
|
1724
|
-
functionName: "fixedPriceMinter"
|
|
1725
|
-
});
|
|
1726
|
-
let tokenSetupActions = create1155TokenSetupArgs({
|
|
1727
|
-
tokenMetadataURI,
|
|
1728
|
-
nextTokenId,
|
|
1729
|
-
salesConfig,
|
|
1730
|
-
maxSupply,
|
|
1731
|
-
fixedPriceMinterAddress,
|
|
1732
|
-
account,
|
|
1733
|
-
mintToCreatorCount,
|
|
1734
|
-
royaltySettings,
|
|
1735
|
-
createReferral
|
|
2534
|
+
this.chainId = chainId;
|
|
2535
|
+
this.publicClient = publicClient;
|
|
2536
|
+
}
|
|
2537
|
+
async createNew1155Token(props) {
|
|
2538
|
+
return createNew1155Token({
|
|
2539
|
+
...props,
|
|
2540
|
+
publicClient: this.publicClient,
|
|
2541
|
+
chainId: this.chainId
|
|
1736
2542
|
});
|
|
1737
|
-
if (getAdditionalSetupActions) {
|
|
1738
|
-
tokenSetupActions = [
|
|
1739
|
-
...getAdditionalSetupActions({ tokenId: nextTokenId, contractAddress }),
|
|
1740
|
-
...tokenSetupActions
|
|
1741
|
-
];
|
|
1742
|
-
}
|
|
1743
|
-
if (!contractAddress && typeof contract === "string") {
|
|
1744
|
-
throw new Error("Invariant: contract cannot be missing and an address");
|
|
1745
|
-
}
|
|
1746
|
-
if (!contractExists && typeof contract !== "string") {
|
|
1747
|
-
const request = makeSimulateContractParamaters({
|
|
1748
|
-
abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
|
|
1749
|
-
functionName: "createContractDeterministic",
|
|
1750
|
-
account,
|
|
1751
|
-
address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[999],
|
|
1752
|
-
args: [
|
|
1753
|
-
contract.uri,
|
|
1754
|
-
contract.name,
|
|
1755
|
-
{
|
|
1756
|
-
// deprecated
|
|
1757
|
-
royaltyMintSchedule: 0,
|
|
1758
|
-
royaltyBPS: royaltySettings?.royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
1759
|
-
royaltyRecipient: royaltySettings?.royaltyRecipient || account
|
|
1760
|
-
},
|
|
1761
|
-
contract.defaultAdmin || account,
|
|
1762
|
-
tokenSetupActions
|
|
1763
|
-
]
|
|
1764
|
-
});
|
|
1765
|
-
return {
|
|
1766
|
-
request,
|
|
1767
|
-
tokenSetupActions,
|
|
1768
|
-
contractAddress,
|
|
1769
|
-
contractExists
|
|
1770
|
-
};
|
|
1771
|
-
} else if (contractExists) {
|
|
1772
|
-
const request = makeSimulateContractParamaters({
|
|
1773
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1774
|
-
functionName: "multicall",
|
|
1775
|
-
account,
|
|
1776
|
-
address: contractAddress,
|
|
1777
|
-
args: [tokenSetupActions]
|
|
1778
|
-
});
|
|
1779
|
-
return {
|
|
1780
|
-
request,
|
|
1781
|
-
tokenSetupActions,
|
|
1782
|
-
contractAddress,
|
|
1783
|
-
contractExists
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1786
|
-
throw new Error("Unsupported contract argument type");
|
|
1787
2543
|
}
|
|
1788
|
-
|
|
2544
|
+
};
|
|
2545
|
+
async function createNew1155Token({
|
|
2546
|
+
contract,
|
|
2547
|
+
account,
|
|
2548
|
+
getAdditionalSetupActions,
|
|
2549
|
+
token: tokenConfig,
|
|
2550
|
+
publicClient,
|
|
2551
|
+
chainId
|
|
2552
|
+
}) {
|
|
2553
|
+
const { contractExists, contractAddress, nextTokenId, contractVersion } = await getContractInfo({
|
|
2554
|
+
publicClient,
|
|
2555
|
+
chainId,
|
|
2556
|
+
contract,
|
|
2557
|
+
account
|
|
2558
|
+
});
|
|
2559
|
+
const {
|
|
2560
|
+
minter,
|
|
2561
|
+
newToken,
|
|
2562
|
+
setupActions: tokenSetupActions
|
|
2563
|
+
} = constructCreate1155TokenCalls({
|
|
2564
|
+
chainId,
|
|
2565
|
+
ownerAddress: account,
|
|
2566
|
+
contractVersion,
|
|
2567
|
+
nextTokenId,
|
|
2568
|
+
...tokenConfig
|
|
2569
|
+
});
|
|
2570
|
+
const setupActions = getAdditionalSetupActions ? [
|
|
2571
|
+
...getAdditionalSetupActions({
|
|
2572
|
+
tokenId: nextTokenId,
|
|
2573
|
+
contractAddress
|
|
2574
|
+
}),
|
|
2575
|
+
...tokenSetupActions
|
|
2576
|
+
] : tokenSetupActions;
|
|
2577
|
+
const request = makeCreateContractAndTokenCall({
|
|
2578
|
+
contractExists,
|
|
2579
|
+
contractAddress,
|
|
2580
|
+
contract,
|
|
2581
|
+
account,
|
|
2582
|
+
tokenSetupActions: setupActions,
|
|
2583
|
+
royaltyBPS: tokenConfig.royaltyBPS,
|
|
2584
|
+
fundsRecipient: tokenConfig.payoutRecipient
|
|
2585
|
+
});
|
|
2586
|
+
return {
|
|
2587
|
+
parameters: request,
|
|
2588
|
+
tokenSetupActions,
|
|
2589
|
+
collectionAddress: contractAddress,
|
|
2590
|
+
contractExists,
|
|
2591
|
+
newTokenId: nextTokenId,
|
|
2592
|
+
newToken,
|
|
2593
|
+
minter
|
|
2594
|
+
};
|
|
1789
2595
|
}
|
|
1790
2596
|
|
|
1791
2597
|
// src/mints/mints-queries.ts
|
|
@@ -1845,8 +2651,8 @@ var sumBalances = (mintAccountBalances) => {
|
|
|
1845
2651
|
};
|
|
1846
2652
|
|
|
1847
2653
|
// src/mints/mints-contracts.ts
|
|
1848
|
-
var
|
|
1849
|
-
var
|
|
2654
|
+
var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
|
|
2655
|
+
var import_viem9 = require("viem");
|
|
1850
2656
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
1851
2657
|
var mintWithEthParams = ({
|
|
1852
2658
|
quantity,
|
|
@@ -1854,9 +2660,9 @@ var mintWithEthParams = ({
|
|
|
1854
2660
|
chainId,
|
|
1855
2661
|
pricePerMint,
|
|
1856
2662
|
account
|
|
1857
|
-
}) =>
|
|
1858
|
-
abi:
|
|
1859
|
-
address:
|
|
2663
|
+
}) => makeContractParameters({
|
|
2664
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
2665
|
+
address: import_protocol_deployments10.zoraMintsManagerImplConfig.address[chainId],
|
|
1860
2666
|
functionName: "mintWithEth",
|
|
1861
2667
|
args: [quantity, recipient || addressOrAccountAddress(account)],
|
|
1862
2668
|
value: pricePerMint * quantity,
|
|
@@ -1871,8 +2677,8 @@ var mintsBalanceOfAccountParams = ({
|
|
|
1871
2677
|
account,
|
|
1872
2678
|
chainId
|
|
1873
2679
|
}) => ({
|
|
1874
|
-
abi:
|
|
1875
|
-
address:
|
|
2680
|
+
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
2681
|
+
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
1876
2682
|
functionName: "balanceOfAccount",
|
|
1877
2683
|
args: [account]
|
|
1878
2684
|
});
|
|
@@ -1881,8 +2687,8 @@ var encodeCollectOnManager = ({
|
|
|
1881
2687
|
minter,
|
|
1882
2688
|
zoraCreator1155TokenId,
|
|
1883
2689
|
mintArguments
|
|
1884
|
-
}) => (0,
|
|
1885
|
-
abi:
|
|
2690
|
+
}) => (0, import_viem9.encodeFunctionData)({
|
|
2691
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
1886
2692
|
functionName: "collect",
|
|
1887
2693
|
args: [
|
|
1888
2694
|
zoraCreator1155Contract,
|
|
@@ -1910,9 +2716,9 @@ function collectWithMintsParams({
|
|
|
1910
2716
|
minter,
|
|
1911
2717
|
mintArguments
|
|
1912
2718
|
});
|
|
1913
|
-
return
|
|
1914
|
-
abi:
|
|
1915
|
-
address:
|
|
2719
|
+
return makeContractParameters({
|
|
2720
|
+
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
2721
|
+
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
1916
2722
|
functionName: "transferBatchToManagerAndCall",
|
|
1917
2723
|
args: [tokenIds, quantities, call],
|
|
1918
2724
|
// if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
|
|
@@ -1925,12 +2731,12 @@ function getMintsEthPrice({
|
|
|
1925
2731
|
publicClient
|
|
1926
2732
|
}) {
|
|
1927
2733
|
const chainId = publicClient.chain?.id;
|
|
1928
|
-
if (!chainId || !
|
|
2734
|
+
if (!chainId || !import_protocol_deployments10.zoraMintsManagerImplAddress[chainId]) {
|
|
1929
2735
|
throw new Error(`Chain id ${chainId} not supported`);
|
|
1930
2736
|
}
|
|
1931
2737
|
return publicClient.readContract({
|
|
1932
|
-
abi:
|
|
1933
|
-
address:
|
|
2738
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplABI,
|
|
2739
|
+
address: import_protocol_deployments10.zoraMintsManagerImplAddress[chainId],
|
|
1934
2740
|
functionName: "getEthPrice"
|
|
1935
2741
|
});
|
|
1936
2742
|
}
|
|
@@ -1954,7 +2760,7 @@ function makePermitTransferBatchAndTypeData({
|
|
|
1954
2760
|
safeTransferData
|
|
1955
2761
|
};
|
|
1956
2762
|
const typedData = {
|
|
1957
|
-
...(0,
|
|
2763
|
+
...(0, import_protocol_deployments10.mintsSafeTransferBatchTypedDataDefinition)({
|
|
1958
2764
|
chainId,
|
|
1959
2765
|
message: permit
|
|
1960
2766
|
}),
|
|
@@ -1985,7 +2791,7 @@ function makePermitTransferTypeData({
|
|
|
1985
2791
|
safeTransferData
|
|
1986
2792
|
};
|
|
1987
2793
|
const typedData = {
|
|
1988
|
-
...(0,
|
|
2794
|
+
...(0, import_protocol_deployments10.mintsSafeTransferTypedDataDefinition)({
|
|
1989
2795
|
chainId,
|
|
1990
2796
|
message: permit
|
|
1991
2797
|
}),
|
|
@@ -2001,9 +2807,9 @@ var encodePremintOnManager = ({
|
|
|
2001
2807
|
premintConfig,
|
|
2002
2808
|
premintSignature,
|
|
2003
2809
|
mintArguments,
|
|
2004
|
-
signerContract =
|
|
2005
|
-
}) => (0,
|
|
2006
|
-
abi:
|
|
2810
|
+
signerContract = import_viem9.zeroAddress
|
|
2811
|
+
}) => (0, import_viem9.encodeFunctionData)({
|
|
2812
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
2007
2813
|
functionName: "collectPremintV2",
|
|
2008
2814
|
args: [
|
|
2009
2815
|
contractCreationConfig,
|
|
@@ -2042,7 +2848,7 @@ var makePermitToCollectPremintOrNonPremint = ({
|
|
|
2042
2848
|
nonce,
|
|
2043
2849
|
deadline,
|
|
2044
2850
|
safeTransferData,
|
|
2045
|
-
to:
|
|
2851
|
+
to: import_protocol_deployments10.zoraMintsManagerImplConfig.address[chainId]
|
|
2046
2852
|
});
|
|
2047
2853
|
};
|
|
2048
2854
|
function collectPremintV2WithMintsParams({
|
|
@@ -2056,9 +2862,9 @@ function collectPremintV2WithMintsParams({
|
|
|
2056
2862
|
const call = encodePremintOnManager({
|
|
2057
2863
|
...rest
|
|
2058
2864
|
});
|
|
2059
|
-
return
|
|
2060
|
-
abi:
|
|
2061
|
-
address:
|
|
2865
|
+
return makeContractParameters({
|
|
2866
|
+
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
2867
|
+
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
2062
2868
|
functionName: "transferBatchToManagerAndCall",
|
|
2063
2869
|
args: [tokenIds, quantities, call],
|
|
2064
2870
|
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
@@ -2069,21 +2875,21 @@ function decodeCallFailedError(error) {
|
|
|
2069
2875
|
if (error.data?.errorName !== "CallFailed")
|
|
2070
2876
|
throw new Error("Not a CallFailed error");
|
|
2071
2877
|
const internalErrorData = error.data?.args?.[0];
|
|
2072
|
-
return (0,
|
|
2073
|
-
abi:
|
|
2878
|
+
return (0, import_viem9.decodeErrorResult)({
|
|
2879
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplABI,
|
|
2074
2880
|
data: internalErrorData
|
|
2075
2881
|
});
|
|
2076
2882
|
}
|
|
2077
2883
|
|
|
2078
2884
|
// src/mints/mints-eth-unwrapper-and-caller.ts
|
|
2079
|
-
var
|
|
2080
|
-
var
|
|
2885
|
+
var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
|
|
2886
|
+
var import_viem10 = require("viem");
|
|
2081
2887
|
var makeCallWithEthSafeTransferData = ({
|
|
2082
2888
|
address: addressToCall,
|
|
2083
2889
|
call: functionToCall,
|
|
2084
2890
|
value: valueToSend
|
|
2085
|
-
}) => (0,
|
|
2086
|
-
abi:
|
|
2891
|
+
}) => (0, import_viem10.encodeFunctionData)({
|
|
2892
|
+
abi: import_protocol_deployments11.iUnwrapAndForwardActionABI,
|
|
2087
2893
|
functionName: "callWithEth",
|
|
2088
2894
|
args: [addressToCall, functionToCall, valueToSend]
|
|
2089
2895
|
});
|
|
@@ -2103,27 +2909,70 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2103
2909
|
tokenIds,
|
|
2104
2910
|
quantities,
|
|
2105
2911
|
safeTransferData: safeTransferData || makeCallWithEthSafeTransferData(callWithEth),
|
|
2106
|
-
to:
|
|
2912
|
+
to: import_protocol_deployments11.mintsEthUnwrapperAndCallerAddress[chainId],
|
|
2107
2913
|
nonce
|
|
2108
2914
|
});
|
|
2915
|
+
|
|
2916
|
+
// src/sdk.ts
|
|
2917
|
+
function createCreatorClient(clientConfig) {
|
|
2918
|
+
const premintClient = new PremintClient({
|
|
2919
|
+
chainId: clientConfig.chainId,
|
|
2920
|
+
publicClient: clientConfig.publicClient,
|
|
2921
|
+
premintApi: clientConfig.premintApi || new PremintAPIClient(clientConfig.chainId)
|
|
2922
|
+
});
|
|
2923
|
+
const create1155CreatorClient = new Create1155Client({
|
|
2924
|
+
chainId: clientConfig.chainId,
|
|
2925
|
+
publicClient: clientConfig.publicClient
|
|
2926
|
+
});
|
|
2927
|
+
return {
|
|
2928
|
+
createPremint: (p) => premintClient.createPremint(p),
|
|
2929
|
+
updatePremint: (p) => premintClient.updatePremint(p),
|
|
2930
|
+
deletePremint: (p) => premintClient.deletePremint(p),
|
|
2931
|
+
create1155: (p) => create1155CreatorClient.createNew1155Token(p)
|
|
2932
|
+
};
|
|
2933
|
+
}
|
|
2934
|
+
function createCollectorClient(params) {
|
|
2935
|
+
const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
|
|
2936
|
+
const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
|
|
2937
|
+
const mintClient = new MintClient({
|
|
2938
|
+
publicClient: params.publicClient,
|
|
2939
|
+
premintGetter: premintGetterToUse,
|
|
2940
|
+
mintGetter: mintGetterToUse
|
|
2941
|
+
});
|
|
2942
|
+
return {
|
|
2943
|
+
getPremint: (p) => premintGetterToUse.get({
|
|
2944
|
+
collectionAddress: p.address,
|
|
2945
|
+
uid: p.uid
|
|
2946
|
+
}),
|
|
2947
|
+
getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
|
|
2948
|
+
getToken: (p) => mintClient.get(p),
|
|
2949
|
+
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
2950
|
+
mint: (p) => mintClient.mint(p),
|
|
2951
|
+
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2109
2954
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2110
2955
|
0 && (module.exports = {
|
|
2111
|
-
|
|
2956
|
+
Create1155Client,
|
|
2112
2957
|
Errors,
|
|
2113
|
-
|
|
2958
|
+
MintClient,
|
|
2114
2959
|
PremintAPIClient,
|
|
2960
|
+
PremintClient,
|
|
2115
2961
|
PremintConfigVersion,
|
|
2962
|
+
SubgraphMintGetter,
|
|
2116
2963
|
ZORA_API_BASE,
|
|
2117
2964
|
applyUpdateToPremint,
|
|
2965
|
+
buildPremintMintCall,
|
|
2966
|
+
collectOnchain,
|
|
2967
|
+
collectPremint,
|
|
2118
2968
|
collectPremintV2WithMintsParams,
|
|
2119
2969
|
collectWithMintsParams,
|
|
2120
2970
|
convertCollectionFromApi,
|
|
2121
2971
|
convertGetPremintApiResponse,
|
|
2972
|
+
convertGetPremintOfCollectionApiResponse,
|
|
2122
2973
|
convertPremintFromApi,
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
createMintClient,
|
|
2126
|
-
createPremintClient,
|
|
2974
|
+
createCollectorClient,
|
|
2975
|
+
createCreatorClient,
|
|
2127
2976
|
decodeCallFailedError,
|
|
2128
2977
|
defaultAdditionalAdmins,
|
|
2129
2978
|
defaultTokenConfigV1MintArguments,
|
|
@@ -2133,17 +2982,22 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2133
2982
|
encodePostSignatureInput,
|
|
2134
2983
|
encodePremintForAPI,
|
|
2135
2984
|
getApiNetworkConfigForChain,
|
|
2985
|
+
getDataFromPremintReceipt,
|
|
2136
2986
|
getDefaultFixedPriceMinterAddress,
|
|
2137
|
-
getMintCosts,
|
|
2138
2987
|
getMintsAccountBalanceWithPriceQuery,
|
|
2139
2988
|
getMintsEthPrice,
|
|
2140
2989
|
getPremintCollectionAddress,
|
|
2141
2990
|
getPremintExecutorAddress,
|
|
2142
2991
|
getPremintMintCosts,
|
|
2992
|
+
getPremintMintCostsWithUnknownTokenPrice,
|
|
2143
2993
|
getPremintMintFee,
|
|
2994
|
+
getPremintPricePerToken,
|
|
2144
2995
|
getPremintedLogFromReceipt,
|
|
2996
|
+
getSignature,
|
|
2145
2997
|
getTokenIdFromCreateReceipt,
|
|
2146
2998
|
isAuthorizedToCreatePremint,
|
|
2999
|
+
isPremintConfigV1,
|
|
3000
|
+
isPremintConfigV2,
|
|
2147
3001
|
isValidSignature,
|
|
2148
3002
|
makeCallWithEthSafeTransferData,
|
|
2149
3003
|
makeMintRewardsRecipient,
|