@zoralabs/protocol-sdk 0.9.1 → 0.9.3
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 +7 -7
- package/CHANGELOG.md +12 -0
- package/dist/anvil.d.ts.map +1 -1
- package/dist/apis/http-api-base.d.ts +1 -1
- package/dist/apis/http-api-base.d.ts.map +1 -1
- package/dist/apis/subgraph-querier.d.ts +6 -0
- package/dist/apis/subgraph-querier.d.ts.map +1 -1
- package/dist/create/1155-create-helper.d.ts +4 -1
- package/dist/create/1155-create-helper.d.ts.map +1 -1
- package/dist/create/contract-getter.d.ts +30 -0
- package/dist/create/contract-getter.d.ts.map +1 -0
- package/dist/create/contract-setup.d.ts +4 -8
- package/dist/create/contract-setup.d.ts.map +1 -1
- package/dist/create/mint-from-create.d.ts +3 -3
- package/dist/create/mint-from-create.d.ts.map +1 -1
- package/dist/create/minter-defaults.d.ts +1 -1
- package/dist/create/minter-defaults.d.ts.map +1 -1
- package/dist/create/subgraph-queries.d.ts +13 -0
- package/dist/create/subgraph-queries.d.ts.map +1 -0
- package/dist/create/token-setup.d.ts +2 -0
- package/dist/create/token-setup.d.ts.map +1 -1
- package/dist/index.cjs +2166 -2099
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2188 -2121
- package/dist/index.js.map +1 -1
- package/dist/mint/subgraph-mint-getter.d.ts +2 -2
- package/dist/mint/subgraph-mint-getter.d.ts.map +1 -1
- package/dist/mint/subgraph-queries.d.ts +1 -5
- package/dist/mint/subgraph-queries.d.ts.map +1 -1
- package/dist/retries.d.ts +7 -0
- package/dist/retries.d.ts.map +1 -0
- package/dist/sdk.d.ts +2 -0
- package/dist/sdk.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/apis/http-api-base.ts +12 -20
- package/src/apis/subgraph-querier.ts +7 -0
- package/src/create/1155-create-helper.test.ts +68 -3
- package/src/create/1155-create-helper.ts +23 -9
- package/src/create/contract-getter.ts +90 -0
- package/src/create/contract-setup.ts +17 -46
- package/src/create/mint-from-create.ts +7 -15
- package/src/create/minter-defaults.ts +11 -20
- package/src/create/subgraph-queries.ts +35 -0
- package/src/create/token-setup.ts +5 -1
- package/src/create/types.ts +1 -1
- package/src/mint/subgraph-mint-getter.ts +5 -2
- package/src/mint/subgraph-queries.ts +1 -7
- package/src/retries.ts +49 -0
- package/src/sdk.ts +8 -0
- package/test-integration/create-multiple-tokens-on-contract.ts +104 -0
package/dist/index.cjs
CHANGED
|
@@ -2551,6 +2551,44 @@ var toContractCreationConfigOrAddress = ({
|
|
|
2551
2551
|
// src/premint/premint-client.ts
|
|
2552
2552
|
var import_protocol_deployments4 = require("@zoralabs/protocol-deployments");
|
|
2553
2553
|
|
|
2554
|
+
// src/retries.ts
|
|
2555
|
+
async function wait(delayMs) {
|
|
2556
|
+
return new Promise((resolve) => {
|
|
2557
|
+
setTimeout(resolve, delayMs);
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
var retryInternal = async ({
|
|
2561
|
+
tryFn,
|
|
2562
|
+
maxTries = 3,
|
|
2563
|
+
atTry,
|
|
2564
|
+
linearBackoffMS = 200,
|
|
2565
|
+
shouldRetryOnError = () => true
|
|
2566
|
+
}) => {
|
|
2567
|
+
try {
|
|
2568
|
+
return await tryFn();
|
|
2569
|
+
} catch (err) {
|
|
2570
|
+
if (shouldRetryOnError(err)) {
|
|
2571
|
+
if (atTry <= maxTries) {
|
|
2572
|
+
await wait(atTry * linearBackoffMS);
|
|
2573
|
+
return await retryInternal({
|
|
2574
|
+
tryFn,
|
|
2575
|
+
maxTries,
|
|
2576
|
+
atTry: atTry + 1,
|
|
2577
|
+
linearBackoffMS,
|
|
2578
|
+
shouldRetryOnError
|
|
2579
|
+
});
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
throw err;
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
var retriesGeneric = async (params) => {
|
|
2586
|
+
return retryInternal({
|
|
2587
|
+
...params,
|
|
2588
|
+
atTry: 1
|
|
2589
|
+
});
|
|
2590
|
+
};
|
|
2591
|
+
|
|
2554
2592
|
// src/apis/http-api-base.ts
|
|
2555
2593
|
var BadResponseError = class extends Error {
|
|
2556
2594
|
constructor(message, status, json) {
|
|
@@ -2560,11 +2598,6 @@ var BadResponseError = class extends Error {
|
|
|
2560
2598
|
this.json = json;
|
|
2561
2599
|
}
|
|
2562
2600
|
};
|
|
2563
|
-
async function wait(delayMs) {
|
|
2564
|
-
return new Promise((resolve) => {
|
|
2565
|
-
setTimeout(resolve, delayMs);
|
|
2566
|
-
});
|
|
2567
|
-
}
|
|
2568
2601
|
var get = async (url) => {
|
|
2569
2602
|
const response = await fetch(url, { method: "GET" });
|
|
2570
2603
|
if (response.status !== 200) {
|
|
@@ -2610,20 +2643,16 @@ var post = async (url, data) => {
|
|
|
2610
2643
|
}
|
|
2611
2644
|
return await response.json();
|
|
2612
2645
|
};
|
|
2613
|
-
var retries = async (tryFn, maxTries = 3,
|
|
2614
|
-
|
|
2615
|
-
return
|
|
2616
|
-
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
}
|
|
2624
|
-
}
|
|
2625
|
-
throw err;
|
|
2626
|
-
}
|
|
2646
|
+
var retries = async (tryFn, maxTries = 3, linearBackoffMS = 200) => {
|
|
2647
|
+
const shouldRetry = (err) => {
|
|
2648
|
+
return err instanceof BadResponseError && err.status >= 500;
|
|
2649
|
+
};
|
|
2650
|
+
return retriesGeneric({
|
|
2651
|
+
tryFn,
|
|
2652
|
+
maxTries,
|
|
2653
|
+
linearBackoffMS,
|
|
2654
|
+
shouldRetryOnError: shouldRetry
|
|
2655
|
+
});
|
|
2627
2656
|
};
|
|
2628
2657
|
var httpClient = {
|
|
2629
2658
|
get,
|
|
@@ -4247,7 +4276,7 @@ async function mint({
|
|
|
4247
4276
|
}
|
|
4248
4277
|
|
|
4249
4278
|
// src/create/1155-create-helper.ts
|
|
4250
|
-
var
|
|
4279
|
+
var import_protocol_deployments10 = require("@zoralabs/protocol-deployments");
|
|
4251
4280
|
var import_viem10 = require("viem");
|
|
4252
4281
|
|
|
4253
4282
|
// src/create/contract-setup.ts
|
|
@@ -4259,36 +4288,6 @@ function new1155ContractVersion(chainId) {
|
|
|
4259
4288
|
}
|
|
4260
4289
|
return address.CONTRACT_1155_IMPL_VERSION;
|
|
4261
4290
|
}
|
|
4262
|
-
async function getContractInfoExistingContract({
|
|
4263
|
-
publicClient,
|
|
4264
|
-
contractAddress
|
|
4265
|
-
}) {
|
|
4266
|
-
let contractVersion;
|
|
4267
|
-
try {
|
|
4268
|
-
contractVersion = await publicClient.readContract({
|
|
4269
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4270
|
-
address: contractAddress,
|
|
4271
|
-
functionName: "contractVersion"
|
|
4272
|
-
});
|
|
4273
|
-
} catch (e) {
|
|
4274
|
-
throw new Error(`Contract does not exist at ${contractAddress}`);
|
|
4275
|
-
}
|
|
4276
|
-
const nextTokenId = await publicClient.readContract({
|
|
4277
|
-
address: contractAddress,
|
|
4278
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4279
|
-
functionName: "nextTokenId"
|
|
4280
|
-
});
|
|
4281
|
-
const contractName = await publicClient.readContract({
|
|
4282
|
-
address: contractAddress,
|
|
4283
|
-
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4284
|
-
functionName: "name"
|
|
4285
|
-
});
|
|
4286
|
-
return {
|
|
4287
|
-
contractVersion,
|
|
4288
|
-
contractName,
|
|
4289
|
-
nextTokenId
|
|
4290
|
-
};
|
|
4291
|
-
}
|
|
4292
4291
|
async function getDeterministicContractAddress({
|
|
4293
4292
|
publicClient,
|
|
4294
4293
|
account,
|
|
@@ -4310,2193 +4309,2261 @@ async function getDeterministicContractAddress({
|
|
|
4310
4309
|
});
|
|
4311
4310
|
return contractAddress;
|
|
4312
4311
|
}
|
|
4312
|
+
async function getNewContractMintFee({
|
|
4313
|
+
publicClient,
|
|
4314
|
+
chainId
|
|
4315
|
+
}) {
|
|
4316
|
+
const implAddress = import_protocol_deployments7.contracts1155.addresses[chainId].CONTRACT_1155_IMPL;
|
|
4317
|
+
return await publicClient.readContract({
|
|
4318
|
+
abi: import_protocol_deployments7.zoraCreator1155ImplABI,
|
|
4319
|
+
address: implAddress,
|
|
4320
|
+
functionName: "mintFee"
|
|
4321
|
+
});
|
|
4322
|
+
}
|
|
4313
4323
|
|
|
4314
4324
|
// src/create/token-setup.ts
|
|
4315
4325
|
var import_protocol_deployments9 = require("@zoralabs/protocol-deployments");
|
|
4316
4326
|
var import_viem8 = require("viem");
|
|
4317
4327
|
var semver2 = __toESM(require_semver2(), 1);
|
|
4318
4328
|
|
|
4319
|
-
// src/
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
//
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4329
|
+
// src/create/minter-defaults.ts
|
|
4330
|
+
var SALE_END_FOREVER = 18446744073709551615n;
|
|
4331
|
+
var DEFAULT_SALE_START_AND_END = {
|
|
4332
|
+
// Sale start time – defaults to beginning of unix time
|
|
4333
|
+
saleStart: 0n,
|
|
4334
|
+
// This is the end of uint64, plenty of time
|
|
4335
|
+
saleEnd: SALE_END_FOREVER
|
|
4336
|
+
};
|
|
4337
|
+
var DEFAULT_MAX_TOKENS_PER_ADDRESS = {
|
|
4338
|
+
maxTokensPerAddress: 0n
|
|
4339
|
+
};
|
|
4340
|
+
var erc20SaleSettingsWithDefaults = (params) => ({
|
|
4341
|
+
...DEFAULT_SALE_START_AND_END,
|
|
4342
|
+
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
4343
|
+
...params
|
|
4344
|
+
});
|
|
4345
|
+
var allowListWithDefaults = (allowlist) => {
|
|
4346
|
+
return {
|
|
4347
|
+
...DEFAULT_SALE_START_AND_END,
|
|
4348
|
+
...allowlist
|
|
4349
|
+
};
|
|
4350
|
+
};
|
|
4351
|
+
var fixedPriceSettingsWithDefaults = (params) => ({
|
|
4352
|
+
...DEFAULT_SALE_START_AND_END,
|
|
4353
|
+
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
4354
|
+
type: "fixedPrice",
|
|
4355
|
+
...params
|
|
4356
|
+
});
|
|
4357
|
+
var parseNameIntoSymbol = (name) => {
|
|
4358
|
+
if (name === "") {
|
|
4359
|
+
throw new Error("Name must be provided to generate a symbol");
|
|
4336
4360
|
}
|
|
4337
|
-
|
|
4338
|
-
|
|
4339
|
-
|
|
4340
|
-
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
4341
|
-
return o;
|
|
4342
|
-
if (o instanceof ArrayBuffer)
|
|
4343
|
-
return new Uint8Array(o);
|
|
4344
|
-
if (ArrayBuffer.isView(o)) {
|
|
4345
|
-
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
4361
|
+
const result = "$" + name.replace(/[^a-zA-Z0-9]/g, "").replace(/^\$+/, "").toUpperCase().replace(/[AEIOU\s]/g, "").slice(0, 4);
|
|
4362
|
+
if (result === "$") {
|
|
4363
|
+
throw new Error("Not enough valid characters to generate a symbol");
|
|
4346
4364
|
}
|
|
4347
|
-
|
|
4348
|
-
}
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4365
|
+
return result;
|
|
4366
|
+
};
|
|
4367
|
+
var timedSaleSettingsWithDefaults = async (params, contractName) => {
|
|
4368
|
+
const erc20Name = params.erc20Name || contractName;
|
|
4369
|
+
const symbol = params.erc20Symbol || parseNameIntoSymbol(erc20Name);
|
|
4370
|
+
return {
|
|
4371
|
+
type: "timed",
|
|
4372
|
+
...DEFAULT_SALE_START_AND_END,
|
|
4373
|
+
...params,
|
|
4374
|
+
erc20Name,
|
|
4375
|
+
erc20Symbol: symbol
|
|
4376
|
+
};
|
|
4377
|
+
};
|
|
4378
|
+
var isAllowList = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
4379
|
+
var isErc20 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
4380
|
+
var isFixedPrice = (salesConfig) => {
|
|
4381
|
+
return salesConfig.type === "fixedPrice" || salesConfig.pricePerToken > 0n;
|
|
4382
|
+
};
|
|
4383
|
+
var getSalesConfigWithDefaults = async (salesConfig, contractName) => {
|
|
4384
|
+
if (!salesConfig)
|
|
4385
|
+
return timedSaleSettingsWithDefaults({}, contractName);
|
|
4386
|
+
if (isAllowList(salesConfig)) {
|
|
4387
|
+
return allowListWithDefaults(salesConfig);
|
|
4354
4388
|
}
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
BASE_MAP[j] = 255;
|
|
4389
|
+
if (isErc20(salesConfig)) {
|
|
4390
|
+
return erc20SaleSettingsWithDefaults(salesConfig);
|
|
4358
4391
|
}
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
var xc = x.charCodeAt(0);
|
|
4362
|
-
if (BASE_MAP[xc] !== 255) {
|
|
4363
|
-
throw new TypeError(x + " is ambiguous");
|
|
4364
|
-
}
|
|
4365
|
-
BASE_MAP[xc] = i;
|
|
4392
|
+
if (isFixedPrice(salesConfig)) {
|
|
4393
|
+
return fixedPriceSettingsWithDefaults(salesConfig);
|
|
4366
4394
|
}
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4395
|
+
return timedSaleSettingsWithDefaults(salesConfig, contractName);
|
|
4396
|
+
};
|
|
4397
|
+
|
|
4398
|
+
// src/create/minter-setup.ts
|
|
4399
|
+
var import_protocol_deployments8 = require("@zoralabs/protocol-deployments");
|
|
4400
|
+
var import_viem7 = require("viem");
|
|
4401
|
+
var PERMISSION_BITS = {
|
|
4402
|
+
MINTER: 2n ** 2n
|
|
4403
|
+
};
|
|
4404
|
+
function setupErc20Minter({
|
|
4405
|
+
pricePerToken,
|
|
4406
|
+
chainId,
|
|
4407
|
+
tokenId: nextTokenId,
|
|
4408
|
+
currency,
|
|
4409
|
+
saleStart,
|
|
4410
|
+
saleEnd,
|
|
4411
|
+
maxTokensPerAddress: mintLimit,
|
|
4412
|
+
fundsRecipient
|
|
4413
|
+
}) {
|
|
4414
|
+
const erc20MinterAddress = import_protocol_deployments8.erc20MinterAddress[chainId];
|
|
4415
|
+
if (!erc20MinterAddress)
|
|
4416
|
+
throw new Error(`ERC20Minter not deployed on chainId ${chainId}`);
|
|
4417
|
+
const erc20MinterApproval = (0, import_viem7.encodeFunctionData)({
|
|
4418
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4419
|
+
functionName: "addPermission",
|
|
4420
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, PERMISSION_BITS.MINTER]
|
|
4421
|
+
});
|
|
4422
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
4423
|
+
abi: import_protocol_deployments8.erc20MinterABI,
|
|
4424
|
+
functionName: "setSale",
|
|
4425
|
+
args: [
|
|
4426
|
+
BigInt(nextTokenId),
|
|
4427
|
+
{
|
|
4428
|
+
saleStart: saleStart || BigInt(0),
|
|
4429
|
+
saleEnd: saleEnd || BigInt(0),
|
|
4430
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
4431
|
+
pricePerToken,
|
|
4432
|
+
fundsRecipient,
|
|
4433
|
+
currency
|
|
4405
4434
|
}
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4435
|
+
]
|
|
4436
|
+
});
|
|
4437
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
4438
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4439
|
+
functionName: "callSale",
|
|
4440
|
+
args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
|
|
4441
|
+
});
|
|
4442
|
+
return {
|
|
4443
|
+
minter: erc20MinterAddress,
|
|
4444
|
+
setupActions: [erc20MinterApproval, callSale]
|
|
4445
|
+
};
|
|
4446
|
+
}
|
|
4447
|
+
function setupFixedPriceMinter({
|
|
4448
|
+
pricePerToken: price,
|
|
4449
|
+
tokenId: nextTokenId,
|
|
4450
|
+
chainId,
|
|
4451
|
+
saleStart,
|
|
4452
|
+
saleEnd,
|
|
4453
|
+
maxTokensPerAddress: mintLimit,
|
|
4454
|
+
fundsRecipient
|
|
4455
|
+
}) {
|
|
4456
|
+
const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
4457
|
+
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
4458
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4459
|
+
functionName: "addPermission",
|
|
4460
|
+
args: [
|
|
4461
|
+
BigInt(nextTokenId),
|
|
4462
|
+
fixedPriceStrategyAddress,
|
|
4463
|
+
PERMISSION_BITS.MINTER
|
|
4464
|
+
]
|
|
4465
|
+
});
|
|
4466
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
4467
|
+
abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
|
|
4468
|
+
functionName: "setSale",
|
|
4469
|
+
args: [
|
|
4470
|
+
BigInt(nextTokenId),
|
|
4471
|
+
{
|
|
4472
|
+
pricePerToken: price,
|
|
4473
|
+
saleStart: saleStart || BigInt(0),
|
|
4474
|
+
saleEnd: saleEnd || BigInt(0),
|
|
4475
|
+
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
4476
|
+
fundsRecipient
|
|
4442
4477
|
}
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4478
|
+
]
|
|
4479
|
+
});
|
|
4480
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
4481
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4482
|
+
functionName: "callSale",
|
|
4483
|
+
args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
|
|
4484
|
+
});
|
|
4485
|
+
return {
|
|
4486
|
+
minter: fixedPriceStrategyAddress,
|
|
4487
|
+
setupActions: [fixedPriceApproval, callSale]
|
|
4488
|
+
};
|
|
4489
|
+
}
|
|
4490
|
+
function setupTimedSaleMinter({
|
|
4491
|
+
chainId,
|
|
4492
|
+
tokenId,
|
|
4493
|
+
erc20Name: erc20zName,
|
|
4494
|
+
erc20Symbol: erc20zSymbol,
|
|
4495
|
+
saleStart,
|
|
4496
|
+
saleEnd
|
|
4497
|
+
}) {
|
|
4498
|
+
const minterAddress = import_protocol_deployments8.zoraTimedSaleStrategyAddress[chainId];
|
|
4499
|
+
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
4500
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4501
|
+
functionName: "addPermission",
|
|
4502
|
+
args: [BigInt(tokenId), minterAddress, PERMISSION_BITS.MINTER]
|
|
4503
|
+
});
|
|
4504
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
4505
|
+
abi: import_protocol_deployments8.zoraTimedSaleStrategyABI,
|
|
4506
|
+
functionName: "setSale",
|
|
4507
|
+
args: [
|
|
4508
|
+
BigInt(tokenId),
|
|
4509
|
+
{
|
|
4510
|
+
saleStart,
|
|
4511
|
+
saleEnd,
|
|
4512
|
+
name: erc20zName,
|
|
4513
|
+
symbol: erc20zSymbol
|
|
4448
4514
|
}
|
|
4449
|
-
|
|
4450
|
-
|
|
4515
|
+
]
|
|
4516
|
+
});
|
|
4517
|
+
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
4518
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4519
|
+
functionName: "callSale",
|
|
4520
|
+
args: [BigInt(tokenId), minterAddress, saleData]
|
|
4521
|
+
});
|
|
4522
|
+
return {
|
|
4523
|
+
minter: minterAddress,
|
|
4524
|
+
setupActions: [fixedPriceApproval, callSale]
|
|
4525
|
+
};
|
|
4526
|
+
}
|
|
4527
|
+
function setupAllowListMinter({
|
|
4528
|
+
chainId,
|
|
4529
|
+
tokenId: nextTokenId,
|
|
4530
|
+
allowlist,
|
|
4531
|
+
fundsRecipient
|
|
4532
|
+
}) {
|
|
4533
|
+
const merkleSaleStrategyAddress = import_protocol_deployments8.zoraCreatorMerkleMinterStrategyAddress[chainId];
|
|
4534
|
+
const merkleApproval = (0, import_viem7.encodeFunctionData)({
|
|
4535
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4536
|
+
functionName: "addPermission",
|
|
4537
|
+
args: [nextTokenId, merkleSaleStrategyAddress, PERMISSION_BITS.MINTER]
|
|
4538
|
+
});
|
|
4539
|
+
const merkleRoot = allowlist.presaleMerkleRoot.startsWith("0x") ? allowlist.presaleMerkleRoot : `0x${allowlist.presaleMerkleRoot}`;
|
|
4540
|
+
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
4541
|
+
abi: import_protocol_deployments8.zoraCreatorMerkleMinterStrategyABI,
|
|
4542
|
+
functionName: "setSale",
|
|
4543
|
+
args: [
|
|
4544
|
+
BigInt(nextTokenId),
|
|
4545
|
+
{
|
|
4546
|
+
presaleStart: allowlist.saleStart,
|
|
4547
|
+
presaleEnd: allowlist.saleEnd,
|
|
4548
|
+
merkleRoot,
|
|
4549
|
+
fundsRecipient
|
|
4451
4550
|
}
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4551
|
+
]
|
|
4552
|
+
});
|
|
4553
|
+
const callSaleMerkle = (0, import_viem7.encodeFunctionData)({
|
|
4554
|
+
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
4555
|
+
functionName: "callSale",
|
|
4556
|
+
args: [BigInt(nextTokenId), merkleSaleStrategyAddress, saleData]
|
|
4557
|
+
});
|
|
4558
|
+
return {
|
|
4559
|
+
minter: merkleSaleStrategyAddress,
|
|
4560
|
+
setupActions: [merkleApproval, callSaleMerkle]
|
|
4561
|
+
};
|
|
4562
|
+
}
|
|
4563
|
+
var isAllowList2 = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
4564
|
+
var isErc202 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
4565
|
+
var isFixedPrice2 = (salesConfig) => salesConfig.type === "fixedPrice" || salesConfig.pricePerToken > BigInt(0);
|
|
4566
|
+
function setupMinters({ salesConfig, ...rest }) {
|
|
4567
|
+
if (isErc202(salesConfig)) {
|
|
4568
|
+
return setupErc20Minter({
|
|
4569
|
+
...salesConfig,
|
|
4570
|
+
...rest
|
|
4571
|
+
});
|
|
4468
4572
|
}
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
}
|
|
4474
|
-
throw new Error(`Non-${name} character`);
|
|
4573
|
+
if (isAllowList2(salesConfig)) {
|
|
4574
|
+
return setupAllowListMinter({
|
|
4575
|
+
allowlist: salesConfig,
|
|
4576
|
+
...rest
|
|
4577
|
+
});
|
|
4475
4578
|
}
|
|
4579
|
+
if (isFixedPrice2(salesConfig))
|
|
4580
|
+
return setupFixedPriceMinter({
|
|
4581
|
+
...salesConfig,
|
|
4582
|
+
...rest
|
|
4583
|
+
});
|
|
4584
|
+
return setupTimedSaleMinter({
|
|
4585
|
+
...salesConfig,
|
|
4586
|
+
...rest
|
|
4587
|
+
});
|
|
4588
|
+
}
|
|
4589
|
+
|
|
4590
|
+
// src/create/token-setup.ts
|
|
4591
|
+
async function applyNew1155Defaults(props, ownerAddress, contractName) {
|
|
4592
|
+
const { payoutRecipient: fundsRecipient } = props;
|
|
4593
|
+
const fundsRecipientOrOwner = fundsRecipient && fundsRecipient !== import_viem8.zeroAddress ? fundsRecipient : ownerAddress;
|
|
4476
4594
|
return {
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4595
|
+
payoutRecipient: fundsRecipientOrOwner,
|
|
4596
|
+
createReferral: props.createReferral || import_viem8.zeroAddress,
|
|
4597
|
+
maxSupply: typeof props.maxSupply === "undefined" ? OPEN_EDITION_MINT_SIZE : BigInt(props.maxSupply),
|
|
4598
|
+
royaltyBPS: props.royaltyBPS || 1e3,
|
|
4599
|
+
tokenMetadataURI: props.tokenMetadataURI,
|
|
4600
|
+
salesConfig: await getSalesConfigWithDefaults(
|
|
4601
|
+
props.salesConfig,
|
|
4602
|
+
contractName
|
|
4603
|
+
)
|
|
4480
4604
|
};
|
|
4481
4605
|
}
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
this.baseEncode = baseEncode;
|
|
4606
|
+
function buildSetupNewToken({
|
|
4607
|
+
tokenURI,
|
|
4608
|
+
maxSupply = OPEN_EDITION_MINT_SIZE,
|
|
4609
|
+
createReferral = import_viem8.zeroAddress,
|
|
4610
|
+
contractVersion
|
|
4611
|
+
}) {
|
|
4612
|
+
if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
|
|
4613
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
4614
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
4615
|
+
functionName: "setupNewTokenWithCreateReferral",
|
|
4616
|
+
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
4617
|
+
});
|
|
4495
4618
|
}
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
throw Error("Unknown type, must be binary type");
|
|
4501
|
-
}
|
|
4619
|
+
if (createReferral !== import_viem8.zeroAddress) {
|
|
4620
|
+
throw new Error(
|
|
4621
|
+
"Contract does not support create referral, but one was provided"
|
|
4622
|
+
);
|
|
4502
4623
|
}
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
__publicField(this, "prefix");
|
|
4508
|
-
__publicField(this, "baseDecode");
|
|
4509
|
-
__publicField(this, "prefixCodePoint");
|
|
4510
|
-
this.name = name;
|
|
4511
|
-
this.prefix = prefix;
|
|
4512
|
-
if (prefix.codePointAt(0) === void 0) {
|
|
4513
|
-
throw new Error("Invalid prefix character");
|
|
4514
|
-
}
|
|
4515
|
-
this.prefixCodePoint = prefix.codePointAt(0);
|
|
4516
|
-
this.baseDecode = baseDecode;
|
|
4517
|
-
}
|
|
4518
|
-
decode(text) {
|
|
4519
|
-
if (typeof text === "string") {
|
|
4520
|
-
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
4521
|
-
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
4522
|
-
}
|
|
4523
|
-
return this.baseDecode(text.slice(this.prefix.length));
|
|
4524
|
-
} else {
|
|
4525
|
-
throw Error("Can only multibase decode strings");
|
|
4526
|
-
}
|
|
4527
|
-
}
|
|
4528
|
-
or(decoder) {
|
|
4529
|
-
return or(this, decoder);
|
|
4530
|
-
}
|
|
4531
|
-
};
|
|
4532
|
-
var ComposedDecoder = class {
|
|
4533
|
-
constructor(decoders) {
|
|
4534
|
-
__publicField(this, "decoders");
|
|
4535
|
-
this.decoders = decoders;
|
|
4536
|
-
}
|
|
4537
|
-
or(decoder) {
|
|
4538
|
-
return or(this, decoder);
|
|
4539
|
-
}
|
|
4540
|
-
decode(input) {
|
|
4541
|
-
const prefix = input[0];
|
|
4542
|
-
const decoder = this.decoders[prefix];
|
|
4543
|
-
if (decoder != null) {
|
|
4544
|
-
return decoder.decode(input);
|
|
4545
|
-
} else {
|
|
4546
|
-
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
4547
|
-
}
|
|
4548
|
-
}
|
|
4549
|
-
};
|
|
4550
|
-
function or(left, right) {
|
|
4551
|
-
return new ComposedDecoder({
|
|
4552
|
-
...left.decoders ?? { [left.prefix]: left },
|
|
4553
|
-
...right.decoders ?? { [right.prefix]: right }
|
|
4624
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
4625
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
4626
|
+
functionName: "setupNewToken",
|
|
4627
|
+
args: [tokenURI, BigInt(maxSupply)]
|
|
4554
4628
|
});
|
|
4555
4629
|
}
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4630
|
+
function setupRoyaltyConfig({
|
|
4631
|
+
royaltyBPS,
|
|
4632
|
+
royaltyRecipient,
|
|
4633
|
+
nextTokenId
|
|
4634
|
+
}) {
|
|
4635
|
+
if (royaltyBPS > 0 && royaltyRecipient != import_viem8.zeroAddress) {
|
|
4636
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
4637
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
4638
|
+
functionName: "updateRoyaltiesForToken",
|
|
4639
|
+
args: [
|
|
4640
|
+
nextTokenId,
|
|
4641
|
+
{
|
|
4642
|
+
royaltyBPS,
|
|
4643
|
+
royaltyRecipient,
|
|
4644
|
+
royaltyMintSchedule: 0
|
|
4645
|
+
}
|
|
4646
|
+
]
|
|
4647
|
+
});
|
|
4573
4648
|
}
|
|
4574
|
-
|
|
4575
|
-
|
|
4649
|
+
return null;
|
|
4650
|
+
}
|
|
4651
|
+
function makeAdminMintCall({
|
|
4652
|
+
ownerAddress,
|
|
4653
|
+
mintQuantity,
|
|
4654
|
+
nextTokenId
|
|
4655
|
+
}) {
|
|
4656
|
+
if (!mintQuantity || mintQuantity <= 0 || !ownerAddress) {
|
|
4657
|
+
return null;
|
|
4576
4658
|
}
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4659
|
+
return (0, import_viem8.encodeFunctionData)({
|
|
4660
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
4661
|
+
functionName: "adminMint",
|
|
4662
|
+
args: [ownerAddress, nextTokenId, BigInt(mintQuantity), import_viem8.zeroAddress]
|
|
4663
|
+
});
|
|
4580
4664
|
}
|
|
4581
|
-
function
|
|
4582
|
-
const {
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4665
|
+
async function constructCreate1155TokenCalls(props) {
|
|
4666
|
+
const {
|
|
4667
|
+
chainId,
|
|
4668
|
+
nextTokenId,
|
|
4669
|
+
mintToCreatorCount,
|
|
4670
|
+
ownerAddress,
|
|
4671
|
+
contractVersion
|
|
4672
|
+
} = props;
|
|
4673
|
+
const new1155TokenPropsWithDefaults = await applyNew1155Defaults(
|
|
4674
|
+
props,
|
|
4675
|
+
ownerAddress,
|
|
4676
|
+
props.contractName
|
|
4677
|
+
);
|
|
4678
|
+
const verifyTokenIdExpected = (0, import_viem8.encodeFunctionData)({
|
|
4679
|
+
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
4680
|
+
functionName: "assumeLastTokenIdMatches",
|
|
4681
|
+
args: [nextTokenId - 1n]
|
|
4682
|
+
});
|
|
4683
|
+
const setupNewToken = buildSetupNewToken({
|
|
4684
|
+
tokenURI: new1155TokenPropsWithDefaults.tokenMetadataURI,
|
|
4685
|
+
maxSupply: new1155TokenPropsWithDefaults.maxSupply,
|
|
4686
|
+
createReferral: new1155TokenPropsWithDefaults.createReferral,
|
|
4687
|
+
contractVersion
|
|
4688
|
+
});
|
|
4689
|
+
const royaltyConfig = setupRoyaltyConfig({
|
|
4690
|
+
royaltyBPS: new1155TokenPropsWithDefaults.royaltyBPS,
|
|
4691
|
+
royaltyRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
4692
|
+
nextTokenId
|
|
4588
4693
|
});
|
|
4694
|
+
const { minter, setupActions: mintersSetup } = setupMinters({
|
|
4695
|
+
tokenId: nextTokenId,
|
|
4696
|
+
chainId,
|
|
4697
|
+
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
4698
|
+
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
4699
|
+
});
|
|
4700
|
+
const adminMintCall = makeAdminMintCall({
|
|
4701
|
+
ownerAddress,
|
|
4702
|
+
mintQuantity: mintToCreatorCount,
|
|
4703
|
+
nextTokenId
|
|
4704
|
+
});
|
|
4705
|
+
const setupActions = [
|
|
4706
|
+
verifyTokenIdExpected,
|
|
4707
|
+
setupNewToken,
|
|
4708
|
+
...mintersSetup,
|
|
4709
|
+
royaltyConfig,
|
|
4710
|
+
adminMintCall
|
|
4711
|
+
].filter((item) => item !== null);
|
|
4712
|
+
return {
|
|
4713
|
+
setupActions,
|
|
4714
|
+
minter,
|
|
4715
|
+
newToken: new1155TokenPropsWithDefaults
|
|
4716
|
+
};
|
|
4589
4717
|
}
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
codes[alphabet[i]] = i;
|
|
4594
|
-
}
|
|
4595
|
-
let end = string.length;
|
|
4596
|
-
while (string[end - 1] === "=") {
|
|
4597
|
-
--end;
|
|
4598
|
-
}
|
|
4599
|
-
const out = new Uint8Array(end * bitsPerChar / 8 | 0);
|
|
4600
|
-
let bits = 0;
|
|
4601
|
-
let buffer = 0;
|
|
4602
|
-
let written = 0;
|
|
4603
|
-
for (let i = 0; i < end; ++i) {
|
|
4604
|
-
const value = codes[string[i]];
|
|
4605
|
-
if (value === void 0) {
|
|
4606
|
-
throw new SyntaxError(`Non-${name} character`);
|
|
4607
|
-
}
|
|
4608
|
-
buffer = buffer << bitsPerChar | value;
|
|
4609
|
-
bits += bitsPerChar;
|
|
4610
|
-
if (bits >= 8) {
|
|
4611
|
-
bits -= 8;
|
|
4612
|
-
out[written++] = 255 & buffer >> bits;
|
|
4613
|
-
}
|
|
4718
|
+
var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
4719
|
+
if (!contractStandard || !contractVersion) {
|
|
4720
|
+
return false;
|
|
4614
4721
|
}
|
|
4615
|
-
|
|
4616
|
-
|
|
4722
|
+
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
4723
|
+
if (!semVerContractVersion)
|
|
4724
|
+
return false;
|
|
4725
|
+
if (contractStandard === "ERC1155") {
|
|
4726
|
+
return semver2.gte(semVerContractVersion, "1.3.5");
|
|
4727
|
+
} else {
|
|
4728
|
+
return semver2.gte(semVerContractVersion, "14.0.0");
|
|
4617
4729
|
}
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4730
|
+
};
|
|
4731
|
+
|
|
4732
|
+
// src/create/mint-from-create.ts
|
|
4733
|
+
var import_viem9 = require("viem");
|
|
4734
|
+
async function toSalesStrategyFromSubgraph({
|
|
4735
|
+
minter,
|
|
4736
|
+
salesConfig,
|
|
4737
|
+
getContractMintFee
|
|
4738
|
+
}) {
|
|
4739
|
+
if (salesConfig.type === "timed") {
|
|
4740
|
+
return {
|
|
4741
|
+
saleType: "timed",
|
|
4742
|
+
address: minter,
|
|
4743
|
+
// for now we hardcode this
|
|
4744
|
+
mintFeePerQuantity: (0, import_viem9.parseEther)("0.000111"),
|
|
4745
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
4746
|
+
saleEnd: salesConfig.saleEnd.toString(),
|
|
4747
|
+
// the following are not needed for now but we wanna satisfy concrete
|
|
4748
|
+
erc20Z: import_viem9.zeroAddress,
|
|
4749
|
+
mintFee: 0n,
|
|
4750
|
+
pool: import_viem9.zeroAddress,
|
|
4751
|
+
secondaryActivated: false
|
|
4752
|
+
};
|
|
4633
4753
|
}
|
|
4634
|
-
if (
|
|
4635
|
-
|
|
4754
|
+
if (salesConfig.type === "erc20Mint") {
|
|
4755
|
+
return {
|
|
4756
|
+
saleType: "erc20",
|
|
4757
|
+
address: minter,
|
|
4758
|
+
mintFeePerQuantity: 0n,
|
|
4759
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
4760
|
+
saleEnd: salesConfig.saleEnd.toString(),
|
|
4761
|
+
currency: salesConfig.currency,
|
|
4762
|
+
pricePerToken: salesConfig.pricePerToken,
|
|
4763
|
+
maxTokensPerAddress: salesConfig.maxTokensPerAddress
|
|
4764
|
+
};
|
|
4636
4765
|
}
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4766
|
+
const contractMintFee = await getContractMintFee();
|
|
4767
|
+
if (salesConfig.type === "fixedPrice") {
|
|
4768
|
+
return {
|
|
4769
|
+
saleType: "fixedPrice",
|
|
4770
|
+
address: minter,
|
|
4771
|
+
maxTokensPerAddress: salesConfig.maxTokensPerAddress,
|
|
4772
|
+
mintFeePerQuantity: contractMintFee,
|
|
4773
|
+
pricePerToken: salesConfig.pricePerToken,
|
|
4774
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
4775
|
+
saleEnd: salesConfig.saleEnd.toString()
|
|
4776
|
+
};
|
|
4641
4777
|
}
|
|
4642
|
-
return
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
},
|
|
4651
|
-
decode(input) {
|
|
4652
|
-
return decode(input, alphabet, bitsPerChar, name);
|
|
4653
|
-
}
|
|
4654
|
-
});
|
|
4778
|
+
return {
|
|
4779
|
+
saleType: "allowlist",
|
|
4780
|
+
address: minter,
|
|
4781
|
+
saleStart: salesConfig.saleStart.toString(),
|
|
4782
|
+
saleEnd: salesConfig.saleEnd.toString(),
|
|
4783
|
+
merkleRoot: salesConfig.presaleMerkleRoot,
|
|
4784
|
+
mintFeePerQuantity: contractMintFee
|
|
4785
|
+
};
|
|
4655
4786
|
}
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
})
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
});
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
}
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
}
|
|
4688
|
-
var base32hexupper = rfc4648({
|
|
4689
|
-
prefix: "V",
|
|
4690
|
-
name: "base32hexupper",
|
|
4691
|
-
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
|
|
4692
|
-
bitsPerChar: 5
|
|
4693
|
-
});
|
|
4694
|
-
var base32hexpad = rfc4648({
|
|
4695
|
-
prefix: "t",
|
|
4696
|
-
name: "base32hexpad",
|
|
4697
|
-
alphabet: "0123456789abcdefghijklmnopqrstuv=",
|
|
4698
|
-
bitsPerChar: 5
|
|
4699
|
-
});
|
|
4700
|
-
var base32hexpadupper = rfc4648({
|
|
4701
|
-
prefix: "T",
|
|
4702
|
-
name: "base32hexpadupper",
|
|
4703
|
-
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
|
|
4704
|
-
bitsPerChar: 5
|
|
4705
|
-
});
|
|
4706
|
-
var base32z = rfc4648({
|
|
4707
|
-
prefix: "h",
|
|
4708
|
-
name: "base32z",
|
|
4709
|
-
alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
|
|
4710
|
-
bitsPerChar: 5
|
|
4711
|
-
});
|
|
4712
|
-
|
|
4713
|
-
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base58.js
|
|
4714
|
-
var base58btc = baseX({
|
|
4715
|
-
name: "base58btc",
|
|
4716
|
-
prefix: "z",
|
|
4717
|
-
alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
4718
|
-
});
|
|
4719
|
-
var base58flickr = baseX({
|
|
4720
|
-
name: "base58flickr",
|
|
4721
|
-
prefix: "Z",
|
|
4722
|
-
alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
4723
|
-
});
|
|
4724
|
-
|
|
4725
|
-
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/vendor/varint.js
|
|
4726
|
-
var encode_1 = encode2;
|
|
4727
|
-
var MSB = 128;
|
|
4728
|
-
var REST = 127;
|
|
4729
|
-
var MSBALL = ~REST;
|
|
4730
|
-
var INT = Math.pow(2, 31);
|
|
4731
|
-
function encode2(num, out, offset) {
|
|
4732
|
-
out = out || [];
|
|
4733
|
-
offset = offset || 0;
|
|
4734
|
-
var oldOffset = offset;
|
|
4735
|
-
while (num >= INT) {
|
|
4736
|
-
out[offset++] = num & 255 | MSB;
|
|
4737
|
-
num /= 128;
|
|
4738
|
-
}
|
|
4739
|
-
while (num & MSBALL) {
|
|
4740
|
-
out[offset++] = num & 255 | MSB;
|
|
4741
|
-
num >>>= 7;
|
|
4742
|
-
}
|
|
4743
|
-
out[offset] = num | 0;
|
|
4744
|
-
encode2.bytes = offset - oldOffset + 1;
|
|
4745
|
-
return out;
|
|
4787
|
+
function makeOnchainPrepareMintFromCreate({
|
|
4788
|
+
contractAddress,
|
|
4789
|
+
tokenId,
|
|
4790
|
+
result,
|
|
4791
|
+
minter,
|
|
4792
|
+
getContractMintFee,
|
|
4793
|
+
contractVersion
|
|
4794
|
+
}) {
|
|
4795
|
+
return async (params) => {
|
|
4796
|
+
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
4797
|
+
minter,
|
|
4798
|
+
getContractMintFee,
|
|
4799
|
+
salesConfig: result
|
|
4800
|
+
});
|
|
4801
|
+
return {
|
|
4802
|
+
parameters: makePrepareMint1155TokenParams({
|
|
4803
|
+
salesConfigAndTokenInfo: {
|
|
4804
|
+
salesConfig: subgraphSalesConfig,
|
|
4805
|
+
contractVersion
|
|
4806
|
+
},
|
|
4807
|
+
...params,
|
|
4808
|
+
tokenContract: contractAddress,
|
|
4809
|
+
tokenId
|
|
4810
|
+
}),
|
|
4811
|
+
costs: parseMintCosts({
|
|
4812
|
+
allowListEntry: params.allowListEntry,
|
|
4813
|
+
quantityToMint: BigInt(params.quantityToMint),
|
|
4814
|
+
salesConfig: subgraphSalesConfig
|
|
4815
|
+
}),
|
|
4816
|
+
erc20Approval: getRequiredErc20Approvals(params, subgraphSalesConfig)
|
|
4817
|
+
};
|
|
4818
|
+
};
|
|
4746
4819
|
}
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
var
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4820
|
+
|
|
4821
|
+
// src/create/1155-create-helper.ts
|
|
4822
|
+
var ROYALTY_BPS_DEFAULT = 1e3;
|
|
4823
|
+
var getTokenIdFromCreateReceipt = (receipt) => {
|
|
4824
|
+
for (const data of receipt.logs) {
|
|
4825
|
+
try {
|
|
4826
|
+
const decodedLog = (0, import_viem10.decodeEventLog)({
|
|
4827
|
+
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
4828
|
+
eventName: "SetupNewToken",
|
|
4829
|
+
...data
|
|
4830
|
+
});
|
|
4831
|
+
if (decodedLog && decodedLog.eventName === "SetupNewToken") {
|
|
4832
|
+
return decodedLog.args.tokenId;
|
|
4833
|
+
}
|
|
4834
|
+
} catch (err) {
|
|
4756
4835
|
}
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
read.bytes = counter - offset;
|
|
4762
|
-
return res;
|
|
4763
|
-
}
|
|
4764
|
-
var N1 = Math.pow(2, 7);
|
|
4765
|
-
var N2 = Math.pow(2, 14);
|
|
4766
|
-
var N3 = Math.pow(2, 21);
|
|
4767
|
-
var N4 = Math.pow(2, 28);
|
|
4768
|
-
var N5 = Math.pow(2, 35);
|
|
4769
|
-
var N6 = Math.pow(2, 42);
|
|
4770
|
-
var N7 = Math.pow(2, 49);
|
|
4771
|
-
var N8 = Math.pow(2, 56);
|
|
4772
|
-
var N9 = Math.pow(2, 63);
|
|
4773
|
-
var length = function(value) {
|
|
4774
|
-
return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
|
|
4836
|
+
}
|
|
4837
|
+
throw new Error(
|
|
4838
|
+
"No event found in receipt that could be used to get tokenId"
|
|
4839
|
+
);
|
|
4775
4840
|
};
|
|
4776
|
-
var
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4841
|
+
var getContractAddressFromReceipt = (receipt) => {
|
|
4842
|
+
for (const data of receipt.logs) {
|
|
4843
|
+
try {
|
|
4844
|
+
const decodedLog = (0, import_viem10.decodeEventLog)({
|
|
4845
|
+
abi: import_protocol_deployments10.zoraCreator1155FactoryImplABI,
|
|
4846
|
+
eventName: "SetupNewContract",
|
|
4847
|
+
...data
|
|
4848
|
+
});
|
|
4849
|
+
if (decodedLog && decodedLog.eventName === "SetupNewContract") {
|
|
4850
|
+
return decodedLog.args.newContract;
|
|
4851
|
+
}
|
|
4852
|
+
} catch (err) {
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
throw new Error(
|
|
4856
|
+
"No event found in receipt that could be used to get contract address"
|
|
4857
|
+
);
|
|
4780
4858
|
};
|
|
4781
|
-
|
|
4782
|
-
|
|
4783
|
-
|
|
4784
|
-
|
|
4785
|
-
|
|
4786
|
-
|
|
4787
|
-
|
|
4788
|
-
}
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
4859
|
+
function makeCreateContractAndTokenCall({
|
|
4860
|
+
account,
|
|
4861
|
+
contract,
|
|
4862
|
+
royaltyBPS,
|
|
4863
|
+
fundsRecipient,
|
|
4864
|
+
tokenSetupActions,
|
|
4865
|
+
chainId
|
|
4866
|
+
}) {
|
|
4867
|
+
const accountAddress = typeof account === "string" ? account : account.address;
|
|
4868
|
+
return makeContractParameters({
|
|
4869
|
+
abi: import_protocol_deployments10.zoraCreator1155FactoryImplABI,
|
|
4870
|
+
functionName: "createContractDeterministic",
|
|
4871
|
+
account,
|
|
4872
|
+
address: import_protocol_deployments10.zoraCreator1155FactoryImplAddress[chainId],
|
|
4873
|
+
args: [
|
|
4874
|
+
contract.uri,
|
|
4875
|
+
contract.name,
|
|
4876
|
+
{
|
|
4877
|
+
// deprecated
|
|
4878
|
+
royaltyMintSchedule: 0,
|
|
4879
|
+
royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
4880
|
+
royaltyRecipient: fundsRecipient || accountAddress
|
|
4881
|
+
},
|
|
4882
|
+
contract.defaultAdmin || accountAddress,
|
|
4883
|
+
tokenSetupActions
|
|
4884
|
+
]
|
|
4885
|
+
});
|
|
4792
4886
|
}
|
|
4793
|
-
function
|
|
4794
|
-
|
|
4887
|
+
function makeCreateTokenCall({
|
|
4888
|
+
contractAddress,
|
|
4889
|
+
account,
|
|
4890
|
+
tokenSetupActions
|
|
4891
|
+
}) {
|
|
4892
|
+
return makeContractParameters({
|
|
4893
|
+
abi: import_protocol_deployments10.zoraCreator1155ImplABI,
|
|
4894
|
+
functionName: "multicall",
|
|
4895
|
+
account,
|
|
4896
|
+
address: contractAddress,
|
|
4897
|
+
args: [tokenSetupActions]
|
|
4898
|
+
});
|
|
4795
4899
|
}
|
|
4796
|
-
|
|
4797
|
-
|
|
4798
|
-
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
bytes.set(digest, digestOffset);
|
|
4806
|
-
return new Digest(code, size, digest, bytes);
|
|
4807
|
-
}
|
|
4808
|
-
function decode4(multihash) {
|
|
4809
|
-
const bytes = coerce2(multihash);
|
|
4810
|
-
const [code, sizeOffset] = decode3(bytes);
|
|
4811
|
-
const [size, digestOffset] = decode3(bytes.subarray(sizeOffset));
|
|
4812
|
-
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
4813
|
-
if (digest.byteLength !== size) {
|
|
4814
|
-
throw new Error("Incorrect length");
|
|
4900
|
+
var Create1155Client = class {
|
|
4901
|
+
constructor({
|
|
4902
|
+
chainId,
|
|
4903
|
+
publicClient,
|
|
4904
|
+
contractGetter
|
|
4905
|
+
}) {
|
|
4906
|
+
this.chainId = chainId;
|
|
4907
|
+
this.publicClient = publicClient;
|
|
4908
|
+
this.contractGetter = contractGetter;
|
|
4815
4909
|
}
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
const data = b;
|
|
4823
|
-
return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals(a.bytes, data.bytes);
|
|
4910
|
+
async createNew1155(props) {
|
|
4911
|
+
return createNew1155ContractAndToken({
|
|
4912
|
+
...props,
|
|
4913
|
+
publicClient: this.publicClient,
|
|
4914
|
+
chainId: this.chainId
|
|
4915
|
+
});
|
|
4824
4916
|
}
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4917
|
+
async createNew1155OnExistingContract({
|
|
4918
|
+
contractAddress: contract,
|
|
4919
|
+
account,
|
|
4920
|
+
token,
|
|
4921
|
+
getAdditionalSetupActions
|
|
4922
|
+
}) {
|
|
4923
|
+
return createNew1155Token({
|
|
4924
|
+
contractAddress: contract,
|
|
4925
|
+
account,
|
|
4926
|
+
token,
|
|
4927
|
+
getAdditionalSetupActions,
|
|
4928
|
+
publicClient: this.publicClient,
|
|
4929
|
+
chainId: this.chainId,
|
|
4930
|
+
contractGetter: this.contractGetter
|
|
4931
|
+
});
|
|
4839
4932
|
}
|
|
4840
4933
|
};
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4934
|
+
async function createNew1155ContractAndToken({
|
|
4935
|
+
contract,
|
|
4936
|
+
account,
|
|
4937
|
+
chainId,
|
|
4938
|
+
token,
|
|
4939
|
+
publicClient,
|
|
4940
|
+
getAdditionalSetupActions
|
|
4941
|
+
}) {
|
|
4942
|
+
const nextTokenId = 1n;
|
|
4943
|
+
const contractVersion = new1155ContractVersion(chainId);
|
|
4944
|
+
const {
|
|
4945
|
+
minter,
|
|
4946
|
+
newToken,
|
|
4947
|
+
setupActions: tokenSetupActions
|
|
4948
|
+
} = await prepareSetupActions({
|
|
4949
|
+
chainId,
|
|
4950
|
+
account,
|
|
4951
|
+
contractVersion,
|
|
4952
|
+
nextTokenId,
|
|
4953
|
+
token,
|
|
4954
|
+
getAdditionalSetupActions,
|
|
4955
|
+
contractName: contract.name
|
|
4956
|
+
});
|
|
4957
|
+
const request = makeCreateContractAndTokenCall({
|
|
4958
|
+
contract,
|
|
4959
|
+
account,
|
|
4960
|
+
chainId,
|
|
4961
|
+
tokenSetupActions,
|
|
4962
|
+
fundsRecipient: token.payoutRecipient,
|
|
4963
|
+
royaltyBPS: token.royaltyBPS
|
|
4964
|
+
});
|
|
4965
|
+
const contractAddress = await getDeterministicContractAddress({
|
|
4966
|
+
account,
|
|
4967
|
+
publicClient,
|
|
4968
|
+
setupActions: tokenSetupActions,
|
|
4969
|
+
chainId,
|
|
4970
|
+
contract
|
|
4971
|
+
});
|
|
4972
|
+
const prepareMint = makeOnchainPrepareMintFromCreate({
|
|
4973
|
+
contractAddress,
|
|
4974
|
+
contractVersion,
|
|
4975
|
+
minter,
|
|
4976
|
+
result: newToken.salesConfig,
|
|
4977
|
+
tokenId: nextTokenId,
|
|
4978
|
+
// to get the contract wide mint fee, we get what it would be for a new contract
|
|
4979
|
+
getContractMintFee: async () => getNewContractMintFee({
|
|
4980
|
+
publicClient,
|
|
4981
|
+
chainId
|
|
4982
|
+
})
|
|
4983
|
+
});
|
|
4984
|
+
return {
|
|
4985
|
+
parameters: request,
|
|
4986
|
+
tokenSetupActions,
|
|
4987
|
+
newTokenId: nextTokenId,
|
|
4988
|
+
newToken,
|
|
4989
|
+
contractAddress,
|
|
4990
|
+
contractVersion,
|
|
4991
|
+
minter,
|
|
4992
|
+
prepareMint
|
|
4993
|
+
};
|
|
4851
4994
|
}
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
4995
|
+
async function createNew1155Token({
|
|
4996
|
+
contractAddress,
|
|
4997
|
+
account,
|
|
4998
|
+
getAdditionalSetupActions,
|
|
4999
|
+
token,
|
|
5000
|
+
chainId,
|
|
5001
|
+
contractGetter
|
|
5002
|
+
}) {
|
|
5003
|
+
const { nextTokenId, contractVersion, mintFee, name } = await contractGetter.getContractInfo({ contractAddress, retries: 5 });
|
|
5004
|
+
const {
|
|
5005
|
+
minter,
|
|
5006
|
+
newToken,
|
|
5007
|
+
setupActions: tokenSetupActions
|
|
5008
|
+
} = await prepareSetupActions({
|
|
5009
|
+
chainId,
|
|
5010
|
+
account,
|
|
5011
|
+
contractVersion,
|
|
5012
|
+
nextTokenId,
|
|
5013
|
+
token,
|
|
5014
|
+
getAdditionalSetupActions,
|
|
5015
|
+
contractName: name
|
|
5016
|
+
});
|
|
5017
|
+
const request = makeCreateTokenCall({
|
|
5018
|
+
contractAddress,
|
|
5019
|
+
account,
|
|
5020
|
+
tokenSetupActions
|
|
5021
|
+
});
|
|
5022
|
+
const prepareMint = makeOnchainPrepareMintFromCreate({
|
|
5023
|
+
contractAddress,
|
|
5024
|
+
contractVersion,
|
|
5025
|
+
minter,
|
|
5026
|
+
result: newToken.salesConfig,
|
|
5027
|
+
tokenId: nextTokenId,
|
|
5028
|
+
getContractMintFee: async () => mintFee
|
|
5029
|
+
});
|
|
5030
|
+
return {
|
|
5031
|
+
parameters: request,
|
|
5032
|
+
tokenSetupActions,
|
|
5033
|
+
newTokenId: nextTokenId,
|
|
5034
|
+
newToken,
|
|
5035
|
+
contractVersion,
|
|
5036
|
+
minter,
|
|
5037
|
+
prepareMint
|
|
5038
|
+
};
|
|
4861
5039
|
}
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
return this;
|
|
5040
|
+
async function prepareSetupActions({
|
|
5041
|
+
chainId,
|
|
5042
|
+
account,
|
|
5043
|
+
contractVersion,
|
|
5044
|
+
nextTokenId,
|
|
5045
|
+
token,
|
|
5046
|
+
contractName,
|
|
5047
|
+
getAdditionalSetupActions
|
|
5048
|
+
}) {
|
|
5049
|
+
const {
|
|
5050
|
+
minter,
|
|
5051
|
+
newToken,
|
|
5052
|
+
setupActions: tokenSetupActions
|
|
5053
|
+
} = await constructCreate1155TokenCalls({
|
|
5054
|
+
chainId,
|
|
5055
|
+
ownerAddress: account,
|
|
5056
|
+
contractVersion,
|
|
5057
|
+
nextTokenId,
|
|
5058
|
+
...token,
|
|
5059
|
+
contractName
|
|
5060
|
+
});
|
|
5061
|
+
const setupActions = getAdditionalSetupActions ? [
|
|
5062
|
+
...getAdditionalSetupActions({
|
|
5063
|
+
tokenId: nextTokenId
|
|
5064
|
+
}),
|
|
5065
|
+
...tokenSetupActions
|
|
5066
|
+
] : tokenSetupActions;
|
|
5067
|
+
return { minter, newToken, setupActions };
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5070
|
+
// src/sparks/mints-queries.ts
|
|
5071
|
+
var getMintsAccountBalanceWithPriceQuery = (account) => {
|
|
5072
|
+
const query = `
|
|
5073
|
+
query GetMintAccountBalances($account: String!) {
|
|
5074
|
+
mintAccountBalances(where: { account: $account }) {
|
|
5075
|
+
balance
|
|
5076
|
+
mintToken {
|
|
5077
|
+
id
|
|
5078
|
+
pricePerToken
|
|
5079
|
+
}
|
|
4903
5080
|
}
|
|
4904
|
-
case 1: {
|
|
4905
|
-
const { code, multihash } = this;
|
|
4906
|
-
if (code !== DAG_PB_CODE) {
|
|
4907
|
-
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
4908
|
-
}
|
|
4909
|
-
if (multihash.code !== SHA_256_CODE) {
|
|
4910
|
-
throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
|
|
4911
|
-
}
|
|
4912
|
-
return _CID.createV0(multihash);
|
|
4913
|
-
}
|
|
4914
|
-
default: {
|
|
4915
|
-
throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
|
|
4916
|
-
}
|
|
4917
|
-
}
|
|
4918
|
-
}
|
|
4919
|
-
toV1() {
|
|
4920
|
-
switch (this.version) {
|
|
4921
|
-
case 0: {
|
|
4922
|
-
const { code, digest } = this.multihash;
|
|
4923
|
-
const multihash = create(code, digest);
|
|
4924
|
-
return _CID.createV1(this.code, multihash);
|
|
4925
|
-
}
|
|
4926
|
-
case 1: {
|
|
4927
|
-
return this;
|
|
4928
|
-
}
|
|
4929
|
-
default: {
|
|
4930
|
-
throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
|
|
4931
|
-
}
|
|
4932
|
-
}
|
|
4933
|
-
}
|
|
4934
|
-
equals(other) {
|
|
4935
|
-
return _CID.equals(this, other);
|
|
4936
|
-
}
|
|
4937
|
-
static equals(self, other) {
|
|
4938
|
-
const unknown = other;
|
|
4939
|
-
return unknown != null && self.code === unknown.code && self.version === unknown.version && equals2(self.multihash, unknown.multihash);
|
|
4940
|
-
}
|
|
4941
|
-
toString(base3) {
|
|
4942
|
-
return format(this, base3);
|
|
4943
|
-
}
|
|
4944
|
-
toJSON() {
|
|
4945
|
-
return { "/": format(this) };
|
|
4946
|
-
}
|
|
4947
|
-
link() {
|
|
4948
|
-
return this;
|
|
4949
|
-
}
|
|
4950
|
-
// Legacy
|
|
4951
|
-
[(_a = Symbol.toStringTag, Symbol.for("nodejs.util.inspect.custom"))]() {
|
|
4952
|
-
return `CID(${this.toString()})`;
|
|
4953
|
-
}
|
|
4954
|
-
/**
|
|
4955
|
-
* Takes any input `value` and returns a `CID` instance if it was
|
|
4956
|
-
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
|
|
4957
|
-
* it will return value back. If `value` is not instance of this CID
|
|
4958
|
-
* class, but is compatible CID it will return new instance of this
|
|
4959
|
-
* `CID` class. Otherwise returns null.
|
|
4960
|
-
*
|
|
4961
|
-
* This allows two different incompatible versions of CID library to
|
|
4962
|
-
* co-exist and interop as long as binary interface is compatible.
|
|
4963
|
-
*/
|
|
4964
|
-
static asCID(input) {
|
|
4965
|
-
if (input == null) {
|
|
4966
|
-
return null;
|
|
4967
5081
|
}
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
}
|
|
4981
|
-
}
|
|
4982
|
-
/**
|
|
4983
|
-
* @param version - Version of the CID
|
|
4984
|
-
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
4985
|
-
* @param digest - (Multi)hash of the of the content.
|
|
4986
|
-
*/
|
|
4987
|
-
static create(version, code, digest) {
|
|
4988
|
-
if (typeof code !== "number") {
|
|
4989
|
-
throw new Error("String codecs are no longer supported");
|
|
4990
|
-
}
|
|
4991
|
-
if (!(digest.bytes instanceof Uint8Array)) {
|
|
4992
|
-
throw new Error("Invalid digest");
|
|
4993
|
-
}
|
|
4994
|
-
switch (version) {
|
|
4995
|
-
case 0: {
|
|
4996
|
-
if (code !== DAG_PB_CODE) {
|
|
4997
|
-
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
4998
|
-
} else {
|
|
4999
|
-
return new _CID(version, code, digest, digest.bytes);
|
|
5000
|
-
}
|
|
5001
|
-
}
|
|
5002
|
-
case 1: {
|
|
5003
|
-
const bytes = encodeCID(version, code, digest.bytes);
|
|
5004
|
-
return new _CID(version, code, digest, bytes);
|
|
5005
|
-
}
|
|
5006
|
-
default: {
|
|
5007
|
-
throw new Error("Invalid version");
|
|
5008
|
-
}
|
|
5009
|
-
}
|
|
5010
|
-
}
|
|
5011
|
-
/**
|
|
5012
|
-
* Simplified version of `create` for CIDv0.
|
|
5013
|
-
*/
|
|
5014
|
-
static createV0(digest) {
|
|
5015
|
-
return _CID.create(0, DAG_PB_CODE, digest);
|
|
5016
|
-
}
|
|
5017
|
-
/**
|
|
5018
|
-
* Simplified version of `create` for CIDv1.
|
|
5019
|
-
*
|
|
5020
|
-
* @param code - Content encoding format code.
|
|
5021
|
-
* @param digest - Multihash of the content.
|
|
5022
|
-
*/
|
|
5023
|
-
static createV1(code, digest) {
|
|
5024
|
-
return _CID.create(1, code, digest);
|
|
5025
|
-
}
|
|
5026
|
-
/**
|
|
5027
|
-
* Decoded a CID from its binary representation. The byte array must contain
|
|
5028
|
-
* only the CID with no additional bytes.
|
|
5029
|
-
*
|
|
5030
|
-
* An error will be thrown if the bytes provided do not contain a valid
|
|
5031
|
-
* binary representation of a CID.
|
|
5032
|
-
*/
|
|
5033
|
-
static decode(bytes) {
|
|
5034
|
-
const [cid, remainder] = _CID.decodeFirst(bytes);
|
|
5035
|
-
if (remainder.length !== 0) {
|
|
5036
|
-
throw new Error("Incorrect length");
|
|
5037
|
-
}
|
|
5038
|
-
return cid;
|
|
5039
|
-
}
|
|
5040
|
-
/**
|
|
5041
|
-
* Decoded a CID from its binary representation at the beginning of a byte
|
|
5042
|
-
* array.
|
|
5043
|
-
*
|
|
5044
|
-
* Returns an array with the first element containing the CID and the second
|
|
5045
|
-
* element containing the remainder of the original byte array. The remainder
|
|
5046
|
-
* will be a zero-length byte array if the provided bytes only contained a
|
|
5047
|
-
* binary CID representation.
|
|
5048
|
-
*/
|
|
5049
|
-
static decodeFirst(bytes) {
|
|
5050
|
-
const specs = _CID.inspectBytes(bytes);
|
|
5051
|
-
const prefixSize = specs.size - specs.multihashSize;
|
|
5052
|
-
const multihashBytes = coerce2(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
5053
|
-
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
5054
|
-
throw new Error("Incorrect length");
|
|
5055
|
-
}
|
|
5056
|
-
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
5057
|
-
const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
5058
|
-
const cid = specs.version === 0 ? _CID.createV0(digest) : _CID.createV1(specs.codec, digest);
|
|
5059
|
-
return [cid, bytes.subarray(specs.size)];
|
|
5060
|
-
}
|
|
5061
|
-
/**
|
|
5062
|
-
* Inspect the initial bytes of a CID to determine its properties.
|
|
5063
|
-
*
|
|
5064
|
-
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
|
|
5065
|
-
* bytes but for larger multicodec code values and larger multihash digest
|
|
5066
|
-
* lengths these varints can be quite large. It is recommended that at least
|
|
5067
|
-
* 10 bytes be made available in the `initialBytes` argument for a complete
|
|
5068
|
-
* inspection.
|
|
5069
|
-
*/
|
|
5070
|
-
static inspectBytes(initialBytes) {
|
|
5071
|
-
let offset = 0;
|
|
5072
|
-
const next = () => {
|
|
5073
|
-
const [i, length2] = decode3(initialBytes.subarray(offset));
|
|
5074
|
-
offset += length2;
|
|
5075
|
-
return i;
|
|
5082
|
+
`;
|
|
5083
|
+
return {
|
|
5084
|
+
query,
|
|
5085
|
+
variables: { account }
|
|
5086
|
+
};
|
|
5087
|
+
};
|
|
5088
|
+
var selectMintsToCollectWithFromQueryResult = (mintAccountBalances, quantityToCollect) => {
|
|
5089
|
+
const parsed = mintAccountBalances.map((r) => {
|
|
5090
|
+
return {
|
|
5091
|
+
tokenId: BigInt(r.mintToken.id),
|
|
5092
|
+
quantity: BigInt(r.balance),
|
|
5093
|
+
pricePerToken: BigInt(r.mintToken.pricePerToken)
|
|
5076
5094
|
};
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
if (
|
|
5080
|
-
|
|
5081
|
-
offset = 0;
|
|
5082
|
-
} else {
|
|
5083
|
-
codec = next();
|
|
5084
|
-
}
|
|
5085
|
-
if (version !== 0 && version !== 1) {
|
|
5086
|
-
throw new RangeError(`Invalid CID version ${version}`);
|
|
5095
|
+
});
|
|
5096
|
+
const sorted = parsed.sort((a, b) => {
|
|
5097
|
+
if (a.pricePerToken < b.pricePerToken) {
|
|
5098
|
+
return -1;
|
|
5087
5099
|
}
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
* decoder is not provided will use a default from the configuration. It will
|
|
5098
|
-
* throw an error if encoding of the CID is not compatible with supplied (or
|
|
5099
|
-
* a default decoder).
|
|
5100
|
-
*/
|
|
5101
|
-
static parse(source, base3) {
|
|
5102
|
-
const [prefix, bytes] = parseCIDtoBytes(source, base3);
|
|
5103
|
-
const cid = _CID.decode(bytes);
|
|
5104
|
-
if (cid.version === 0 && source[0] !== "Q") {
|
|
5105
|
-
throw Error("Version 0 CID string must not include multibase prefix");
|
|
5100
|
+
return 1;
|
|
5101
|
+
});
|
|
5102
|
+
let remainingQuantity = quantityToCollect;
|
|
5103
|
+
const tokenIds = [];
|
|
5104
|
+
const quantities = [];
|
|
5105
|
+
while (remainingQuantity > 0) {
|
|
5106
|
+
const next = sorted.shift();
|
|
5107
|
+
if (!next) {
|
|
5108
|
+
throw new Error("Not enough MINTs to collect with");
|
|
5106
5109
|
}
|
|
5107
|
-
|
|
5108
|
-
|
|
5110
|
+
const quantityToUse = remainingQuantity > next.quantity ? next.quantity : remainingQuantity;
|
|
5111
|
+
tokenIds.push(next.tokenId);
|
|
5112
|
+
quantities.push(quantityToUse);
|
|
5113
|
+
remainingQuantity -= quantityToUse;
|
|
5109
5114
|
}
|
|
5115
|
+
return {
|
|
5116
|
+
tokenIds,
|
|
5117
|
+
quantities
|
|
5118
|
+
};
|
|
5119
|
+
};
|
|
5120
|
+
var sumBalances = (mintAccountBalances) => {
|
|
5121
|
+
return mintAccountBalances.reduce((acc, curr) => {
|
|
5122
|
+
return acc + BigInt(curr.balance);
|
|
5123
|
+
}, BigInt(0));
|
|
5110
5124
|
};
|
|
5111
|
-
function parseCIDtoBytes(source, base3) {
|
|
5112
|
-
switch (source[0]) {
|
|
5113
|
-
case "Q": {
|
|
5114
|
-
const decoder = base3 ?? base58btc;
|
|
5115
|
-
return [
|
|
5116
|
-
base58btc.prefix,
|
|
5117
|
-
decoder.decode(`${base58btc.prefix}${source}`)
|
|
5118
|
-
];
|
|
5119
|
-
}
|
|
5120
|
-
case base58btc.prefix: {
|
|
5121
|
-
const decoder = base3 ?? base58btc;
|
|
5122
|
-
return [base58btc.prefix, decoder.decode(source)];
|
|
5123
|
-
}
|
|
5124
|
-
case base32.prefix: {
|
|
5125
|
-
const decoder = base3 ?? base32;
|
|
5126
|
-
return [base32.prefix, decoder.decode(source)];
|
|
5127
|
-
}
|
|
5128
|
-
default: {
|
|
5129
|
-
if (base3 == null) {
|
|
5130
|
-
throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");
|
|
5131
|
-
}
|
|
5132
|
-
return [source[0], base3.decode(source)];
|
|
5133
|
-
}
|
|
5134
|
-
}
|
|
5135
|
-
}
|
|
5136
|
-
function toStringV0(bytes, cache2, base3) {
|
|
5137
|
-
const { prefix } = base3;
|
|
5138
|
-
if (prefix !== base58btc.prefix) {
|
|
5139
|
-
throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
|
|
5140
|
-
}
|
|
5141
|
-
const cid = cache2.get(prefix);
|
|
5142
|
-
if (cid == null) {
|
|
5143
|
-
const cid2 = base3.encode(bytes).slice(1);
|
|
5144
|
-
cache2.set(prefix, cid2);
|
|
5145
|
-
return cid2;
|
|
5146
|
-
} else {
|
|
5147
|
-
return cid;
|
|
5148
|
-
}
|
|
5149
|
-
}
|
|
5150
|
-
function toStringV1(bytes, cache2, base3) {
|
|
5151
|
-
const { prefix } = base3;
|
|
5152
|
-
const cid = cache2.get(prefix);
|
|
5153
|
-
if (cid == null) {
|
|
5154
|
-
const cid2 = base3.encode(bytes);
|
|
5155
|
-
cache2.set(prefix, cid2);
|
|
5156
|
-
return cid2;
|
|
5157
|
-
} else {
|
|
5158
|
-
return cid;
|
|
5159
|
-
}
|
|
5160
|
-
}
|
|
5161
|
-
var DAG_PB_CODE = 112;
|
|
5162
|
-
var SHA_256_CODE = 18;
|
|
5163
|
-
function encodeCID(version, code, multihash) {
|
|
5164
|
-
const codeOffset = encodingLength(version);
|
|
5165
|
-
const hashOffset = codeOffset + encodingLength(code);
|
|
5166
|
-
const bytes = new Uint8Array(hashOffset + multihash.byteLength);
|
|
5167
|
-
encodeTo(version, bytes, 0);
|
|
5168
|
-
encodeTo(code, bytes, codeOffset);
|
|
5169
|
-
bytes.set(multihash, hashOffset);
|
|
5170
|
-
return bytes;
|
|
5171
|
-
}
|
|
5172
|
-
var cidSymbol = Symbol.for("@ipld/js-cid/CID");
|
|
5173
5125
|
|
|
5174
|
-
// src/
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5189
|
-
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5126
|
+
// src/sparks/sparks-contracts.ts
|
|
5127
|
+
var import_protocol_deployments11 = require("@zoralabs/protocol-deployments");
|
|
5128
|
+
var import_viem11 = require("viem");
|
|
5129
|
+
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
5130
|
+
var mintWithEthParams = ({
|
|
5131
|
+
tokenId,
|
|
5132
|
+
quantity,
|
|
5133
|
+
recipient,
|
|
5134
|
+
chainId,
|
|
5135
|
+
pricePerMint,
|
|
5136
|
+
account
|
|
5137
|
+
}) => makeContractParameters({
|
|
5138
|
+
abi: import_protocol_deployments11.zoraSparksManagerImplABI,
|
|
5139
|
+
address: import_protocol_deployments11.zoraSparksManagerImplAddress[chainId],
|
|
5140
|
+
functionName: "mintWithEth",
|
|
5141
|
+
args: [tokenId, quantity, recipient || addressOrAccountAddress(account)],
|
|
5142
|
+
value: pricePerMint * quantity,
|
|
5143
|
+
account
|
|
5144
|
+
});
|
|
5145
|
+
var getPaidMintValue = (quantities, pricePerMint) => {
|
|
5146
|
+
if (!pricePerMint || pricePerMint === 0n)
|
|
5147
|
+
return;
|
|
5148
|
+
return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
|
|
5149
|
+
};
|
|
5150
|
+
var mintsBalanceOfAccountParams = ({
|
|
5151
|
+
account,
|
|
5152
|
+
chainId
|
|
5153
|
+
}) => ({
|
|
5154
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
5155
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
5156
|
+
functionName: "balanceOfAccount",
|
|
5157
|
+
args: [account]
|
|
5158
|
+
});
|
|
5159
|
+
var encodeCollectOnManager = ({
|
|
5160
|
+
zoraCreator1155Contract,
|
|
5161
|
+
minter,
|
|
5162
|
+
zoraCreator1155TokenId,
|
|
5163
|
+
mintArguments
|
|
5164
|
+
}) => (0, import_viem11.encodeFunctionData)({
|
|
5165
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplConfig.abi,
|
|
5166
|
+
functionName: "collect",
|
|
5167
|
+
args: [
|
|
5168
|
+
zoraCreator1155Contract,
|
|
5169
|
+
minter,
|
|
5170
|
+
zoraCreator1155TokenId,
|
|
5171
|
+
mintArguments
|
|
5172
|
+
]
|
|
5173
|
+
});
|
|
5174
|
+
function collectWithMintsParams({
|
|
5175
|
+
tokenIds,
|
|
5176
|
+
quantities,
|
|
5177
|
+
chainId,
|
|
5178
|
+
paidMintPricePerToken,
|
|
5179
|
+
account,
|
|
5180
|
+
mintArguments,
|
|
5181
|
+
minter,
|
|
5182
|
+
zoraCreator1155Contract,
|
|
5183
|
+
zoraCreator1155TokenId
|
|
5184
|
+
}) {
|
|
5185
|
+
const call = encodeCollectOnManager({
|
|
5186
|
+
tokenIds,
|
|
5187
|
+
quantities,
|
|
5188
|
+
zoraCreator1155Contract,
|
|
5189
|
+
zoraCreator1155TokenId,
|
|
5190
|
+
minter,
|
|
5191
|
+
mintArguments
|
|
5192
|
+
});
|
|
5193
|
+
return makeContractParameters({
|
|
5194
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
5195
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
5196
|
+
functionName: "transferBatchToManagerAndCall",
|
|
5197
|
+
args: [tokenIds, quantities, call],
|
|
5198
|
+
// if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
|
|
5199
|
+
// for the paid mint cost.
|
|
5200
|
+
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
5201
|
+
account
|
|
5202
|
+
});
|
|
5207
5203
|
}
|
|
5208
|
-
function
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
}
|
|
5214
|
-
return false;
|
|
5215
|
-
}
|
|
5204
|
+
function getMintsEthPrice({
|
|
5205
|
+
publicClient
|
|
5206
|
+
}) {
|
|
5207
|
+
const chainId = publicClient.chain?.id;
|
|
5208
|
+
if (!chainId || !import_protocol_deployments11.zoraMintsManagerImplAddress[chainId]) {
|
|
5209
|
+
throw new Error(`Chain id ${chainId} not supported`);
|
|
5216
5210
|
}
|
|
5217
|
-
return
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
|
|
5221
|
-
}
|
|
5222
|
-
function isNormalizeableIPFSUrl(url) {
|
|
5223
|
-
return url ? isIPFSUrl(url) || isCID(url) : false;
|
|
5211
|
+
return publicClient.readContract({
|
|
5212
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplABI,
|
|
5213
|
+
address: import_protocol_deployments11.zoraMintsManagerImplAddress[chainId],
|
|
5214
|
+
functionName: "getEthPrice"
|
|
5215
|
+
});
|
|
5224
5216
|
}
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5217
|
+
function makePermitTransferBatchAndTypeData({
|
|
5218
|
+
tokenIds,
|
|
5219
|
+
quantities,
|
|
5220
|
+
chainId,
|
|
5221
|
+
mintsOwner,
|
|
5222
|
+
to,
|
|
5223
|
+
nonce,
|
|
5224
|
+
deadline,
|
|
5225
|
+
safeTransferData
|
|
5226
|
+
}) {
|
|
5227
|
+
const permit = {
|
|
5228
|
+
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
5229
|
+
to,
|
|
5230
|
+
tokenIds,
|
|
5231
|
+
quantities,
|
|
5232
|
+
deadline,
|
|
5233
|
+
nonce,
|
|
5234
|
+
safeTransferData
|
|
5235
|
+
};
|
|
5236
|
+
const typedData = {
|
|
5237
|
+
...(0, import_protocol_deployments11.mintsSafeTransferBatchTypedDataDefinition)({
|
|
5238
|
+
chainId,
|
|
5239
|
+
message: permit
|
|
5240
|
+
}),
|
|
5241
|
+
account: mintsOwner
|
|
5242
|
+
};
|
|
5243
|
+
return {
|
|
5244
|
+
permit,
|
|
5245
|
+
typedData
|
|
5246
|
+
};
|
|
5233
5247
|
}
|
|
5234
|
-
function
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
|
|
5241
|
-
|
|
5248
|
+
function makePermitTransferTypeData({
|
|
5249
|
+
tokenId,
|
|
5250
|
+
quantity,
|
|
5251
|
+
chainId,
|
|
5252
|
+
mintsOwner,
|
|
5253
|
+
to,
|
|
5254
|
+
nonce,
|
|
5255
|
+
deadline,
|
|
5256
|
+
safeTransferData
|
|
5257
|
+
}) {
|
|
5258
|
+
const permit = {
|
|
5259
|
+
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
5260
|
+
to,
|
|
5261
|
+
tokenId,
|
|
5262
|
+
quantity,
|
|
5263
|
+
deadline,
|
|
5264
|
+
nonce,
|
|
5265
|
+
safeTransferData
|
|
5266
|
+
};
|
|
5267
|
+
const typedData = {
|
|
5268
|
+
...(0, import_protocol_deployments11.mintsSafeTransferTypedDataDefinition)({
|
|
5269
|
+
chainId,
|
|
5270
|
+
message: permit
|
|
5271
|
+
}),
|
|
5272
|
+
account: mintsOwner
|
|
5273
|
+
};
|
|
5274
|
+
return {
|
|
5275
|
+
permit,
|
|
5276
|
+
typedData
|
|
5277
|
+
};
|
|
5242
5278
|
}
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5279
|
+
var encodePremintOnManager = ({
|
|
5280
|
+
contractCreationConfig,
|
|
5281
|
+
premintConfig,
|
|
5282
|
+
premintSignature,
|
|
5283
|
+
mintArguments,
|
|
5284
|
+
signerContract = import_viem11.zeroAddress
|
|
5285
|
+
}) => (0, import_viem11.encodeFunctionData)({
|
|
5286
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplConfig.abi,
|
|
5287
|
+
functionName: "collectPremintV2",
|
|
5288
|
+
args: [
|
|
5289
|
+
contractCreationConfig,
|
|
5290
|
+
premintConfig,
|
|
5291
|
+
premintSignature,
|
|
5292
|
+
mintArguments,
|
|
5293
|
+
signerContract
|
|
5294
|
+
]
|
|
5295
|
+
});
|
|
5296
|
+
var makePermitToCollectPremintOrNonPremint = ({
|
|
5297
|
+
mintsOwner,
|
|
5298
|
+
chainId,
|
|
5299
|
+
deadline,
|
|
5300
|
+
tokenIds,
|
|
5301
|
+
// this quantity of MINTs will be used to collect premint
|
|
5302
|
+
// and will be burned. This same quantity is the quantity of
|
|
5303
|
+
// premint to collect.
|
|
5304
|
+
quantities,
|
|
5305
|
+
nonce,
|
|
5306
|
+
premint,
|
|
5307
|
+
collect
|
|
5308
|
+
}) => {
|
|
5309
|
+
let safeTransferData;
|
|
5310
|
+
if (premint) {
|
|
5311
|
+
safeTransferData = encodePremintOnManager(premint);
|
|
5312
|
+
} else if (collect) {
|
|
5313
|
+
safeTransferData = encodeCollectOnManager(collect);
|
|
5314
|
+
} else {
|
|
5315
|
+
throw new Error("Invalid operation");
|
|
5256
5316
|
}
|
|
5257
|
-
return
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
var NUMBERS = ".numbers";
|
|
5268
|
-
var EXCEL = ".xlsx";
|
|
5269
|
-
var PDF = "application/pdf";
|
|
5270
|
-
var JPG = "image/jpg";
|
|
5271
|
-
var JPEG = "image/jpeg";
|
|
5272
|
-
var PNG = "image/png";
|
|
5273
|
-
var WEBP = "image/webp";
|
|
5274
|
-
var SVG = "image/svg+xml";
|
|
5275
|
-
var TIFF = "image/tiff";
|
|
5276
|
-
var GIF = "image/gif";
|
|
5277
|
-
var isImage = (mimeType) => {
|
|
5278
|
-
if (!mimeType)
|
|
5279
|
-
return false;
|
|
5280
|
-
return [JPG, JPEG, PNG, WEBP, SVG, TIFF, GIF].includes(mimeType);
|
|
5281
|
-
};
|
|
5282
|
-
var DEFAULT_THUMBNAIL_CID_HASHES = {
|
|
5283
|
-
["AUDIO" /* AUDIO */]: "bafkreidir5laqi26ta6ivnpe2zpekgrfcyi4tb5x6vhwmwnledmzxshfb4",
|
|
5284
|
-
["VIDEO" /* VIDEO */]: "bafkreifm4edadl3j5luoyvw4p6elxeqd77la7bulee6vhq5gq4chfk32mu",
|
|
5285
|
-
["HTML" /* HTML */]: "bafkreifgvi6xfwqy2l6g45csyokejpaib52ee7zrw6etrxl2tas4xkkclq",
|
|
5286
|
-
["ZIP" /* ZIP */]: "bafkreihe5rr5jbkwzegisjlhxbb7jw22xw5oilfmgd2re6tz6buo4pasdq",
|
|
5287
|
-
// assuming all zip files are html directories
|
|
5288
|
-
["TEXT" /* TEXT */]: "bafkreiaez25nfgggzrnza2loxf6xueb2esm44pnyjyulwoslnipowrf56q",
|
|
5289
|
-
default: "bafkreihcoahllisbpb4eeypdwtm7go5uh275wxd7wf2tantpxlpjhviok4"
|
|
5290
|
-
};
|
|
5291
|
-
var MP4 = "video/mp4";
|
|
5292
|
-
var QUICKTIME = "video/quicktime";
|
|
5293
|
-
var M4V = "video/x-m4v";
|
|
5294
|
-
var WEBM = "video/webm";
|
|
5295
|
-
var M4A = "audio/x-m4a";
|
|
5296
|
-
var MPEG = "audio/mpeg";
|
|
5297
|
-
var MP3 = "audio/mp3";
|
|
5298
|
-
var WAV = "audio/wav";
|
|
5299
|
-
var VND_WAV = "audio/vnd.wav";
|
|
5300
|
-
var VND_WAVE = "audio/vnd.wave";
|
|
5301
|
-
var WAVE = "audio/wave";
|
|
5302
|
-
var X_WAV = "audio/x-wav";
|
|
5303
|
-
var AIFF = "audio/aiff";
|
|
5304
|
-
var GLTF = "model/gltf+json";
|
|
5305
|
-
var GLB = "model/gltf-binary";
|
|
5306
|
-
var GLTF_EXT = ".gltf";
|
|
5307
|
-
var GLB_EXT = ".glb";
|
|
5308
|
-
var JSON_MIME_TYPE = "application/json";
|
|
5309
|
-
var ZIP = "application/zip";
|
|
5310
|
-
var mimeToMediaType = {
|
|
5311
|
-
[HTML]: "HTML" /* HTML */,
|
|
5312
|
-
[JPG]: "IMAGE" /* IMAGE */,
|
|
5313
|
-
[JPEG]: "IMAGE" /* IMAGE */,
|
|
5314
|
-
[PNG]: "IMAGE" /* IMAGE */,
|
|
5315
|
-
[WEBP]: "IMAGE" /* IMAGE */,
|
|
5316
|
-
[SVG]: "IMAGE" /* IMAGE */,
|
|
5317
|
-
[TIFF]: "TIFF" /* TIFF */,
|
|
5318
|
-
[GIF]: "IMAGE" /* IMAGE */,
|
|
5319
|
-
[MP4]: "VIDEO" /* VIDEO */,
|
|
5320
|
-
[WEBM]: "VIDEO" /* VIDEO */,
|
|
5321
|
-
[QUICKTIME]: "VIDEO" /* VIDEO */,
|
|
5322
|
-
[M4V]: "VIDEO" /* VIDEO */,
|
|
5323
|
-
[MPEG]: "AUDIO" /* AUDIO */,
|
|
5324
|
-
[MP3]: "AUDIO" /* AUDIO */,
|
|
5325
|
-
[M4A]: "AUDIO" /* AUDIO */,
|
|
5326
|
-
[VND_WAV]: "AUDIO" /* AUDIO */,
|
|
5327
|
-
[VND_WAVE]: "AUDIO" /* AUDIO */,
|
|
5328
|
-
[WAV]: "AUDIO" /* AUDIO */,
|
|
5329
|
-
[WAVE]: "AUDIO" /* AUDIO */,
|
|
5330
|
-
[X_WAV]: "AUDIO" /* AUDIO */,
|
|
5331
|
-
[AIFF]: "AUDIO" /* AUDIO */,
|
|
5332
|
-
[TEXT_PLAIN]: "TEXT" /* TEXT */,
|
|
5333
|
-
[TEXT_PLAIN_UTF8]: "TEXT" /* TEXT */,
|
|
5334
|
-
[MARKDOWN]: "TEXT" /* TEXT */,
|
|
5335
|
-
[MARKDOWN_UTF8]: "TEXT" /* TEXT */,
|
|
5336
|
-
[CSV]: "CSV" /* CSV */,
|
|
5337
|
-
[NUMBERS]: "NUMBERS" /* NUMBERS */,
|
|
5338
|
-
[EXCEL]: "EXCEL" /* EXCEL */,
|
|
5339
|
-
[PDF]: "PDF" /* PDF */,
|
|
5340
|
-
[ZIP]: "ZIP" /* ZIP */,
|
|
5341
|
-
[GLTF]: "MODEL" /* MODEL */,
|
|
5342
|
-
[GLTF_EXT]: "MODEL" /* MODEL */,
|
|
5343
|
-
[GLB]: "MODEL" /* MODEL */,
|
|
5344
|
-
// GLTF returns 'application/json' as the mimetype,
|
|
5345
|
-
// and as the only JSON-encoded media we currently support,
|
|
5346
|
-
// we assume that if the mimetype is JSON, it's a GLTF
|
|
5347
|
-
[JSON_MIME_TYPE]: "MODEL" /* MODEL */,
|
|
5348
|
-
[GLB_EXT]: "MODEL" /* MODEL */
|
|
5317
|
+
return makePermitTransferBatchAndTypeData({
|
|
5318
|
+
tokenIds,
|
|
5319
|
+
quantities,
|
|
5320
|
+
chainId,
|
|
5321
|
+
mintsOwner,
|
|
5322
|
+
nonce,
|
|
5323
|
+
deadline,
|
|
5324
|
+
safeTransferData,
|
|
5325
|
+
to: import_protocol_deployments11.zoraMintsManagerImplConfig.address[chainId]
|
|
5326
|
+
});
|
|
5349
5327
|
};
|
|
5350
|
-
function
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5328
|
+
function collectPremintV2WithMintsParams({
|
|
5329
|
+
tokenIds,
|
|
5330
|
+
quantities,
|
|
5331
|
+
paidMintPricePerToken,
|
|
5332
|
+
account,
|
|
5333
|
+
chainId,
|
|
5334
|
+
...rest
|
|
5335
|
+
}) {
|
|
5336
|
+
const call = encodePremintOnManager({
|
|
5337
|
+
...rest
|
|
5338
|
+
});
|
|
5339
|
+
return makeContractParameters({
|
|
5340
|
+
abi: import_protocol_deployments11.zoraMints1155Config.abi,
|
|
5341
|
+
address: import_protocol_deployments11.zoraMints1155Config.address[chainId],
|
|
5342
|
+
functionName: "transferBatchToManagerAndCall",
|
|
5343
|
+
args: [tokenIds, quantities, call],
|
|
5344
|
+
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
5345
|
+
account
|
|
5346
|
+
});
|
|
5354
5347
|
}
|
|
5355
|
-
|
|
5356
|
-
if (
|
|
5357
|
-
|
|
5358
|
-
const
|
|
5359
|
-
|
|
5360
|
-
|
|
5348
|
+
function decodeCallFailedError(error) {
|
|
5349
|
+
if (error.data?.errorName !== "CallFailed")
|
|
5350
|
+
throw new Error("Not a CallFailed error");
|
|
5351
|
+
const internalErrorData = error.data?.args?.[0];
|
|
5352
|
+
return (0, import_viem11.decodeErrorResult)({
|
|
5353
|
+
abi: import_protocol_deployments11.zoraMintsManagerImplABI,
|
|
5354
|
+
data: internalErrorData
|
|
5355
|
+
});
|
|
5361
5356
|
}
|
|
5362
5357
|
|
|
5363
|
-
// src/
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
mime: TEXT_PLAIN,
|
|
5368
|
-
uri: textFileUrl
|
|
5369
|
-
} : null;
|
|
5370
|
-
const image = thumbnailUrl;
|
|
5371
|
-
const animation_url = textFileUrl;
|
|
5358
|
+
// src/create/subgraph-queries.ts
|
|
5359
|
+
function buildContractInfoQuery({
|
|
5360
|
+
contractAddress
|
|
5361
|
+
}) {
|
|
5372
5362
|
return {
|
|
5373
|
-
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5363
|
+
query: `
|
|
5364
|
+
query ($contractAddress: Bytes!) {
|
|
5365
|
+
zoraCreateContract(id: $contractAddress) {
|
|
5366
|
+
contractVersion
|
|
5367
|
+
name
|
|
5368
|
+
mintFeePerQuantity
|
|
5369
|
+
tokens(first: 1, orderBy: tokenId, orderDirection: desc) {
|
|
5370
|
+
tokenId
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
`,
|
|
5375
|
+
variables: {
|
|
5376
|
+
contractAddress: contractAddress.toLowerCase()
|
|
5377
|
+
},
|
|
5378
|
+
parseResponseData: (responseData) => responseData.zoraCreateContract
|
|
5378
5379
|
};
|
|
5379
|
-
}
|
|
5380
|
-
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5384
|
-
|
|
5385
|
-
|
|
5386
|
-
}
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5380
|
+
}
|
|
5381
|
+
|
|
5382
|
+
// src/create/contract-getter.ts
|
|
5383
|
+
var SubgraphContractGetter = class {
|
|
5384
|
+
constructor(chainId, subgraphQuerier) {
|
|
5385
|
+
this.subgraphQuerier = subgraphQuerier || new SubgraphQuerier(httpClient);
|
|
5386
|
+
this.networkConfig = getApiNetworkConfigForChain(chainId);
|
|
5387
|
+
}
|
|
5388
|
+
async querySubgraphWithRetries({
|
|
5389
|
+
query,
|
|
5390
|
+
variables,
|
|
5391
|
+
parseResponseData
|
|
5392
|
+
}) {
|
|
5393
|
+
const responseData = await this.subgraphQuerier.query({
|
|
5394
|
+
subgraphUrl: this.networkConfig.subgraphUrl,
|
|
5395
|
+
query,
|
|
5396
|
+
variables
|
|
5397
|
+
});
|
|
5398
|
+
return parseResponseData(responseData);
|
|
5399
|
+
}
|
|
5400
|
+
async getContractInfo({
|
|
5401
|
+
contractAddress,
|
|
5402
|
+
retries: retries2 = 1
|
|
5403
|
+
}) {
|
|
5404
|
+
const tryFn = async () => {
|
|
5405
|
+
const responseData2 = await this.querySubgraphWithRetries(
|
|
5406
|
+
buildContractInfoQuery({ contractAddress })
|
|
5407
|
+
);
|
|
5408
|
+
if (!responseData2) {
|
|
5409
|
+
console.log("could not find contract");
|
|
5410
|
+
throw new Error("Cannot find contract");
|
|
5411
|
+
}
|
|
5412
|
+
return responseData2;
|
|
5413
|
+
};
|
|
5414
|
+
const responseData = await retriesGeneric({
|
|
5415
|
+
tryFn,
|
|
5416
|
+
maxTries: retries2,
|
|
5417
|
+
linearBackoffMS: 1e3
|
|
5418
|
+
});
|
|
5419
|
+
const nextTokenId = responseData.tokens.length === 0 ? 1n : BigInt(responseData.tokens[0].tokenId) + 1n;
|
|
5420
|
+
return {
|
|
5421
|
+
name: responseData.name,
|
|
5422
|
+
contractVersion: responseData.contractVersion,
|
|
5423
|
+
mintFee: BigInt(responseData.mintFeePerQuantity),
|
|
5424
|
+
nextTokenId
|
|
5425
|
+
};
|
|
5400
5426
|
}
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5427
|
+
};
|
|
5428
|
+
|
|
5429
|
+
// src/sdk.ts
|
|
5430
|
+
function createCreatorClient(clientConfig) {
|
|
5431
|
+
const premintClient = new PremintClient({
|
|
5432
|
+
chainId: clientConfig.chainId,
|
|
5433
|
+
publicClient: clientConfig.publicClient,
|
|
5434
|
+
premintApi: clientConfig.premintApi || new PremintAPIClient(clientConfig.chainId)
|
|
5435
|
+
});
|
|
5436
|
+
const create1155CreatorClient = new Create1155Client({
|
|
5437
|
+
chainId: clientConfig.chainId,
|
|
5438
|
+
publicClient: clientConfig.publicClient,
|
|
5439
|
+
contractGetter: clientConfig.contractGetter || new SubgraphContractGetter(clientConfig.chainId)
|
|
5440
|
+
});
|
|
5407
5441
|
return {
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
attributes
|
|
5442
|
+
createPremint: (p) => premintClient.createPremint(p),
|
|
5443
|
+
updatePremint: (p) => premintClient.updatePremint(p),
|
|
5444
|
+
deletePremint: (p) => premintClient.deletePremint(p),
|
|
5445
|
+
create1155: (p) => create1155CreatorClient.createNew1155(p),
|
|
5446
|
+
create1155OnExistingContract: (p) => create1155CreatorClient.createNew1155OnExistingContract(p)
|
|
5414
5447
|
};
|
|
5415
|
-
};
|
|
5416
|
-
async function fetchTokenMetadata(tokenMetadataURI) {
|
|
5417
|
-
const fetchableUrl = getFetchableUrl(tokenMetadataURI);
|
|
5418
|
-
if (!fetchableUrl) {
|
|
5419
|
-
throw new Error(`Invalid token metadata URI: ${tokenMetadataURI}`);
|
|
5420
|
-
}
|
|
5421
|
-
const json = await (await fetch(fetchableUrl)).json();
|
|
5422
|
-
if (!json) {
|
|
5423
|
-
throw new Error(`Failed to fetch metadata from ${fetchableUrl}`);
|
|
5424
|
-
}
|
|
5425
|
-
return json;
|
|
5426
5448
|
}
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
};
|
|
5436
|
-
var DEFAULT_MAX_TOKENS_PER_ADDRESS = {
|
|
5437
|
-
maxTokensPerAddress: 0n
|
|
5438
|
-
};
|
|
5439
|
-
var erc20SaleSettingsWithDefaults = (params) => ({
|
|
5440
|
-
...DEFAULT_SALE_START_AND_END,
|
|
5441
|
-
...DEFAULT_MAX_TOKENS_PER_ADDRESS,
|
|
5442
|
-
...params
|
|
5443
|
-
});
|
|
5444
|
-
var allowListWithDefaults = (allowlist) => {
|
|
5449
|
+
function createCollectorClient(params) {
|
|
5450
|
+
const premintGetterToUse = params.premintGetter || new PremintAPIClient(params.chainId);
|
|
5451
|
+
const mintGetterToUse = params.mintGetter || new SubgraphMintGetter(params.chainId);
|
|
5452
|
+
const mintClient = new MintClient({
|
|
5453
|
+
publicClient: params.publicClient,
|
|
5454
|
+
premintGetter: premintGetterToUse,
|
|
5455
|
+
mintGetter: mintGetterToUse
|
|
5456
|
+
});
|
|
5445
5457
|
return {
|
|
5446
|
-
|
|
5447
|
-
|
|
5458
|
+
getPremint: (p) => premintGetterToUse.get({
|
|
5459
|
+
collectionAddress: p.address,
|
|
5460
|
+
uid: p.uid
|
|
5461
|
+
}),
|
|
5462
|
+
getCollectDataFromPremintReceipt: (p) => getDataFromPremintReceipt(p, params.chainId),
|
|
5463
|
+
getToken: (p) => mintClient.get(p),
|
|
5464
|
+
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
5465
|
+
mint: (p) => mintClient.mint(p),
|
|
5466
|
+
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
5448
5467
|
};
|
|
5449
|
-
}
|
|
5450
|
-
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5468
|
+
}
|
|
5469
|
+
|
|
5470
|
+
// src/ipfs/arweave.ts
|
|
5471
|
+
function isArweaveURL(url) {
|
|
5472
|
+
return url && typeof url === "string" ? url.startsWith("ar://") : false;
|
|
5473
|
+
}
|
|
5474
|
+
|
|
5475
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bytes.js
|
|
5476
|
+
var empty = new Uint8Array(0);
|
|
5477
|
+
function equals(aa, bb) {
|
|
5478
|
+
if (aa === bb)
|
|
5479
|
+
return true;
|
|
5480
|
+
if (aa.byteLength !== bb.byteLength) {
|
|
5481
|
+
return false;
|
|
5459
5482
|
}
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5483
|
+
for (let ii = 0; ii < aa.byteLength; ii++) {
|
|
5484
|
+
if (aa[ii] !== bb[ii]) {
|
|
5485
|
+
return false;
|
|
5486
|
+
}
|
|
5463
5487
|
}
|
|
5464
|
-
return
|
|
5465
|
-
}
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
|
|
5488
|
+
return true;
|
|
5489
|
+
}
|
|
5490
|
+
function coerce3(o) {
|
|
5491
|
+
if (o instanceof Uint8Array && o.constructor.name === "Uint8Array")
|
|
5492
|
+
return o;
|
|
5493
|
+
if (o instanceof ArrayBuffer)
|
|
5494
|
+
return new Uint8Array(o);
|
|
5495
|
+
if (ArrayBuffer.isView(o)) {
|
|
5496
|
+
return new Uint8Array(o.buffer, o.byteOffset, o.byteLength);
|
|
5470
5497
|
}
|
|
5471
|
-
|
|
5498
|
+
throw new Error("Unknown type, must be binary type");
|
|
5472
5499
|
}
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
...DEFAULT_SALE_START_AND_END,
|
|
5479
|
-
erc20Name,
|
|
5480
|
-
erc20Symbol: symbol
|
|
5481
|
-
};
|
|
5482
|
-
};
|
|
5483
|
-
var isAllowList = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
5484
|
-
var isErc20 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
5485
|
-
var isFixedPrice = (salesConfig) => {
|
|
5486
|
-
return salesConfig.pricePerToken > 0n;
|
|
5487
|
-
};
|
|
5488
|
-
var getSalesConfigWithDefaults = async (salesConfig, tokenMetadataURI) => {
|
|
5489
|
-
if (!salesConfig)
|
|
5490
|
-
return timedSaleSettingsWithDefaults({}, tokenMetadataURI);
|
|
5491
|
-
if (isAllowList(salesConfig)) {
|
|
5492
|
-
return allowListWithDefaults(salesConfig);
|
|
5500
|
+
|
|
5501
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/vendor/base-x.js
|
|
5502
|
+
function base2(ALPHABET, name) {
|
|
5503
|
+
if (ALPHABET.length >= 255) {
|
|
5504
|
+
throw new TypeError("Alphabet too long");
|
|
5493
5505
|
}
|
|
5494
|
-
|
|
5495
|
-
|
|
5506
|
+
var BASE_MAP = new Uint8Array(256);
|
|
5507
|
+
for (var j = 0; j < BASE_MAP.length; j++) {
|
|
5508
|
+
BASE_MAP[j] = 255;
|
|
5496
5509
|
}
|
|
5497
|
-
|
|
5498
|
-
|
|
5510
|
+
for (var i = 0; i < ALPHABET.length; i++) {
|
|
5511
|
+
var x = ALPHABET.charAt(i);
|
|
5512
|
+
var xc = x.charCodeAt(0);
|
|
5513
|
+
if (BASE_MAP[xc] !== 255) {
|
|
5514
|
+
throw new TypeError(x + " is ambiguous");
|
|
5515
|
+
}
|
|
5516
|
+
BASE_MAP[xc] = i;
|
|
5499
5517
|
}
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
|
|
5504
|
-
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5518
|
+
var BASE = ALPHABET.length;
|
|
5519
|
+
var LEADER = ALPHABET.charAt(0);
|
|
5520
|
+
var FACTOR = Math.log(BASE) / Math.log(256);
|
|
5521
|
+
var iFACTOR = Math.log(256) / Math.log(BASE);
|
|
5522
|
+
function encode3(source) {
|
|
5523
|
+
if (source instanceof Uint8Array)
|
|
5524
|
+
;
|
|
5525
|
+
else if (ArrayBuffer.isView(source)) {
|
|
5526
|
+
source = new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
5527
|
+
} else if (Array.isArray(source)) {
|
|
5528
|
+
source = Uint8Array.from(source);
|
|
5529
|
+
}
|
|
5530
|
+
if (!(source instanceof Uint8Array)) {
|
|
5531
|
+
throw new TypeError("Expected Uint8Array");
|
|
5532
|
+
}
|
|
5533
|
+
if (source.length === 0) {
|
|
5534
|
+
return "";
|
|
5535
|
+
}
|
|
5536
|
+
var zeroes = 0;
|
|
5537
|
+
var length2 = 0;
|
|
5538
|
+
var pbegin = 0;
|
|
5539
|
+
var pend = source.length;
|
|
5540
|
+
while (pbegin !== pend && source[pbegin] === 0) {
|
|
5541
|
+
pbegin++;
|
|
5542
|
+
zeroes++;
|
|
5543
|
+
}
|
|
5544
|
+
var size = (pend - pbegin) * iFACTOR + 1 >>> 0;
|
|
5545
|
+
var b58 = new Uint8Array(size);
|
|
5546
|
+
while (pbegin !== pend) {
|
|
5547
|
+
var carry = source[pbegin];
|
|
5548
|
+
var i2 = 0;
|
|
5549
|
+
for (var it1 = size - 1; (carry !== 0 || i2 < length2) && it1 !== -1; it1--, i2++) {
|
|
5550
|
+
carry += 256 * b58[it1] >>> 0;
|
|
5551
|
+
b58[it1] = carry % BASE >>> 0;
|
|
5552
|
+
carry = carry / BASE >>> 0;
|
|
5553
|
+
}
|
|
5554
|
+
if (carry !== 0) {
|
|
5555
|
+
throw new Error("Non-zero carry");
|
|
5556
|
+
}
|
|
5557
|
+
length2 = i2;
|
|
5558
|
+
pbegin++;
|
|
5559
|
+
}
|
|
5560
|
+
var it2 = size - length2;
|
|
5561
|
+
while (it2 !== size && b58[it2] === 0) {
|
|
5562
|
+
it2++;
|
|
5563
|
+
}
|
|
5564
|
+
var str = LEADER.repeat(zeroes);
|
|
5565
|
+
for (; it2 < size; ++it2) {
|
|
5566
|
+
str += ALPHABET.charAt(b58[it2]);
|
|
5567
|
+
}
|
|
5568
|
+
return str;
|
|
5569
|
+
}
|
|
5570
|
+
function decodeUnsafe(source) {
|
|
5571
|
+
if (typeof source !== "string") {
|
|
5572
|
+
throw new TypeError("Expected String");
|
|
5573
|
+
}
|
|
5574
|
+
if (source.length === 0) {
|
|
5575
|
+
return new Uint8Array();
|
|
5576
|
+
}
|
|
5577
|
+
var psz = 0;
|
|
5578
|
+
if (source[psz] === " ") {
|
|
5579
|
+
return;
|
|
5580
|
+
}
|
|
5581
|
+
var zeroes = 0;
|
|
5582
|
+
var length2 = 0;
|
|
5583
|
+
while (source[psz] === LEADER) {
|
|
5584
|
+
zeroes++;
|
|
5585
|
+
psz++;
|
|
5586
|
+
}
|
|
5587
|
+
var size = (source.length - psz) * FACTOR + 1 >>> 0;
|
|
5588
|
+
var b256 = new Uint8Array(size);
|
|
5589
|
+
while (source[psz]) {
|
|
5590
|
+
var carry = BASE_MAP[source.charCodeAt(psz)];
|
|
5591
|
+
if (carry === 255) {
|
|
5592
|
+
return;
|
|
5539
5593
|
}
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
|
|
5543
|
-
|
|
5544
|
-
|
|
5545
|
-
args: [BigInt(nextTokenId), erc20MinterAddress, saleData]
|
|
5546
|
-
});
|
|
5547
|
-
return {
|
|
5548
|
-
minter: erc20MinterAddress,
|
|
5549
|
-
setupActions: [erc20MinterApproval, callSale]
|
|
5550
|
-
};
|
|
5551
|
-
}
|
|
5552
|
-
function setupFixedPriceMinter({
|
|
5553
|
-
pricePerToken: price,
|
|
5554
|
-
tokenId: nextTokenId,
|
|
5555
|
-
chainId,
|
|
5556
|
-
saleStart,
|
|
5557
|
-
saleEnd,
|
|
5558
|
-
maxTokensPerAddress: mintLimit,
|
|
5559
|
-
fundsRecipient
|
|
5560
|
-
}) {
|
|
5561
|
-
const fixedPriceStrategyAddress = import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyAddress[chainId];
|
|
5562
|
-
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
5563
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5564
|
-
functionName: "addPermission",
|
|
5565
|
-
args: [
|
|
5566
|
-
BigInt(nextTokenId),
|
|
5567
|
-
fixedPriceStrategyAddress,
|
|
5568
|
-
PERMISSION_BITS.MINTER
|
|
5569
|
-
]
|
|
5570
|
-
});
|
|
5571
|
-
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
5572
|
-
abi: import_protocol_deployments8.zoraCreatorFixedPriceSaleStrategyABI,
|
|
5573
|
-
functionName: "setSale",
|
|
5574
|
-
args: [
|
|
5575
|
-
BigInt(nextTokenId),
|
|
5576
|
-
{
|
|
5577
|
-
pricePerToken: price,
|
|
5578
|
-
saleStart: saleStart || BigInt(0),
|
|
5579
|
-
saleEnd: saleEnd || BigInt(0),
|
|
5580
|
-
maxTokensPerAddress: BigInt(mintLimit || 0),
|
|
5581
|
-
fundsRecipient
|
|
5594
|
+
var i2 = 0;
|
|
5595
|
+
for (var it3 = size - 1; (carry !== 0 || i2 < length2) && it3 !== -1; it3--, i2++) {
|
|
5596
|
+
carry += BASE * b256[it3] >>> 0;
|
|
5597
|
+
b256[it3] = carry % 256 >>> 0;
|
|
5598
|
+
carry = carry / 256 >>> 0;
|
|
5582
5599
|
}
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
const callSale = (0, import_viem7.encodeFunctionData)({
|
|
5586
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5587
|
-
functionName: "callSale",
|
|
5588
|
-
args: [BigInt(nextTokenId), fixedPriceStrategyAddress, saleData]
|
|
5589
|
-
});
|
|
5590
|
-
return {
|
|
5591
|
-
minter: fixedPriceStrategyAddress,
|
|
5592
|
-
setupActions: [fixedPriceApproval, callSale]
|
|
5593
|
-
};
|
|
5594
|
-
}
|
|
5595
|
-
function setupTimedSaleMinter({
|
|
5596
|
-
chainId,
|
|
5597
|
-
tokenId,
|
|
5598
|
-
erc20Name: erc20zName,
|
|
5599
|
-
erc20Symbol: erc20zSymbol,
|
|
5600
|
-
saleStart,
|
|
5601
|
-
saleEnd
|
|
5602
|
-
}) {
|
|
5603
|
-
const minterAddress = import_protocol_deployments8.zoraTimedSaleStrategyAddress[chainId];
|
|
5604
|
-
const fixedPriceApproval = (0, import_viem7.encodeFunctionData)({
|
|
5605
|
-
abi: import_protocol_deployments8.zoraCreator1155ImplABI,
|
|
5606
|
-
functionName: "addPermission",
|
|
5607
|
-
args: [BigInt(tokenId), minterAddress, PERMISSION_BITS.MINTER]
|
|
5608
|
-
});
|
|
5609
|
-
const saleData = (0, import_viem7.encodeFunctionData)({
|
|
5610
|
-
abi: import_protocol_deployments8.zoraTimedSaleStrategyABI,
|
|
5611
|
-
functionName: "setSale",
|
|
5612
|
-
args: [
|
|
5613
|
-
BigInt(tokenId),
|
|
5614
|
-
{
|
|
5615
|
-
saleStart,
|
|
5616
|
-
saleEnd,
|
|
5617
|
-
name: erc20zName,
|
|
5618
|
-
symbol: erc20zSymbol
|
|
5600
|
+
if (carry !== 0) {
|
|
5601
|
+
throw new Error("Non-zero carry");
|
|
5619
5602
|
}
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5603
|
+
length2 = i2;
|
|
5604
|
+
psz++;
|
|
5605
|
+
}
|
|
5606
|
+
if (source[psz] === " ") {
|
|
5607
|
+
return;
|
|
5608
|
+
}
|
|
5609
|
+
var it4 = size - length2;
|
|
5610
|
+
while (it4 !== size && b256[it4] === 0) {
|
|
5611
|
+
it4++;
|
|
5612
|
+
}
|
|
5613
|
+
var vch = new Uint8Array(zeroes + (size - it4));
|
|
5614
|
+
var j2 = zeroes;
|
|
5615
|
+
while (it4 !== size) {
|
|
5616
|
+
vch[j2++] = b256[it4++];
|
|
5617
|
+
}
|
|
5618
|
+
return vch;
|
|
5619
|
+
}
|
|
5620
|
+
function decode5(string) {
|
|
5621
|
+
var buffer = decodeUnsafe(string);
|
|
5622
|
+
if (buffer) {
|
|
5623
|
+
return buffer;
|
|
5624
|
+
}
|
|
5625
|
+
throw new Error(`Non-${name} character`);
|
|
5626
|
+
}
|
|
5627
5627
|
return {
|
|
5628
|
-
|
|
5629
|
-
|
|
5628
|
+
encode: encode3,
|
|
5629
|
+
decodeUnsafe,
|
|
5630
|
+
decode: decode5
|
|
5630
5631
|
};
|
|
5631
5632
|
}
|
|
5632
|
-
|
|
5633
|
-
|
|
5634
|
-
|
|
5635
|
-
|
|
5636
|
-
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5646
|
-
|
|
5647
|
-
|
|
5648
|
-
|
|
5649
|
-
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
|
|
5633
|
+
var src = base2;
|
|
5634
|
+
var _brrp__multiformats_scope_baseX = src;
|
|
5635
|
+
var base_x_default = _brrp__multiformats_scope_baseX;
|
|
5636
|
+
|
|
5637
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base.js
|
|
5638
|
+
var Encoder = class {
|
|
5639
|
+
constructor(name, prefix, baseEncode) {
|
|
5640
|
+
__publicField(this, "name");
|
|
5641
|
+
__publicField(this, "prefix");
|
|
5642
|
+
__publicField(this, "baseEncode");
|
|
5643
|
+
this.name = name;
|
|
5644
|
+
this.prefix = prefix;
|
|
5645
|
+
this.baseEncode = baseEncode;
|
|
5646
|
+
}
|
|
5647
|
+
encode(bytes) {
|
|
5648
|
+
if (bytes instanceof Uint8Array) {
|
|
5649
|
+
return `${this.prefix}${this.baseEncode(bytes)}`;
|
|
5650
|
+
} else {
|
|
5651
|
+
throw Error("Unknown type, must be binary type");
|
|
5652
|
+
}
|
|
5653
|
+
}
|
|
5654
|
+
};
|
|
5655
|
+
var Decoder = class {
|
|
5656
|
+
constructor(name, prefix, baseDecode) {
|
|
5657
|
+
__publicField(this, "name");
|
|
5658
|
+
__publicField(this, "prefix");
|
|
5659
|
+
__publicField(this, "baseDecode");
|
|
5660
|
+
__publicField(this, "prefixCodePoint");
|
|
5661
|
+
this.name = name;
|
|
5662
|
+
this.prefix = prefix;
|
|
5663
|
+
if (prefix.codePointAt(0) === void 0) {
|
|
5664
|
+
throw new Error("Invalid prefix character");
|
|
5665
|
+
}
|
|
5666
|
+
this.prefixCodePoint = prefix.codePointAt(0);
|
|
5667
|
+
this.baseDecode = baseDecode;
|
|
5668
|
+
}
|
|
5669
|
+
decode(text) {
|
|
5670
|
+
if (typeof text === "string") {
|
|
5671
|
+
if (text.codePointAt(0) !== this.prefixCodePoint) {
|
|
5672
|
+
throw Error(`Unable to decode multibase string ${JSON.stringify(text)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);
|
|
5655
5673
|
}
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5660
|
-
functionName: "callSale",
|
|
5661
|
-
args: [BigInt(nextTokenId), merkleSaleStrategyAddress, saleData]
|
|
5662
|
-
});
|
|
5663
|
-
return {
|
|
5664
|
-
minter: merkleSaleStrategyAddress,
|
|
5665
|
-
setupActions: [merkleApproval, callSaleMerkle]
|
|
5666
|
-
};
|
|
5667
|
-
}
|
|
5668
|
-
var isAllowList2 = (salesConfig) => salesConfig.type === "allowlistMint";
|
|
5669
|
-
var isErc202 = (salesConfig) => salesConfig.type === "erc20Mint";
|
|
5670
|
-
var isFixedPrice2 = (salesConfig) => salesConfig.type === "fixedPrice" || salesConfig.pricePerToken > BigInt(0);
|
|
5671
|
-
function setupMinters({ salesConfig, ...rest }) {
|
|
5672
|
-
if (isErc202(salesConfig)) {
|
|
5673
|
-
return setupErc20Minter({
|
|
5674
|
-
...salesConfig,
|
|
5675
|
-
...rest
|
|
5676
|
-
});
|
|
5674
|
+
return this.baseDecode(text.slice(this.prefix.length));
|
|
5675
|
+
} else {
|
|
5676
|
+
throw Error("Can only multibase decode strings");
|
|
5677
|
+
}
|
|
5677
5678
|
}
|
|
5678
|
-
|
|
5679
|
-
return
|
|
5680
|
-
allowlist: salesConfig,
|
|
5681
|
-
...rest
|
|
5682
|
-
});
|
|
5679
|
+
or(decoder) {
|
|
5680
|
+
return or(this, decoder);
|
|
5683
5681
|
}
|
|
5684
|
-
|
|
5685
|
-
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5682
|
+
};
|
|
5683
|
+
var ComposedDecoder = class {
|
|
5684
|
+
constructor(decoders) {
|
|
5685
|
+
__publicField(this, "decoders");
|
|
5686
|
+
this.decoders = decoders;
|
|
5687
|
+
}
|
|
5688
|
+
or(decoder) {
|
|
5689
|
+
return or(this, decoder);
|
|
5690
|
+
}
|
|
5691
|
+
decode(input) {
|
|
5692
|
+
const prefix = input[0];
|
|
5693
|
+
const decoder = this.decoders[prefix];
|
|
5694
|
+
if (decoder != null) {
|
|
5695
|
+
return decoder.decode(input);
|
|
5696
|
+
} else {
|
|
5697
|
+
throw RangeError(`Unable to decode multibase string ${JSON.stringify(input)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`);
|
|
5698
|
+
}
|
|
5699
|
+
}
|
|
5700
|
+
};
|
|
5701
|
+
function or(left, right) {
|
|
5702
|
+
return new ComposedDecoder({
|
|
5703
|
+
...left.decoders ?? { [left.prefix]: left },
|
|
5704
|
+
...right.decoders ?? { [right.prefix]: right }
|
|
5692
5705
|
});
|
|
5693
5706
|
}
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
|
|
5707
|
-
|
|
5708
|
-
)
|
|
5709
|
-
};
|
|
5710
|
-
}
|
|
5711
|
-
function buildSetupNewToken({
|
|
5712
|
-
tokenURI,
|
|
5713
|
-
maxSupply = OPEN_EDITION_MINT_SIZE,
|
|
5714
|
-
createReferral = import_viem8.zeroAddress,
|
|
5715
|
-
contractVersion
|
|
5716
|
-
}) {
|
|
5717
|
-
if (contractSupportsMintRewards(contractVersion, "ERC1155")) {
|
|
5718
|
-
return (0, import_viem8.encodeFunctionData)({
|
|
5719
|
-
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5720
|
-
functionName: "setupNewTokenWithCreateReferral",
|
|
5721
|
-
args: [tokenURI, BigInt(maxSupply), createReferral]
|
|
5722
|
-
});
|
|
5707
|
+
var Codec = class {
|
|
5708
|
+
constructor(name, prefix, baseEncode, baseDecode) {
|
|
5709
|
+
__publicField(this, "name");
|
|
5710
|
+
__publicField(this, "prefix");
|
|
5711
|
+
__publicField(this, "baseEncode");
|
|
5712
|
+
__publicField(this, "baseDecode");
|
|
5713
|
+
__publicField(this, "encoder");
|
|
5714
|
+
__publicField(this, "decoder");
|
|
5715
|
+
this.name = name;
|
|
5716
|
+
this.prefix = prefix;
|
|
5717
|
+
this.baseEncode = baseEncode;
|
|
5718
|
+
this.baseDecode = baseDecode;
|
|
5719
|
+
this.encoder = new Encoder(name, prefix, baseEncode);
|
|
5720
|
+
this.decoder = new Decoder(name, prefix, baseDecode);
|
|
5723
5721
|
}
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
"Contract does not support create referral, but one was provided"
|
|
5727
|
-
);
|
|
5722
|
+
encode(input) {
|
|
5723
|
+
return this.encoder.encode(input);
|
|
5728
5724
|
}
|
|
5729
|
-
|
|
5730
|
-
|
|
5731
|
-
|
|
5732
|
-
|
|
5725
|
+
decode(input) {
|
|
5726
|
+
return this.decoder.decode(input);
|
|
5727
|
+
}
|
|
5728
|
+
};
|
|
5729
|
+
function from({ name, prefix, encode: encode3, decode: decode5 }) {
|
|
5730
|
+
return new Codec(name, prefix, encode3, decode5);
|
|
5731
|
+
}
|
|
5732
|
+
function baseX({ name, prefix, alphabet }) {
|
|
5733
|
+
const { encode: encode3, decode: decode5 } = base_x_default(alphabet, name);
|
|
5734
|
+
return from({
|
|
5735
|
+
prefix,
|
|
5736
|
+
name,
|
|
5737
|
+
encode: encode3,
|
|
5738
|
+
decode: (text) => coerce3(decode5(text))
|
|
5733
5739
|
});
|
|
5734
5740
|
}
|
|
5735
|
-
function
|
|
5736
|
-
|
|
5737
|
-
|
|
5738
|
-
|
|
5739
|
-
}) {
|
|
5740
|
-
if (royaltyBPS > 0 && royaltyRecipient != import_viem8.zeroAddress) {
|
|
5741
|
-
return (0, import_viem8.encodeFunctionData)({
|
|
5742
|
-
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5743
|
-
functionName: "updateRoyaltiesForToken",
|
|
5744
|
-
args: [
|
|
5745
|
-
nextTokenId,
|
|
5746
|
-
{
|
|
5747
|
-
royaltyBPS,
|
|
5748
|
-
royaltyRecipient,
|
|
5749
|
-
royaltyMintSchedule: 0
|
|
5750
|
-
}
|
|
5751
|
-
]
|
|
5752
|
-
});
|
|
5741
|
+
function decode(string, alphabet, bitsPerChar, name) {
|
|
5742
|
+
const codes = {};
|
|
5743
|
+
for (let i = 0; i < alphabet.length; ++i) {
|
|
5744
|
+
codes[alphabet[i]] = i;
|
|
5753
5745
|
}
|
|
5754
|
-
|
|
5746
|
+
let end = string.length;
|
|
5747
|
+
while (string[end - 1] === "=") {
|
|
5748
|
+
--end;
|
|
5749
|
+
}
|
|
5750
|
+
const out = new Uint8Array(end * bitsPerChar / 8 | 0);
|
|
5751
|
+
let bits = 0;
|
|
5752
|
+
let buffer = 0;
|
|
5753
|
+
let written = 0;
|
|
5754
|
+
for (let i = 0; i < end; ++i) {
|
|
5755
|
+
const value = codes[string[i]];
|
|
5756
|
+
if (value === void 0) {
|
|
5757
|
+
throw new SyntaxError(`Non-${name} character`);
|
|
5758
|
+
}
|
|
5759
|
+
buffer = buffer << bitsPerChar | value;
|
|
5760
|
+
bits += bitsPerChar;
|
|
5761
|
+
if (bits >= 8) {
|
|
5762
|
+
bits -= 8;
|
|
5763
|
+
out[written++] = 255 & buffer >> bits;
|
|
5764
|
+
}
|
|
5765
|
+
}
|
|
5766
|
+
if (bits >= bitsPerChar || (255 & buffer << 8 - bits) !== 0) {
|
|
5767
|
+
throw new SyntaxError("Unexpected end of data");
|
|
5768
|
+
}
|
|
5769
|
+
return out;
|
|
5755
5770
|
}
|
|
5756
|
-
function
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5761
|
-
|
|
5762
|
-
|
|
5771
|
+
function encode(data, alphabet, bitsPerChar) {
|
|
5772
|
+
const pad = alphabet[alphabet.length - 1] === "=";
|
|
5773
|
+
const mask = (1 << bitsPerChar) - 1;
|
|
5774
|
+
let out = "";
|
|
5775
|
+
let bits = 0;
|
|
5776
|
+
let buffer = 0;
|
|
5777
|
+
for (let i = 0; i < data.length; ++i) {
|
|
5778
|
+
buffer = buffer << 8 | data[i];
|
|
5779
|
+
bits += 8;
|
|
5780
|
+
while (bits > bitsPerChar) {
|
|
5781
|
+
bits -= bitsPerChar;
|
|
5782
|
+
out += alphabet[mask & buffer >> bits];
|
|
5783
|
+
}
|
|
5763
5784
|
}
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5785
|
+
if (bits !== 0) {
|
|
5786
|
+
out += alphabet[mask & buffer << bitsPerChar - bits];
|
|
5787
|
+
}
|
|
5788
|
+
if (pad) {
|
|
5789
|
+
while ((out.length * bitsPerChar & 7) !== 0) {
|
|
5790
|
+
out += "=";
|
|
5791
|
+
}
|
|
5792
|
+
}
|
|
5793
|
+
return out;
|
|
5769
5794
|
}
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
ownerAddress
|
|
5781
|
-
);
|
|
5782
|
-
const verifyTokenIdExpected = (0, import_viem8.encodeFunctionData)({
|
|
5783
|
-
abi: import_protocol_deployments9.zoraCreator1155ImplABI,
|
|
5784
|
-
functionName: "assumeLastTokenIdMatches",
|
|
5785
|
-
args: [nextTokenId - 1n]
|
|
5786
|
-
});
|
|
5787
|
-
const setupNewToken = buildSetupNewToken({
|
|
5788
|
-
tokenURI: new1155TokenPropsWithDefaults.tokenMetadataURI,
|
|
5789
|
-
maxSupply: new1155TokenPropsWithDefaults.maxSupply,
|
|
5790
|
-
createReferral: new1155TokenPropsWithDefaults.createReferral,
|
|
5791
|
-
contractVersion
|
|
5792
|
-
});
|
|
5793
|
-
const royaltyConfig = setupRoyaltyConfig({
|
|
5794
|
-
royaltyBPS: new1155TokenPropsWithDefaults.royaltyBPS,
|
|
5795
|
-
royaltyRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
5796
|
-
nextTokenId
|
|
5797
|
-
});
|
|
5798
|
-
const { minter, setupActions: mintersSetup } = setupMinters({
|
|
5799
|
-
tokenId: nextTokenId,
|
|
5800
|
-
chainId,
|
|
5801
|
-
fundsRecipient: new1155TokenPropsWithDefaults.payoutRecipient,
|
|
5802
|
-
salesConfig: new1155TokenPropsWithDefaults.salesConfig
|
|
5803
|
-
});
|
|
5804
|
-
const adminMintCall = makeAdminMintCall({
|
|
5805
|
-
ownerAddress,
|
|
5806
|
-
mintQuantity: mintToCreatorCount,
|
|
5807
|
-
nextTokenId
|
|
5795
|
+
function rfc4648({ name, prefix, bitsPerChar, alphabet }) {
|
|
5796
|
+
return from({
|
|
5797
|
+
prefix,
|
|
5798
|
+
name,
|
|
5799
|
+
encode(input) {
|
|
5800
|
+
return encode(input, alphabet, bitsPerChar);
|
|
5801
|
+
},
|
|
5802
|
+
decode(input) {
|
|
5803
|
+
return decode(input, alphabet, bitsPerChar, name);
|
|
5804
|
+
}
|
|
5808
5805
|
});
|
|
5809
|
-
const setupActions = [
|
|
5810
|
-
verifyTokenIdExpected,
|
|
5811
|
-
setupNewToken,
|
|
5812
|
-
...mintersSetup,
|
|
5813
|
-
royaltyConfig,
|
|
5814
|
-
adminMintCall
|
|
5815
|
-
].filter((item) => item !== null);
|
|
5816
|
-
return {
|
|
5817
|
-
setupActions,
|
|
5818
|
-
minter,
|
|
5819
|
-
newToken: new1155TokenPropsWithDefaults
|
|
5820
|
-
};
|
|
5821
5806
|
}
|
|
5822
|
-
var contractSupportsMintRewards = (contractVersion, contractStandard) => {
|
|
5823
|
-
if (!contractStandard || !contractVersion) {
|
|
5824
|
-
return false;
|
|
5825
|
-
}
|
|
5826
|
-
const semVerContractVersion = semver2.coerce(contractVersion)?.raw;
|
|
5827
|
-
if (!semVerContractVersion)
|
|
5828
|
-
return false;
|
|
5829
|
-
if (contractStandard === "ERC1155") {
|
|
5830
|
-
return semver2.gte(semVerContractVersion, "1.3.5");
|
|
5831
|
-
} else {
|
|
5832
|
-
return semver2.gte(semVerContractVersion, "14.0.0");
|
|
5833
|
-
}
|
|
5834
|
-
};
|
|
5835
5807
|
|
|
5836
|
-
// src/
|
|
5837
|
-
var
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5808
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base32.js
|
|
5809
|
+
var base32 = rfc4648({
|
|
5810
|
+
prefix: "b",
|
|
5811
|
+
name: "base32",
|
|
5812
|
+
alphabet: "abcdefghijklmnopqrstuvwxyz234567",
|
|
5813
|
+
bitsPerChar: 5
|
|
5814
|
+
});
|
|
5815
|
+
var base32upper = rfc4648({
|
|
5816
|
+
prefix: "B",
|
|
5817
|
+
name: "base32upper",
|
|
5818
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",
|
|
5819
|
+
bitsPerChar: 5
|
|
5820
|
+
});
|
|
5821
|
+
var base32pad = rfc4648({
|
|
5822
|
+
prefix: "c",
|
|
5823
|
+
name: "base32pad",
|
|
5824
|
+
alphabet: "abcdefghijklmnopqrstuvwxyz234567=",
|
|
5825
|
+
bitsPerChar: 5
|
|
5826
|
+
});
|
|
5827
|
+
var base32padupper = rfc4648({
|
|
5828
|
+
prefix: "C",
|
|
5829
|
+
name: "base32padupper",
|
|
5830
|
+
alphabet: "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
|
|
5831
|
+
bitsPerChar: 5
|
|
5832
|
+
});
|
|
5833
|
+
var base32hex = rfc4648({
|
|
5834
|
+
prefix: "v",
|
|
5835
|
+
name: "base32hex",
|
|
5836
|
+
alphabet: "0123456789abcdefghijklmnopqrstuv",
|
|
5837
|
+
bitsPerChar: 5
|
|
5838
|
+
});
|
|
5839
|
+
var base32hexupper = rfc4648({
|
|
5840
|
+
prefix: "V",
|
|
5841
|
+
name: "base32hexupper",
|
|
5842
|
+
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV",
|
|
5843
|
+
bitsPerChar: 5
|
|
5844
|
+
});
|
|
5845
|
+
var base32hexpad = rfc4648({
|
|
5846
|
+
prefix: "t",
|
|
5847
|
+
name: "base32hexpad",
|
|
5848
|
+
alphabet: "0123456789abcdefghijklmnopqrstuv=",
|
|
5849
|
+
bitsPerChar: 5
|
|
5850
|
+
});
|
|
5851
|
+
var base32hexpadupper = rfc4648({
|
|
5852
|
+
prefix: "T",
|
|
5853
|
+
name: "base32hexpadupper",
|
|
5854
|
+
alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUV=",
|
|
5855
|
+
bitsPerChar: 5
|
|
5856
|
+
});
|
|
5857
|
+
var base32z = rfc4648({
|
|
5858
|
+
prefix: "h",
|
|
5859
|
+
name: "base32z",
|
|
5860
|
+
alphabet: "ybndrfg8ejkmcpqxot1uwisza345h769",
|
|
5861
|
+
bitsPerChar: 5
|
|
5862
|
+
});
|
|
5863
|
+
|
|
5864
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/bases/base58.js
|
|
5865
|
+
var base58btc = baseX({
|
|
5866
|
+
name: "base58btc",
|
|
5867
|
+
prefix: "z",
|
|
5868
|
+
alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
|
|
5869
|
+
});
|
|
5870
|
+
var base58flickr = baseX({
|
|
5871
|
+
name: "base58flickr",
|
|
5872
|
+
prefix: "Z",
|
|
5873
|
+
alphabet: "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
|
|
5874
|
+
});
|
|
5875
|
+
|
|
5876
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/vendor/varint.js
|
|
5877
|
+
var encode_1 = encode2;
|
|
5878
|
+
var MSB = 128;
|
|
5879
|
+
var REST = 127;
|
|
5880
|
+
var MSBALL = ~REST;
|
|
5881
|
+
var INT = Math.pow(2, 31);
|
|
5882
|
+
function encode2(num, out, offset) {
|
|
5883
|
+
out = out || [];
|
|
5884
|
+
offset = offset || 0;
|
|
5885
|
+
var oldOffset = offset;
|
|
5886
|
+
while (num >= INT) {
|
|
5887
|
+
out[offset++] = num & 255 | MSB;
|
|
5888
|
+
num /= 128;
|
|
5871
5889
|
}
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
functionName: "mintFee"
|
|
5876
|
-
});
|
|
5877
|
-
if (salesConfig.type === "fixedPrice") {
|
|
5878
|
-
return {
|
|
5879
|
-
saleType: "fixedPrice",
|
|
5880
|
-
address: minter,
|
|
5881
|
-
maxTokensPerAddress: salesConfig.maxTokensPerAddress,
|
|
5882
|
-
mintFeePerQuantity: contractMintFee,
|
|
5883
|
-
pricePerToken: salesConfig.pricePerToken,
|
|
5884
|
-
saleStart: salesConfig.saleStart.toString(),
|
|
5885
|
-
saleEnd: salesConfig.saleEnd.toString()
|
|
5886
|
-
};
|
|
5890
|
+
while (num & MSBALL) {
|
|
5891
|
+
out[offset++] = num & 255 | MSB;
|
|
5892
|
+
num >>>= 7;
|
|
5887
5893
|
}
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
saleStart: salesConfig.saleStart.toString(),
|
|
5892
|
-
saleEnd: salesConfig.saleEnd.toString(),
|
|
5893
|
-
merkleRoot: salesConfig.presaleMerkleRoot,
|
|
5894
|
-
mintFeePerQuantity: contractMintFee
|
|
5895
|
-
};
|
|
5896
|
-
}
|
|
5897
|
-
function makeOnchainPrepareMintFromCreate({
|
|
5898
|
-
contractAddress,
|
|
5899
|
-
tokenId,
|
|
5900
|
-
result,
|
|
5901
|
-
minter,
|
|
5902
|
-
publicClient,
|
|
5903
|
-
contractVersion
|
|
5904
|
-
}) {
|
|
5905
|
-
return async (params) => {
|
|
5906
|
-
const subgraphSalesConfig = await toSalesStrategyFromSubgraph({
|
|
5907
|
-
minter,
|
|
5908
|
-
contractAddress,
|
|
5909
|
-
publicClient,
|
|
5910
|
-
salesConfig: result
|
|
5911
|
-
});
|
|
5912
|
-
return {
|
|
5913
|
-
parameters: makePrepareMint1155TokenParams({
|
|
5914
|
-
salesConfigAndTokenInfo: {
|
|
5915
|
-
salesConfig: subgraphSalesConfig,
|
|
5916
|
-
contractVersion
|
|
5917
|
-
},
|
|
5918
|
-
...params,
|
|
5919
|
-
tokenContract: contractAddress,
|
|
5920
|
-
tokenId
|
|
5921
|
-
}),
|
|
5922
|
-
costs: parseMintCosts({
|
|
5923
|
-
allowListEntry: params.allowListEntry,
|
|
5924
|
-
quantityToMint: BigInt(params.quantityToMint),
|
|
5925
|
-
salesConfig: subgraphSalesConfig
|
|
5926
|
-
}),
|
|
5927
|
-
erc20Approval: getRequiredErc20Approvals(params, subgraphSalesConfig)
|
|
5928
|
-
};
|
|
5929
|
-
};
|
|
5894
|
+
out[offset] = num | 0;
|
|
5895
|
+
encode2.bytes = offset - oldOffset + 1;
|
|
5896
|
+
return out;
|
|
5930
5897
|
}
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
var
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
...data
|
|
5941
|
-
});
|
|
5942
|
-
if (decodedLog && decodedLog.eventName === "SetupNewToken") {
|
|
5943
|
-
return decodedLog.args.tokenId;
|
|
5944
|
-
}
|
|
5945
|
-
} catch (err) {
|
|
5898
|
+
var decode2 = read;
|
|
5899
|
+
var MSB$1 = 128;
|
|
5900
|
+
var REST$1 = 127;
|
|
5901
|
+
function read(buf, offset) {
|
|
5902
|
+
var res = 0, offset = offset || 0, shift = 0, counter = offset, b, l = buf.length;
|
|
5903
|
+
do {
|
|
5904
|
+
if (counter >= l) {
|
|
5905
|
+
read.bytes = 0;
|
|
5906
|
+
throw new RangeError("Could not decode varint");
|
|
5946
5907
|
}
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
);
|
|
5908
|
+
b = buf[counter++];
|
|
5909
|
+
res += shift < 28 ? (b & REST$1) << shift : (b & REST$1) * Math.pow(2, shift);
|
|
5910
|
+
shift += 7;
|
|
5911
|
+
} while (b >= MSB$1);
|
|
5912
|
+
read.bytes = counter - offset;
|
|
5913
|
+
return res;
|
|
5914
|
+
}
|
|
5915
|
+
var N1 = Math.pow(2, 7);
|
|
5916
|
+
var N2 = Math.pow(2, 14);
|
|
5917
|
+
var N3 = Math.pow(2, 21);
|
|
5918
|
+
var N4 = Math.pow(2, 28);
|
|
5919
|
+
var N5 = Math.pow(2, 35);
|
|
5920
|
+
var N6 = Math.pow(2, 42);
|
|
5921
|
+
var N7 = Math.pow(2, 49);
|
|
5922
|
+
var N8 = Math.pow(2, 56);
|
|
5923
|
+
var N9 = Math.pow(2, 63);
|
|
5924
|
+
var length = function(value) {
|
|
5925
|
+
return value < N1 ? 1 : value < N2 ? 2 : value < N3 ? 3 : value < N4 ? 4 : value < N5 ? 5 : value < N6 ? 6 : value < N7 ? 7 : value < N8 ? 8 : value < N9 ? 9 : 10;
|
|
5951
5926
|
};
|
|
5952
|
-
var
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
abi: import_protocol_deployments11.zoraCreator1155FactoryImplABI,
|
|
5957
|
-
eventName: "SetupNewContract",
|
|
5958
|
-
...data
|
|
5959
|
-
});
|
|
5960
|
-
if (decodedLog && decodedLog.eventName === "SetupNewContract") {
|
|
5961
|
-
return decodedLog.args.newContract;
|
|
5962
|
-
}
|
|
5963
|
-
} catch (err) {
|
|
5964
|
-
}
|
|
5965
|
-
}
|
|
5966
|
-
throw new Error(
|
|
5967
|
-
"No event found in receipt that could be used to get contract address"
|
|
5968
|
-
);
|
|
5927
|
+
var varint = {
|
|
5928
|
+
encode: encode_1,
|
|
5929
|
+
decode: decode2,
|
|
5930
|
+
encodingLength: length
|
|
5969
5931
|
};
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
|
|
5974
|
-
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
}) {
|
|
5978
|
-
const accountAddress = typeof account === "string" ? account : account.address;
|
|
5979
|
-
return makeContractParameters({
|
|
5980
|
-
abi: import_protocol_deployments11.zoraCreator1155FactoryImplABI,
|
|
5981
|
-
functionName: "createContractDeterministic",
|
|
5982
|
-
account,
|
|
5983
|
-
address: import_protocol_deployments11.zoraCreator1155FactoryImplAddress[chainId],
|
|
5984
|
-
args: [
|
|
5985
|
-
contract.uri,
|
|
5986
|
-
contract.name,
|
|
5987
|
-
{
|
|
5988
|
-
// deprecated
|
|
5989
|
-
royaltyMintSchedule: 0,
|
|
5990
|
-
royaltyBPS: royaltyBPS || ROYALTY_BPS_DEFAULT,
|
|
5991
|
-
royaltyRecipient: fundsRecipient || accountAddress
|
|
5992
|
-
},
|
|
5993
|
-
contract.defaultAdmin || accountAddress,
|
|
5994
|
-
tokenSetupActions
|
|
5995
|
-
]
|
|
5996
|
-
});
|
|
5932
|
+
var _brrp_varint = varint;
|
|
5933
|
+
var varint_default = _brrp_varint;
|
|
5934
|
+
|
|
5935
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/varint.js
|
|
5936
|
+
function decode3(data, offset = 0) {
|
|
5937
|
+
const code = varint_default.decode(data, offset);
|
|
5938
|
+
return [code, varint_default.decode.bytes];
|
|
5997
5939
|
}
|
|
5998
|
-
function
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
return
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
5940
|
+
function encodeTo(int, target, offset = 0) {
|
|
5941
|
+
varint_default.encode(int, target, offset);
|
|
5942
|
+
return target;
|
|
5943
|
+
}
|
|
5944
|
+
function encodingLength(int) {
|
|
5945
|
+
return varint_default.encodingLength(int);
|
|
5946
|
+
}
|
|
5947
|
+
|
|
5948
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/hashes/digest.js
|
|
5949
|
+
function create(code, digest) {
|
|
5950
|
+
const size = digest.byteLength;
|
|
5951
|
+
const sizeOffset = encodingLength(code);
|
|
5952
|
+
const digestOffset = sizeOffset + encodingLength(size);
|
|
5953
|
+
const bytes = new Uint8Array(digestOffset + size);
|
|
5954
|
+
encodeTo(code, bytes, 0);
|
|
5955
|
+
encodeTo(size, bytes, sizeOffset);
|
|
5956
|
+
bytes.set(digest, digestOffset);
|
|
5957
|
+
return new Digest(code, size, digest, bytes);
|
|
6010
5958
|
}
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
5959
|
+
function decode4(multihash) {
|
|
5960
|
+
const bytes = coerce3(multihash);
|
|
5961
|
+
const [code, sizeOffset] = decode3(bytes);
|
|
5962
|
+
const [size, digestOffset] = decode3(bytes.subarray(sizeOffset));
|
|
5963
|
+
const digest = bytes.subarray(sizeOffset + digestOffset);
|
|
5964
|
+
if (digest.byteLength !== size) {
|
|
5965
|
+
throw new Error("Incorrect length");
|
|
6018
5966
|
}
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
5967
|
+
return new Digest(code, size, digest, bytes);
|
|
5968
|
+
}
|
|
5969
|
+
function equals2(a, b) {
|
|
5970
|
+
if (a === b) {
|
|
5971
|
+
return true;
|
|
5972
|
+
} else {
|
|
5973
|
+
const data = b;
|
|
5974
|
+
return a.code === data.code && a.size === data.size && data.bytes instanceof Uint8Array && equals(a.bytes, data.bytes);
|
|
6025
5975
|
}
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
5976
|
+
}
|
|
5977
|
+
var Digest = class {
|
|
5978
|
+
/**
|
|
5979
|
+
* Creates a multihash digest.
|
|
5980
|
+
*/
|
|
5981
|
+
constructor(code, size, digest, bytes) {
|
|
5982
|
+
__publicField(this, "code");
|
|
5983
|
+
__publicField(this, "size");
|
|
5984
|
+
__publicField(this, "digest");
|
|
5985
|
+
__publicField(this, "bytes");
|
|
5986
|
+
this.code = code;
|
|
5987
|
+
this.size = size;
|
|
5988
|
+
this.digest = digest;
|
|
5989
|
+
this.bytes = bytes;
|
|
6040
5990
|
}
|
|
6041
5991
|
};
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
const {
|
|
6053
|
-
minter,
|
|
6054
|
-
newToken,
|
|
6055
|
-
setupActions: tokenSetupActions
|
|
6056
|
-
} = await prepareSetupActions({
|
|
6057
|
-
chainId,
|
|
6058
|
-
account,
|
|
6059
|
-
contractVersion,
|
|
6060
|
-
nextTokenId,
|
|
6061
|
-
token,
|
|
6062
|
-
getAdditionalSetupActions
|
|
6063
|
-
});
|
|
6064
|
-
const request = makeCreateContractAndTokenCall({
|
|
6065
|
-
contract,
|
|
6066
|
-
account,
|
|
6067
|
-
chainId,
|
|
6068
|
-
tokenSetupActions,
|
|
6069
|
-
fundsRecipient: token.payoutRecipient,
|
|
6070
|
-
royaltyBPS: token.royaltyBPS
|
|
6071
|
-
});
|
|
6072
|
-
const contractAddress = await getDeterministicContractAddress({
|
|
6073
|
-
account,
|
|
6074
|
-
publicClient,
|
|
6075
|
-
setupActions: tokenSetupActions,
|
|
6076
|
-
chainId,
|
|
6077
|
-
contract
|
|
6078
|
-
});
|
|
6079
|
-
const prepareMint = makeOnchainPrepareMintFromCreate({
|
|
6080
|
-
contractAddress,
|
|
6081
|
-
contractVersion,
|
|
6082
|
-
minter,
|
|
6083
|
-
publicClient,
|
|
6084
|
-
result: newToken.salesConfig,
|
|
6085
|
-
tokenId: nextTokenId
|
|
6086
|
-
});
|
|
6087
|
-
return {
|
|
6088
|
-
parameters: request,
|
|
6089
|
-
tokenSetupActions,
|
|
6090
|
-
newTokenId: nextTokenId,
|
|
6091
|
-
newToken,
|
|
6092
|
-
contractAddress,
|
|
6093
|
-
contractVersion,
|
|
6094
|
-
minter,
|
|
6095
|
-
prepareMint
|
|
6096
|
-
};
|
|
6097
|
-
}
|
|
6098
|
-
async function createNew1155Token({
|
|
6099
|
-
contractAddress,
|
|
6100
|
-
account,
|
|
6101
|
-
getAdditionalSetupActions,
|
|
6102
|
-
token,
|
|
6103
|
-
publicClient,
|
|
6104
|
-
chainId
|
|
6105
|
-
}) {
|
|
6106
|
-
const { nextTokenId, contractVersion } = await getContractInfoExistingContract({
|
|
6107
|
-
publicClient,
|
|
6108
|
-
contractAddress
|
|
6109
|
-
});
|
|
6110
|
-
const {
|
|
6111
|
-
minter,
|
|
6112
|
-
newToken,
|
|
6113
|
-
setupActions: tokenSetupActions
|
|
6114
|
-
} = await prepareSetupActions({
|
|
6115
|
-
chainId,
|
|
6116
|
-
account,
|
|
6117
|
-
contractVersion,
|
|
6118
|
-
nextTokenId,
|
|
6119
|
-
token,
|
|
6120
|
-
getAdditionalSetupActions
|
|
6121
|
-
});
|
|
6122
|
-
const request = makeCreateTokenCall({
|
|
6123
|
-
contractAddress,
|
|
6124
|
-
account,
|
|
6125
|
-
tokenSetupActions
|
|
6126
|
-
});
|
|
6127
|
-
const prepareMint = makeOnchainPrepareMintFromCreate({
|
|
6128
|
-
contractAddress,
|
|
6129
|
-
contractVersion,
|
|
6130
|
-
minter,
|
|
6131
|
-
publicClient,
|
|
6132
|
-
result: newToken.salesConfig,
|
|
6133
|
-
tokenId: nextTokenId
|
|
6134
|
-
});
|
|
6135
|
-
return {
|
|
6136
|
-
parameters: request,
|
|
6137
|
-
tokenSetupActions,
|
|
6138
|
-
newTokenId: nextTokenId,
|
|
6139
|
-
newToken,
|
|
6140
|
-
contractVersion,
|
|
6141
|
-
minter,
|
|
6142
|
-
prepareMint
|
|
6143
|
-
};
|
|
5992
|
+
|
|
5993
|
+
// ../../node_modules/.pnpm/multiformats@13.2.1/node_modules/multiformats/dist/src/cid.js
|
|
5994
|
+
function format(link, base3) {
|
|
5995
|
+
const { bytes, version } = link;
|
|
5996
|
+
switch (version) {
|
|
5997
|
+
case 0:
|
|
5998
|
+
return toStringV0(bytes, baseCache(link), base3 ?? base58btc.encoder);
|
|
5999
|
+
default:
|
|
6000
|
+
return toStringV1(bytes, baseCache(link), base3 ?? base32.encoder);
|
|
6001
|
+
}
|
|
6144
6002
|
}
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
}
|
|
6153
|
-
|
|
6154
|
-
minter,
|
|
6155
|
-
newToken,
|
|
6156
|
-
setupActions: tokenSetupActions
|
|
6157
|
-
} = await constructCreate1155TokenCalls({
|
|
6158
|
-
chainId,
|
|
6159
|
-
ownerAddress: account,
|
|
6160
|
-
contractVersion,
|
|
6161
|
-
nextTokenId,
|
|
6162
|
-
...token
|
|
6163
|
-
});
|
|
6164
|
-
const setupActions = getAdditionalSetupActions ? [
|
|
6165
|
-
...getAdditionalSetupActions({
|
|
6166
|
-
tokenId: nextTokenId
|
|
6167
|
-
}),
|
|
6168
|
-
...tokenSetupActions
|
|
6169
|
-
] : tokenSetupActions;
|
|
6170
|
-
return { minter, newToken, setupActions };
|
|
6003
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
6004
|
+
function baseCache(cid) {
|
|
6005
|
+
const baseCache2 = cache.get(cid);
|
|
6006
|
+
if (baseCache2 == null) {
|
|
6007
|
+
const baseCache3 = /* @__PURE__ */ new Map();
|
|
6008
|
+
cache.set(cid, baseCache3);
|
|
6009
|
+
return baseCache3;
|
|
6010
|
+
}
|
|
6011
|
+
return baseCache2;
|
|
6171
6012
|
}
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
6180
|
-
|
|
6181
|
-
|
|
6013
|
+
var _a;
|
|
6014
|
+
var CID = class _CID {
|
|
6015
|
+
/**
|
|
6016
|
+
* @param version - Version of the CID
|
|
6017
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
6018
|
+
* @param multihash - (Multi)hash of the of the content.
|
|
6019
|
+
*/
|
|
6020
|
+
constructor(version, code, multihash, bytes) {
|
|
6021
|
+
__publicField(this, "code");
|
|
6022
|
+
__publicField(this, "version");
|
|
6023
|
+
__publicField(this, "multihash");
|
|
6024
|
+
__publicField(this, "bytes");
|
|
6025
|
+
__publicField(this, "/");
|
|
6026
|
+
__publicField(this, _a, "CID");
|
|
6027
|
+
this.code = code;
|
|
6028
|
+
this.version = version;
|
|
6029
|
+
this.multihash = multihash;
|
|
6030
|
+
this.bytes = bytes;
|
|
6031
|
+
this["/"] = bytes;
|
|
6032
|
+
}
|
|
6033
|
+
/**
|
|
6034
|
+
* Signalling `cid.asCID === cid` has been replaced with `cid['/'] === cid.bytes`
|
|
6035
|
+
* please either use `CID.asCID(cid)` or switch to new signalling mechanism
|
|
6036
|
+
*
|
|
6037
|
+
* @deprecated
|
|
6038
|
+
*/
|
|
6039
|
+
get asCID() {
|
|
6040
|
+
return this;
|
|
6041
|
+
}
|
|
6042
|
+
// ArrayBufferView
|
|
6043
|
+
get byteOffset() {
|
|
6044
|
+
return this.bytes.byteOffset;
|
|
6045
|
+
}
|
|
6046
|
+
// ArrayBufferView
|
|
6047
|
+
get byteLength() {
|
|
6048
|
+
return this.bytes.byteLength;
|
|
6049
|
+
}
|
|
6050
|
+
toV0() {
|
|
6051
|
+
switch (this.version) {
|
|
6052
|
+
case 0: {
|
|
6053
|
+
return this;
|
|
6054
|
+
}
|
|
6055
|
+
case 1: {
|
|
6056
|
+
const { code, multihash } = this;
|
|
6057
|
+
if (code !== DAG_PB_CODE) {
|
|
6058
|
+
throw new Error("Cannot convert a non dag-pb CID to CIDv0");
|
|
6059
|
+
}
|
|
6060
|
+
if (multihash.code !== SHA_256_CODE) {
|
|
6061
|
+
throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");
|
|
6182
6062
|
}
|
|
6063
|
+
return _CID.createV0(multihash);
|
|
6064
|
+
}
|
|
6065
|
+
default: {
|
|
6066
|
+
throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`);
|
|
6183
6067
|
}
|
|
6184
6068
|
}
|
|
6185
|
-
|
|
6186
|
-
|
|
6187
|
-
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6069
|
+
}
|
|
6070
|
+
toV1() {
|
|
6071
|
+
switch (this.version) {
|
|
6072
|
+
case 0: {
|
|
6073
|
+
const { code, digest } = this.multihash;
|
|
6074
|
+
const multihash = create(code, digest);
|
|
6075
|
+
return _CID.createV1(this.code, multihash);
|
|
6076
|
+
}
|
|
6077
|
+
case 1: {
|
|
6078
|
+
return this;
|
|
6079
|
+
}
|
|
6080
|
+
default: {
|
|
6081
|
+
throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`);
|
|
6082
|
+
}
|
|
6083
|
+
}
|
|
6084
|
+
}
|
|
6085
|
+
equals(other) {
|
|
6086
|
+
return _CID.equals(this, other);
|
|
6087
|
+
}
|
|
6088
|
+
static equals(self, other) {
|
|
6089
|
+
const unknown = other;
|
|
6090
|
+
return unknown != null && self.code === unknown.code && self.version === unknown.version && equals2(self.multihash, unknown.multihash);
|
|
6091
|
+
}
|
|
6092
|
+
toString(base3) {
|
|
6093
|
+
return format(this, base3);
|
|
6094
|
+
}
|
|
6095
|
+
toJSON() {
|
|
6096
|
+
return { "/": format(this) };
|
|
6097
|
+
}
|
|
6098
|
+
link() {
|
|
6099
|
+
return this;
|
|
6100
|
+
}
|
|
6101
|
+
// Legacy
|
|
6102
|
+
[(_a = Symbol.toStringTag, Symbol.for("nodejs.util.inspect.custom"))]() {
|
|
6103
|
+
return `CID(${this.toString()})`;
|
|
6104
|
+
}
|
|
6105
|
+
/**
|
|
6106
|
+
* Takes any input `value` and returns a `CID` instance if it was
|
|
6107
|
+
* a `CID` otherwise returns `null`. If `value` is instanceof `CID`
|
|
6108
|
+
* it will return value back. If `value` is not instance of this CID
|
|
6109
|
+
* class, but is compatible CID it will return new instance of this
|
|
6110
|
+
* `CID` class. Otherwise returns null.
|
|
6111
|
+
*
|
|
6112
|
+
* This allows two different incompatible versions of CID library to
|
|
6113
|
+
* co-exist and interop as long as binary interface is compatible.
|
|
6114
|
+
*/
|
|
6115
|
+
static asCID(input) {
|
|
6116
|
+
if (input == null) {
|
|
6117
|
+
return null;
|
|
6118
|
+
}
|
|
6119
|
+
const value = input;
|
|
6120
|
+
if (value instanceof _CID) {
|
|
6121
|
+
return value;
|
|
6122
|
+
} else if (value["/"] != null && value["/"] === value.bytes || value.asCID === value) {
|
|
6123
|
+
const { version, code, multihash, bytes } = value;
|
|
6124
|
+
return new _CID(version, code, multihash, bytes ?? encodeCID(version, code, multihash.bytes));
|
|
6125
|
+
} else if (value[cidSymbol] === true) {
|
|
6126
|
+
const { version, multihash, code } = value;
|
|
6127
|
+
const digest = decode4(multihash);
|
|
6128
|
+
return _CID.create(version, code, digest);
|
|
6129
|
+
} else {
|
|
6130
|
+
return null;
|
|
6131
|
+
}
|
|
6132
|
+
}
|
|
6133
|
+
/**
|
|
6134
|
+
* @param version - Version of the CID
|
|
6135
|
+
* @param code - Code of the codec content is encoded in, see https://github.com/multiformats/multicodec/blob/master/table.csv
|
|
6136
|
+
* @param digest - (Multi)hash of the of the content.
|
|
6137
|
+
*/
|
|
6138
|
+
static create(version, code, digest) {
|
|
6139
|
+
if (typeof code !== "number") {
|
|
6140
|
+
throw new Error("String codecs are no longer supported");
|
|
6141
|
+
}
|
|
6142
|
+
if (!(digest.bytes instanceof Uint8Array)) {
|
|
6143
|
+
throw new Error("Invalid digest");
|
|
6144
|
+
}
|
|
6145
|
+
switch (version) {
|
|
6146
|
+
case 0: {
|
|
6147
|
+
if (code !== DAG_PB_CODE) {
|
|
6148
|
+
throw new Error(`Version 0 CID must use dag-pb (code: ${DAG_PB_CODE}) block encoding`);
|
|
6149
|
+
} else {
|
|
6150
|
+
return new _CID(version, code, digest, digest.bytes);
|
|
6151
|
+
}
|
|
6152
|
+
}
|
|
6153
|
+
case 1: {
|
|
6154
|
+
const bytes = encodeCID(version, code, digest.bytes);
|
|
6155
|
+
return new _CID(version, code, digest, bytes);
|
|
6156
|
+
}
|
|
6157
|
+
default: {
|
|
6158
|
+
throw new Error("Invalid version");
|
|
6159
|
+
}
|
|
6160
|
+
}
|
|
6161
|
+
}
|
|
6162
|
+
/**
|
|
6163
|
+
* Simplified version of `create` for CIDv0.
|
|
6164
|
+
*/
|
|
6165
|
+
static createV0(digest) {
|
|
6166
|
+
return _CID.create(0, DAG_PB_CODE, digest);
|
|
6167
|
+
}
|
|
6168
|
+
/**
|
|
6169
|
+
* Simplified version of `create` for CIDv1.
|
|
6170
|
+
*
|
|
6171
|
+
* @param code - Content encoding format code.
|
|
6172
|
+
* @param digest - Multihash of the content.
|
|
6173
|
+
*/
|
|
6174
|
+
static createV1(code, digest) {
|
|
6175
|
+
return _CID.create(1, code, digest);
|
|
6176
|
+
}
|
|
6177
|
+
/**
|
|
6178
|
+
* Decoded a CID from its binary representation. The byte array must contain
|
|
6179
|
+
* only the CID with no additional bytes.
|
|
6180
|
+
*
|
|
6181
|
+
* An error will be thrown if the bytes provided do not contain a valid
|
|
6182
|
+
* binary representation of a CID.
|
|
6183
|
+
*/
|
|
6184
|
+
static decode(bytes) {
|
|
6185
|
+
const [cid, remainder] = _CID.decodeFirst(bytes);
|
|
6186
|
+
if (remainder.length !== 0) {
|
|
6187
|
+
throw new Error("Incorrect length");
|
|
6188
|
+
}
|
|
6189
|
+
return cid;
|
|
6190
|
+
}
|
|
6191
|
+
/**
|
|
6192
|
+
* Decoded a CID from its binary representation at the beginning of a byte
|
|
6193
|
+
* array.
|
|
6194
|
+
*
|
|
6195
|
+
* Returns an array with the first element containing the CID and the second
|
|
6196
|
+
* element containing the remainder of the original byte array. The remainder
|
|
6197
|
+
* will be a zero-length byte array if the provided bytes only contained a
|
|
6198
|
+
* binary CID representation.
|
|
6199
|
+
*/
|
|
6200
|
+
static decodeFirst(bytes) {
|
|
6201
|
+
const specs = _CID.inspectBytes(bytes);
|
|
6202
|
+
const prefixSize = specs.size - specs.multihashSize;
|
|
6203
|
+
const multihashBytes = coerce3(bytes.subarray(prefixSize, prefixSize + specs.multihashSize));
|
|
6204
|
+
if (multihashBytes.byteLength !== specs.multihashSize) {
|
|
6205
|
+
throw new Error("Incorrect length");
|
|
6206
|
+
}
|
|
6207
|
+
const digestBytes = multihashBytes.subarray(specs.multihashSize - specs.digestSize);
|
|
6208
|
+
const digest = new Digest(specs.multihashCode, specs.digestSize, digestBytes, multihashBytes);
|
|
6209
|
+
const cid = specs.version === 0 ? _CID.createV0(digest) : _CID.createV1(specs.codec, digest);
|
|
6210
|
+
return [cid, bytes.subarray(specs.size)];
|
|
6211
|
+
}
|
|
6212
|
+
/**
|
|
6213
|
+
* Inspect the initial bytes of a CID to determine its properties.
|
|
6214
|
+
*
|
|
6215
|
+
* Involves decoding up to 4 varints. Typically this will require only 4 to 6
|
|
6216
|
+
* bytes but for larger multicodec code values and larger multihash digest
|
|
6217
|
+
* lengths these varints can be quite large. It is recommended that at least
|
|
6218
|
+
* 10 bytes be made available in the `initialBytes` argument for a complete
|
|
6219
|
+
* inspection.
|
|
6220
|
+
*/
|
|
6221
|
+
static inspectBytes(initialBytes) {
|
|
6222
|
+
let offset = 0;
|
|
6223
|
+
const next = () => {
|
|
6224
|
+
const [i, length2] = decode3(initialBytes.subarray(offset));
|
|
6225
|
+
offset += length2;
|
|
6226
|
+
return i;
|
|
6197
6227
|
};
|
|
6198
|
-
|
|
6199
|
-
|
|
6200
|
-
if (
|
|
6201
|
-
|
|
6228
|
+
let version = next();
|
|
6229
|
+
let codec = DAG_PB_CODE;
|
|
6230
|
+
if (version === 18) {
|
|
6231
|
+
version = 0;
|
|
6232
|
+
offset = 0;
|
|
6233
|
+
} else {
|
|
6234
|
+
codec = next();
|
|
6202
6235
|
}
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
let remainingQuantity = quantityToCollect;
|
|
6206
|
-
const tokenIds = [];
|
|
6207
|
-
const quantities = [];
|
|
6208
|
-
while (remainingQuantity > 0) {
|
|
6209
|
-
const next = sorted.shift();
|
|
6210
|
-
if (!next) {
|
|
6211
|
-
throw new Error("Not enough MINTs to collect with");
|
|
6236
|
+
if (version !== 0 && version !== 1) {
|
|
6237
|
+
throw new RangeError(`Invalid CID version ${version}`);
|
|
6212
6238
|
}
|
|
6213
|
-
const
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6239
|
+
const prefixSize = offset;
|
|
6240
|
+
const multihashCode = next();
|
|
6241
|
+
const digestSize = next();
|
|
6242
|
+
const size = offset + digestSize;
|
|
6243
|
+
const multihashSize = size - prefixSize;
|
|
6244
|
+
return { version, codec, multihashCode, digestSize, multihashSize, size };
|
|
6245
|
+
}
|
|
6246
|
+
/**
|
|
6247
|
+
* Takes cid in a string representation and creates an instance. If `base`
|
|
6248
|
+
* decoder is not provided will use a default from the configuration. It will
|
|
6249
|
+
* throw an error if encoding of the CID is not compatible with supplied (or
|
|
6250
|
+
* a default decoder).
|
|
6251
|
+
*/
|
|
6252
|
+
static parse(source, base3) {
|
|
6253
|
+
const [prefix, bytes] = parseCIDtoBytes(source, base3);
|
|
6254
|
+
const cid = _CID.decode(bytes);
|
|
6255
|
+
if (cid.version === 0 && source[0] !== "Q") {
|
|
6256
|
+
throw Error("Version 0 CID string must not include multibase prefix");
|
|
6257
|
+
}
|
|
6258
|
+
baseCache(cid).set(prefix, source);
|
|
6259
|
+
return cid;
|
|
6217
6260
|
}
|
|
6218
|
-
return {
|
|
6219
|
-
tokenIds,
|
|
6220
|
-
quantities
|
|
6221
|
-
};
|
|
6222
|
-
};
|
|
6223
|
-
var sumBalances = (mintAccountBalances) => {
|
|
6224
|
-
return mintAccountBalances.reduce((acc, curr) => {
|
|
6225
|
-
return acc + BigInt(curr.balance);
|
|
6226
|
-
}, BigInt(0));
|
|
6227
|
-
};
|
|
6228
|
-
|
|
6229
|
-
// src/sparks/sparks-contracts.ts
|
|
6230
|
-
var import_protocol_deployments12 = require("@zoralabs/protocol-deployments");
|
|
6231
|
-
var import_viem11 = require("viem");
|
|
6232
|
-
var addressOrAccountAddress = (address) => typeof address === "string" ? address : address.address;
|
|
6233
|
-
var mintWithEthParams = ({
|
|
6234
|
-
tokenId,
|
|
6235
|
-
quantity,
|
|
6236
|
-
recipient,
|
|
6237
|
-
chainId,
|
|
6238
|
-
pricePerMint,
|
|
6239
|
-
account
|
|
6240
|
-
}) => makeContractParameters({
|
|
6241
|
-
abi: import_protocol_deployments12.zoraSparksManagerImplABI,
|
|
6242
|
-
address: import_protocol_deployments12.zoraSparksManagerImplAddress[chainId],
|
|
6243
|
-
functionName: "mintWithEth",
|
|
6244
|
-
args: [tokenId, quantity, recipient || addressOrAccountAddress(account)],
|
|
6245
|
-
value: pricePerMint * quantity,
|
|
6246
|
-
account
|
|
6247
|
-
});
|
|
6248
|
-
var getPaidMintValue = (quantities, pricePerMint) => {
|
|
6249
|
-
if (!pricePerMint || pricePerMint === 0n)
|
|
6250
|
-
return;
|
|
6251
|
-
return quantities.reduce((a, b) => a + b, 0n) * pricePerMint;
|
|
6252
6261
|
};
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
|
|
6261
|
-
}
|
|
6262
|
-
|
|
6263
|
-
|
|
6264
|
-
|
|
6265
|
-
|
|
6266
|
-
|
|
6267
|
-
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
}
|
|
6277
|
-
function collectWithMintsParams({
|
|
6278
|
-
tokenIds,
|
|
6279
|
-
quantities,
|
|
6280
|
-
chainId,
|
|
6281
|
-
paidMintPricePerToken,
|
|
6282
|
-
account,
|
|
6283
|
-
mintArguments,
|
|
6284
|
-
minter,
|
|
6285
|
-
zoraCreator1155Contract,
|
|
6286
|
-
zoraCreator1155TokenId
|
|
6287
|
-
}) {
|
|
6288
|
-
const call = encodeCollectOnManager({
|
|
6289
|
-
tokenIds,
|
|
6290
|
-
quantities,
|
|
6291
|
-
zoraCreator1155Contract,
|
|
6292
|
-
zoraCreator1155TokenId,
|
|
6293
|
-
minter,
|
|
6294
|
-
mintArguments
|
|
6295
|
-
});
|
|
6296
|
-
return makeContractParameters({
|
|
6297
|
-
abi: import_protocol_deployments12.zoraMints1155Config.abi,
|
|
6298
|
-
address: import_protocol_deployments12.zoraMints1155Config.address[chainId],
|
|
6299
|
-
functionName: "transferBatchToManagerAndCall",
|
|
6300
|
-
args: [tokenIds, quantities, call],
|
|
6301
|
-
// if it is a paid mint, the aadditional value will be sent to the manager contract and forwarded to the creator 1155 contract
|
|
6302
|
-
// for the paid mint cost.
|
|
6303
|
-
value: getPaidMintValue(quantities, paidMintPricePerToken),
|
|
6304
|
-
account
|
|
6305
|
-
});
|
|
6262
|
+
function parseCIDtoBytes(source, base3) {
|
|
6263
|
+
switch (source[0]) {
|
|
6264
|
+
case "Q": {
|
|
6265
|
+
const decoder = base3 ?? base58btc;
|
|
6266
|
+
return [
|
|
6267
|
+
base58btc.prefix,
|
|
6268
|
+
decoder.decode(`${base58btc.prefix}${source}`)
|
|
6269
|
+
];
|
|
6270
|
+
}
|
|
6271
|
+
case base58btc.prefix: {
|
|
6272
|
+
const decoder = base3 ?? base58btc;
|
|
6273
|
+
return [base58btc.prefix, decoder.decode(source)];
|
|
6274
|
+
}
|
|
6275
|
+
case base32.prefix: {
|
|
6276
|
+
const decoder = base3 ?? base32;
|
|
6277
|
+
return [base32.prefix, decoder.decode(source)];
|
|
6278
|
+
}
|
|
6279
|
+
default: {
|
|
6280
|
+
if (base3 == null) {
|
|
6281
|
+
throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");
|
|
6282
|
+
}
|
|
6283
|
+
return [source[0], base3.decode(source)];
|
|
6284
|
+
}
|
|
6285
|
+
}
|
|
6306
6286
|
}
|
|
6307
|
-
function
|
|
6308
|
-
|
|
6309
|
-
|
|
6310
|
-
|
|
6311
|
-
|
|
6312
|
-
|
|
6287
|
+
function toStringV0(bytes, cache2, base3) {
|
|
6288
|
+
const { prefix } = base3;
|
|
6289
|
+
if (prefix !== base58btc.prefix) {
|
|
6290
|
+
throw Error(`Cannot string encode V0 in ${base3.name} encoding`);
|
|
6291
|
+
}
|
|
6292
|
+
const cid = cache2.get(prefix);
|
|
6293
|
+
if (cid == null) {
|
|
6294
|
+
const cid2 = base3.encode(bytes).slice(1);
|
|
6295
|
+
cache2.set(prefix, cid2);
|
|
6296
|
+
return cid2;
|
|
6297
|
+
} else {
|
|
6298
|
+
return cid;
|
|
6313
6299
|
}
|
|
6314
|
-
return publicClient.readContract({
|
|
6315
|
-
abi: import_protocol_deployments12.zoraMintsManagerImplABI,
|
|
6316
|
-
address: import_protocol_deployments12.zoraMintsManagerImplAddress[chainId],
|
|
6317
|
-
functionName: "getEthPrice"
|
|
6318
|
-
});
|
|
6319
6300
|
}
|
|
6320
|
-
function
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
}
|
|
6330
|
-
const permit = {
|
|
6331
|
-
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
6332
|
-
to,
|
|
6333
|
-
tokenIds,
|
|
6334
|
-
quantities,
|
|
6335
|
-
deadline,
|
|
6336
|
-
nonce,
|
|
6337
|
-
safeTransferData
|
|
6338
|
-
};
|
|
6339
|
-
const typedData = {
|
|
6340
|
-
...(0, import_protocol_deployments12.mintsSafeTransferBatchTypedDataDefinition)({
|
|
6341
|
-
chainId,
|
|
6342
|
-
message: permit
|
|
6343
|
-
}),
|
|
6344
|
-
account: mintsOwner
|
|
6345
|
-
};
|
|
6346
|
-
return {
|
|
6347
|
-
permit,
|
|
6348
|
-
typedData
|
|
6349
|
-
};
|
|
6301
|
+
function toStringV1(bytes, cache2, base3) {
|
|
6302
|
+
const { prefix } = base3;
|
|
6303
|
+
const cid = cache2.get(prefix);
|
|
6304
|
+
if (cid == null) {
|
|
6305
|
+
const cid2 = base3.encode(bytes);
|
|
6306
|
+
cache2.set(prefix, cid2);
|
|
6307
|
+
return cid2;
|
|
6308
|
+
} else {
|
|
6309
|
+
return cid;
|
|
6310
|
+
}
|
|
6350
6311
|
}
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
const permit = {
|
|
6362
|
-
owner: typeof mintsOwner === "string" ? mintsOwner : mintsOwner.address,
|
|
6363
|
-
to,
|
|
6364
|
-
tokenId,
|
|
6365
|
-
quantity,
|
|
6366
|
-
deadline,
|
|
6367
|
-
nonce,
|
|
6368
|
-
safeTransferData
|
|
6369
|
-
};
|
|
6370
|
-
const typedData = {
|
|
6371
|
-
...(0, import_protocol_deployments12.mintsSafeTransferTypedDataDefinition)({
|
|
6372
|
-
chainId,
|
|
6373
|
-
message: permit
|
|
6374
|
-
}),
|
|
6375
|
-
account: mintsOwner
|
|
6376
|
-
};
|
|
6377
|
-
return {
|
|
6378
|
-
permit,
|
|
6379
|
-
typedData
|
|
6380
|
-
};
|
|
6312
|
+
var DAG_PB_CODE = 112;
|
|
6313
|
+
var SHA_256_CODE = 18;
|
|
6314
|
+
function encodeCID(version, code, multihash) {
|
|
6315
|
+
const codeOffset = encodingLength(version);
|
|
6316
|
+
const hashOffset = codeOffset + encodingLength(code);
|
|
6317
|
+
const bytes = new Uint8Array(hashOffset + multihash.byteLength);
|
|
6318
|
+
encodeTo(version, bytes, 0);
|
|
6319
|
+
encodeTo(code, bytes, codeOffset);
|
|
6320
|
+
bytes.set(multihash, hashOffset);
|
|
6321
|
+
return bytes;
|
|
6381
6322
|
}
|
|
6382
|
-
var
|
|
6383
|
-
|
|
6384
|
-
|
|
6385
|
-
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6408
|
-
|
|
6409
|
-
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6323
|
+
var cidSymbol = Symbol.for("@ipld/js-cid/CID");
|
|
6324
|
+
|
|
6325
|
+
// src/ipfs/ipfs.ts
|
|
6326
|
+
function isCID(str) {
|
|
6327
|
+
if (!str)
|
|
6328
|
+
return false;
|
|
6329
|
+
try {
|
|
6330
|
+
CID.parse(str);
|
|
6331
|
+
return true;
|
|
6332
|
+
} catch (e) {
|
|
6333
|
+
if (/^(bafy|Qm)/.test(str))
|
|
6334
|
+
return true;
|
|
6335
|
+
return false;
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6338
|
+
function normalizeIPFSUrl(url) {
|
|
6339
|
+
if (!url || typeof url !== "string")
|
|
6340
|
+
return null;
|
|
6341
|
+
url = url.replace(/"/g, "");
|
|
6342
|
+
if (isNormalizedIPFSURL(url))
|
|
6343
|
+
return url;
|
|
6344
|
+
if (isCID(url))
|
|
6345
|
+
return `ipfs://${url}`;
|
|
6346
|
+
if (!isIPFSUrl(url))
|
|
6347
|
+
return null;
|
|
6348
|
+
if (isGatewayIPFSUrl(url)) {
|
|
6349
|
+
const parsed = new URL(url.replace(/^\/\//, "http://"));
|
|
6350
|
+
parsed.pathname = parsed.pathname.replace(/^\/ipfs\//, "");
|
|
6351
|
+
const cid = parsed.toString().replace(`${parsed.protocol}//${parsed.host}/`, "");
|
|
6352
|
+
return `ipfs://${cid}`;
|
|
6353
|
+
}
|
|
6354
|
+
return null;
|
|
6355
|
+
}
|
|
6356
|
+
function isNormalizedIPFSURL(url) {
|
|
6357
|
+
return url && typeof url === "string" ? url.startsWith("ipfs://") : false;
|
|
6358
|
+
}
|
|
6359
|
+
function isGatewayIPFSUrl(url) {
|
|
6360
|
+
if (url && typeof url === "string") {
|
|
6361
|
+
try {
|
|
6362
|
+
const parsed = new URL(url.replace(/^"|'(.*)"|'$/, "$1"));
|
|
6363
|
+
return !isNormalizedIPFSURL(url) && parsed && parsed.pathname.startsWith("/ipfs/");
|
|
6364
|
+
} catch {
|
|
6365
|
+
return false;
|
|
6366
|
+
}
|
|
6367
|
+
}
|
|
6368
|
+
return false;
|
|
6369
|
+
}
|
|
6370
|
+
function isIPFSUrl(url) {
|
|
6371
|
+
return url ? isNormalizedIPFSURL(url) || isGatewayIPFSUrl(url) : false;
|
|
6372
|
+
}
|
|
6373
|
+
function isNormalizeableIPFSUrl(url) {
|
|
6374
|
+
return url ? isIPFSUrl(url) || isCID(url) : false;
|
|
6375
|
+
}
|
|
6376
|
+
|
|
6377
|
+
// src/ipfs/gateway.ts
|
|
6378
|
+
var IPFS_GATEWAY = "https://magic.decentralized-content.com";
|
|
6379
|
+
var ARWEAVE_GATEWAY = "https://arweave.net";
|
|
6380
|
+
function arweaveGatewayUrl(normalizedArweaveUrl) {
|
|
6381
|
+
if (!normalizedArweaveUrl || typeof normalizedArweaveUrl !== "string")
|
|
6382
|
+
return null;
|
|
6383
|
+
return normalizedArweaveUrl.replace("ar://", `${ARWEAVE_GATEWAY}/`);
|
|
6384
|
+
}
|
|
6385
|
+
function ipfsGatewayUrl(url) {
|
|
6386
|
+
if (!url || typeof url !== "string")
|
|
6387
|
+
return null;
|
|
6388
|
+
const normalizedIPFSUrl = normalizeIPFSUrl(url);
|
|
6389
|
+
if (normalizedIPFSUrl) {
|
|
6390
|
+
return normalizedIPFSUrl.replace("ipfs://", `${IPFS_GATEWAY}/ipfs/`);
|
|
6419
6391
|
}
|
|
6420
|
-
return
|
|
6421
|
-
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
}
|
|
6392
|
+
return null;
|
|
6393
|
+
}
|
|
6394
|
+
function getFetchableUrl(uri) {
|
|
6395
|
+
if (!uri || typeof uri !== "string")
|
|
6396
|
+
return null;
|
|
6397
|
+
if (uri.startsWith("http://"))
|
|
6398
|
+
return null;
|
|
6399
|
+
if (isNormalizeableIPFSUrl(uri)) {
|
|
6400
|
+
return ipfsGatewayUrl(uri);
|
|
6401
|
+
}
|
|
6402
|
+
if (isArweaveURL(uri)) {
|
|
6403
|
+
return arweaveGatewayUrl(uri);
|
|
6404
|
+
}
|
|
6405
|
+
if (/^(https|data|blob):/.test(uri)) {
|
|
6406
|
+
return uri;
|
|
6407
|
+
}
|
|
6408
|
+
return null;
|
|
6409
|
+
}
|
|
6410
|
+
|
|
6411
|
+
// src/ipfs/mimeTypes.ts
|
|
6412
|
+
var HTML = "text/html";
|
|
6413
|
+
var MARKDOWN = "text/markdown";
|
|
6414
|
+
var MARKDOWN_UTF8 = "text/markdown; charset=utf-8";
|
|
6415
|
+
var TEXT_PLAIN_UTF8 = "text/plain; charset=utf-8";
|
|
6416
|
+
var TEXT_PLAIN = "text/plain";
|
|
6417
|
+
var CSV = "text/csv";
|
|
6418
|
+
var NUMBERS = ".numbers";
|
|
6419
|
+
var EXCEL = ".xlsx";
|
|
6420
|
+
var PDF = "application/pdf";
|
|
6421
|
+
var JPG = "image/jpg";
|
|
6422
|
+
var JPEG = "image/jpeg";
|
|
6423
|
+
var PNG = "image/png";
|
|
6424
|
+
var WEBP = "image/webp";
|
|
6425
|
+
var SVG = "image/svg+xml";
|
|
6426
|
+
var TIFF = "image/tiff";
|
|
6427
|
+
var GIF = "image/gif";
|
|
6428
|
+
var isImage = (mimeType) => {
|
|
6429
|
+
if (!mimeType)
|
|
6430
|
+
return false;
|
|
6431
|
+
return [JPG, JPEG, PNG, WEBP, SVG, TIFF, GIF].includes(mimeType);
|
|
6430
6432
|
};
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6433
|
+
var DEFAULT_THUMBNAIL_CID_HASHES = {
|
|
6434
|
+
["AUDIO" /* AUDIO */]: "bafkreidir5laqi26ta6ivnpe2zpekgrfcyi4tb5x6vhwmwnledmzxshfb4",
|
|
6435
|
+
["VIDEO" /* VIDEO */]: "bafkreifm4edadl3j5luoyvw4p6elxeqd77la7bulee6vhq5gq4chfk32mu",
|
|
6436
|
+
["HTML" /* HTML */]: "bafkreifgvi6xfwqy2l6g45csyokejpaib52ee7zrw6etrxl2tas4xkkclq",
|
|
6437
|
+
["ZIP" /* ZIP */]: "bafkreihe5rr5jbkwzegisjlhxbb7jw22xw5oilfmgd2re6tz6buo4pasdq",
|
|
6438
|
+
// assuming all zip files are html directories
|
|
6439
|
+
["TEXT" /* TEXT */]: "bafkreiaez25nfgggzrnza2loxf6xueb2esm44pnyjyulwoslnipowrf56q",
|
|
6440
|
+
default: "bafkreihcoahllisbpb4eeypdwtm7go5uh275wxd7wf2tantpxlpjhviok4"
|
|
6441
|
+
};
|
|
6442
|
+
var MP4 = "video/mp4";
|
|
6443
|
+
var QUICKTIME = "video/quicktime";
|
|
6444
|
+
var M4V = "video/x-m4v";
|
|
6445
|
+
var WEBM = "video/webm";
|
|
6446
|
+
var M4A = "audio/x-m4a";
|
|
6447
|
+
var MPEG = "audio/mpeg";
|
|
6448
|
+
var MP3 = "audio/mp3";
|
|
6449
|
+
var WAV = "audio/wav";
|
|
6450
|
+
var VND_WAV = "audio/vnd.wav";
|
|
6451
|
+
var VND_WAVE = "audio/vnd.wave";
|
|
6452
|
+
var WAVE = "audio/wave";
|
|
6453
|
+
var X_WAV = "audio/x-wav";
|
|
6454
|
+
var AIFF = "audio/aiff";
|
|
6455
|
+
var GLTF = "model/gltf+json";
|
|
6456
|
+
var GLB = "model/gltf-binary";
|
|
6457
|
+
var GLTF_EXT = ".gltf";
|
|
6458
|
+
var GLB_EXT = ".glb";
|
|
6459
|
+
var JSON_MIME_TYPE = "application/json";
|
|
6460
|
+
var ZIP = "application/zip";
|
|
6461
|
+
var mimeToMediaType = {
|
|
6462
|
+
[HTML]: "HTML" /* HTML */,
|
|
6463
|
+
[JPG]: "IMAGE" /* IMAGE */,
|
|
6464
|
+
[JPEG]: "IMAGE" /* IMAGE */,
|
|
6465
|
+
[PNG]: "IMAGE" /* IMAGE */,
|
|
6466
|
+
[WEBP]: "IMAGE" /* IMAGE */,
|
|
6467
|
+
[SVG]: "IMAGE" /* IMAGE */,
|
|
6468
|
+
[TIFF]: "TIFF" /* TIFF */,
|
|
6469
|
+
[GIF]: "IMAGE" /* IMAGE */,
|
|
6470
|
+
[MP4]: "VIDEO" /* VIDEO */,
|
|
6471
|
+
[WEBM]: "VIDEO" /* VIDEO */,
|
|
6472
|
+
[QUICKTIME]: "VIDEO" /* VIDEO */,
|
|
6473
|
+
[M4V]: "VIDEO" /* VIDEO */,
|
|
6474
|
+
[MPEG]: "AUDIO" /* AUDIO */,
|
|
6475
|
+
[MP3]: "AUDIO" /* AUDIO */,
|
|
6476
|
+
[M4A]: "AUDIO" /* AUDIO */,
|
|
6477
|
+
[VND_WAV]: "AUDIO" /* AUDIO */,
|
|
6478
|
+
[VND_WAVE]: "AUDIO" /* AUDIO */,
|
|
6479
|
+
[WAV]: "AUDIO" /* AUDIO */,
|
|
6480
|
+
[WAVE]: "AUDIO" /* AUDIO */,
|
|
6481
|
+
[X_WAV]: "AUDIO" /* AUDIO */,
|
|
6482
|
+
[AIFF]: "AUDIO" /* AUDIO */,
|
|
6483
|
+
[TEXT_PLAIN]: "TEXT" /* TEXT */,
|
|
6484
|
+
[TEXT_PLAIN_UTF8]: "TEXT" /* TEXT */,
|
|
6485
|
+
[MARKDOWN]: "TEXT" /* TEXT */,
|
|
6486
|
+
[MARKDOWN_UTF8]: "TEXT" /* TEXT */,
|
|
6487
|
+
[CSV]: "CSV" /* CSV */,
|
|
6488
|
+
[NUMBERS]: "NUMBERS" /* NUMBERS */,
|
|
6489
|
+
[EXCEL]: "EXCEL" /* EXCEL */,
|
|
6490
|
+
[PDF]: "PDF" /* PDF */,
|
|
6491
|
+
[ZIP]: "ZIP" /* ZIP */,
|
|
6492
|
+
[GLTF]: "MODEL" /* MODEL */,
|
|
6493
|
+
[GLTF_EXT]: "MODEL" /* MODEL */,
|
|
6494
|
+
[GLB]: "MODEL" /* MODEL */,
|
|
6495
|
+
// GLTF returns 'application/json' as the mimetype,
|
|
6496
|
+
// and as the only JSON-encoded media we currently support,
|
|
6497
|
+
// we assume that if the mimetype is JSON, it's a GLTF
|
|
6498
|
+
[JSON_MIME_TYPE]: "MODEL" /* MODEL */,
|
|
6499
|
+
[GLB_EXT]: "MODEL" /* MODEL */
|
|
6500
|
+
};
|
|
6501
|
+
function mimeTypeToMedia(mimeType) {
|
|
6502
|
+
if (!mimeType)
|
|
6503
|
+
return "UNKNOWN" /* UNKNOWN */;
|
|
6504
|
+
return mimeToMediaType[mimeType] || "UNKNOWN" /* UNKNOWN */;
|
|
6450
6505
|
}
|
|
6451
|
-
function
|
|
6452
|
-
if (
|
|
6453
|
-
|
|
6454
|
-
const
|
|
6455
|
-
|
|
6456
|
-
|
|
6457
|
-
data: internalErrorData
|
|
6458
|
-
});
|
|
6506
|
+
async function getMimeType(uri) {
|
|
6507
|
+
if (!uri)
|
|
6508
|
+
return uri;
|
|
6509
|
+
const res = await fetch(uri, { method: "HEAD" });
|
|
6510
|
+
let mimeType = res.headers.get("content-type");
|
|
6511
|
+
return mimeType;
|
|
6459
6512
|
}
|
|
6460
6513
|
|
|
6461
|
-
// src/
|
|
6462
|
-
|
|
6463
|
-
const
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
}
|
|
6468
|
-
const
|
|
6469
|
-
|
|
6470
|
-
publicClient: clientConfig.publicClient
|
|
6471
|
-
});
|
|
6514
|
+
// src/ipfs/token-metadata.ts
|
|
6515
|
+
var makeTextTokenMetadata = (parameters) => {
|
|
6516
|
+
const { name, textFileUrl, thumbnailUrl, attributes = [] } = parameters;
|
|
6517
|
+
const content = textFileUrl ? {
|
|
6518
|
+
mime: TEXT_PLAIN,
|
|
6519
|
+
uri: textFileUrl
|
|
6520
|
+
} : null;
|
|
6521
|
+
const image = thumbnailUrl;
|
|
6522
|
+
const animation_url = textFileUrl;
|
|
6472
6523
|
return {
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6524
|
+
name,
|
|
6525
|
+
image,
|
|
6526
|
+
animation_url,
|
|
6527
|
+
content,
|
|
6528
|
+
attributes
|
|
6478
6529
|
};
|
|
6479
|
-
}
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6530
|
+
};
|
|
6531
|
+
var makeMediaTokenMetadata = async ({
|
|
6532
|
+
name,
|
|
6533
|
+
description,
|
|
6534
|
+
attributes = [],
|
|
6535
|
+
mediaUrl,
|
|
6536
|
+
thumbnailUrl
|
|
6537
|
+
}) => {
|
|
6538
|
+
const contentUrl = mediaUrl;
|
|
6539
|
+
const fetchableContentUrl = getFetchableUrl(contentUrl);
|
|
6540
|
+
if (!fetchableContentUrl)
|
|
6541
|
+
throw new Error(`Content url (${contentUrl}) is not fetchable`);
|
|
6542
|
+
const mimeType = await getMimeType(fetchableContentUrl);
|
|
6543
|
+
const mediaType = mimeTypeToMedia(mimeType);
|
|
6544
|
+
let image = void 0;
|
|
6545
|
+
let animation_url = null;
|
|
6546
|
+
if (isImage(mimeType)) {
|
|
6547
|
+
image = contentUrl;
|
|
6548
|
+
} else {
|
|
6549
|
+
image = thumbnailUrl;
|
|
6550
|
+
animation_url = mediaUrl;
|
|
6551
|
+
}
|
|
6552
|
+
if (!image)
|
|
6553
|
+
image = `ipfs://${DEFAULT_THUMBNAIL_CID_HASHES[mediaType] || DEFAULT_THUMBNAIL_CID_HASHES.default}`;
|
|
6554
|
+
const content = contentUrl ? {
|
|
6555
|
+
mime: mimeType || "application/octet-stream",
|
|
6556
|
+
uri: contentUrl
|
|
6557
|
+
} : null;
|
|
6488
6558
|
return {
|
|
6489
|
-
|
|
6490
|
-
|
|
6491
|
-
|
|
6492
|
-
|
|
6493
|
-
|
|
6494
|
-
|
|
6495
|
-
getTokensOfContract: (p) => mintClient.getOfContract(p),
|
|
6496
|
-
mint: (p) => mintClient.mint(p),
|
|
6497
|
-
getMintCosts: (p) => mintClient.getMintCosts(p)
|
|
6559
|
+
name,
|
|
6560
|
+
description,
|
|
6561
|
+
image,
|
|
6562
|
+
animation_url,
|
|
6563
|
+
content,
|
|
6564
|
+
attributes
|
|
6498
6565
|
};
|
|
6499
|
-
}
|
|
6566
|
+
};
|
|
6500
6567
|
|
|
6501
6568
|
// src/ipfs/text-metadata.ts
|
|
6502
6569
|
var CHAR_LIMIT = 1111;
|