@zoralabs/protocol-sdk 0.5.17 → 0.6.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 +13 -0
- package/README.md +1 -416
- 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 +1273 -857
- 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 +1233 -831
- package/dist/index.js.map +1 -1
- package/dist/mint/mint-client.d.ts +4083 -43
- package/dist/mint/mint-client.d.ts.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +17 -0
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -0
- package/dist/mint/types.d.ts +79 -0
- package/dist/mint/types.d.ts.map +1 -0
- package/dist/mints/mints-contracts.d.ts +24 -24
- 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 +3 -1
- package/dist/premint/conversions.d.ts.map +1 -1
- package/dist/premint/premint-api-client.d.ts +27 -14
- package/dist/premint/premint-api-client.d.ts.map +1 -1
- package/dist/premint/premint-client.d.ts +62 -46
- package/dist/premint/premint-client.d.ts.map +1 -1
- package/dist/premint/preminter.d.ts +19 -7
- package/dist/premint/preminter.d.ts.map +1 -1
- package/dist/sdk.d.ts +43 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/utils.d.ts +17 -6870
- package/dist/utils.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/create/1155-create-helper.test.ts +235 -56
- 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 +50 -61
- package/src/mint/mint-client.ts +321 -157
- package/src/mint/{mint-api-client.ts → subgraph-mint-getter.ts} +2 -25
- package/src/mint/types.ts +122 -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 +12 -2
- package/src/premint/premint-api-client.ts +55 -43
- package/src/premint/premint-client.test.ts +75 -65
- package/src/premint/premint-client.ts +126 -153
- package/src/premint/preminter.test.ts +4 -5
- package/src/premint/preminter.ts +63 -13
- package/src/sdk.ts +98 -0
- package/src/utils.ts +30 -23
- package/test-integration/premint-client.test.ts +8 -8
- package/dist/mint/mint-api-client.d.ts +0 -35
- package/dist/mint/mint-api-client.d.ts.map +0 -1
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,37 @@ 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
|
+
collectOnchain: () => collectOnchain,
|
|
43
|
+
collectPremint: () => collectPremint,
|
|
30
44
|
collectPremintV2WithMintsParams: () => collectPremintV2WithMintsParams,
|
|
31
45
|
collectWithMintsParams: () => collectWithMintsParams,
|
|
32
46
|
convertCollectionFromApi: () => convertCollectionFromApi,
|
|
33
47
|
convertGetPremintApiResponse: () => convertGetPremintApiResponse,
|
|
34
48
|
convertPremintFromApi: () => convertPremintFromApi,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
createMintClient: () => createMintClient,
|
|
38
|
-
createPremintClient: () => createPremintClient,
|
|
49
|
+
createCollectorClient: () => createCollectorClient,
|
|
50
|
+
createCreatorClient: () => createCreatorClient,
|
|
39
51
|
decodeCallFailedError: () => decodeCallFailedError,
|
|
40
52
|
defaultAdditionalAdmins: () => defaultAdditionalAdmins,
|
|
41
53
|
defaultTokenConfigV1MintArguments: () => defaultTokenConfigV1MintArguments,
|
|
@@ -45,17 +57,24 @@ __export(src_exports, {
|
|
|
45
57
|
encodePostSignatureInput: () => encodePostSignatureInput,
|
|
46
58
|
encodePremintForAPI: () => encodePremintForAPI,
|
|
47
59
|
getApiNetworkConfigForChain: () => getApiNetworkConfigForChain,
|
|
60
|
+
getDataFromPremintReceipt: () => getDataFromPremintReceipt,
|
|
48
61
|
getDefaultFixedPriceMinterAddress: () => getDefaultFixedPriceMinterAddress,
|
|
49
62
|
getMintCosts: () => getMintCosts,
|
|
50
63
|
getMintsAccountBalanceWithPriceQuery: () => getMintsAccountBalanceWithPriceQuery,
|
|
51
64
|
getMintsEthPrice: () => getMintsEthPrice,
|
|
65
|
+
getNecessaryErc20Approval: () => getNecessaryErc20Approval,
|
|
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,
|
|
@@ -63,12 +82,15 @@ __export(src_exports, {
|
|
|
63
82
|
makePermitToCollectPremintOrNonPremint: () => makePermitToCollectPremintOrNonPremint,
|
|
64
83
|
makePermitTransferBatchAndTypeData: () => makePermitTransferBatchAndTypeData,
|
|
65
84
|
makePermitTransferTypeData: () => makePermitTransferTypeData,
|
|
85
|
+
makePrepareMint1155TokenParams: () => makePrepareMint1155TokenParams,
|
|
66
86
|
makeUrls: () => makeUrls,
|
|
67
87
|
migratePremintConfigToV2: () => migratePremintConfigToV2,
|
|
68
88
|
mintWithEthParams: () => mintWithEthParams,
|
|
69
89
|
mintsBalanceOfAccountParams: () => mintsBalanceOfAccountParams,
|
|
90
|
+
parseMintCosts: () => parseMintCosts,
|
|
70
91
|
recoverCreatorFromCreatorAttribution: () => recoverCreatorFromCreatorAttribution,
|
|
71
92
|
recoverPremintSigner: () => recoverPremintSigner,
|
|
93
|
+
requestErc20ApprovalForMint: () => requestErc20ApprovalForMint,
|
|
72
94
|
selectMintsToCollectWithFromQueryResult: () => selectMintsToCollectWithFromQueryResult,
|
|
73
95
|
sumBalances: () => sumBalances,
|
|
74
96
|
supportedPremintVersions: () => supportedPremintVersions,
|
|
@@ -80,22 +102,268 @@ __export(src_exports, {
|
|
|
80
102
|
module.exports = __toCommonJS(src_exports);
|
|
81
103
|
|
|
82
104
|
// src/premint/premint-client.ts
|
|
83
|
-
var
|
|
105
|
+
var import_viem4 = require("viem");
|
|
84
106
|
var import_protocol_deployments3 = require("@zoralabs/protocol-deployments");
|
|
85
107
|
|
|
86
108
|
// src/premint/preminter.ts
|
|
87
|
-
var
|
|
109
|
+
var import_protocol_deployments2 = require("@zoralabs/protocol-deployments");
|
|
110
|
+
var import_viem3 = require("viem");
|
|
111
|
+
|
|
112
|
+
// src/apis/chain-constants.ts
|
|
113
|
+
var import_chains = require("viem/chains");
|
|
114
|
+
var import_viem2 = require("viem");
|
|
115
|
+
|
|
116
|
+
// src/constants.ts
|
|
88
117
|
var import_viem = require("viem");
|
|
89
|
-
var
|
|
118
|
+
var ZORA_API_BASE = "https://api.zora.co/";
|
|
119
|
+
var OPEN_EDITION_MINT_SIZE = BigInt("18446744073709551615");
|
|
120
|
+
var SUBGRAPH_CONFIG_BASE = "https://api.goldsky.com/api/public/project_clhk16b61ay9t49vm6ntn4mkz/subgraphs";
|
|
121
|
+
function getSubgraph(name, version) {
|
|
122
|
+
return `${SUBGRAPH_CONFIG_BASE}/${name}/${version}/gn`;
|
|
123
|
+
}
|
|
124
|
+
var zora721Abi = (0, import_viem.parseAbi)([
|
|
125
|
+
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
126
|
+
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
127
|
+
]);
|
|
128
|
+
var NFT_SALE_QUERY = `
|
|
129
|
+
fragment SaleStrategy on SalesStrategyConfig {
|
|
130
|
+
type
|
|
131
|
+
fixedPrice {
|
|
132
|
+
address
|
|
133
|
+
pricePerToken
|
|
134
|
+
saleEnd
|
|
135
|
+
saleStart
|
|
136
|
+
maxTokensPerAddress
|
|
137
|
+
}
|
|
138
|
+
erc20Minter {
|
|
139
|
+
address
|
|
140
|
+
pricePerToken
|
|
141
|
+
currency
|
|
142
|
+
saleEnd
|
|
143
|
+
saleStart
|
|
144
|
+
maxTokensPerAddress
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
query ($id: ID!) {
|
|
149
|
+
zoraCreateToken(id: $id) {
|
|
150
|
+
id
|
|
151
|
+
contract {
|
|
152
|
+
mintFeePerQuantity
|
|
153
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
154
|
+
...SaleStrategy
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
158
|
+
...SaleStrategy
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
// src/apis/chain-constants.ts
|
|
165
|
+
var REWARD_PER_TOKEN = (0, import_viem2.parseEther)("0.000777");
|
|
166
|
+
var networkConfigByChain = {
|
|
167
|
+
[import_chains.mainnet.id]: {
|
|
168
|
+
chainId: import_chains.mainnet.id,
|
|
169
|
+
isTestnet: false,
|
|
170
|
+
zoraCollectPathChainName: "eth",
|
|
171
|
+
zoraBackendChainName: "ETHEREUM-MAINNET",
|
|
172
|
+
subgraphUrl: getSubgraph("zora-create-mainnet", "stable")
|
|
173
|
+
},
|
|
174
|
+
[import_chains.sepolia.id]: {
|
|
175
|
+
chainId: import_chains.sepolia.id,
|
|
176
|
+
isTestnet: true,
|
|
177
|
+
zoraCollectPathChainName: "sep",
|
|
178
|
+
zoraBackendChainName: "ETHEREUM-SEPOLIA",
|
|
179
|
+
subgraphUrl: getSubgraph("zora-create-sepolia", "stable")
|
|
180
|
+
},
|
|
181
|
+
[import_chains.zora.id]: {
|
|
182
|
+
chainId: import_chains.zora.id,
|
|
183
|
+
isTestnet: false,
|
|
184
|
+
zoraCollectPathChainName: "zora",
|
|
185
|
+
zoraBackendChainName: "ZORA-MAINNET",
|
|
186
|
+
subgraphUrl: getSubgraph("zora-create-zora-mainnet", "stable")
|
|
187
|
+
},
|
|
188
|
+
[import_chains.zoraSepolia.id]: {
|
|
189
|
+
chainId: import_chains.zoraSepolia.id,
|
|
190
|
+
isTestnet: true,
|
|
191
|
+
zoraCollectPathChainName: "zsep",
|
|
192
|
+
zoraBackendChainName: "ZORA-SEPOLIA",
|
|
193
|
+
subgraphUrl: getSubgraph("zora-create-zora-sepolia", "stable")
|
|
194
|
+
},
|
|
195
|
+
[import_chains.optimism.id]: {
|
|
196
|
+
chainId: import_chains.optimism.id,
|
|
197
|
+
isTestnet: false,
|
|
198
|
+
zoraCollectPathChainName: "oeth",
|
|
199
|
+
zoraBackendChainName: "OPTIMISM-MAINNET",
|
|
200
|
+
subgraphUrl: getSubgraph("zora-create-optimism", "stable")
|
|
201
|
+
},
|
|
202
|
+
[import_chains.arbitrum.id]: {
|
|
203
|
+
chainId: import_chains.arbitrum.id,
|
|
204
|
+
isTestnet: true,
|
|
205
|
+
zoraCollectPathChainName: "arb",
|
|
206
|
+
zoraBackendChainName: "ARBITRUM-MAINNET",
|
|
207
|
+
subgraphUrl: getSubgraph("zora-create-arbitrum-one", "stable")
|
|
208
|
+
},
|
|
209
|
+
[import_chains.base.id]: {
|
|
210
|
+
chainId: import_chains.base.id,
|
|
211
|
+
isTestnet: false,
|
|
212
|
+
zoraCollectPathChainName: "base",
|
|
213
|
+
zoraBackendChainName: "BASE-MAINNET",
|
|
214
|
+
subgraphUrl: getSubgraph("zora-create-base-mainnet", "stable")
|
|
215
|
+
},
|
|
216
|
+
[import_chains.baseSepolia.id]: {
|
|
217
|
+
chainId: import_chains.baseSepolia.id,
|
|
218
|
+
isTestnet: true,
|
|
219
|
+
zoraCollectPathChainName: "bsep",
|
|
220
|
+
zoraBackendChainName: "BASE-SEPOLIA",
|
|
221
|
+
subgraphUrl: getSubgraph("zora-create-base-sepolia", "stable")
|
|
222
|
+
},
|
|
223
|
+
[import_chains.foundry.id]: {
|
|
224
|
+
chainId: import_chains.foundry.id,
|
|
225
|
+
isTestnet: true,
|
|
226
|
+
zoraCollectPathChainName: "zgor",
|
|
227
|
+
zoraBackendChainName: "ZORA-GOERLI",
|
|
228
|
+
subgraphUrl: getSubgraph("zora-create-zora-testnet", "stable")
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// src/premint/conversions.ts
|
|
233
|
+
var import_protocol_deployments = require("@zoralabs/protocol-deployments");
|
|
234
|
+
var convertCollectionFromApi = (collection) => {
|
|
235
|
+
if (!collection)
|
|
236
|
+
return void 0;
|
|
237
|
+
return {
|
|
238
|
+
additionalAdmins: collection.additionalAdmins || [],
|
|
239
|
+
contractAdmin: collection.contractAdmin,
|
|
240
|
+
contractName: collection.contractName,
|
|
241
|
+
contractURI: collection.contractURI
|
|
242
|
+
};
|
|
243
|
+
};
|
|
244
|
+
var convertPremintFromApi = (premint) => {
|
|
245
|
+
if (premint.config_version === import_protocol_deployments.PremintConfigVersion.V1 || !premint.config_version) {
|
|
246
|
+
const tokenConfig = premint.tokenConfig;
|
|
247
|
+
return {
|
|
248
|
+
premintConfigVersion: import_protocol_deployments.PremintConfigVersion.V1,
|
|
249
|
+
premintConfig: {
|
|
250
|
+
deleted: premint.deleted,
|
|
251
|
+
uid: premint.uid,
|
|
252
|
+
version: premint.version,
|
|
253
|
+
tokenConfig: {
|
|
254
|
+
...tokenConfig,
|
|
255
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
256
|
+
royaltyRecipient: tokenConfig.royaltyRecipient,
|
|
257
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
258
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
259
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
260
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
261
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
} else {
|
|
266
|
+
const tokenConfig = premint.tokenConfig;
|
|
267
|
+
return {
|
|
268
|
+
premintConfigVersion: import_protocol_deployments.PremintConfigVersion.V2,
|
|
269
|
+
premintConfig: {
|
|
270
|
+
deleted: premint.deleted,
|
|
271
|
+
uid: premint.uid,
|
|
272
|
+
version: premint.version,
|
|
273
|
+
tokenConfig: {
|
|
274
|
+
...tokenConfig,
|
|
275
|
+
fixedPriceMinter: tokenConfig.fixedPriceMinter,
|
|
276
|
+
payoutRecipient: tokenConfig.payoutRecipient,
|
|
277
|
+
createReferral: tokenConfig.createReferral,
|
|
278
|
+
maxSupply: BigInt(tokenConfig.maxSupply),
|
|
279
|
+
pricePerToken: BigInt(tokenConfig.pricePerToken),
|
|
280
|
+
mintStart: BigInt(tokenConfig.mintStart),
|
|
281
|
+
mintDuration: BigInt(tokenConfig.mintDuration),
|
|
282
|
+
maxTokensPerAddress: BigInt(tokenConfig.maxTokensPerAddress)
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
var convertGetPremintApiResponse = (response) => ({
|
|
289
|
+
...convertPremintFromApi(response.premint),
|
|
290
|
+
collection: convertCollectionFromApi(response.collection),
|
|
291
|
+
collectionAddress: response.collection_address,
|
|
292
|
+
signature: response.signature
|
|
293
|
+
});
|
|
294
|
+
var encodePremintV1ForAPI = ({
|
|
295
|
+
tokenConfig,
|
|
296
|
+
...premint
|
|
297
|
+
}) => ({
|
|
298
|
+
...premint,
|
|
299
|
+
config_version: "1",
|
|
300
|
+
tokenConfig: {
|
|
301
|
+
...tokenConfig,
|
|
302
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
303
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
304
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
305
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
306
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
var encodePremintV2ForAPI = ({
|
|
310
|
+
tokenConfig,
|
|
311
|
+
...premint
|
|
312
|
+
}) => ({
|
|
313
|
+
...premint,
|
|
314
|
+
config_version: "2",
|
|
315
|
+
tokenConfig: {
|
|
316
|
+
...tokenConfig,
|
|
317
|
+
maxSupply: tokenConfig.maxSupply.toString(),
|
|
318
|
+
pricePerToken: tokenConfig.pricePerToken.toString(),
|
|
319
|
+
mintStart: tokenConfig.mintStart.toString(),
|
|
320
|
+
mintDuration: tokenConfig.mintDuration.toString(),
|
|
321
|
+
maxTokensPerAddress: tokenConfig.maxTokensPerAddress.toString()
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
var encodePremintForAPI = ({
|
|
325
|
+
premintConfig,
|
|
326
|
+
premintConfigVersion
|
|
327
|
+
}) => {
|
|
328
|
+
if (premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V1) {
|
|
329
|
+
return encodePremintV1ForAPI(premintConfig);
|
|
330
|
+
}
|
|
331
|
+
if (premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V2) {
|
|
332
|
+
return encodePremintV2ForAPI(premintConfig);
|
|
333
|
+
}
|
|
334
|
+
throw new Error(`Invalid premint config version ${premintConfigVersion}`);
|
|
335
|
+
};
|
|
336
|
+
var encodePostSignatureInput = ({
|
|
337
|
+
contract: collection,
|
|
338
|
+
contractAddress: collectionAddress,
|
|
339
|
+
premintConfigVersion,
|
|
340
|
+
premintConfig,
|
|
341
|
+
signature,
|
|
342
|
+
chainId
|
|
343
|
+
}) => ({
|
|
344
|
+
premint: encodePremintForAPI({
|
|
345
|
+
premintConfig,
|
|
346
|
+
premintConfigVersion
|
|
347
|
+
}),
|
|
348
|
+
signature,
|
|
349
|
+
collection,
|
|
350
|
+
collection_address: collectionAddress,
|
|
351
|
+
chain_name: networkConfigByChain[chainId].zoraBackendChainName
|
|
352
|
+
});
|
|
353
|
+
var isPremintConfigV1 = (premintConfigAndVersion) => premintConfigAndVersion.premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V1;
|
|
354
|
+
var isPremintConfigV2 = (premintConfigAndVersion) => premintConfigAndVersion.premintConfigVersion === import_protocol_deployments.PremintConfigVersion.V2;
|
|
355
|
+
|
|
356
|
+
// src/premint/preminter.ts
|
|
357
|
+
var getPremintExecutorAddress = () => import_protocol_deployments2.zoraCreator1155PremintExecutorImplAddress[999];
|
|
90
358
|
async function isAuthorizedToCreatePremint({
|
|
91
|
-
contractAdmin =
|
|
359
|
+
contractAdmin = import_viem3.zeroAddress,
|
|
92
360
|
additionalAdmins = [],
|
|
93
361
|
collectionAddress,
|
|
94
362
|
publicClient,
|
|
95
363
|
signer
|
|
96
364
|
}) {
|
|
97
365
|
return await publicClient.readContract({
|
|
98
|
-
abi:
|
|
366
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
99
367
|
address: getPremintExecutorAddress(),
|
|
100
368
|
functionName: "isAuthorizedToCreatePremintWithAdditionalAdmins",
|
|
101
369
|
args: [
|
|
@@ -110,8 +378,8 @@ async function recoverPremintSigner({
|
|
|
110
378
|
signature,
|
|
111
379
|
...rest
|
|
112
380
|
}) {
|
|
113
|
-
return await (0,
|
|
114
|
-
...(0,
|
|
381
|
+
return await (0, import_viem3.recoverTypedDataAddress)({
|
|
382
|
+
...(0, import_protocol_deployments2.premintTypedDataDefinition)(rest),
|
|
115
383
|
signature
|
|
116
384
|
});
|
|
117
385
|
}
|
|
@@ -137,7 +405,7 @@ async function isValidSignature({
|
|
|
137
405
|
verifyingContract: collectionAddress,
|
|
138
406
|
chainId
|
|
139
407
|
});
|
|
140
|
-
if (!
|
|
408
|
+
if (!import_viem3.recoverAddress) {
|
|
141
409
|
return {
|
|
142
410
|
isAuthorized: false
|
|
143
411
|
};
|
|
@@ -156,7 +424,7 @@ async function isValidSignature({
|
|
|
156
424
|
}
|
|
157
425
|
function migratePremintConfigToV2({
|
|
158
426
|
premintConfig,
|
|
159
|
-
createReferral =
|
|
427
|
+
createReferral = import_viem3.zeroAddress
|
|
160
428
|
}) {
|
|
161
429
|
return {
|
|
162
430
|
...premintConfig,
|
|
@@ -179,7 +447,7 @@ var recoverCreatorFromCreatorAttribution = async ({
|
|
|
179
447
|
chainId,
|
|
180
448
|
tokenContract
|
|
181
449
|
}) => {
|
|
182
|
-
const hashedDomain = (0,
|
|
450
|
+
const hashedDomain = (0, import_viem3.hashDomain)({
|
|
183
451
|
domain: {
|
|
184
452
|
chainId,
|
|
185
453
|
name: domainName,
|
|
@@ -202,8 +470,8 @@ var recoverCreatorFromCreatorAttribution = async ({
|
|
|
202
470
|
}
|
|
203
471
|
});
|
|
204
472
|
const parts = ["0x1901", hashedDomain, structHash];
|
|
205
|
-
const hashedTypedData = (0,
|
|
206
|
-
return await (0,
|
|
473
|
+
const hashedTypedData = (0, import_viem3.keccak256)((0, import_viem3.concat)(parts));
|
|
474
|
+
return await (0, import_viem3.recoverAddress)({
|
|
207
475
|
hash: hashedTypedData,
|
|
208
476
|
signature
|
|
209
477
|
});
|
|
@@ -213,7 +481,7 @@ var supportedPremintVersions = async ({
|
|
|
213
481
|
publicClient
|
|
214
482
|
}) => {
|
|
215
483
|
return await publicClient.readContract({
|
|
216
|
-
abi:
|
|
484
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
217
485
|
address: getPremintExecutorAddress(),
|
|
218
486
|
functionName: "supportedPremintSignatureVersions",
|
|
219
487
|
args: [tokenContract]
|
|
@@ -228,13 +496,13 @@ var supportsPremintVersion = async ({
|
|
|
228
496
|
};
|
|
229
497
|
async function getPremintCollectionAddress({
|
|
230
498
|
publicClient,
|
|
231
|
-
collection,
|
|
232
|
-
collectionAddress
|
|
499
|
+
contract: collection,
|
|
500
|
+
contractAddress: collectionAddress
|
|
233
501
|
}) {
|
|
234
502
|
if (typeof collection !== "undefined") {
|
|
235
503
|
return publicClient.readContract({
|
|
236
504
|
address: getPremintExecutorAddress(),
|
|
237
|
-
abi:
|
|
505
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
238
506
|
functionName: "getContractWithAdditionalAdminsAddress",
|
|
239
507
|
args: [
|
|
240
508
|
{
|
|
@@ -282,13 +550,13 @@ async function getPremintMintFee({
|
|
|
282
550
|
try {
|
|
283
551
|
return await publicClient.readContract({
|
|
284
552
|
address: getPremintExecutorAddress(),
|
|
285
|
-
abi:
|
|
553
|
+
abi: import_protocol_deployments2.zoraCreator1155PremintExecutorImplABI,
|
|
286
554
|
functionName: "mintFee",
|
|
287
555
|
args: [tokenContract]
|
|
288
556
|
});
|
|
289
557
|
} catch (e) {
|
|
290
558
|
console.error(e);
|
|
291
|
-
return (0,
|
|
559
|
+
return (0, import_viem3.parseEther)("0.000777");
|
|
292
560
|
}
|
|
293
561
|
}
|
|
294
562
|
async function getPremintMintCosts({
|
|
@@ -298,23 +566,53 @@ async function getPremintMintCosts({
|
|
|
298
566
|
quantityToMint
|
|
299
567
|
}) {
|
|
300
568
|
const mintFee = await getPremintMintFee({ tokenContract, publicClient });
|
|
569
|
+
const quantityToMintBigInt = BigInt(quantityToMint);
|
|
301
570
|
return {
|
|
302
|
-
mintFee: mintFee *
|
|
303
|
-
|
|
304
|
-
|
|
571
|
+
mintFee: mintFee * quantityToMintBigInt,
|
|
572
|
+
totalPurchaseCost: tokenPrice * quantityToMintBigInt,
|
|
573
|
+
totalCostEth: (mintFee + tokenPrice) * quantityToMintBigInt
|
|
305
574
|
};
|
|
306
575
|
}
|
|
576
|
+
async function getPremintPricePerToken({
|
|
577
|
+
collection,
|
|
578
|
+
uid,
|
|
579
|
+
premintGetter
|
|
580
|
+
}) {
|
|
581
|
+
const premintConfigWithVersion = await premintGetter.getSignature({
|
|
582
|
+
collectionAddress: collection,
|
|
583
|
+
uid
|
|
584
|
+
});
|
|
585
|
+
if (isPremintConfigV1(premintConfigWithVersion) || isPremintConfigV2(premintConfigWithVersion)) {
|
|
586
|
+
return premintConfigWithVersion.premintConfig.tokenConfig.pricePerToken;
|
|
587
|
+
}
|
|
588
|
+
throw new Error("Premint version not supported to get price");
|
|
589
|
+
}
|
|
590
|
+
async function getPremintMintCostsWithUnknownTokenPrice({
|
|
591
|
+
premintGetter,
|
|
592
|
+
uid,
|
|
593
|
+
...rest
|
|
594
|
+
}) {
|
|
595
|
+
const pricePerToken = await getPremintPricePerToken({
|
|
596
|
+
uid,
|
|
597
|
+
premintGetter,
|
|
598
|
+
collection: rest.tokenContract
|
|
599
|
+
});
|
|
600
|
+
return await getPremintMintCosts({
|
|
601
|
+
...rest,
|
|
602
|
+
tokenPrice: pricePerToken
|
|
603
|
+
});
|
|
604
|
+
}
|
|
307
605
|
function makeMintRewardsRecipient({
|
|
308
|
-
mintReferral =
|
|
309
|
-
platformReferral =
|
|
606
|
+
mintReferral = import_viem3.zeroAddress,
|
|
607
|
+
platformReferral = import_viem3.zeroAddress
|
|
310
608
|
}) {
|
|
311
609
|
return [mintReferral, platformReferral];
|
|
312
610
|
}
|
|
313
611
|
function getDefaultFixedPriceMinterAddress(chainId) {
|
|
314
|
-
return
|
|
612
|
+
return import_protocol_deployments2.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
315
613
|
}
|
|
316
614
|
var emptyContractCreationConfig = () => ({
|
|
317
|
-
contractAdmin:
|
|
615
|
+
contractAdmin: import_viem3.zeroAddress,
|
|
318
616
|
contractURI: "",
|
|
319
617
|
contractName: "",
|
|
320
618
|
additionalAdmins: []
|
|
@@ -331,12 +629,12 @@ var toContractCreationConfigOrAddress = ({
|
|
|
331
629
|
}) => {
|
|
332
630
|
if (typeof collection !== "undefined") {
|
|
333
631
|
return {
|
|
334
|
-
collection
|
|
632
|
+
contract: collection
|
|
335
633
|
};
|
|
336
634
|
}
|
|
337
635
|
if (typeof collectionAddress !== "undefined") {
|
|
338
636
|
return {
|
|
339
|
-
collectionAddress
|
|
637
|
+
contractAddress: collectionAddress
|
|
340
638
|
};
|
|
341
639
|
}
|
|
342
640
|
throw new Error("Must provide either a collection or a collection address");
|
|
@@ -413,414 +711,105 @@ var retries = async (tryFn, maxTries = 3, atTry = 1, linearBackoffMS = 200) => {
|
|
|
413
711
|
throw err;
|
|
414
712
|
}
|
|
415
713
|
};
|
|
416
|
-
var httpClient = {
|
|
417
|
-
get,
|
|
418
|
-
post,
|
|
419
|
-
retries
|
|
420
|
-
};
|
|
421
|
-
|
|
422
|
-
// src/constants.ts
|
|
423
|
-
var import_viem2 = require("viem");
|
|
424
|
-
var ZORA_API_BASE = "https://api.zora.co/";
|
|
425
|
-
var OPEN_EDITION_MINT_SIZE = BigInt("18446744073709551615");
|
|
426
|
-
var SUBGRAPH_CONFIG_BASE = "https://api.goldsky.com/api/public/project_clhk16b61ay9t49vm6ntn4mkz/subgraphs";
|
|
427
|
-
function getSubgraph(name, version) {
|
|
428
|
-
return `${SUBGRAPH_CONFIG_BASE}/${name}/${version}/gn`;
|
|
429
|
-
}
|
|
430
|
-
var zora721Abi = (0, import_viem2.parseAbi)([
|
|
431
|
-
"function mintWithRewards(address recipient, uint256 quantity, string calldata comment, address mintReferral) external payable",
|
|
432
|
-
"function zoraFeeForAmount(uint256 amount) public view returns (address, uint256)"
|
|
433
|
-
]);
|
|
434
|
-
var NFT_SALE_QUERY = `
|
|
435
|
-
fragment SaleStrategy on SalesStrategyConfig {
|
|
436
|
-
type
|
|
437
|
-
fixedPrice {
|
|
438
|
-
address
|
|
439
|
-
pricePerToken
|
|
440
|
-
saleEnd
|
|
441
|
-
saleStart
|
|
442
|
-
maxTokensPerAddress
|
|
443
|
-
}
|
|
444
|
-
erc20Minter {
|
|
445
|
-
address
|
|
446
|
-
pricePerToken
|
|
447
|
-
currency
|
|
448
|
-
saleEnd
|
|
449
|
-
saleStart
|
|
450
|
-
maxTokensPerAddress
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
query ($id: ID!) {
|
|
455
|
-
zoraCreateToken(id: $id) {
|
|
456
|
-
id
|
|
457
|
-
contract {
|
|
458
|
-
mintFeePerQuantity
|
|
459
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
460
|
-
...SaleStrategy
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
salesStrategies(where: {type_in: ["FIXED_PRICE", "ERC_20_MINTER"]}) {
|
|
464
|
-
...SaleStrategy
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
`;
|
|
469
|
-
|
|
470
|
-
// src/apis/chain-constants.ts
|
|
471
|
-
var import_chains = require("viem/chains");
|
|
472
|
-
var import_viem3 = require("viem");
|
|
473
|
-
var REWARD_PER_TOKEN = (0, import_viem3.parseEther)("0.000777");
|
|
474
|
-
var networkConfigByChain = {
|
|
475
|
-
[import_chains.mainnet.id]: {
|
|
476
|
-
chainId: import_chains.mainnet.id,
|
|
477
|
-
isTestnet: false,
|
|
478
|
-
zoraCollectPathChainName: "eth",
|
|
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")
|
|
537
|
-
}
|
|
538
|
-
};
|
|
539
|
-
|
|
540
|
-
// src/mint/mint-api-client.ts
|
|
541
|
-
var getApiNetworkConfigForChain = (chainId) => {
|
|
542
|
-
if (!networkConfigByChain[chainId]) {
|
|
543
|
-
throw new Error(`chain id ${chainId} network not configured `);
|
|
544
|
-
}
|
|
545
|
-
return networkConfigByChain[chainId];
|
|
546
|
-
};
|
|
547
|
-
var MintAPIClient = class {
|
|
548
|
-
constructor(chainId, httpClient2) {
|
|
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;
|
|
641
|
-
return {
|
|
642
|
-
premintConfigVersion: import_protocol_deployments2.PremintConfigVersion.V1,
|
|
643
|
-
premintConfig: {
|
|
644
|
-
deleted: premint.deleted,
|
|
645
|
-
uid: premint.uid,
|
|
646
|
-
version: premint.version,
|
|
647
|
-
tokenConfig: {
|
|
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
|
-
}
|
|
658
|
-
};
|
|
659
|
-
} else {
|
|
660
|
-
const tokenConfig = premint.tokenConfig;
|
|
661
|
-
return {
|
|
662
|
-
premintConfigVersion: import_protocol_deployments2.PremintConfigVersion.V2,
|
|
663
|
-
premintConfig: {
|
|
664
|
-
deleted: premint.deleted,
|
|
665
|
-
uid: premint.uid,
|
|
666
|
-
version: premint.version,
|
|
667
|
-
tokenConfig: {
|
|
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
|
-
}
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
};
|
|
682
|
-
var convertGetPremintApiResponse = (response) => ({
|
|
683
|
-
...convertPremintFromApi(response.premint),
|
|
684
|
-
collection: convertCollectionFromApi(response.collection),
|
|
685
|
-
collectionAddress: response.collection_address,
|
|
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
|
-
});
|
|
714
|
+
var httpClient = {
|
|
715
|
+
get,
|
|
716
|
+
post,
|
|
717
|
+
retries
|
|
718
|
+
};
|
|
747
719
|
|
|
748
|
-
// src/
|
|
749
|
-
var
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
}
|
|
753
|
-
|
|
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
|
-
)
|
|
774
|
-
);
|
|
775
|
-
return result;
|
|
720
|
+
// src/mint/subgraph-mint-getter.ts
|
|
721
|
+
var getApiNetworkConfigForChain = (chainId) => {
|
|
722
|
+
if (!networkConfigByChain[chainId]) {
|
|
723
|
+
throw new Error(`chain id ${chainId} network not configured `);
|
|
724
|
+
}
|
|
725
|
+
return networkConfigByChain[chainId];
|
|
776
726
|
};
|
|
777
|
-
var
|
|
727
|
+
var SubgraphMintGetter = class {
|
|
778
728
|
constructor(chainId, httpClient2) {
|
|
779
|
-
this.postSignature = async ({
|
|
780
|
-
signature,
|
|
781
|
-
...rest
|
|
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
|
|
801
|
-
}) => {
|
|
802
|
-
const response = await getSignature({
|
|
803
|
-
collection_address: collectionAddress.toLowerCase(),
|
|
804
|
-
uid,
|
|
805
|
-
chain_name: this.networkConfig.zoraBackendChainName,
|
|
806
|
-
httpClient: this.httpClient
|
|
807
|
-
});
|
|
808
|
-
return convertGetPremintApiResponse(response);
|
|
809
|
-
};
|
|
810
729
|
this.httpClient = httpClient2 || httpClient;
|
|
811
730
|
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
812
731
|
}
|
|
732
|
+
async getSalesConfigAndTokenInfo({
|
|
733
|
+
tokenAddress,
|
|
734
|
+
tokenId,
|
|
735
|
+
saleType
|
|
736
|
+
}) {
|
|
737
|
+
const { retries: retries2, post: post2 } = this.httpClient;
|
|
738
|
+
return retries2(async () => {
|
|
739
|
+
const response = await post2(this.networkConfig.subgraphUrl, {
|
|
740
|
+
query: NFT_SALE_QUERY,
|
|
741
|
+
variables: {
|
|
742
|
+
id: tokenId !== void 0 ? (
|
|
743
|
+
// Generic Token ID types all stringify down to the base numeric equivalent.
|
|
744
|
+
`${tokenAddress.toLowerCase()}-${tokenId}`
|
|
745
|
+
) : `${tokenAddress.toLowerCase()}-0`
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
const token = response.data?.zoraCreateToken;
|
|
749
|
+
if (!token) {
|
|
750
|
+
throw new Error("Cannot find a token to mint");
|
|
751
|
+
}
|
|
752
|
+
const allStrategies = (typeof tokenId !== "undefined" ? token.salesStrategies : token.contract.salesStrategies) || [];
|
|
753
|
+
const saleStrategies = allStrategies.sort(
|
|
754
|
+
(a, b) => BigInt(
|
|
755
|
+
a.type === "ERC_20_MINTER" ? a.erc20Minter.saleEnd : a.fixedPrice.saleEnd
|
|
756
|
+
) > BigInt(
|
|
757
|
+
b.type === "FIXED_PRICE" ? b.fixedPrice.saleEnd : b.erc20Minter.saleEnd
|
|
758
|
+
) ? 1 : -1
|
|
759
|
+
);
|
|
760
|
+
let targetStrategy;
|
|
761
|
+
if (!saleType) {
|
|
762
|
+
targetStrategy = saleStrategies[0];
|
|
763
|
+
if (!targetStrategy) {
|
|
764
|
+
throw new Error("Cannot find sale strategy");
|
|
765
|
+
}
|
|
766
|
+
} else {
|
|
767
|
+
const mappedSaleType = saleType === "erc20" ? "ERC_20_MINTER" : "FIXED_PRICE";
|
|
768
|
+
targetStrategy = saleStrategies.find(
|
|
769
|
+
(strategy) => strategy.type === mappedSaleType
|
|
770
|
+
);
|
|
771
|
+
if (!targetStrategy) {
|
|
772
|
+
throw new Error(`Cannot find sale strategy for ${mappedSaleType}`);
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
if (targetStrategy.type === "FIXED_PRICE") {
|
|
776
|
+
return {
|
|
777
|
+
salesConfig: {
|
|
778
|
+
saleType: "fixedPrice",
|
|
779
|
+
...targetStrategy.fixedPrice,
|
|
780
|
+
maxTokensPerAddress: BigInt(
|
|
781
|
+
targetStrategy.fixedPrice.maxTokensPerAddress
|
|
782
|
+
),
|
|
783
|
+
pricePerToken: BigInt(targetStrategy.fixedPrice.pricePerToken)
|
|
784
|
+
},
|
|
785
|
+
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
if (targetStrategy.type === "ERC_20_MINTER") {
|
|
789
|
+
return {
|
|
790
|
+
salesConfig: {
|
|
791
|
+
saleType: "erc20",
|
|
792
|
+
...targetStrategy.erc20Minter,
|
|
793
|
+
maxTokensPerAddress: BigInt(
|
|
794
|
+
targetStrategy.erc20Minter.maxTokensPerAddress
|
|
795
|
+
),
|
|
796
|
+
pricePerToken: BigInt(targetStrategy.erc20Minter.pricePerToken)
|
|
797
|
+
},
|
|
798
|
+
mintFeePerQuantity: BigInt(token.contract.mintFeePerQuantity)
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
throw new Error("Invalid saleType");
|
|
802
|
+
});
|
|
803
|
+
}
|
|
813
804
|
};
|
|
814
805
|
|
|
815
806
|
// src/utils.ts
|
|
816
|
-
var
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
publicClient: publicClient || (0, import_viem4.createPublicClient)({ chain, transport: (0, import_viem4.http)() })
|
|
823
|
-
};
|
|
807
|
+
var makeContractParameters = (args) => args;
|
|
808
|
+
function mintRecipientOrAccount({
|
|
809
|
+
mintRecipient,
|
|
810
|
+
minterAccount
|
|
811
|
+
}) {
|
|
812
|
+
return mintRecipient || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
824
813
|
}
|
|
825
814
|
|
|
826
815
|
// src/premint/premint-client.ts
|
|
@@ -828,8 +817,7 @@ var defaultTokenConfigV1MintArguments = () => ({
|
|
|
828
817
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
829
818
|
maxTokensPerAddress: 0n,
|
|
830
819
|
pricePerToken: 0n,
|
|
831
|
-
mintDuration:
|
|
832
|
-
// 1 week
|
|
820
|
+
mintDuration: 0n,
|
|
833
821
|
mintStart: 0n,
|
|
834
822
|
royaltyMintSchedule: 0,
|
|
835
823
|
royaltyBPS: 1e3
|
|
@@ -854,7 +842,7 @@ var pickTokenConfigV2 = (tokenConfig) => ({
|
|
|
854
842
|
royaltyBPS: tokenConfig.royaltyBPS,
|
|
855
843
|
tokenURI: tokenConfig.tokenURI,
|
|
856
844
|
payoutRecipient: tokenConfig.payoutRecipient,
|
|
857
|
-
createReferral: tokenConfig.createReferral ||
|
|
845
|
+
createReferral: tokenConfig.createReferral || import_viem4.zeroAddress
|
|
858
846
|
});
|
|
859
847
|
var tokenConfigV1WithDefault = (tokenConfig, fixedPriceMinter) => ({
|
|
860
848
|
...pickTokenConfigV1(tokenConfig),
|
|
@@ -870,8 +858,7 @@ var defaultTokenConfigV2MintArguments = () => ({
|
|
|
870
858
|
maxSupply: OPEN_EDITION_MINT_SIZE,
|
|
871
859
|
maxTokensPerAddress: 0n,
|
|
872
860
|
pricePerToken: 0n,
|
|
873
|
-
mintDuration:
|
|
874
|
-
// 1 week
|
|
861
|
+
mintDuration: 0n,
|
|
875
862
|
mintStart: 0n,
|
|
876
863
|
royaltyBPS: 1e3
|
|
877
864
|
// 10%,
|
|
@@ -905,7 +892,7 @@ var makeTokenConfigWithDefaults = ({
|
|
|
905
892
|
function getPremintedLogFromReceipt(receipt) {
|
|
906
893
|
for (const data of receipt.logs) {
|
|
907
894
|
try {
|
|
908
|
-
const decodedLog = (0,
|
|
895
|
+
const decodedLog = (0, import_viem4.decodeEventLog)({
|
|
909
896
|
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
910
897
|
eventName: "PremintedV2",
|
|
911
898
|
...data
|
|
@@ -918,20 +905,17 @@ function getPremintedLogFromReceipt(receipt) {
|
|
|
918
905
|
}
|
|
919
906
|
}
|
|
920
907
|
var PremintClient = class {
|
|
921
|
-
constructor(
|
|
922
|
-
|
|
923
|
-
|
|
908
|
+
constructor({
|
|
909
|
+
chainId,
|
|
910
|
+
publicClient,
|
|
911
|
+
premintApi
|
|
912
|
+
}) {
|
|
913
|
+
this.chainId = chainId;
|
|
914
|
+
this.apiClient = premintApi;
|
|
924
915
|
this.publicClient = publicClient;
|
|
925
916
|
}
|
|
926
|
-
getDataFromPremintReceipt(receipt) {
|
|
927
|
-
|
|
928
|
-
return {
|
|
929
|
-
premintedLog,
|
|
930
|
-
urls: this.makeUrls({
|
|
931
|
-
address: premintedLog?.contractAddress,
|
|
932
|
-
tokenId: premintedLog?.tokenId
|
|
933
|
-
})
|
|
934
|
-
};
|
|
917
|
+
getDataFromPremintReceipt(receipt, blockExplorerUrl) {
|
|
918
|
+
return getDataFromPremintReceipt(receipt, this.chainId, blockExplorerUrl);
|
|
935
919
|
}
|
|
936
920
|
/**
|
|
937
921
|
* Prepares data for updating a premint
|
|
@@ -944,7 +928,7 @@ var PremintClient = class {
|
|
|
944
928
|
...args,
|
|
945
929
|
apiClient: this.apiClient,
|
|
946
930
|
publicClient: this.publicClient,
|
|
947
|
-
chainId: this.
|
|
931
|
+
chainId: this.chainId
|
|
948
932
|
});
|
|
949
933
|
}
|
|
950
934
|
/**
|
|
@@ -958,7 +942,7 @@ var PremintClient = class {
|
|
|
958
942
|
...params,
|
|
959
943
|
apiClient: this.apiClient,
|
|
960
944
|
publicClient: this.publicClient,
|
|
961
|
-
chainId: this.
|
|
945
|
+
chainId: this.chainId
|
|
962
946
|
});
|
|
963
947
|
}
|
|
964
948
|
/**
|
|
@@ -972,7 +956,7 @@ var PremintClient = class {
|
|
|
972
956
|
...parameters,
|
|
973
957
|
publicClient: this.publicClient,
|
|
974
958
|
apiClient: this.apiClient,
|
|
975
|
-
chainId: this.
|
|
959
|
+
chainId: this.chainId
|
|
976
960
|
});
|
|
977
961
|
}
|
|
978
962
|
/**
|
|
@@ -982,10 +966,7 @@ var PremintClient = class {
|
|
|
982
966
|
* @param uid UID for the desired premint
|
|
983
967
|
* @returns PremintSignatureGetResponse of premint data from the API
|
|
984
968
|
*/
|
|
985
|
-
async
|
|
986
|
-
address,
|
|
987
|
-
uid
|
|
988
|
-
}) {
|
|
969
|
+
async getPremint({ address, uid }) {
|
|
989
970
|
return await this.apiClient.getSignature({
|
|
990
971
|
collectionAddress: address,
|
|
991
972
|
uid
|
|
@@ -998,48 +979,9 @@ var PremintClient = class {
|
|
|
998
979
|
*/
|
|
999
980
|
async getCollectionAddress(collection) {
|
|
1000
981
|
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,
|
|
982
|
+
contract: collection,
|
|
1019
983
|
publicClient: this.publicClient
|
|
1020
984
|
});
|
|
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
|
|
1029
|
-
});
|
|
1030
|
-
return { isValid: isAuthorized, recoveredSigner: recoveredAddress };
|
|
1031
|
-
}
|
|
1032
|
-
makeUrls({
|
|
1033
|
-
uid,
|
|
1034
|
-
address,
|
|
1035
|
-
tokenId
|
|
1036
|
-
}) {
|
|
1037
|
-
return makeUrls({
|
|
1038
|
-
uid,
|
|
1039
|
-
address,
|
|
1040
|
-
tokenId,
|
|
1041
|
-
chain: this.chain
|
|
1042
|
-
});
|
|
1043
985
|
}
|
|
1044
986
|
async getMintCosts({
|
|
1045
987
|
tokenContract,
|
|
@@ -1060,17 +1002,40 @@ var PremintClient = class {
|
|
|
1060
1002
|
* @param parameters - Parameters for collecting the Premint {@link MakeMintParametersArguments}
|
|
1061
1003
|
* @returns receipt, log, zoraURL
|
|
1062
1004
|
*/
|
|
1063
|
-
async makeMintParameters(
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1005
|
+
async makeMintParameters({
|
|
1006
|
+
minterAccount,
|
|
1007
|
+
tokenContract,
|
|
1008
|
+
uid,
|
|
1009
|
+
mintArguments,
|
|
1010
|
+
firstMinter
|
|
1011
|
+
}) {
|
|
1012
|
+
return await collectPremint({
|
|
1013
|
+
uid,
|
|
1014
|
+
tokenContract,
|
|
1015
|
+
minterAccount,
|
|
1016
|
+
quantityToMint: mintArguments?.quantityToMint || 1n,
|
|
1017
|
+
mintComment: mintArguments?.mintComment,
|
|
1018
|
+
mintReferral: mintArguments?.mintReferral,
|
|
1019
|
+
mintRecipient: mintArguments?.mintRecipient,
|
|
1020
|
+
firstMinter,
|
|
1021
|
+
premintGetter: this.apiClient,
|
|
1067
1022
|
publicClient: this.publicClient
|
|
1068
1023
|
});
|
|
1069
1024
|
}
|
|
1070
1025
|
};
|
|
1071
|
-
function
|
|
1072
|
-
const
|
|
1073
|
-
return
|
|
1026
|
+
function getDataFromPremintReceipt(receipt, chainId, blockExplorerUrl) {
|
|
1027
|
+
const premintedLog = getPremintedLogFromReceipt(receipt);
|
|
1028
|
+
return {
|
|
1029
|
+
tokenId: premintedLog?.tokenId,
|
|
1030
|
+
collectionAddres: premintedLog?.contractAddress,
|
|
1031
|
+
premintedLog,
|
|
1032
|
+
urls: makeUrls({
|
|
1033
|
+
address: premintedLog?.contractAddress,
|
|
1034
|
+
tokenId: premintedLog?.tokenId,
|
|
1035
|
+
chainId,
|
|
1036
|
+
blockExplorerUrl
|
|
1037
|
+
})
|
|
1038
|
+
};
|
|
1074
1039
|
}
|
|
1075
1040
|
function makePremintReturn({
|
|
1076
1041
|
premintConfig,
|
|
@@ -1100,7 +1065,7 @@ function makePremintReturn({
|
|
|
1100
1065
|
await submit({
|
|
1101
1066
|
signature,
|
|
1102
1067
|
checkSignature,
|
|
1103
|
-
signerAccount
|
|
1068
|
+
account: signerAccount
|
|
1104
1069
|
});
|
|
1105
1070
|
return {
|
|
1106
1071
|
signature,
|
|
@@ -1110,7 +1075,7 @@ function makePremintReturn({
|
|
|
1110
1075
|
const submit = async ({
|
|
1111
1076
|
signature,
|
|
1112
1077
|
checkSignature,
|
|
1113
|
-
|
|
1078
|
+
account
|
|
1114
1079
|
}) => {
|
|
1115
1080
|
if (checkSignature) {
|
|
1116
1081
|
const isAuthorized = await isAuthorizedToCreatePremint({
|
|
@@ -1118,7 +1083,7 @@ function makePremintReturn({
|
|
|
1118
1083
|
additionalAdmins: collection?.additionalAdmins,
|
|
1119
1084
|
contractAdmin: collection?.contractAdmin,
|
|
1120
1085
|
publicClient,
|
|
1121
|
-
signer:
|
|
1086
|
+
signer: account
|
|
1122
1087
|
});
|
|
1123
1088
|
if (!isAuthorized) {
|
|
1124
1089
|
throw new Error("Not authorized to create premint");
|
|
@@ -1161,7 +1126,7 @@ async function signPremint({
|
|
|
1161
1126
|
};
|
|
1162
1127
|
}
|
|
1163
1128
|
async function createPremint({
|
|
1164
|
-
tokenCreationConfig,
|
|
1129
|
+
token: tokenCreationConfig,
|
|
1165
1130
|
uid,
|
|
1166
1131
|
publicClient,
|
|
1167
1132
|
apiClient,
|
|
@@ -1184,7 +1149,7 @@ async function createPremint({
|
|
|
1184
1149
|
premintConfig,
|
|
1185
1150
|
premintConfigVersion,
|
|
1186
1151
|
collectionAddress: collectionAddressToUse,
|
|
1187
|
-
collection: collectionOrAddress.
|
|
1152
|
+
collection: collectionOrAddress.contract,
|
|
1188
1153
|
publicClient,
|
|
1189
1154
|
apiClient,
|
|
1190
1155
|
chainId
|
|
@@ -1291,32 +1256,32 @@ async function deletePremint({
|
|
|
1291
1256
|
chainId
|
|
1292
1257
|
});
|
|
1293
1258
|
}
|
|
1294
|
-
async function
|
|
1259
|
+
async function collectPremint({
|
|
1295
1260
|
uid,
|
|
1296
1261
|
tokenContract,
|
|
1297
1262
|
minterAccount,
|
|
1298
|
-
|
|
1263
|
+
quantityToMint,
|
|
1264
|
+
mintComment = "",
|
|
1265
|
+
mintReferral,
|
|
1266
|
+
mintRecipient,
|
|
1299
1267
|
firstMinter,
|
|
1300
|
-
|
|
1268
|
+
premintGetter,
|
|
1301
1269
|
publicClient
|
|
1302
1270
|
}) {
|
|
1303
|
-
if (
|
|
1271
|
+
if (typeof quantityToMint !== "undefined" && quantityToMint < 1) {
|
|
1304
1272
|
throw new Error("Quantity to mint cannot be below 1");
|
|
1305
1273
|
}
|
|
1306
|
-
if (!minterAccount) {
|
|
1307
|
-
throw new Error("Wallet not passed in");
|
|
1308
|
-
}
|
|
1309
1274
|
const {
|
|
1310
1275
|
premintConfig,
|
|
1311
1276
|
premintConfigVersion,
|
|
1312
1277
|
collection,
|
|
1313
1278
|
collectionAddress,
|
|
1314
1279
|
signature
|
|
1315
|
-
} = await
|
|
1280
|
+
} = await premintGetter.getSignature({
|
|
1316
1281
|
collectionAddress: tokenContract,
|
|
1317
1282
|
uid
|
|
1318
1283
|
});
|
|
1319
|
-
const numberToMint = BigInt(
|
|
1284
|
+
const numberToMint = BigInt(quantityToMint || 1);
|
|
1320
1285
|
if (premintConfigVersion === import_protocol_deployments4.PremintConfigVersion.V3) {
|
|
1321
1286
|
throw new Error("PremintV3 not supported in premint SDK");
|
|
1322
1287
|
}
|
|
@@ -1325,18 +1290,21 @@ async function makeMintParameters({
|
|
|
1325
1290
|
quantityToMint: numberToMint,
|
|
1326
1291
|
publicClient,
|
|
1327
1292
|
tokenPrice: premintConfig.tokenConfig.pricePerToken
|
|
1328
|
-
})).
|
|
1293
|
+
})).totalCostEth;
|
|
1329
1294
|
const mintArgumentsContract = {
|
|
1330
|
-
mintComment
|
|
1331
|
-
mintRecipient:
|
|
1295
|
+
mintComment,
|
|
1296
|
+
mintRecipient: mintRecipientOrAccount({
|
|
1297
|
+
mintRecipient,
|
|
1298
|
+
minterAccount
|
|
1299
|
+
}),
|
|
1332
1300
|
mintRewardsRecipients: makeMintRewardsRecipient({
|
|
1333
|
-
mintReferral
|
|
1301
|
+
mintReferral
|
|
1334
1302
|
})
|
|
1335
1303
|
};
|
|
1336
1304
|
const collectionOrEmpty = collection ? defaultAdditionalAdmins(collection) : emptyContractCreationConfig();
|
|
1337
|
-
const collectionAddressToSubmit = collection ?
|
|
1305
|
+
const collectionAddressToSubmit = collection ? import_viem4.zeroAddress : collectionAddress;
|
|
1338
1306
|
const firstMinterToSubmit = firstMinter || (typeof minterAccount === "string" ? minterAccount : minterAccount.address);
|
|
1339
|
-
return
|
|
1307
|
+
return makeContractParameters({
|
|
1340
1308
|
account: minterAccount,
|
|
1341
1309
|
abi: import_protocol_deployments3.zoraCreator1155PremintExecutorImplABI,
|
|
1342
1310
|
functionName: "premint",
|
|
@@ -1353,7 +1321,7 @@ async function makeMintParameters({
|
|
|
1353
1321
|
numberToMint,
|
|
1354
1322
|
mintArgumentsContract,
|
|
1355
1323
|
firstMinterToSubmit,
|
|
1356
|
-
|
|
1324
|
+
import_viem4.zeroAddress
|
|
1357
1325
|
]
|
|
1358
1326
|
});
|
|
1359
1327
|
}
|
|
@@ -1361,15 +1329,16 @@ function makeUrls({
|
|
|
1361
1329
|
uid,
|
|
1362
1330
|
address,
|
|
1363
1331
|
tokenId,
|
|
1364
|
-
|
|
1332
|
+
chainId,
|
|
1333
|
+
blockExplorerUrl
|
|
1365
1334
|
}) {
|
|
1366
1335
|
if ((!uid || !tokenId) && !address) {
|
|
1367
1336
|
return { explorer: null, zoraCollect: null, zoraManage: null };
|
|
1368
1337
|
}
|
|
1369
1338
|
const zoraTokenPath = uid ? `premint-${uid}` : tokenId;
|
|
1370
|
-
const network = getApiNetworkConfigForChain(
|
|
1339
|
+
const network = getApiNetworkConfigForChain(chainId);
|
|
1371
1340
|
return {
|
|
1372
|
-
explorer: tokenId ? `https://${
|
|
1341
|
+
explorer: tokenId ? `https://${blockExplorerUrl}/token/${address}/instance/${tokenId}` : null,
|
|
1373
1342
|
zoraCollect: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`,
|
|
1374
1343
|
zoraManage: `https://${network.isTestnet ? "testnet." : ""}zora.co/collect/${network.zoraCollectPathChainName}:${address}/${zoraTokenPath}`
|
|
1375
1344
|
};
|
|
@@ -1384,9 +1353,85 @@ var PremintConfigVersion3 = ((PremintConfigVersion4) => {
|
|
|
1384
1353
|
return PremintConfigVersion4;
|
|
1385
1354
|
})(PremintConfigVersion3 || {});
|
|
1386
1355
|
|
|
1356
|
+
// src/premint/premint-api-client.ts
|
|
1357
|
+
var postSignature = async ({
|
|
1358
|
+
httpClient: { post: post2, retries: retries2 } = httpClient,
|
|
1359
|
+
...data
|
|
1360
|
+
}) => retries2(
|
|
1361
|
+
() => post2(`${ZORA_API_BASE}premint/signature`, data)
|
|
1362
|
+
);
|
|
1363
|
+
var getNextUID = async ({
|
|
1364
|
+
chainId,
|
|
1365
|
+
collection_address,
|
|
1366
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
1367
|
+
}) => retries2(
|
|
1368
|
+
() => get2(
|
|
1369
|
+
`${ZORA_API_BASE}premint/signature/${getApiNetworkConfigForChain(chainId).zoraBackendChainName}/${collection_address}/next_uid`
|
|
1370
|
+
)
|
|
1371
|
+
);
|
|
1372
|
+
var getSignature = async ({
|
|
1373
|
+
collectionAddress,
|
|
1374
|
+
uid,
|
|
1375
|
+
chainId,
|
|
1376
|
+
httpClient: { retries: retries2, get: get2 } = httpClient
|
|
1377
|
+
}) => {
|
|
1378
|
+
const chainName = getApiNetworkConfigForChain(chainId).zoraBackendChainName;
|
|
1379
|
+
const result = await retries2(
|
|
1380
|
+
() => get2(
|
|
1381
|
+
`${ZORA_API_BASE}premint/signature/${chainName}/${collectionAddress.toLowerCase()}/${uid}`
|
|
1382
|
+
)
|
|
1383
|
+
);
|
|
1384
|
+
return convertGetPremintApiResponse(result);
|
|
1385
|
+
};
|
|
1386
|
+
var PremintAPIClient = class {
|
|
1387
|
+
constructor(chainId, httpClient2) {
|
|
1388
|
+
this.postSignature = ({
|
|
1389
|
+
signature,
|
|
1390
|
+
...rest
|
|
1391
|
+
}) => {
|
|
1392
|
+
const data = encodePostSignatureInput({
|
|
1393
|
+
...rest,
|
|
1394
|
+
chainId: this.chainId,
|
|
1395
|
+
signature
|
|
1396
|
+
});
|
|
1397
|
+
return postSignature({
|
|
1398
|
+
...data,
|
|
1399
|
+
httpClient: this.httpClient
|
|
1400
|
+
});
|
|
1401
|
+
};
|
|
1402
|
+
this.getNextUID = async (collectionAddress) => (await getNextUID({
|
|
1403
|
+
collection_address: collectionAddress.toLowerCase(),
|
|
1404
|
+
chainId: this.chainId,
|
|
1405
|
+
httpClient: this.httpClient
|
|
1406
|
+
})).next_uid;
|
|
1407
|
+
this.getSignature = async ({
|
|
1408
|
+
collectionAddress,
|
|
1409
|
+
uid
|
|
1410
|
+
}) => {
|
|
1411
|
+
return getSignature({
|
|
1412
|
+
collectionAddress,
|
|
1413
|
+
uid,
|
|
1414
|
+
chainId: this.chainId,
|
|
1415
|
+
httpClient: this.httpClient
|
|
1416
|
+
});
|
|
1417
|
+
};
|
|
1418
|
+
this.chainId = chainId;
|
|
1419
|
+
this.httpClient = httpClient2 || httpClient;
|
|
1420
|
+
}
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1387
1423
|
// src/mint/mint-client.ts
|
|
1388
|
-
var
|
|
1424
|
+
var import_viem5 = require("viem");
|
|
1389
1425
|
var import_protocol_deployments6 = require("@zoralabs/protocol-deployments");
|
|
1426
|
+
|
|
1427
|
+
// src/mint/types.ts
|
|
1428
|
+
var isOnChainMint = (mint2) => mint2.mintType !== "premint";
|
|
1429
|
+
var is1155Mint = (mint2) => mint2.mintType === "1155";
|
|
1430
|
+
function isErc20SaleStrategy(salesConfig) {
|
|
1431
|
+
return salesConfig.saleType === "erc20";
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1434
|
+
// src/mint/mint-client.ts
|
|
1390
1435
|
var MintError = class extends Error {
|
|
1391
1436
|
};
|
|
1392
1437
|
var MintInactiveError = class extends Error {
|
|
@@ -1396,260 +1441,597 @@ var Errors = {
|
|
|
1396
1441
|
MintInactiveError
|
|
1397
1442
|
};
|
|
1398
1443
|
var MintClient = class {
|
|
1399
|
-
constructor(
|
|
1400
|
-
|
|
1444
|
+
constructor({
|
|
1445
|
+
chainId,
|
|
1446
|
+
publicClient,
|
|
1447
|
+
premintGetter,
|
|
1448
|
+
mintGetter
|
|
1449
|
+
}) {
|
|
1450
|
+
this.chainId = chainId;
|
|
1401
1451
|
this.publicClient = publicClient;
|
|
1452
|
+
this.mintGetter = mintGetter;
|
|
1453
|
+
this.premintGetter = premintGetter;
|
|
1402
1454
|
}
|
|
1403
1455
|
/**
|
|
1404
1456
|
* Returns the parameters needed to prepare a transaction mint a token.
|
|
1457
|
+
* Works with premint, onchain 1155, and onchain 721.
|
|
1405
1458
|
*
|
|
1406
|
-
* @param parameters - Parameters for collecting the token {@link
|
|
1459
|
+
* @param parameters - Parameters for collecting the token {@link MakeMintParametersArguments}
|
|
1407
1460
|
* @returns Parameters for simulating/executing the mint transaction
|
|
1408
1461
|
*/
|
|
1409
|
-
async
|
|
1410
|
-
return
|
|
1462
|
+
async mint(parameters) {
|
|
1463
|
+
return mint({
|
|
1464
|
+
parameters,
|
|
1465
|
+
chainId: this.chainId,
|
|
1466
|
+
publicClient: this.publicClient,
|
|
1467
|
+
mintGetter: this.mintGetter,
|
|
1468
|
+
premintGetter: this.premintGetter
|
|
1469
|
+
});
|
|
1470
|
+
}
|
|
1471
|
+
/**
|
|
1472
|
+
* Gets the costs to mint the quantity of tokens specified for a mint.
|
|
1473
|
+
* @param parameters - Parameters for the mint {@link GetMintCostsParameters}
|
|
1474
|
+
* @returns Costs to mint the quantity of tokens specified
|
|
1475
|
+
*/
|
|
1476
|
+
async getMintCosts(parameters) {
|
|
1477
|
+
return getMintCosts({
|
|
1411
1478
|
...parameters,
|
|
1412
|
-
|
|
1479
|
+
mintGetter: this.mintGetter,
|
|
1480
|
+
premintGetter: this.premintGetter,
|
|
1413
1481
|
publicClient: this.publicClient
|
|
1414
1482
|
});
|
|
1415
1483
|
}
|
|
1416
1484
|
};
|
|
1417
|
-
function
|
|
1418
|
-
|
|
1419
|
-
return new MintClient(chain, publicClient, httpClient2);
|
|
1485
|
+
function isPremintCollect(parameters) {
|
|
1486
|
+
return parameters.mintType === "premint";
|
|
1420
1487
|
}
|
|
1421
|
-
|
|
1488
|
+
function is721Collect(parameters) {
|
|
1489
|
+
return parameters.mintType === "721";
|
|
1490
|
+
}
|
|
1491
|
+
async function mint({
|
|
1492
|
+
parameters,
|
|
1493
|
+
chainId,
|
|
1422
1494
|
publicClient,
|
|
1423
|
-
|
|
1424
|
-
|
|
1495
|
+
mintGetter,
|
|
1496
|
+
premintGetter
|
|
1497
|
+
}) {
|
|
1498
|
+
if (isPremintCollect(parameters)) {
|
|
1499
|
+
return {
|
|
1500
|
+
parameters: await collectPremint({
|
|
1501
|
+
...parameters,
|
|
1502
|
+
premintGetter,
|
|
1503
|
+
publicClient
|
|
1504
|
+
})
|
|
1505
|
+
};
|
|
1506
|
+
}
|
|
1507
|
+
return {
|
|
1508
|
+
parameters: await collectOnchain({
|
|
1509
|
+
...parameters,
|
|
1510
|
+
mintGetter,
|
|
1511
|
+
chainId
|
|
1512
|
+
})
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
function requestErc20ApprovalForMint({
|
|
1516
|
+
account,
|
|
1425
1517
|
tokenAddress,
|
|
1426
|
-
|
|
1427
|
-
|
|
1518
|
+
quantityErc20,
|
|
1519
|
+
erc20MinterAddress: erc20MinterAddress2
|
|
1520
|
+
}) {
|
|
1521
|
+
return makeContractParameters({
|
|
1522
|
+
abi: import_viem5.erc20Abi,
|
|
1523
|
+
address: tokenAddress,
|
|
1524
|
+
account,
|
|
1525
|
+
functionName: "approve",
|
|
1526
|
+
args: [erc20MinterAddress2, quantityErc20]
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
async function getNecessaryErc20Approval({
|
|
1530
|
+
chainId,
|
|
1531
|
+
account,
|
|
1532
|
+
tokenAddress,
|
|
1533
|
+
quantityErc20,
|
|
1534
|
+
publicClient
|
|
1535
|
+
}) {
|
|
1536
|
+
const destination = import_protocol_deployments6.erc20MinterAddress[chainId];
|
|
1537
|
+
const allowance = await publicClient.readContract({
|
|
1538
|
+
abi: import_viem5.erc20Abi,
|
|
1539
|
+
address: tokenAddress,
|
|
1540
|
+
functionName: "allowance",
|
|
1541
|
+
account,
|
|
1542
|
+
args: [
|
|
1543
|
+
destination,
|
|
1544
|
+
import_protocol_deployments6.erc20MinterAddress[chainId]
|
|
1545
|
+
]
|
|
1546
|
+
});
|
|
1547
|
+
if (allowance < quantityErc20) {
|
|
1548
|
+
return requestErc20ApprovalForMint({
|
|
1549
|
+
erc20MinterAddress: destination,
|
|
1550
|
+
account,
|
|
1551
|
+
tokenAddress,
|
|
1552
|
+
quantityErc20: quantityErc20 - allowance
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1555
|
+
return void 0;
|
|
1556
|
+
}
|
|
1557
|
+
async function collectOnchain({
|
|
1558
|
+
chainId,
|
|
1559
|
+
mintGetter,
|
|
1560
|
+
...parameters
|
|
1428
1561
|
}) {
|
|
1429
|
-
const
|
|
1562
|
+
const { tokenContract, saleType } = parameters;
|
|
1563
|
+
const tokenId = is1155Mint(parameters) ? parameters.tokenId : void 0;
|
|
1564
|
+
const salesConfigAndTokenInfo = await mintGetter.getSalesConfigAndTokenInfo({
|
|
1430
1565
|
tokenId,
|
|
1431
|
-
tokenAddress,
|
|
1432
|
-
saleType
|
|
1566
|
+
tokenAddress: tokenContract,
|
|
1567
|
+
saleType
|
|
1433
1568
|
});
|
|
1434
|
-
if (
|
|
1569
|
+
if (is721Collect(parameters)) {
|
|
1435
1570
|
return makePrepareMint721TokenParams({
|
|
1436
1571
|
salesConfigAndTokenInfo,
|
|
1437
|
-
|
|
1438
|
-
mintArguments,
|
|
1439
|
-
...rest
|
|
1572
|
+
...parameters
|
|
1440
1573
|
});
|
|
1441
1574
|
}
|
|
1442
1575
|
return makePrepareMint1155TokenParams({
|
|
1443
1576
|
salesConfigAndTokenInfo,
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
mintArguments,
|
|
1447
|
-
...rest
|
|
1577
|
+
chainId,
|
|
1578
|
+
...parameters
|
|
1448
1579
|
});
|
|
1449
1580
|
}
|
|
1450
1581
|
async function makePrepareMint721TokenParams({
|
|
1451
|
-
tokenAddress,
|
|
1452
1582
|
salesConfigAndTokenInfo,
|
|
1453
1583
|
minterAccount,
|
|
1454
|
-
|
|
1584
|
+
tokenContract,
|
|
1585
|
+
mintComment,
|
|
1586
|
+
mintReferral,
|
|
1587
|
+
mintRecipient,
|
|
1588
|
+
quantityToMint
|
|
1455
1589
|
}) {
|
|
1456
|
-
const
|
|
1590
|
+
const actualQuantityToMint = BigInt(quantityToMint || 1);
|
|
1591
|
+
const mintValue = parseMintCosts({
|
|
1457
1592
|
salesConfigAndTokenInfo,
|
|
1458
|
-
quantityToMint:
|
|
1459
|
-
}).
|
|
1460
|
-
return
|
|
1593
|
+
quantityToMint: actualQuantityToMint
|
|
1594
|
+
}).totalCostEth;
|
|
1595
|
+
return makeContractParameters({
|
|
1461
1596
|
abi: zora721Abi,
|
|
1462
|
-
address:
|
|
1597
|
+
address: tokenContract,
|
|
1463
1598
|
account: minterAccount,
|
|
1464
1599
|
functionName: "mintWithRewards",
|
|
1465
1600
|
value: mintValue,
|
|
1466
1601
|
args: [
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1602
|
+
mintRecipientOrAccount({ mintRecipient, minterAccount }),
|
|
1603
|
+
actualQuantityToMint,
|
|
1604
|
+
mintComment || "",
|
|
1605
|
+
mintReferral || import_viem5.zeroAddress
|
|
1471
1606
|
]
|
|
1472
1607
|
});
|
|
1473
1608
|
}
|
|
1474
|
-
function
|
|
1609
|
+
function parseMintCosts({
|
|
1475
1610
|
salesConfigAndTokenInfo,
|
|
1476
1611
|
quantityToMint
|
|
1477
1612
|
}) {
|
|
1478
1613
|
const mintFeeForTokens = salesConfigAndTokenInfo.mintFeePerQuantity * quantityToMint;
|
|
1479
1614
|
const tokenPurchaseCost = BigInt(salesConfigAndTokenInfo.salesConfig.pricePerToken) * quantityToMint;
|
|
1615
|
+
const totalPurchaseCostCurrency = isErc20SaleStrategy(
|
|
1616
|
+
salesConfigAndTokenInfo.salesConfig
|
|
1617
|
+
) ? salesConfigAndTokenInfo.salesConfig.currency : void 0;
|
|
1618
|
+
const totalPurchaseCostEth = totalPurchaseCostCurrency ? 0n : tokenPurchaseCost;
|
|
1480
1619
|
return {
|
|
1481
1620
|
mintFee: mintFeeForTokens,
|
|
1482
|
-
tokenPurchaseCost,
|
|
1483
|
-
|
|
1621
|
+
totalPurchaseCost: tokenPurchaseCost,
|
|
1622
|
+
totalPurchaseCostCurrency,
|
|
1623
|
+
totalCostEth: mintFeeForTokens + totalPurchaseCostEth
|
|
1484
1624
|
};
|
|
1485
1625
|
}
|
|
1486
|
-
async function
|
|
1626
|
+
async function getMintCosts(params) {
|
|
1627
|
+
const { quantityMinted: quantityToMint, collection, publicClient } = params;
|
|
1628
|
+
if (isOnChainMint(params)) {
|
|
1629
|
+
const tokenId = is1155Mint(params) ? params.tokenId : void 0;
|
|
1630
|
+
const salesConfigAndTokenInfo = await params.mintGetter.getSalesConfigAndTokenInfo({
|
|
1631
|
+
tokenId,
|
|
1632
|
+
tokenAddress: collection
|
|
1633
|
+
});
|
|
1634
|
+
return parseMintCosts({
|
|
1635
|
+
salesConfigAndTokenInfo,
|
|
1636
|
+
quantityToMint: BigInt(quantityToMint)
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
return getPremintMintCostsWithUnknownTokenPrice({
|
|
1640
|
+
premintGetter: params.premintGetter,
|
|
1641
|
+
publicClient,
|
|
1642
|
+
quantityToMint: BigInt(quantityToMint),
|
|
1643
|
+
uid: params.uid,
|
|
1644
|
+
tokenContract: collection
|
|
1645
|
+
});
|
|
1646
|
+
}
|
|
1647
|
+
function makePrepareMint1155TokenParams({
|
|
1648
|
+
tokenContract,
|
|
1487
1649
|
tokenId,
|
|
1488
1650
|
salesConfigAndTokenInfo,
|
|
1489
1651
|
minterAccount,
|
|
1490
|
-
|
|
1491
|
-
|
|
1652
|
+
mintComment,
|
|
1653
|
+
mintReferral,
|
|
1654
|
+
mintRecipient,
|
|
1655
|
+
quantityToMint,
|
|
1656
|
+
chainId
|
|
1492
1657
|
}) {
|
|
1493
|
-
const mintQuantity = BigInt(
|
|
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
|
-
default:
|
|
1539
|
-
throw new MintError("Unsupported sale type");
|
|
1658
|
+
const mintQuantity = BigInt(quantityToMint || 1);
|
|
1659
|
+
const mintTo = mintRecipientOrAccount({ mintRecipient, minterAccount });
|
|
1660
|
+
const saleType = salesConfigAndTokenInfo.salesConfig.saleType;
|
|
1661
|
+
if (saleType === "fixedPrice") {
|
|
1662
|
+
const mintValue = parseMintCosts({
|
|
1663
|
+
salesConfigAndTokenInfo,
|
|
1664
|
+
quantityToMint: mintQuantity
|
|
1665
|
+
}).totalCostEth;
|
|
1666
|
+
return makeContractParameters({
|
|
1667
|
+
abi: import_protocol_deployments6.zoraCreator1155ImplABI,
|
|
1668
|
+
functionName: "mintWithRewards",
|
|
1669
|
+
account: minterAccount,
|
|
1670
|
+
value: mintValue,
|
|
1671
|
+
address: tokenContract,
|
|
1672
|
+
/* args: minter, tokenId, quantity, minterArguments, mintReferral */
|
|
1673
|
+
args: [
|
|
1674
|
+
salesConfigAndTokenInfo.salesConfig.address || import_protocol_deployments6.zoraCreatorFixedPriceSaleStrategyAddress[chainId],
|
|
1675
|
+
BigInt(tokenId),
|
|
1676
|
+
mintQuantity,
|
|
1677
|
+
(0, import_viem5.encodeAbiParameters)((0, import_viem5.parseAbiParameters)("address, string"), [
|
|
1678
|
+
mintTo,
|
|
1679
|
+
mintComment || ""
|
|
1680
|
+
]),
|
|
1681
|
+
mintReferral || import_viem5.zeroAddress
|
|
1682
|
+
]
|
|
1683
|
+
});
|
|
1684
|
+
}
|
|
1685
|
+
if (saleType === "erc20") {
|
|
1686
|
+
return makeContractParameters({
|
|
1687
|
+
abi: import_protocol_deployments6.erc20MinterABI,
|
|
1688
|
+
functionName: "mint",
|
|
1689
|
+
account: minterAccount,
|
|
1690
|
+
address: salesConfigAndTokenInfo?.salesConfig.address || import_protocol_deployments6.erc20MinterAddress[chainId],
|
|
1691
|
+
/* args: mintTo, quantity, tokenAddress, tokenId, totalValue, currency, mintReferral, comment */
|
|
1692
|
+
args: [
|
|
1693
|
+
mintTo,
|
|
1694
|
+
mintQuantity,
|
|
1695
|
+
tokenContract,
|
|
1696
|
+
BigInt(tokenId),
|
|
1697
|
+
salesConfigAndTokenInfo.salesConfig.pricePerToken * mintQuantity,
|
|
1698
|
+
salesConfigAndTokenInfo.salesConfig.currency,
|
|
1699
|
+
mintReferral || import_viem5.zeroAddress,
|
|
1700
|
+
mintComment || ""
|
|
1701
|
+
]
|
|
1702
|
+
});
|
|
1540
1703
|
}
|
|
1704
|
+
throw new MintError("Unsupported sale type");
|
|
1541
1705
|
}
|
|
1542
1706
|
|
|
1543
1707
|
// src/create/1155-create-helper.ts
|
|
1544
|
-
var
|
|
1708
|
+
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
1545
1709
|
var import_viem7 = require("viem");
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
var
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
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
|
|
1710
|
+
|
|
1711
|
+
// src/create/contract-setup.ts
|
|
1712
|
+
var import_protocol_deployments7 = require("@zoralabs/protocol-deployments");
|
|
1713
|
+
function new1155ContractVersion(chainId) {
|
|
1714
|
+
const address = import_protocol_deployments7.contracts1155.addresses[chainId];
|
|
1715
|
+
if (!address) {
|
|
1716
|
+
throw new Error(`No contract address for chainId ${chainId}`);
|
|
1717
|
+
}
|
|
1718
|
+
return address.CONTRACT_1155_IMPL_VERSION;
|
|
1719
|
+
}
|
|
1720
|
+
async function getContractInfo({
|
|
1721
|
+
publicClient,
|
|
1722
|
+
chainId,
|
|
1723
|
+
contract,
|
|
1724
|
+
account
|
|
1575
1725
|
}) {
|
|
1576
|
-
|
|
1577
|
-
|
|
1726
|
+
const contractAddress = typeof contract === "string" ? contract : await publicClient.readContract({
|
|
1727
|
+
abi: import_protocol_deployments7.zoraCreator1155FactoryImplABI,
|
|
1728
|
+
// Since this address is deterministic we can hardcode a chain id safely here.
|
|
1729
|
+
address: import_protocol_deployments7.zoraCreator1155FactoryImplAddress[chainId],
|
|
1730
|
+
functionName: "deterministicContractAddress",
|
|
1731
|
+
args: [
|
|
1732
|
+
account,
|
|
1733
|
+
contract.uri,
|
|
1734
|
+
contract.name,
|
|
1735
|
+
contract.defaultAdmin || account
|
|
1736
|
+
]
|
|
1737
|
+
});
|
|
1738
|
+
let contractVersion;
|
|
1739
|
+
let contractExists;
|
|
1740
|
+
try {
|
|
1741
|
+
contractVersion = await publicClient.readContract({
|
|
1742
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1743
|
+
address: contractAddress,
|
|
1744
|
+
functionName: "contractVersion"
|
|
1745
|
+
});
|
|
1746
|
+
contractExists = true;
|
|
1747
|
+
} catch (e) {
|
|
1748
|
+
contractVersion = new1155ContractVersion(chainId);
|
|
1749
|
+
contractExists = false;
|
|
1578
1750
|
}
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1751
|
+
const nextTokenId = contractExists ? await publicClient.readContract({
|
|
1752
|
+
address: contractAddress,
|
|
1753
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
1754
|
+
functionName: "nextTokenId"
|
|
1755
|
+
}) : 1n;
|
|
1756
|
+
return {
|
|
1757
|
+
contractExists,
|
|
1758
|
+
contractAddress,
|
|
1759
|
+
contractVersion,
|
|
1760
|
+
nextTokenId
|
|
1761
|
+
};
|
|
1762
|
+
}
|
|
1763
|
+
|
|
1764
|
+
// src/create/token-setup.ts
|
|
1765
|
+
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
1766
|
+
var import_viem6 = require("viem");
|
|
1767
|
+
var semver = __toESM(require("semver"), 1);
|
|
1768
|
+
var PERMISSION_BITS = {
|
|
1769
|
+
MINTER: 2n ** 2n
|
|
1770
|
+
};
|
|
1771
|
+
var saleSettingsOrDefault = (saleSettings) => {
|
|
1772
|
+
const SALE_END_FOREVER = 18446744073709551615n;
|
|
1773
|
+
const DEFAULT_SALE_SETTINGS = {
|
|
1774
|
+
currency: import_viem6.zeroAddress,
|
|
1775
|
+
// Free Mint
|
|
1776
|
+
pricePerToken: 0n,
|
|
1777
|
+
// Sale start time – defaults to beginning of unix time
|
|
1778
|
+
saleStart: 0n,
|
|
1779
|
+
// This is the end of uint64, plenty of time
|
|
1780
|
+
saleEnd: SALE_END_FOREVER,
|
|
1781
|
+
// 0 Here means no limit
|
|
1782
|
+
maxTokensPerAddress: 0n
|
|
1783
|
+
};
|
|
1784
|
+
return {
|
|
1583
1785
|
...DEFAULT_SALE_SETTINGS,
|
|
1584
|
-
|
|
1585
|
-
...salesConfig
|
|
1786
|
+
...saleSettings
|
|
1586
1787
|
};
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
createReferral
|
|
1594
|
-
|
|
1788
|
+
};
|
|
1789
|
+
function applyNew1155Defaults(props, ownerAddress) {
|
|
1790
|
+
const { payoutRecipient: fundsRecipient } = props;
|
|
1791
|
+
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem6.zeroAddress ? fundsRecipient : ownerAddress;
|
|
1792
|
+
return {
|
|
1793
|
+
payoutRecipient: fundsRecipientOrOwner,
|
|
1794
|
+
createReferral: props.createReferral || import_viem6.zeroAddress,
|
|
1795
|
+
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
1796
|
+
royaltyBPS: props.royaltyBPS || 1e3,
|
|
1797
|
+
salesConfig: saleSettingsOrDefault(props.salesConfig),
|
|
1798
|
+
tokenMetadataURI: props.tokenMetadataURI
|
|
1799
|
+
};
|
|
1800
|
+
}
|
|
1801
|
+
function setupErc20Minter({
|
|
1802
|
+
pricePerToken,
|
|
1803
|
+
chainId,
|
|
1804
|
+
tokenId: nextTokenId,
|
|
1805
|
+
currency,
|
|
1806
|
+
saleStart,
|
|
1807
|
+
saleEnd,
|
|
1808
|
+
maxTokensPerAddress: mintLimit,
|
|
1809
|
+
fundsRecipient
|
|
1810
|
+
}) {
|
|
1811
|
+
const erc20MinterAddress2 = import_protocol_deployments8.erc20MinterAddress[chainId];
|
|
1812
|
+
if (!erc20MinterAddress2)
|
|
1813
|
+
throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
|
|
1814
|
+
const erc20MinterApproval = (0, import_viem6.encodeFunctionData)({
|
|
1815
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1816
|
+
functionName: "addPermission",
|
|
1817
|
+
args: [BigInt(nextTokenId), erc20MinterAddress2, PERMISSION_BITS.MINTER]
|
|
1818
|
+
});
|
|
1819
|
+
const saleData = (0, import_viem6.encodeFunctionData)({
|
|
1820
|
+
abi: import_protocol_deployments8.erc20MinterABI,
|
|
1821
|
+
functionName: "setSale",
|
|
1822
|
+
args: [
|
|
1823
|
+
BigInt(nextTokenId),
|
|
1824
|
+
{
|
|
1825
|
+
saleStart: saleStart || BigInt(0),
|
|
1826
|
+
saleEnd: saleEnd || BigInt(0),
|
|
1827
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
1828
|
+
pricePerToken,
|
|
1829
|
+
fundsRecipient,
|
|
1830
|
+
currency
|
|
1831
|
+
}
|
|
1832
|
+
]
|
|
1833
|
+
});
|
|
1834
|
+
const callSale = (0, import_viem6.encodeFunctionData)({
|
|
1835
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1836
|
+
functionName: "callSale",
|
|
1837
|
+
args: [BigInt(nextTokenId), erc20MinterAddress2, saleData]
|
|
1838
|
+
});
|
|
1839
|
+
return {
|
|
1840
|
+
minter: erc20MinterAddress2,
|
|
1841
|
+
setupActions: [erc20MinterApproval, callSale]
|
|
1842
|
+
};
|
|
1843
|
+
}
|
|
1844
|
+
function setupFixedPriceMinter({
|
|
1845
|
+
pricePerToken: price,
|
|
1846
|
+
tokenId: nextTokenId,
|
|
1847
|
+
chainId,
|
|
1848
|
+
saleStart,
|
|
1849
|
+
saleEnd,
|
|
1850
|
+
maxTokensPerAddress: mintLimit,
|
|
1851
|
+
fundsRecipient
|
|
1852
|
+
}) {
|
|
1853
|
+
const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
1854
|
+
const fixedPriceApproval = (0, import_viem6.encodeFunctionData)({
|
|
1855
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1856
|
+
functionName: "addPermission",
|
|
1857
|
+
args: [
|
|
1858
|
+
BigInt(nextTokenId),
|
|
1859
|
+
fixedPriceStrategyAddress,
|
|
1860
|
+
PERMISSION_BITS.MINTER
|
|
1861
|
+
]
|
|
1862
|
+
});
|
|
1863
|
+
const saleData = (0, import_viem6.encodeFunctionData)({
|
|
1864
|
+
abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
|
|
1865
|
+
functionName: "setSale",
|
|
1866
|
+
args: [
|
|
1867
|
+
BigInt(nextTokenId),
|
|
1868
|
+
{
|
|
1869
|
+
pricePerToken: price,
|
|
1870
|
+
saleStart: saleStart || BigInt(0),
|
|
1871
|
+
saleEnd: saleEnd || BigInt(0),
|
|
1872
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
1873
|
+
fundsRecipient
|
|
1874
|
+
}
|
|
1875
|
+
]
|
|
1876
|
+
});
|
|
1877
|
+
const callSale = (0, import_viem6.encodeFunctionData)({
|
|
1878
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1879
|
+
functionName: "callSale",
|
|
1880
|
+
args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
|
|
1881
|
+
});
|
|
1882
|
+
return {
|
|
1883
|
+
minter: fixedPriceStrategyAddress,
|
|
1884
|
+
setupActions: [fixedPriceApproval, callSale]
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
function setupMinters({ salesConfig, ...rest }) {
|
|
1888
|
+
if (!salesConfig)
|
|
1889
|
+
throw new Error("No sales config for token");
|
|
1890
|
+
const { currency: currencyAddress } = salesConfig;
|
|
1891
|
+
if (currencyAddress === import_viem6.zeroAddress) {
|
|
1892
|
+
return setupFixedPriceMinter({
|
|
1893
|
+
...salesConfig,
|
|
1894
|
+
...rest
|
|
1895
|
+
});
|
|
1896
|
+
} else {
|
|
1897
|
+
return setupErc20Minter({
|
|
1898
|
+
...salesConfig,
|
|
1899
|
+
...rest
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
}
|
|
1903
|
+
function buildSetupNewToken({
|
|
1904
|
+
tokenURI,
|
|
1905
|
+
maxSupply = OPEN_EDITION_MINT_SIZE,
|
|
1906
|
+
createReferral = import_viem6.zeroAddress,
|
|
1907
|
+
contractVersion
|
|
1908
|
+
}) {
|
|
1909
|
+
if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
|
|
1910
|
+
return (0, import_viem6.encodeFunctionData)({
|
|
1911
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1595
1912
|
functionName: "setupNewTokenWithCreateReferral",
|
|
1596
|
-
args: [
|
|
1597
|
-
})
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1913
|
+
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
if (createReferral !== import_viem6.zeroAddress) {
|
|
1917
|
+
throw new Error(
|
|
1918
|
+
"Contract does not support create referral, but one was provided"
|
|
1919
|
+
);
|
|
1920
|
+
}
|
|
1921
|
+
return (0, import_viem6.encodeFunctionData)({
|
|
1922
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1923
|
+
functionName: "setupNewToken",
|
|
1924
|
+
args: [tokenURI, BigInt(maxSupply)]
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
function setupRoyaltyConfig({
|
|
1928
|
+
royaltyBPS,
|
|
1929
|
+
royaltyRecipient,
|
|
1930
|
+
nextTokenId
|
|
1931
|
+
}) {
|
|
1932
|
+
if (royaltyBPS > 0 && royaltyRecipient != import_viem6.zeroAddress) {
|
|
1933
|
+
return (0, import_viem6.encodeFunctionData)({
|
|
1934
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1935
|
+
functionName: "updateRoyaltiesForToken",
|
|
1610
1936
|
args: [
|
|
1611
1937
|
nextTokenId,
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
})
|
|
1938
|
+
{
|
|
1939
|
+
royaltyBPS,
|
|
1940
|
+
royaltyRecipient,
|
|
1941
|
+
royaltyMintSchedule: 0
|
|
1942
|
+
}
|
|
1618
1943
|
]
|
|
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
|
-
);
|
|
1944
|
+
});
|
|
1629
1945
|
}
|
|
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
|
-
);
|
|
1946
|
+
return null;
|
|
1947
|
+
}
|
|
1948
|
+
function makeAdminMintCall({
|
|
1949
|
+
ownerAddress,
|
|
1950
|
+
mintQuantity,
|
|
1951
|
+
nextTokenId
|
|
1952
|
+
}) {
|
|
1953
|
+
if (!mintQuantity || mintQuantity <= 0 || !ownerAddress) {
|
|
1954
|
+
return null;
|
|
1645
1955
|
}
|
|
1646
|
-
return
|
|
1956
|
+
return (0, import_viem6.encodeFunctionData)({
|
|
1957
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1958
|
+
functionName: "adminMint",
|
|
1959
|
+
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem6.zeroAddress]
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
function constructCreate1155TokenCalls(props) {
|
|
1963
|
+
const {
|
|
1964
|
+
chainId,
|
|
1965
|
+
nextTokenId,
|
|
1966
|
+
mintToCreatorCount,
|
|
1967
|
+
ownerAddress,
|
|
1968
|
+
contractVersion
|
|
1969
|
+
} = props;
|
|
1970
|
+
const new1155TokenPropsWithDefaults = applyNew1155Defaults(
|
|
1971
|
+
props,
|
|
1972
|
+
ownerAddress
|
|
1973
|
+
);
|
|
1974
|
+
const verifyTokenIdExpected = (0, import_viem6.encodeFunctionData)({
|
|
1975
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
1976
|
+
functionName: "assumeLastTokenIdMatches",
|
|
1977
|
+
args: [nextTokenId - 1n]
|
|
1978
|
+
});
|
|
1979
|
+
const setupNewToken = buildSetupNewToken({
|
|
1980
|
+
tokenURI: new1155TokenPropsWithDefaults.tokenMetadataURI,
|
|
1981
|
+
maxSupply: new1155TokenPropsWithDefaults.maxSupply,
|
|
1982
|
+
createReferral: new1155TokenPropsWithDefaults.createReferral,
|
|
1983
|
+
contractVersion
|
|
1984
|
+
});
|
|
1985
|
+
const royaltyConfig = setupRoyaltyConfig({
|
|
1986
|
+
royaltyBPS: new1155TokenPropsWithDefaults.royaltyBPS,
|
|
1987
|
+
royaltyRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
1988
|
+
nextTokenId
|
|
1989
|
+
});
|
|
1990
|
+
const { minter, setupActions: mintersSetup } = setupMinters({
|
|
1991
|
+
tokenId: nextTokenId,
|
|
1992
|
+
chainId,
|
|
1993
|
+
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
1994
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
1995
|
+
});
|
|
1996
|
+
const adminMintCall = makeAdminMintCall({
|
|
1997
|
+
ownerAddress,
|
|
1998
|
+
mintQuantity: mintToCreatorCount,
|
|
1999
|
+
nextTokenId
|
|
2000
|
+
});
|
|
2001
|
+
const setupActions = [
|
|
2002
|
+
verifyTokenIdExpected,
|
|
2003
|
+
setupNewToken,
|
|
2004
|
+
...mintersSetup,
|
|
2005
|
+
royaltyConfig,
|
|
2006
|
+
adminMintCall
|
|
2007
|
+
].filter((item) => item !== null);
|
|
2008
|
+
return {
|
|
2009
|
+
setupActions,
|
|
2010
|
+
minter,
|
|
2011
|
+
newToken: new1155TokenPropsWithDefaults
|
|
2012
|
+
};
|
|
1647
2013
|
}
|
|
2014
|
+
var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
2015
|
+
if (!contractStandard || !contractVersion) {
|
|
2016
|
+
return false;
|
|
2017
|
+
}
|
|
2018
|
+
const semVerContractVersion = semver.coerce(contractVersion)?.raw;
|
|
2019
|
+
if (!semVerContractVersion)
|
|
2020
|
+
return false;
|
|
2021
|
+
if (contractStandard === "ERC1155") {
|
|
2022
|
+
return semver.gte(semVerContractVersion, "1.3.5");
|
|
2023
|
+
} else {
|
|
2024
|
+
return semver.gte(semVerContractVersion, "14.0.0");
|
|
2025
|
+
}
|
|
2026
|
+
};
|
|
2027
|
+
|
|
2028
|
+
// src/create/1155-create-helper.ts
|
|
2029
|
+
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
1648
2030
|
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
1649
2031
|
for (const data of receipt.logs) {
|
|
1650
2032
|
try {
|
|
1651
2033
|
const decodedLog = (0, import_viem7.decodeEventLog)({
|
|
1652
|
-
abi:
|
|
2034
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
1653
2035
|
eventName: "SetupNewToken",
|
|
1654
2036
|
...data
|
|
1655
2037
|
});
|
|
@@ -1660,132 +2042,116 @@ var getTokenIdFromCreateReceipt = (receipt) => {
|
|
|
1660
2042
|
}
|
|
1661
2043
|
}
|
|
1662
2044
|
};
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
2045
|
+
function makeCreateContractAndTokenCall({
|
|
2046
|
+
contractExists,
|
|
2047
|
+
contractAddress,
|
|
2048
|
+
contract,
|
|
2049
|
+
account,
|
|
2050
|
+
royaltyBPS,
|
|
2051
|
+
tokenSetupActions,
|
|
2052
|
+
fundsRecipient
|
|
2053
|
+
}) {
|
|
2054
|
+
if (!contractAddress && typeof contract === "string") {
|
|
2055
|
+
throw new Error("Invariant: contract cannot be missing and an address");
|
|
2056
|
+
}
|
|
2057
|
+
if (!contractExists) {
|
|
2058
|
+
if (typeof contract === "string") {
|
|
2059
|
+
throw new Error("Invariant: expected contract object");
|
|
2060
|
+
}
|
|
2061
|
+
const accountAddress = typeof account === "string" ? account : account.address;
|
|
2062
|
+
return makeContractParameters({
|
|
2063
|
+
abi: import_protocol_deployments9.zoraCreator1155FactoryImplABI,
|
|
2064
|
+
functionName: "createContractDeterministic",
|
|
2065
|
+
account,
|
|
2066
|
+
address: import_protocol_deployments9.zoraCreator1155FactoryImplAddress[999],
|
|
1672
2067
|
args: [
|
|
1673
|
-
account,
|
|
1674
2068
|
contract.uri,
|
|
1675
2069
|
contract.name,
|
|
1676
|
-
|
|
2070
|
+
{
|
|
2071
|
+
// deprecated
|
|
2072
|
+
royaltyMintSchedule: 0,
|
|
2073
|
+
royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
2074
|
+
royaltyRecipient: fundsRecipient || accountAddress
|
|
2075
|
+
},
|
|
2076
|
+
contract.defaultAdmin || accountAddress,
|
|
2077
|
+
tokenSetupActions
|
|
1677
2078
|
]
|
|
1678
2079
|
});
|
|
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
2080
|
}
|
|
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,
|
|
2081
|
+
return makeContractParameters({
|
|
2082
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
2083
|
+
functionName: "multicall",
|
|
1703
2084
|
account,
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
2085
|
+
address: contractAddress,
|
|
2086
|
+
args: [tokenSetupActions]
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
var Create1155Client = class {
|
|
2090
|
+
constructor({
|
|
2091
|
+
chainId,
|
|
2092
|
+
publicClient
|
|
1707
2093
|
}) {
|
|
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
|
|
2094
|
+
this.chainId = chainId;
|
|
2095
|
+
this.publicClient = publicClient;
|
|
2096
|
+
}
|
|
2097
|
+
async createNew1155Token(props) {
|
|
2098
|
+
return createNew1155Token({
|
|
2099
|
+
...props,
|
|
2100
|
+
publicClient: this.publicClient,
|
|
2101
|
+
chainId: this.chainId
|
|
1736
2102
|
});
|
|
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
2103
|
}
|
|
1788
|
-
|
|
2104
|
+
};
|
|
2105
|
+
async function createNew1155Token({
|
|
2106
|
+
contract,
|
|
2107
|
+
account,
|
|
2108
|
+
getAdditionalSetupActions,
|
|
2109
|
+
token: tokenConfig,
|
|
2110
|
+
publicClient,
|
|
2111
|
+
chainId
|
|
2112
|
+
}) {
|
|
2113
|
+
const { contractExists, contractAddress, nextTokenId, contractVersion } = await getContractInfo({
|
|
2114
|
+
publicClient,
|
|
2115
|
+
chainId,
|
|
2116
|
+
contract,
|
|
2117
|
+
account
|
|
2118
|
+
});
|
|
2119
|
+
const {
|
|
2120
|
+
minter,
|
|
2121
|
+
newToken,
|
|
2122
|
+
setupActions: tokenSetupActions
|
|
2123
|
+
} = constructCreate1155TokenCalls({
|
|
2124
|
+
chainId,
|
|
2125
|
+
ownerAddress: account,
|
|
2126
|
+
contractVersion,
|
|
2127
|
+
nextTokenId,
|
|
2128
|
+
...tokenConfig
|
|
2129
|
+
});
|
|
2130
|
+
const setupActions = getAdditionalSetupActions ? [
|
|
2131
|
+
...getAdditionalSetupActions({
|
|
2132
|
+
tokenId: nextTokenId,
|
|
2133
|
+
contractAddress
|
|
2134
|
+
}),
|
|
2135
|
+
...tokenSetupActions
|
|
2136
|
+
] : tokenSetupActions;
|
|
2137
|
+
const request = makeCreateContractAndTokenCall({
|
|
2138
|
+
contractExists,
|
|
2139
|
+
contractAddress,
|
|
2140
|
+
contract,
|
|
2141
|
+
account,
|
|
2142
|
+
tokenSetupActions: setupActions,
|
|
2143
|
+
royaltyBPS: tokenConfig.royaltyBPS,
|
|
2144
|
+
fundsRecipient: tokenConfig.payoutRecipient
|
|
2145
|
+
});
|
|
2146
|
+
return {
|
|
2147
|
+
parameters: request,
|
|
2148
|
+
tokenSetupActions,
|
|
2149
|
+
collectionAddress: contractAddress,
|
|
2150
|
+
contractExists,
|
|
2151
|
+
newTokenId: nextTokenId,
|
|
2152
|
+
newToken,
|
|
2153
|
+
minter
|
|
2154
|
+
};
|
|
1789
2155
|
}
|
|
1790
2156
|
|
|
1791
2157
|
// src/mints/mints-queries.ts
|
|
@@ -1845,7 +2211,7 @@ var sumBalances = (mintAccountBalances) => {
|
|
|
1845
2211
|
};
|
|
1846
2212
|
|
|
1847
2213
|
// src/mints/mints-contracts.ts
|
|
1848
|
-
var
|
|
2214
|
+
var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
|
|
1849
2215
|
var import_viem8 = require("viem");
|
|
1850
2216
|
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
1851
2217
|
var mintWithEthParams = ({
|
|
@@ -1854,9 +2220,9 @@ var mintWithEthParams = ({
|
|
|
1854
2220
|
chainId,
|
|
1855
2221
|
pricePerMint,
|
|
1856
2222
|
account
|
|
1857
|
-
}) =>
|
|
1858
|
-
abi:
|
|
1859
|
-
address:
|
|
2223
|
+
}) => makeContractParameters({
|
|
2224
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
2225
|
+
address: import_protocol_deployments10.zoraMintsManagerImplConfig.address[chainId],
|
|
1860
2226
|
functionName: "mintWithEth",
|
|
1861
2227
|
args: [quantity, recipient || addressOrAccountAddress(account)],
|
|
1862
2228
|
value: pricePerMint * quantity,
|
|
@@ -1871,8 +2237,8 @@ var mintsBalanceOfAccountParams = ({
|
|
|
1871
2237
|
account,
|
|
1872
2238
|
chainId
|
|
1873
2239
|
}) => ({
|
|
1874
|
-
abi:
|
|
1875
|
-
address:
|
|
2240
|
+
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
2241
|
+
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
1876
2242
|
functionName: "balanceOfAccount",
|
|
1877
2243
|
args: [account]
|
|
1878
2244
|
});
|
|
@@ -1882,7 +2248,7 @@ var encodeCollectOnManager = ({
|
|
|
1882
2248
|
zoraCreator1155TokenId,
|
|
1883
2249
|
mintArguments
|
|
1884
2250
|
}) => (0, import_viem8.encodeFunctionData)({
|
|
1885
|
-
abi:
|
|
2251
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
1886
2252
|
functionName: "collect",
|
|
1887
2253
|
args: [
|
|
1888
2254
|
zoraCreator1155Contract,
|
|
@@ -1910,9 +2276,9 @@ function collectWithMintsParams({
|
|
|
1910
2276
|
minter,
|
|
1911
2277
|
mintArguments
|
|
1912
2278
|
});
|
|
1913
|
-
return
|
|
1914
|
-
abi:
|
|
1915
|
-
address:
|
|
2279
|
+
return makeContractParameters({
|
|
2280
|
+
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
2281
|
+
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
1916
2282
|
functionName: "transferBatchToManagerAndCall",
|
|
1917
2283
|
args: [tokenIds, quantities, call],
|
|
1918
2284
|
// 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 +2291,12 @@ function getMintsEthPrice({
|
|
|
1925
2291
|
publicClient
|
|
1926
2292
|
}) {
|
|
1927
2293
|
const chainId = publicClient.chain?.id;
|
|
1928
|
-
if (!chainId || !
|
|
2294
|
+
if (!chainId || !import_protocol_deployments10.zoraMintsManagerImplAddress[chainId]) {
|
|
1929
2295
|
throw new Error(`Chain id ${chainId} not supported`);
|
|
1930
2296
|
}
|
|
1931
2297
|
return publicClient.readContract({
|
|
1932
|
-
abi:
|
|
1933
|
-
address:
|
|
2298
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplABI,
|
|
2299
|
+
address: import_protocol_deployments10.zoraMintsManagerImplAddress[chainId],
|
|
1934
2300
|
functionName: "getEthPrice"
|
|
1935
2301
|
});
|
|
1936
2302
|
}
|
|
@@ -1954,7 +2320,7 @@ function makePermitTransferBatchAndTypeData({
|
|
|
1954
2320
|
safeTransferData
|
|
1955
2321
|
};
|
|
1956
2322
|
const typedData = {
|
|
1957
|
-
...(0,
|
|
2323
|
+
...(0, import_protocol_deployments10.mintsSafeTransferBatchTypedDataDefinition)({
|
|
1958
2324
|
chainId,
|
|
1959
2325
|
message: permit
|
|
1960
2326
|
}),
|
|
@@ -1985,7 +2351,7 @@ function makePermitTransferTypeData({
|
|
|
1985
2351
|
safeTransferData
|
|
1986
2352
|
};
|
|
1987
2353
|
const typedData = {
|
|
1988
|
-
...(0,
|
|
2354
|
+
...(0, import_protocol_deployments10.mintsSafeTransferTypedDataDefinition)({
|
|
1989
2355
|
chainId,
|
|
1990
2356
|
message: permit
|
|
1991
2357
|
}),
|
|
@@ -2003,7 +2369,7 @@ var encodePremintOnManager = ({
|
|
|
2003
2369
|
mintArguments,
|
|
2004
2370
|
signerContract = import_viem8.zeroAddress
|
|
2005
2371
|
}) => (0, import_viem8.encodeFunctionData)({
|
|
2006
|
-
abi:
|
|
2372
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplConfig.abi,
|
|
2007
2373
|
functionName: "collectPremintV2",
|
|
2008
2374
|
args: [
|
|
2009
2375
|
contractCreationConfig,
|
|
@@ -2042,7 +2408,7 @@ var makePermitToCollectPremintOrNonPremint = ({
|
|
|
2042
2408
|
nonce,
|
|
2043
2409
|
deadline,
|
|
2044
2410
|
safeTransferData,
|
|
2045
|
-
to:
|
|
2411
|
+
to: import_protocol_deployments10.zoraMintsManagerImplConfig.address[chainId]
|
|
2046
2412
|
});
|
|
2047
2413
|
};
|
|
2048
2414
|
function collectPremintV2WithMintsParams({
|
|
@@ -2056,9 +2422,9 @@ function collectPremintV2WithMintsParams({
|
|
|
2056
2422
|
const call = encodePremintOnManager({
|
|
2057
2423
|
...rest
|
|
2058
2424
|
});
|
|
2059
|
-
return
|
|
2060
|
-
abi:
|
|
2061
|
-
address:
|
|
2425
|
+
return makeContractParameters({
|
|
2426
|
+
abi: import_protocol_deployments10.zoraMints1155Config.abi,
|
|
2427
|
+
address: import_protocol_deployments10.zoraMints1155Config.address[chainId],
|
|
2062
2428
|
functionName: "transferBatchToManagerAndCall",
|
|
2063
2429
|
args: [tokenIds, quantities, call],
|
|
2064
2430
|
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
@@ -2070,20 +2436,20 @@ function decodeCallFailedError(error) {
|
|
|
2070
2436
|
throw new Error("Not a CallFailed error");
|
|
2071
2437
|
const internalErrorData = error.data?.args?.[0];
|
|
2072
2438
|
return (0, import_viem8.decodeErrorResult)({
|
|
2073
|
-
abi:
|
|
2439
|
+
abi: import_protocol_deployments10.zoraMintsManagerImplABI,
|
|
2074
2440
|
data: internalErrorData
|
|
2075
2441
|
});
|
|
2076
2442
|
}
|
|
2077
2443
|
|
|
2078
2444
|
// src/mints/mints-eth-unwrapper-and-caller.ts
|
|
2079
|
-
var
|
|
2445
|
+
var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
|
|
2080
2446
|
var import_viem9 = require("viem");
|
|
2081
2447
|
var makeCallWithEthSafeTransferData = ({
|
|
2082
2448
|
address: addressToCall,
|
|
2083
2449
|
call: functionToCall,
|
|
2084
2450
|
value: valueToSend
|
|
2085
2451
|
}) => (0, import_viem9.encodeFunctionData)({
|
|
2086
|
-
abi:
|
|
2452
|
+
abi: import_protocol_deployments11.iUnwrapAndForwardActionABI,
|
|
2087
2453
|
functionName: "callWithEth",
|
|
2088
2454
|
args: [addressToCall, functionToCall, valueToSend]
|
|
2089
2455
|
});
|
|
@@ -2103,27 +2469,67 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2103
2469
|
tokenIds,
|
|
2104
2470
|
quantities,
|
|
2105
2471
|
safeTransferData: safeTransferData || makeCallWithEthSafeTransferData(callWithEth),
|
|
2106
|
-
to:
|
|
2472
|
+
to: import_protocol_deployments11.mintsEthUnwrapperAndCallerAddress[chainId],
|
|
2107
2473
|
nonce
|
|
2108
2474
|
});
|
|
2475
|
+
|
|
2476
|
+
// src/sdk.ts
|
|
2477
|
+
function createCreatorClient(clientConfig) {
|
|
2478
|
+
const premintClient = new PremintClient({
|
|
2479
|
+
chainId: clientConfig.chainId,
|
|
2480
|
+
publicClient: clientConfig.publicClient,
|
|
2481
|
+
premintApi: clientConfig.premintApi || new PremintAPIClient(clientConfig.chainId)
|
|
2482
|
+
});
|
|
2483
|
+
const create1155CreatorClient = new Create1155Client({
|
|
2484
|
+
chainId: clientConfig.chainId,
|
|
2485
|
+
publicClient: clientConfig.publicClient
|
|
2486
|
+
});
|
|
2487
|
+
return {
|
|
2488
|
+
createPremint: (p) => premintClient.createPremint(p),
|
|
2489
|
+
updatePremint: (p) => premintClient.updatePremint(p),
|
|
2490
|
+
deletePremint: (p) => premintClient.deletePremint(p),
|
|
2491
|
+
create1155: (p) => create1155CreatorClient.createNew1155Token(p)
|
|
2492
|
+
};
|
|
2493
|
+
}
|
|
2494
|
+
function createCollectorClient(params) {
|
|
2495
|
+
const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
|
|
2496
|
+
const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
|
|
2497
|
+
const mintClient = new MintClient({
|
|
2498
|
+
chainId: params.chainId,
|
|
2499
|
+
publicClient: params.publicClient,
|
|
2500
|
+
premintGetter: premintGetterToUse,
|
|
2501
|
+
mintGetter: mintGetterToUse
|
|
2502
|
+
});
|
|
2503
|
+
return {
|
|
2504
|
+
getPremint: (p) => premintGetterToUse.getSignature({
|
|
2505
|
+
collectionAddress: p.address,
|
|
2506
|
+
uid: p.uid
|
|
2507
|
+
}),
|
|
2508
|
+
getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
|
|
2509
|
+
mint: (p) => mintClient.mint(p),
|
|
2510
|
+
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
2511
|
+
};
|
|
2512
|
+
}
|
|
2109
2513
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2110
2514
|
0 && (module.exports = {
|
|
2111
|
-
|
|
2515
|
+
Create1155Client,
|
|
2112
2516
|
Errors,
|
|
2113
|
-
|
|
2517
|
+
MintClient,
|
|
2114
2518
|
PremintAPIClient,
|
|
2519
|
+
PremintClient,
|
|
2115
2520
|
PremintConfigVersion,
|
|
2521
|
+
SubgraphMintGetter,
|
|
2116
2522
|
ZORA_API_BASE,
|
|
2117
2523
|
applyUpdateToPremint,
|
|
2524
|
+
collectOnchain,
|
|
2525
|
+
collectPremint,
|
|
2118
2526
|
collectPremintV2WithMintsParams,
|
|
2119
2527
|
collectWithMintsParams,
|
|
2120
2528
|
convertCollectionFromApi,
|
|
2121
2529
|
convertGetPremintApiResponse,
|
|
2122
2530
|
convertPremintFromApi,
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
createMintClient,
|
|
2126
|
-
createPremintClient,
|
|
2531
|
+
createCollectorClient,
|
|
2532
|
+
createCreatorClient,
|
|
2127
2533
|
decodeCallFailedError,
|
|
2128
2534
|
defaultAdditionalAdmins,
|
|
2129
2535
|
defaultTokenConfigV1MintArguments,
|
|
@@ -2133,17 +2539,24 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2133
2539
|
encodePostSignatureInput,
|
|
2134
2540
|
encodePremintForAPI,
|
|
2135
2541
|
getApiNetworkConfigForChain,
|
|
2542
|
+
getDataFromPremintReceipt,
|
|
2136
2543
|
getDefaultFixedPriceMinterAddress,
|
|
2137
2544
|
getMintCosts,
|
|
2138
2545
|
getMintsAccountBalanceWithPriceQuery,
|
|
2139
2546
|
getMintsEthPrice,
|
|
2547
|
+
getNecessaryErc20Approval,
|
|
2140
2548
|
getPremintCollectionAddress,
|
|
2141
2549
|
getPremintExecutorAddress,
|
|
2142
2550
|
getPremintMintCosts,
|
|
2551
|
+
getPremintMintCostsWithUnknownTokenPrice,
|
|
2143
2552
|
getPremintMintFee,
|
|
2553
|
+
getPremintPricePerToken,
|
|
2144
2554
|
getPremintedLogFromReceipt,
|
|
2555
|
+
getSignature,
|
|
2145
2556
|
getTokenIdFromCreateReceipt,
|
|
2146
2557
|
isAuthorizedToCreatePremint,
|
|
2558
|
+
isPremintConfigV1,
|
|
2559
|
+
isPremintConfigV2,
|
|
2147
2560
|
isValidSignature,
|
|
2148
2561
|
makeCallWithEthSafeTransferData,
|
|
2149
2562
|
makeMintRewardsRecipient,
|
|
@@ -2151,12 +2564,15 @@ var unwrapAndForwardEthPermitAndTypedDataDefinition = ({
|
|
|
2151
2564
|
makePermitToCollectPremintOrNonPremint,
|
|
2152
2565
|
makePermitTransferBatchAndTypeData,
|
|
2153
2566
|
makePermitTransferTypeData,
|
|
2567
|
+
makePrepareMint1155TokenParams,
|
|
2154
2568
|
makeUrls,
|
|
2155
2569
|
migratePremintConfigToV2,
|
|
2156
2570
|
mintWithEthParams,
|
|
2157
2571
|
mintsBalanceOfAccountParams,
|
|
2572
|
+
parseMintCosts,
|
|
2158
2573
|
recoverCreatorFromCreatorAttribution,
|
|
2159
2574
|
recoverPremintSigner,
|
|
2575
|
+
requestErc20ApprovalForMint,
|
|
2160
2576
|
selectMintsToCollectWithFromQueryResult,
|
|
2161
2577
|
sumBalances,
|
|
2162
2578
|
supportedPremintVersions,
|