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