@rareprotocol/rare-cli 1.0.0 → 1.0.1

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/dist/client.js CHANGED
@@ -50,13 +50,11 @@ var contractAddresses = {
50
50
  },
51
51
  base: {
52
52
  factory: getAddress("0xf776204233bfb52ba0ddff24810cbdbf3dbf94dd"),
53
- auction: getAddress("0x51c36ffb05e17ed80ee5c02fa83d7677c5613de2"),
54
- batchAuctionHouse: getAddress("0xf776204233bfb52ba0ddff24810cbdbf3dbf94dd")
53
+ auction: getAddress("0x51c36ffb05e17ed80ee5c02fa83d7677c5613de2")
55
54
  },
56
55
  "base-sepolia": {
57
56
  factory: getAddress("0x2b181ae0f1aea6fed75591b04991b1a3f9868d51"),
58
- auction: getAddress("0x1f0c946f0ee87acb268d50ede6c9b4d010af65d2"),
59
- batchAuctionHouse: getAddress("0x2b181ae0f1aea6fed75591b04991b1a3f9868d51")
57
+ auction: getAddress("0x1f0c946f0ee87acb268d50ede6c9b4d010af65d2")
60
58
  }
61
59
  };
62
60
  var canonicalV4Pools = {
@@ -3527,6 +3525,16 @@ var NftApprovalRequiredError = class extends Error {
3527
3525
  this.operator = params.operator;
3528
3526
  }
3529
3527
  };
3528
+ var MinterApprovalRequiredError = class extends Error {
3529
+ collection;
3530
+ minter;
3531
+ constructor(params) {
3532
+ super(`Minter approval is required for collection ${params.collection} and minter ${params.minter}.`);
3533
+ this.name = "MinterApprovalRequiredError";
3534
+ this.collection = params.collection;
3535
+ this.minter = params.minter;
3536
+ }
3537
+ };
3530
3538
  async function approveNftContractIfNeeded(opts) {
3531
3539
  const isApproved = await opts.publicClient.readContract({
3532
3540
  address: opts.nftAddress,
@@ -3627,17 +3635,14 @@ async function ensureTokenAllowance(publicClient, walletClient, account, owner,
3627
3635
  if (isAddressEqual4(token, ETH_ADDRESS) || amount === 0n) {
3628
3636
  return;
3629
3637
  }
3630
- try {
3631
- const allowance = await publicClient.readContract({
3632
- address: token,
3633
- abi: erc20Abi,
3634
- functionName: "allowance",
3635
- args: [owner, spender]
3636
- });
3637
- if (allowance >= amount) {
3638
- return;
3639
- }
3640
- } catch {
3638
+ const allowance = await publicClient.readContract({
3639
+ address: token,
3640
+ abi: erc20Abi,
3641
+ functionName: "allowance",
3642
+ args: [owner, spender]
3643
+ });
3644
+ if (allowance >= amount) {
3645
+ return;
3641
3646
  }
3642
3647
  const approveTx = await walletClient.writeContract({
3643
3648
  address: token,
@@ -3703,7 +3708,7 @@ async function preparePaymentAmountForSpender(opts) {
3703
3708
  };
3704
3709
  }
3705
3710
  const allowance = await readAllowance(publicClient, currency, accountAddress, spenderAddress);
3706
- if (allowance !== void 0 && allowance >= requiredAmount) {
3711
+ if (allowance >= requiredAmount) {
3707
3712
  return {
3708
3713
  value: 0n,
3709
3714
  requiredAmount
@@ -3751,16 +3756,12 @@ async function calculateMarketplacePaymentAmountFromSettings(publicClient, marke
3751
3756
  return amount + fee;
3752
3757
  }
3753
3758
  async function readAllowance(publicClient, currency, accountAddress, spenderAddress) {
3754
- try {
3755
- return await publicClient.readContract({
3756
- address: currency,
3757
- abi: erc20Abi,
3758
- functionName: "allowance",
3759
- args: [accountAddress, spenderAddress]
3760
- });
3761
- } catch {
3762
- return void 0;
3763
- }
3759
+ return publicClient.readContract({
3760
+ address: currency,
3761
+ abi: erc20Abi,
3762
+ functionName: "allowance",
3763
+ args: [accountAddress, spenderAddress]
3764
+ });
3764
3765
  }
3765
3766
 
3766
3767
  // src/sdk/validation-core.ts
@@ -8803,11 +8804,12 @@ function getWrappedEthAddress(chain) {
8803
8804
  }
8804
8805
  function getKnownCanonicalEthPoolKey(chain, token) {
8805
8806
  const normalizedToken = normalizeAddress(token);
8807
+ const pools = canonicalV4Pools[chain];
8806
8808
  if (normalizedToken === normalizeAddress(getRareAddress(chain))) {
8807
- return getCanonicalRareEthPoolKey(chain);
8809
+ return pools?.rareEthPool ? poolToKey(pools.rareEthPool) : null;
8808
8810
  }
8809
8811
  if (normalizedToken === normalizeAddress(getUsdcAddress(chain))) {
8810
- return getCanonicalUsdcEthPoolKey(chain);
8812
+ return pools?.usdcEthPool ? poolToKey(pools.usdcEthPool) : null;
8811
8813
  }
8812
8814
  return null;
8813
8815
  }
@@ -9438,9 +9440,11 @@ function getBaseUrl(options) {
9438
9440
  return options?.baseUrl ?? process.env.UNISWAP_TRADE_API_BASE_URL ?? DEFAULT_UNISWAP_TRADE_API_BASE_URL;
9439
9441
  }
9440
9442
  function requireApiKey(options) {
9441
- const apiKey = options?.apiKey ?? process.env.UNISWAP_API_KEY;
9443
+ const apiKey = options?.apiKey;
9442
9444
  if (!apiKey) {
9443
- throw new Error("UNISWAP_API_KEY is required to use the Uniswap fallback route.");
9445
+ throw new Error(
9446
+ "A Uniswap API key is required to use the Uniswap route. Run: rare configure --chain <chain> --uniswap-api-key <key> or rare configure --chain <chain> --uniswap-api-key-ref <op://...>."
9447
+ );
9444
9448
  }
9445
9449
  return apiKey;
9446
9450
  }
@@ -9788,12 +9792,14 @@ async function buildLocalTokenTradeQuote(publicClient, chain, addresses, params)
9788
9792
  }
9789
9793
  async function buildUniswapFallbackTradeQuote(publicClient, chainId, token, accountAddress, params) {
9790
9794
  assertRecipientSupportedForUniswapFallback(params.recipient, accountAddress);
9795
+ const apiKey = await resolveUniswapApiKey(params);
9791
9796
  const tokenIn = params.direction === "buy" ? ETH_ADDRESS : token;
9792
9797
  const tokenOut = params.direction === "buy" ? token : ETH_ADDRESS;
9793
9798
  const amountIn = params.direction === "buy" ? toWei(params.amountIn) : await toTokenAmount(publicClient, token, params.amountIn, "amountIn");
9794
9799
  const requestedMinAmountOut = params.direction === "buy" ? params.minAmountOut !== void 0 ? await toTokenAmount(publicClient, token, params.minAmountOut, "minAmountOut") : void 0 : params.minAmountOut !== void 0 ? toWei(params.minAmountOut) : void 0;
9795
9800
  const defaultSlippageBps = resolveSlippageBps(params.slippageBps);
9796
9801
  const initialQuoteResponse = await requestUniswapQuote({
9802
+ apiKey,
9797
9803
  chainId,
9798
9804
  tokenIn,
9799
9805
  tokenOut,
@@ -9809,13 +9815,15 @@ async function buildUniswapFallbackTradeQuote(publicClient, chainId, token, acco
9809
9815
  tokenIn,
9810
9816
  tokenOut,
9811
9817
  amountIn,
9812
- accountAddress
9818
+ accountAddress,
9819
+ uniswapApiKey: apiKey
9813
9820
  });
9814
9821
  return {
9815
9822
  kind: "uniswap",
9816
9823
  rawQuote: quoteResponse.quote,
9817
9824
  tokenIn,
9818
9825
  tokenOut,
9826
+ apiKey,
9819
9827
  quote: buildUniswapTradeQuote({
9820
9828
  amountIn,
9821
9829
  quote: quoteResponse.quote,
@@ -9828,11 +9836,18 @@ async function buildUniswapFallbackTradeQuote(publicClient, chainId, token, acco
9828
9836
  })
9829
9837
  };
9830
9838
  }
9839
+ async function resolveUniswapApiKey(params) {
9840
+ if (params.uniswapApiKey !== void 0) {
9841
+ return params.uniswapApiKey;
9842
+ }
9843
+ return params.resolveUniswapApiKey?.();
9844
+ }
9831
9845
  async function requoteForRequestedMinAmountOut(params) {
9832
9846
  const quotedAmounts = getQuotedRecipientAmount(params.initialQuoteResponse.quote, params.accountAddress);
9833
9847
  assertRequestedMinAmountOut(quotedAmounts.estimatedAmountOut, params.requestedMinAmountOut);
9834
9848
  const derivedSlippageBps = computeSlippageBpsFromAmounts(quotedAmounts.estimatedAmountOut, params.requestedMinAmountOut);
9835
9849
  const quoteResponse = await requestUniswapQuote({
9850
+ apiKey: params.uniswapApiKey,
9836
9851
  chainId: params.chainId,
9837
9852
  tokenIn: params.tokenIn,
9838
9853
  tokenOut: params.tokenOut,
@@ -10005,7 +10020,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10005
10020
  minAmountOut: localInputs.minAmountOut,
10006
10021
  slippageBps: localInputs.slippageBps,
10007
10022
  recipient: params.recipient,
10008
- route: params.route
10023
+ route: params.route,
10024
+ uniswapApiKey: config.uniswapApiKey,
10025
+ resolveUniswapApiKey: config.resolveUniswapApiKey
10009
10026
  }
10010
10027
  );
10011
10028
  return quote.quote;
@@ -10046,7 +10063,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10046
10063
  minAmountOut: localInputs.minAmountOut,
10047
10064
  slippageBps: localInputs.slippageBps,
10048
10065
  recipient: params.recipient,
10049
- route: params.route
10066
+ route: params.route,
10067
+ uniswapApiKey: config.uniswapApiKey,
10068
+ resolveUniswapApiKey: config.resolveUniswapApiKey
10050
10069
  });
10051
10070
  if (quoteDetails.kind === "local") {
10052
10071
  const router = requireConfiguredAddress(addresses.swapRouter, "Liquid router", chain);
@@ -10079,6 +10098,7 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10079
10098
  };
10080
10099
  }
10081
10100
  const swapResponse = await requestUniswapSwap({
10101
+ apiKey: quoteDetails.apiKey,
10082
10102
  quote: quoteDetails.rawQuote,
10083
10103
  deadline: uniswapDeadline
10084
10104
  });
@@ -10109,7 +10129,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10109
10129
  minAmountOut: localInputs.minAmountOut,
10110
10130
  slippageBps: localInputs.slippageBps,
10111
10131
  recipient: params.recipient,
10112
- route: params.route
10132
+ route: params.route,
10133
+ uniswapApiKey: config.uniswapApiKey,
10134
+ resolveUniswapApiKey: config.resolveUniswapApiKey
10113
10135
  }
10114
10136
  );
10115
10137
  return quote.quote;
@@ -10150,7 +10172,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10150
10172
  minAmountOut: localInputs.minAmountOut,
10151
10173
  slippageBps: localInputs.slippageBps,
10152
10174
  recipient: params.recipient,
10153
- route: params.route
10175
+ route: params.route,
10176
+ uniswapApiKey: config.uniswapApiKey,
10177
+ resolveUniswapApiKey: config.resolveUniswapApiKey
10154
10178
  });
10155
10179
  if (quoteDetails.kind === "local") {
10156
10180
  const router = requireConfiguredAddress(addresses.swapRouter, "Liquid router", chain);
@@ -10186,6 +10210,7 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10186
10210
  };
10187
10211
  }
10188
10212
  const approval = await requestUniswapApproval({
10213
+ apiKey: quoteDetails.apiKey,
10189
10214
  chainId,
10190
10215
  walletAddress: accountAddress,
10191
10216
  token: params.token,
@@ -10201,6 +10226,7 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10201
10226
  chainId
10202
10227
  })).txHash : void 0;
10203
10228
  const swapResponse = await requestUniswapSwap({
10229
+ apiKey: quoteDetails.apiKey,
10204
10230
  quote: quoteDetails.rawQuote,
10205
10231
  deadline: uniswapDeadline
10206
10232
  });
@@ -10250,10 +10276,153 @@ function createSwapNamespace(config, chain, chainId, addresses) {
10250
10276
  // src/sdk/release.ts
10251
10277
  import {
10252
10278
  erc20Abi as erc20Abi2,
10279
+ hexToBigInt as hexToBigInt2,
10253
10280
  isAddressEqual as isAddressEqual16,
10254
10281
  parseEventLogs as parseEventLogs6
10255
10282
  } from "viem";
10256
10283
 
10284
+ // src/contracts/abis/collection-owner.ts
10285
+ var collectionOwnerAbi = [
10286
+ {
10287
+ inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
10288
+ name: "tokenCreator",
10289
+ outputs: [{ internalType: "address payable", name: "", type: "address" }],
10290
+ stateMutability: "view",
10291
+ type: "function"
10292
+ },
10293
+ {
10294
+ inputs: [
10295
+ { internalType: "uint256", name: "_tokenId", type: "uint256" },
10296
+ { internalType: "uint256", name: "_salePrice", type: "uint256" }
10297
+ ],
10298
+ name: "royaltyInfo",
10299
+ outputs: [
10300
+ { internalType: "address", name: "receiver", type: "address" },
10301
+ { internalType: "uint256", name: "royaltyAmount", type: "uint256" }
10302
+ ],
10303
+ stateMutability: "view",
10304
+ type: "function"
10305
+ },
10306
+ {
10307
+ inputs: [],
10308
+ name: "getDefaultRoyaltyReceiver",
10309
+ outputs: [{ internalType: "address", name: "", type: "address" }],
10310
+ stateMutability: "view",
10311
+ type: "function"
10312
+ },
10313
+ {
10314
+ inputs: [],
10315
+ name: "getDefaultRoyaltyPercentage",
10316
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
10317
+ stateMutability: "view",
10318
+ type: "function"
10319
+ },
10320
+ {
10321
+ inputs: [{ internalType: "address", name: "_receiver", type: "address" }],
10322
+ name: "setDefaultRoyaltyReceiver",
10323
+ outputs: [],
10324
+ stateMutability: "nonpayable",
10325
+ type: "function"
10326
+ },
10327
+ {
10328
+ inputs: [{ internalType: "uint256", name: "_percentage", type: "uint256" }],
10329
+ name: "setDefaultRoyaltyPercentage",
10330
+ outputs: [],
10331
+ stateMutability: "nonpayable",
10332
+ type: "function"
10333
+ },
10334
+ {
10335
+ inputs: [
10336
+ { internalType: "address", name: "_receiver", type: "address" },
10337
+ { internalType: "uint256", name: "_tokenId", type: "uint256" }
10338
+ ],
10339
+ name: "setRoyaltyReceiverForToken",
10340
+ outputs: [],
10341
+ stateMutability: "nonpayable",
10342
+ type: "function"
10343
+ },
10344
+ {
10345
+ inputs: [],
10346
+ name: "getMintConfig",
10347
+ outputs: [
10348
+ {
10349
+ components: [
10350
+ { internalType: "uint256", name: "numberOfTokens", type: "uint256" },
10351
+ { internalType: "string", name: "baseURI", type: "string" },
10352
+ { internalType: "bool", name: "lockedMetadata", type: "bool" }
10353
+ ],
10354
+ internalType: "struct LazySovereignNFT.MintConfig",
10355
+ name: "mintConfig",
10356
+ type: "tuple"
10357
+ }
10358
+ ],
10359
+ stateMutability: "view",
10360
+ type: "function"
10361
+ },
10362
+ {
10363
+ inputs: [{ internalType: "address", name: "_address", type: "address" }],
10364
+ name: "isApprovedMinter",
10365
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
10366
+ stateMutability: "view",
10367
+ type: "function"
10368
+ },
10369
+ {
10370
+ inputs: [
10371
+ { internalType: "address", name: "_minter", type: "address" },
10372
+ { internalType: "bool", name: "_isMinter", type: "bool" }
10373
+ ],
10374
+ name: "setMinterApproval",
10375
+ outputs: [],
10376
+ stateMutability: "nonpayable",
10377
+ type: "function"
10378
+ },
10379
+ {
10380
+ inputs: [{ internalType: "string", name: "_baseURI", type: "string" }],
10381
+ name: "updateBaseURI",
10382
+ outputs: [],
10383
+ stateMutability: "nonpayable",
10384
+ type: "function"
10385
+ },
10386
+ {
10387
+ inputs: [
10388
+ { internalType: "uint256", name: "_tokenId", type: "uint256" },
10389
+ { internalType: "string", name: "_metadataUri", type: "string" }
10390
+ ],
10391
+ name: "updateTokenURI",
10392
+ outputs: [],
10393
+ stateMutability: "nonpayable",
10394
+ type: "function"
10395
+ },
10396
+ {
10397
+ inputs: [],
10398
+ name: "lockBaseURI",
10399
+ outputs: [],
10400
+ stateMutability: "nonpayable",
10401
+ type: "function"
10402
+ },
10403
+ {
10404
+ anonymous: false,
10405
+ inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
10406
+ name: "MetadataUpdated",
10407
+ type: "event"
10408
+ },
10409
+ {
10410
+ anonymous: false,
10411
+ inputs: [
10412
+ { indexed: true, internalType: "uint256", name: "tokenId", type: "uint256" },
10413
+ { indexed: false, internalType: "string", name: "metadataUri", type: "string" }
10414
+ ],
10415
+ name: "TokenURIUpdated",
10416
+ type: "event"
10417
+ },
10418
+ {
10419
+ anonymous: false,
10420
+ inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
10421
+ name: "MetadataLocked",
10422
+ type: "event"
10423
+ }
10424
+ ];
10425
+
10257
10426
  // src/contracts/abis/rare-minter.ts
10258
10427
  var rareMinterAbi = [
10259
10428
  {
@@ -10429,55 +10598,214 @@ var rareMinterAbi = [
10429
10598
  }
10430
10599
  ];
10431
10600
 
10432
- // src/sdk/release-core.ts
10433
- import {
10434
- getAddress as getAddress9,
10435
- isAddress as isAddress5,
10436
- isAddressEqual as isAddressEqual15,
10437
- isHex as isHex4,
10438
- keccak256 as keccak2562,
10439
- parseEther as parseEther2,
10440
- parseUnits as parseUnits7
10441
- } from "viem";
10442
- var ZERO_BYTES322 = "0x0000000000000000000000000000000000000000000000000000000000000000";
10443
- var RELEASE_ALLOWLIST_ARTIFACT_KIND = "rare-release-allowlist-v1";
10444
- var RELEASE_ALLOWLIST_LEAF_ENCODING = "keccak256(address)";
10445
- var RELEASE_ALLOWLIST_TREE = "sorted-addresses-sort-pairs";
10446
- var MAX_DIRECT_SALE_MINT_QUANTITY = 255n;
10447
- function requireRareMinterAddress(address) {
10448
- if (!address) {
10449
- throw new Error("RareMinter is not configured for this chain. Supported RareMinter chains: mainnet, sepolia.");
10450
- }
10451
- return address;
10601
+ // src/sdk/collection-core.ts
10602
+ var defaultRoyaltyInfoSalePrice = 10000n;
10603
+ function planCreateLazySovereignCollection(params) {
10604
+ const contractType = params.contractType ?? "lazy";
10605
+ return {
10606
+ name: params.name,
10607
+ symbol: params.symbol,
10608
+ maxTokens: toPositiveInteger(params.maxTokens, "maxTokens"),
10609
+ contractType,
10610
+ contractTypeReadName: lazyContractTypeReadName(contractType)
10611
+ };
10452
10612
  }
10453
- function assertReleaseContractOwner(opts) {
10454
- const { contract, accountAddress, owner } = opts;
10455
- if (!isAddressEqual15(owner, accountAddress)) {
10456
- throw new Error(
10457
- `Connected wallet ${accountAddress} is not the owner of collection ${contract}. Contract owner is ${owner}.`
10458
- );
10459
- }
10613
+ function buildCreateLazySovereignCollectionWrite(plan, contractType) {
10614
+ return {
10615
+ functionName: "createSovereignNFTContract",
10616
+ args: [plan.name, plan.symbol, plan.maxTokens, contractType]
10617
+ };
10460
10618
  }
10461
- function normalizeReleaseTimestamp(value, field, opts = {}) {
10462
- const timestamp = value === void 0 ? requiredDefaultTimestamp(field, opts.defaultValue) : normalizeDefinedReleaseTimestamp(value, field);
10463
- if (timestamp < 0n) {
10464
- throw new Error(`${field} must be greater than or equal to 0.`);
10465
- }
10466
- return timestamp;
10619
+ function planCollectionMintBatch(params) {
10620
+ const amount = requireInput(params.amount, "amount");
10621
+ return {
10622
+ contract: params.contract,
10623
+ baseUri: params.baseUri,
10624
+ tokenCount: toPositiveInteger(amount, "amount")
10625
+ };
10467
10626
  }
10468
- function requiredDefaultTimestamp(field, defaultValue) {
10469
- if (defaultValue === void 0) {
10470
- throw new Error(`${field} is required.`);
10627
+ function planCollectionPrepareLazyMint(params) {
10628
+ const amount = requireInput(params.amount, "amount");
10629
+ const basePlan = {
10630
+ contract: params.contract,
10631
+ baseUri: params.baseUri,
10632
+ tokenCount: toPositiveInteger(amount, "amount")
10633
+ };
10634
+ if (params.minter === void 0) {
10635
+ return basePlan;
10471
10636
  }
10472
- return defaultValue;
10637
+ return {
10638
+ ...basePlan,
10639
+ minter: params.minter
10640
+ };
10473
10641
  }
10474
- function normalizeDefinedReleaseTimestamp(value, field) {
10475
- if (value instanceof Date) {
10476
- const milliseconds = value.getTime();
10477
- if (!Number.isFinite(milliseconds)) {
10478
- throw new Error(`${field} must be a valid date.`);
10479
- }
10480
- return BigInt(Math.floor(milliseconds / 1e3));
10642
+ function buildCollectionMintBatchWrite(plan) {
10643
+ return {
10644
+ functionName: "batchMint",
10645
+ args: [plan.baseUri, plan.tokenCount]
10646
+ };
10647
+ }
10648
+ function buildCollectionPrepareLazyMintWrite(plan) {
10649
+ if (plan.minter === void 0) {
10650
+ return {
10651
+ functionName: "prepareMint",
10652
+ args: [plan.baseUri, plan.tokenCount]
10653
+ };
10654
+ }
10655
+ return {
10656
+ functionName: "prepareMintWithMinter",
10657
+ args: [plan.baseUri, plan.tokenCount, plan.minter]
10658
+ };
10659
+ }
10660
+ function planCollectionMinterApproval(params) {
10661
+ return {
10662
+ contract: params.contract,
10663
+ minter: params.minter,
10664
+ approved: params.approved ?? true
10665
+ };
10666
+ }
10667
+ function buildCollectionMinterApprovalWrite(plan) {
10668
+ return {
10669
+ functionName: "setMinterApproval",
10670
+ args: [plan.minter, plan.approved]
10671
+ };
10672
+ }
10673
+ function shapeCollectionPrepareMintEvent(args) {
10674
+ if ("numberOfTokens" in args) {
10675
+ return {
10676
+ baseUri: args.baseURI,
10677
+ tokenCount: args.numberOfTokens
10678
+ };
10679
+ }
10680
+ if (args.endTokenId < args.startTokenId) {
10681
+ throw new Error("PrepareMint endTokenId must be greater than or equal to startTokenId.");
10682
+ }
10683
+ return {
10684
+ baseUri: args.baseURI,
10685
+ tokenCount: args.endTokenId - args.startTokenId + 1n,
10686
+ fromTokenId: args.startTokenId,
10687
+ toTokenId: args.endTokenId
10688
+ };
10689
+ }
10690
+ function planCollectionToken(params) {
10691
+ return {
10692
+ contract: params.contract,
10693
+ tokenId: toNonNegativeInteger(params.tokenId, "tokenId")
10694
+ };
10695
+ }
10696
+ function planCollectionRoyaltyInfo(params) {
10697
+ return {
10698
+ ...planCollectionToken(params),
10699
+ salePrice: params.price === void 0 ? defaultRoyaltyInfoSalePrice : toNonNegativeInteger(params.price, "price")
10700
+ };
10701
+ }
10702
+ function planCollectionReceiver(params) {
10703
+ return {
10704
+ contract: params.contract,
10705
+ receiver: params.receiver
10706
+ };
10707
+ }
10708
+ function planCollectionTokenReceiver(params) {
10709
+ return {
10710
+ ...planCollectionToken(params),
10711
+ receiver: params.receiver
10712
+ };
10713
+ }
10714
+ function planCollectionRoyaltyPercentage(params) {
10715
+ return {
10716
+ contract: params.contract,
10717
+ percentage: toRoyaltyPercentage(params.percentage)
10718
+ };
10719
+ }
10720
+ function buildCollectionRoyaltyPercentageWrite(plan) {
10721
+ return {
10722
+ functionName: "setDefaultRoyaltyPercentage",
10723
+ args: [BigInt(plan.percentage)]
10724
+ };
10725
+ }
10726
+ function planCollectionBaseUri(params) {
10727
+ return {
10728
+ contract: params.contract,
10729
+ baseUri: params.baseUri
10730
+ };
10731
+ }
10732
+ function planCollectionTokenUri(params) {
10733
+ return {
10734
+ ...planCollectionToken(params),
10735
+ tokenUri: params.tokenUri
10736
+ };
10737
+ }
10738
+ function planCollectionContract(params) {
10739
+ return {
10740
+ contract: params.contract
10741
+ };
10742
+ }
10743
+ function lazyContractTypeReadName(contractType) {
10744
+ if (contractType === "lazy-royalty-guard") {
10745
+ return "LAZY_ROYALTY_GUARD";
10746
+ }
10747
+ if (contractType === "lazy-deadman-royalty-guard") {
10748
+ return "LAZY_ROYALTY_GUARD_DEADMAN";
10749
+ }
10750
+ return "LAZY_SOVEREIGN_NFT";
10751
+ }
10752
+ function toRoyaltyPercentage(value) {
10753
+ const percentage = toSafeIntegerNumber(value, "percentage");
10754
+ if (percentage < 0 || percentage > 100) {
10755
+ throw new Error("percentage must be between 0 and 100.");
10756
+ }
10757
+ return percentage;
10758
+ }
10759
+
10760
+ // src/sdk/release-core.ts
10761
+ import {
10762
+ getAddress as getAddress9,
10763
+ isAddress as isAddress5,
10764
+ isAddressEqual as isAddressEqual15,
10765
+ isHex as isHex4,
10766
+ keccak256 as keccak2562,
10767
+ parseEther as parseEther2,
10768
+ parseUnits as parseUnits7
10769
+ } from "viem";
10770
+ var ZERO_BYTES322 = "0x0000000000000000000000000000000000000000000000000000000000000000";
10771
+ var RELEASE_ALLOWLIST_ARTIFACT_KIND = "rare-release-allowlist-v1";
10772
+ var RELEASE_ALLOWLIST_LEAF_ENCODING = "keccak256(address)";
10773
+ var RELEASE_ALLOWLIST_TREE = "sorted-addresses-sort-pairs";
10774
+ var MAX_DIRECT_SALE_MINT_QUANTITY = 255n;
10775
+ function requireRareMinterAddress(address) {
10776
+ if (!address) {
10777
+ throw new Error("RareMinter is not configured for this chain. Supported RareMinter chains: mainnet, sepolia.");
10778
+ }
10779
+ return address;
10780
+ }
10781
+ function assertReleaseContractOwner(opts) {
10782
+ const { contract, accountAddress, owner } = opts;
10783
+ if (!isAddressEqual15(owner, accountAddress)) {
10784
+ throw new Error(
10785
+ `Connected wallet ${accountAddress} is not the owner of collection ${contract}. Contract owner is ${owner}.`
10786
+ );
10787
+ }
10788
+ }
10789
+ function normalizeReleaseTimestamp(value, field, opts = {}) {
10790
+ const timestamp = value === void 0 ? requiredDefaultTimestamp(field, opts.defaultValue) : normalizeDefinedReleaseTimestamp(value, field);
10791
+ if (timestamp < 0n) {
10792
+ throw new Error(`${field} must be greater than or equal to 0.`);
10793
+ }
10794
+ return timestamp;
10795
+ }
10796
+ function requiredDefaultTimestamp(field, defaultValue) {
10797
+ if (defaultValue === void 0) {
10798
+ throw new Error(`${field} is required.`);
10799
+ }
10800
+ return defaultValue;
10801
+ }
10802
+ function normalizeDefinedReleaseTimestamp(value, field) {
10803
+ if (value instanceof Date) {
10804
+ const milliseconds = value.getTime();
10805
+ if (!Number.isFinite(milliseconds)) {
10806
+ throw new Error(`${field} must be a valid date.`);
10807
+ }
10808
+ return BigInt(Math.floor(milliseconds / 1e3));
10481
10809
  }
10482
10810
  if (typeof value === "string") {
10483
10811
  const trimmed = value.trim();
@@ -11114,11 +11442,65 @@ async function assertConfigurableReleaseContract(opts) {
11114
11442
  });
11115
11443
  } catch (error) {
11116
11444
  throw new Error(
11117
- `Collection ${contract} must expose mintTo(address) callable by RareMinter ${rareMinter}. Simulation failed: ${errorMessage2(error)}`,
11445
+ `Collection ${contract} must expose mintTo(address) callable by RareMinter ${rareMinter}. For LazySovereignNFT collections, approve RareMinter as a minter or prepare lazy mint metadata with RareMinter as the minter. Simulation failed: ${errorMessage2(error)}`,
11118
11446
  { cause: error }
11119
11447
  );
11120
11448
  }
11121
11449
  }
11450
+ async function readReleaseMinterApproval(opts) {
11451
+ try {
11452
+ return await opts.publicClient.readContract({
11453
+ address: opts.contract,
11454
+ abi: collectionOwnerAbi,
11455
+ functionName: "isApprovedMinter",
11456
+ args: [opts.minter]
11457
+ });
11458
+ } catch {
11459
+ return null;
11460
+ }
11461
+ }
11462
+ async function approveReleaseMinterIfNeeded(opts) {
11463
+ const approved = await readReleaseMinterApproval({
11464
+ publicClient: opts.publicClient,
11465
+ contract: opts.contract,
11466
+ minter: opts.minter
11467
+ });
11468
+ if (approved !== false) {
11469
+ return void 0;
11470
+ }
11471
+ if (opts.autoApprove === false) {
11472
+ throw new MinterApprovalRequiredError({
11473
+ collection: opts.contract,
11474
+ minter: opts.minter
11475
+ });
11476
+ }
11477
+ const plan = planCollectionMinterApproval({
11478
+ contract: opts.contract,
11479
+ minter: opts.minter,
11480
+ approved: true
11481
+ });
11482
+ const write = buildCollectionMinterApprovalWrite(plan);
11483
+ const approvalTxHash = await opts.walletClient.writeContract({
11484
+ address: plan.contract,
11485
+ abi: collectionOwnerAbi,
11486
+ functionName: write.functionName,
11487
+ args: write.args,
11488
+ account: opts.account,
11489
+ chain: void 0
11490
+ });
11491
+ await opts.publicClient.waitForTransactionReceipt({ hash: approvalTxHash });
11492
+ const confirmed = await readReleaseMinterApproval({
11493
+ publicClient: opts.publicClient,
11494
+ contract: opts.contract,
11495
+ minter: opts.minter
11496
+ });
11497
+ if (confirmed !== true) {
11498
+ throw new Error(
11499
+ `Lazy Sovereign minter approval verification failed for ${opts.minter}. The approval tx was mined but the collection still does not report RareMinter as approved.`
11500
+ );
11501
+ }
11502
+ return approvalTxHash;
11503
+ }
11122
11504
  async function optionalRead(read) {
11123
11505
  try {
11124
11506
  return await read();
@@ -11264,13 +11646,13 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
11264
11646
  async setConfig(params) {
11265
11647
  const rareMinter = requireRareMinterAddress(addresses.rareMinter);
11266
11648
  const { walletClient, account, accountAddress } = requireWallet(config);
11267
- const resolvedParams = await resolveReleaseAllowlistConfigParams(config, params);
11268
- const plan = planReleaseAllowlistConfig(resolvedParams);
11649
+ const plan = planReleaseAllowlistConfig(params);
11269
11650
  await assertCollectionOwnerForReleaseWrite({
11270
11651
  publicClient,
11271
11652
  contract: plan.contract,
11272
11653
  accountAddress
11273
11654
  });
11655
+ await uploadReleaseAllowlistArtifact(config, params, plan.root);
11274
11656
  const txHash = await walletClient.writeContract({
11275
11657
  address: rareMinter,
11276
11658
  abi: rareMinterAbi,
@@ -11415,6 +11797,14 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
11415
11797
  currencyDecimals: currencyDecimals2,
11416
11798
  nowSeconds: currentUnixTimestamp3()
11417
11799
  });
11800
+ const approvalTxHash = await approveReleaseMinterIfNeeded({
11801
+ publicClient,
11802
+ walletClient,
11803
+ account,
11804
+ contract: plan.contract,
11805
+ minter: rareMinter,
11806
+ autoApprove: params.autoApprove
11807
+ });
11418
11808
  await assertConfigurableReleaseContract({
11419
11809
  publicClient,
11420
11810
  contract: plan.contract,
@@ -11448,7 +11838,8 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
11448
11838
  startTime: plan.startTime,
11449
11839
  maxMints: plan.maxMints,
11450
11840
  splitRecipients: plan.splitRecipients,
11451
- splitRatios: plan.splitRatios
11841
+ splitRatios: plan.splitRatios,
11842
+ approvalTxHash
11452
11843
  };
11453
11844
  },
11454
11845
  async mint(params) {
@@ -11537,19 +11928,17 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
11537
11928
  function currentUnixTimestamp3() {
11538
11929
  return BigInt(Math.floor(Date.now() / 1e3));
11539
11930
  }
11540
- async function resolveReleaseAllowlistConfigParams(config, params) {
11931
+ async function uploadReleaseAllowlistArtifact(config, params, expectedRoot) {
11541
11932
  if (params.root !== void 0 || params.artifact === void 0) {
11542
- return params;
11933
+ return;
11543
11934
  }
11544
11935
  const root = await generateApiAddressMerkleRoot(config, {
11545
11936
  addresses: params.artifact.wallets.map((wallet) => wallet.address),
11546
11937
  storageTarget: "collection-allowlist"
11547
11938
  });
11548
- return {
11549
- ...params,
11550
- root,
11551
- artifact: void 0
11552
- };
11939
+ if (hexToBigInt2(root) !== hexToBigInt2(expectedRoot)) {
11940
+ throw new Error(`rare-api allowlist root ${root} does not match artifact root ${expectedRoot}.`);
11941
+ }
11553
11942
  }
11554
11943
 
11555
11944
  // src/sdk/collection.ts
@@ -11680,282 +12069,165 @@ var collectionMintAbi = [
11680
12069
  }
11681
12070
  ];
11682
12071
 
11683
- // src/contracts/abis/collection-owner.ts
11684
- var collectionOwnerAbi = [
12072
+ // src/contracts/abis/collection-status.ts
12073
+ var collectionStatusAbi = [
11685
12074
  {
11686
- inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
11687
- name: "tokenCreator",
11688
- outputs: [{ internalType: "address payable", name: "", type: "address" }],
12075
+ inputs: [],
12076
+ name: "name",
12077
+ outputs: [{ internalType: "string", name: "", type: "string" }],
11689
12078
  stateMutability: "view",
11690
12079
  type: "function"
11691
12080
  },
11692
12081
  {
11693
- inputs: [
11694
- { internalType: "uint256", name: "_tokenId", type: "uint256" },
11695
- { internalType: "uint256", name: "_salePrice", type: "uint256" }
11696
- ],
11697
- name: "royaltyInfo",
11698
- outputs: [
11699
- { internalType: "address", name: "receiver", type: "address" },
11700
- { internalType: "uint256", name: "royaltyAmount", type: "uint256" }
11701
- ],
12082
+ inputs: [],
12083
+ name: "symbol",
12084
+ outputs: [{ internalType: "string", name: "", type: "string" }],
11702
12085
  stateMutability: "view",
11703
12086
  type: "function"
11704
12087
  },
11705
12088
  {
11706
12089
  inputs: [],
11707
- name: "getDefaultRoyaltyReceiver",
12090
+ name: "owner",
11708
12091
  outputs: [{ internalType: "address", name: "", type: "address" }],
11709
12092
  stateMutability: "view",
11710
12093
  type: "function"
11711
12094
  },
11712
12095
  {
11713
12096
  inputs: [],
11714
- name: "getDefaultRoyaltyPercentage",
12097
+ name: "totalSupply",
11715
12098
  outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
11716
12099
  stateMutability: "view",
11717
12100
  type: "function"
11718
12101
  },
11719
12102
  {
11720
- inputs: [{ internalType: "address", name: "_receiver", type: "address" }],
11721
- name: "setDefaultRoyaltyReceiver",
11722
- outputs: [],
11723
- stateMutability: "nonpayable",
12103
+ inputs: [],
12104
+ name: "maxTokens",
12105
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
12106
+ stateMutability: "view",
11724
12107
  type: "function"
11725
12108
  },
11726
12109
  {
11727
- inputs: [{ internalType: "uint256", name: "_percentage", type: "uint256" }],
11728
- name: "setDefaultRoyaltyPercentage",
11729
- outputs: [],
11730
- stateMutability: "nonpayable",
12110
+ inputs: [],
12111
+ name: "disabled",
12112
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
12113
+ stateMutability: "view",
11731
12114
  type: "function"
11732
12115
  },
11733
12116
  {
11734
- inputs: [
11735
- { internalType: "address", name: "_receiver", type: "address" },
11736
- { internalType: "uint256", name: "_tokenId", type: "uint256" }
11737
- ],
11738
- name: "setRoyaltyReceiverForToken",
11739
- outputs: [],
11740
- stateMutability: "nonpayable",
12117
+ inputs: [],
12118
+ name: "areTokenURIsLocked",
12119
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
12120
+ stateMutability: "view",
11741
12121
  type: "function"
11742
12122
  },
11743
12123
  {
11744
12124
  inputs: [],
11745
- name: "getMintConfig",
11746
- outputs: [
11747
- {
11748
- components: [
11749
- { internalType: "uint256", name: "numberOfTokens", type: "uint256" },
11750
- { internalType: "string", name: "baseURI", type: "string" },
11751
- { internalType: "bool", name: "lockedMetadata", type: "bool" }
11752
- ],
11753
- internalType: "struct LazySovereignNFT.MintConfig",
11754
- name: "mintConfig",
11755
- type: "tuple"
11756
- }
11757
- ],
12125
+ name: "getBatchCount",
12126
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
11758
12127
  stateMutability: "view",
11759
12128
  type: "function"
11760
12129
  },
11761
12130
  {
11762
- inputs: [{ internalType: "string", name: "_baseURI", type: "string" }],
11763
- name: "updateBaseURI",
11764
- outputs: [],
11765
- stateMutability: "nonpayable",
12131
+ inputs: [{ internalType: "uint256", name: "tokenId", type: "uint256" }],
12132
+ name: "ownerOf",
12133
+ outputs: [{ internalType: "address", name: "", type: "address" }],
12134
+ stateMutability: "view",
11766
12135
  type: "function"
11767
12136
  },
11768
12137
  {
11769
- inputs: [
11770
- { internalType: "uint256", name: "_tokenId", type: "uint256" },
11771
- { internalType: "string", name: "_metadataUri", type: "string" }
11772
- ],
11773
- name: "updateTokenURI",
11774
- outputs: [],
11775
- stateMutability: "nonpayable",
12138
+ inputs: [{ internalType: "uint256", name: "tokenId", type: "uint256" }],
12139
+ name: "tokenURI",
12140
+ outputs: [{ internalType: "string", name: "", type: "string" }],
12141
+ stateMutability: "view",
11776
12142
  type: "function"
11777
12143
  },
11778
12144
  {
11779
- inputs: [],
11780
- name: "lockBaseURI",
11781
- outputs: [],
11782
- stateMutability: "nonpayable",
12145
+ inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
12146
+ name: "supportsInterface",
12147
+ outputs: [{ internalType: "bool", name: "", type: "bool" }],
12148
+ stateMutability: "view",
11783
12149
  type: "function"
11784
- },
11785
- {
11786
- anonymous: false,
11787
- inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
11788
- name: "MetadataUpdated",
11789
- type: "event"
11790
- },
11791
- {
11792
- anonymous: false,
11793
- inputs: [
11794
- { indexed: true, internalType: "uint256", name: "tokenId", type: "uint256" },
11795
- { indexed: false, internalType: "string", name: "metadataUri", type: "string" }
11796
- ],
11797
- name: "TokenURIUpdated",
11798
- type: "event"
11799
- },
11800
- {
11801
- anonymous: false,
11802
- inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
11803
- name: "MetadataLocked",
11804
- type: "event"
11805
12150
  }
11806
12151
  ];
11807
12152
 
11808
- // src/sdk/collection-core.ts
11809
- var defaultRoyaltyInfoSalePrice = 10000n;
11810
- function planCreateLazySovereignCollection(params) {
11811
- const contractType = params.contractType ?? "lazy";
11812
- return {
11813
- name: params.name,
11814
- symbol: params.symbol,
11815
- maxTokens: toPositiveInteger(params.maxTokens, "maxTokens"),
11816
- contractType,
11817
- contractTypeReadName: lazyContractTypeReadName(contractType)
11818
- };
11819
- }
11820
- function buildCreateLazySovereignCollectionWrite(plan, contractType) {
11821
- return {
11822
- functionName: "createSovereignNFTContract",
11823
- args: [plan.name, plan.symbol, plan.maxTokens, contractType]
11824
- };
11825
- }
11826
- function planCollectionMintBatch(params) {
11827
- const amount = requireInput(params.amount, "amount");
11828
- return {
11829
- contract: params.contract,
11830
- baseUri: params.baseUri,
11831
- tokenCount: toPositiveInteger(amount, "amount")
11832
- };
11833
- }
11834
- function planCollectionPrepareLazyMint(params) {
11835
- const amount = requireInput(params.amount, "amount");
11836
- const basePlan = {
11837
- contract: params.contract,
11838
- baseUri: params.baseUri,
11839
- tokenCount: toPositiveInteger(amount, "amount")
11840
- };
11841
- if (params.minter === void 0) {
11842
- return basePlan;
11843
- }
11844
- return {
11845
- ...basePlan,
11846
- minter: params.minter
11847
- };
11848
- }
11849
- function buildCollectionMintBatchWrite(plan) {
11850
- return {
11851
- functionName: "batchMint",
11852
- args: [plan.baseUri, plan.tokenCount]
11853
- };
11854
- }
11855
- function buildCollectionPrepareLazyMintWrite(plan) {
11856
- if (plan.minter === void 0) {
11857
- return {
11858
- functionName: "prepareMint",
11859
- args: [plan.baseUri, plan.tokenCount]
11860
- };
11861
- }
11862
- return {
11863
- functionName: "prepareMintWithMinter",
11864
- args: [plan.baseUri, plan.tokenCount, plan.minter]
11865
- };
11866
- }
11867
- function shapeCollectionPrepareMintEvent(args) {
11868
- if ("numberOfTokens" in args) {
11869
- return {
11870
- baseUri: args.baseURI,
11871
- tokenCount: args.numberOfTokens
11872
- };
11873
- }
11874
- if (args.endTokenId < args.startTokenId) {
11875
- throw new Error("PrepareMint endTokenId must be greater than or equal to startTokenId.");
11876
- }
11877
- return {
11878
- baseUri: args.baseURI,
11879
- tokenCount: args.endTokenId - args.startTokenId + 1n,
11880
- fromTokenId: args.startTokenId,
11881
- toTokenId: args.endTokenId
11882
- };
11883
- }
11884
- function planCollectionToken(params) {
11885
- return {
11886
- contract: params.contract,
11887
- tokenId: toNonNegativeInteger(params.tokenId, "tokenId")
11888
- };
11889
- }
11890
- function planCollectionRoyaltyInfo(params) {
11891
- return {
11892
- ...planCollectionToken(params),
11893
- salePrice: params.price === void 0 ? defaultRoyaltyInfoSalePrice : toNonNegativeInteger(params.price, "price")
11894
- };
11895
- }
11896
- function planCollectionReceiver(params) {
11897
- return {
11898
- contract: params.contract,
11899
- receiver: params.receiver
11900
- };
11901
- }
11902
- function planCollectionTokenReceiver(params) {
11903
- return {
11904
- ...planCollectionToken(params),
11905
- receiver: params.receiver
11906
- };
11907
- }
11908
- function planCollectionRoyaltyPercentage(params) {
11909
- return {
11910
- contract: params.contract,
11911
- percentage: toRoyaltyPercentage(params.percentage)
11912
- };
11913
- }
11914
- function buildCollectionRoyaltyPercentageWrite(plan) {
11915
- return {
11916
- functionName: "setDefaultRoyaltyPercentage",
11917
- args: [BigInt(plan.percentage)]
11918
- };
11919
- }
11920
- function planCollectionBaseUri(params) {
11921
- return {
11922
- contract: params.contract,
11923
- baseUri: params.baseUri
11924
- };
11925
- }
11926
- function planCollectionTokenUri(params) {
11927
- return {
11928
- ...planCollectionToken(params),
11929
- tokenUri: params.tokenUri
11930
- };
11931
- }
11932
- function planCollectionContract(params) {
11933
- return {
11934
- contract: params.contract
11935
- };
11936
- }
11937
- function lazyContractTypeReadName(contractType) {
11938
- if (contractType === "lazy-royalty-guard") {
11939
- return "LAZY_ROYALTY_GUARD";
11940
- }
11941
- if (contractType === "lazy-deadman-royalty-guard") {
11942
- return "LAZY_ROYALTY_GUARD_DEADMAN";
11943
- }
11944
- return "LAZY_SOVEREIGN_NFT";
11945
- }
11946
- function toRoyaltyPercentage(value) {
11947
- const percentage = toSafeIntegerNumber(value, "percentage");
11948
- if (percentage < 0 || percentage > 100) {
11949
- throw new Error("percentage must be between 0 and 100.");
11950
- }
11951
- return percentage;
11952
- }
11953
-
11954
12153
  // src/sdk/collection.ts
11955
12154
  function createCollectionNamespace(publicClient, config, chain, baseCollection, collectionDeploy, collectionMint) {
11956
12155
  return {
11957
12156
  ...baseCollection,
11958
12157
  mint: collectionMint,
12158
+ async status(params) {
12159
+ const plan = planCollectionContract(params);
12160
+ const tokenPlan = params.tokenId === void 0 ? void 0 : planCollectionToken({ contract: plan.contract, tokenId: params.tokenId });
12161
+ const royaltyPlan = params.tokenId === void 0 ? void 0 : planCollectionRoyaltyInfo({ contract: plan.contract, tokenId: params.tokenId, price: params.price });
12162
+ const [
12163
+ name,
12164
+ symbol,
12165
+ owner,
12166
+ totalSupply,
12167
+ maxTokens,
12168
+ disabled,
12169
+ tokenUrisLocked,
12170
+ batchCount,
12171
+ defaultRoyalty,
12172
+ mintConfig,
12173
+ interfaces,
12174
+ tokenOwner,
12175
+ tokenUri,
12176
+ tokenCreator,
12177
+ tokenRoyalty
12178
+ ] = await Promise.all([
12179
+ readOptionalStatusString(publicClient, plan.contract, "name"),
12180
+ readOptionalStatusString(publicClient, plan.contract, "symbol"),
12181
+ readOptionalStatusAddress(publicClient, plan.contract, "owner"),
12182
+ readOptionalStatusBigint(publicClient, plan.contract, "totalSupply"),
12183
+ readOptionalStatusBigint(publicClient, plan.contract, "maxTokens"),
12184
+ readOptionalStatusBoolean(publicClient, plan.contract, "disabled"),
12185
+ readOptionalStatusBoolean(publicClient, plan.contract, "areTokenURIsLocked"),
12186
+ readOptionalStatusBigint(publicClient, plan.contract, "getBatchCount"),
12187
+ readBestEffortDefaultRoyalty(publicClient, plan.contract),
12188
+ readOptionalMintConfig(publicClient, plan.contract),
12189
+ readSupportedInterfaces(publicClient, plan.contract),
12190
+ tokenPlan === void 0 ? Promise.resolve(void 0) : readOptionalTokenOwner(publicClient, plan.contract, tokenPlan.tokenId),
12191
+ tokenPlan === void 0 ? Promise.resolve(void 0) : readOptionalTokenUri(publicClient, plan.contract, tokenPlan.tokenId),
12192
+ tokenPlan === void 0 ? Promise.resolve(void 0) : readOptionalTokenCreator(publicClient, plan.contract, tokenPlan.tokenId),
12193
+ royaltyPlan === void 0 ? Promise.resolve(void 0) : readOptionalRoyaltyInfo(publicClient, plan.contract, royaltyPlan.tokenId, royaltyPlan.salePrice)
12194
+ ]);
12195
+ return {
12196
+ contract: plan.contract,
12197
+ ...name === void 0 ? {} : { name },
12198
+ ...symbol === void 0 ? {} : { symbol },
12199
+ ...owner === void 0 ? {} : { owner },
12200
+ ...totalSupply === void 0 ? {} : { totalSupply },
12201
+ ...maxTokens === void 0 ? {} : { maxTokens },
12202
+ ...disabled === void 0 ? {} : { disabled },
12203
+ ...tokenUrisLocked === void 0 ? {} : { tokenUrisLocked },
12204
+ ...batchCount === void 0 ? {} : { batchCount },
12205
+ ...defaultRoyalty,
12206
+ ...mintConfig === void 0 ? {} : {
12207
+ mintConfig: {
12208
+ tokenCount: mintConfig.numberOfTokens,
12209
+ baseUri: mintConfig.baseURI,
12210
+ lockedMetadata: mintConfig.lockedMetadata
12211
+ }
12212
+ },
12213
+ ...interfaces === void 0 ? {} : { interfaces },
12214
+ ...tokenPlan === void 0 ? {} : {
12215
+ token: {
12216
+ tokenId: tokenPlan.tokenId,
12217
+ ...tokenOwner === void 0 ? {} : { owner: tokenOwner },
12218
+ ...tokenUri === void 0 ? {} : { tokenUri },
12219
+ ...tokenCreator === void 0 ? {} : { creator: tokenCreator },
12220
+ ...tokenRoyalty === void 0 ? {} : {
12221
+ royalty: {
12222
+ salePrice: tokenRoyalty.salePrice,
12223
+ receiver: tokenRoyalty.receiver,
12224
+ amount: tokenRoyalty.amount
12225
+ }
12226
+ }
12227
+ }
12228
+ }
12229
+ };
12230
+ },
11959
12231
  deploy: {
11960
12232
  ...collectionDeploy,
11961
12233
  async lazyErc721(params) {
@@ -11992,7 +12264,7 @@ function createCollectionNamespace(publicClient, config, chain, baseCollection,
11992
12264
  contract: createdLog.args.contractAddress,
11993
12265
  factory: factoryAddress,
11994
12266
  contractType: plan.contractType,
11995
- nextStep: "Configure release sale and mint settings for this collection before collector minting."
12267
+ nextStep: "Prepare lazy mint metadata, approve RareMinter, then Configure release sale and mint settings."
11996
12268
  };
11997
12269
  }
11998
12270
  },
@@ -12146,12 +12418,14 @@ function createCollectionNamespace(publicClient, config, chain, baseCollection,
12146
12418
  metadata: {
12147
12419
  async status(params) {
12148
12420
  const plan = planCollectionContract(params);
12149
- const mintConfig = await readMintConfig(publicClient, plan.contract);
12421
+ const mintConfig = await readOptionalMintConfig(publicClient, plan.contract);
12150
12422
  return {
12151
12423
  contract: plan.contract,
12152
- tokenCount: mintConfig.numberOfTokens,
12153
- baseUri: mintConfig.baseURI,
12154
- lockedMetadata: mintConfig.lockedMetadata
12424
+ ...mintConfig === void 0 ? {} : {
12425
+ tokenCount: mintConfig.numberOfTokens,
12426
+ baseUri: mintConfig.baseURI,
12427
+ lockedMetadata: mintConfig.lockedMetadata
12428
+ }
12155
12429
  };
12156
12430
  }
12157
12431
  },
@@ -12275,6 +12549,21 @@ async function readTokenCreator(publicClient, contract, tokenId) {
12275
12549
  throw contractSupportError("tokenCreator", contract, error);
12276
12550
  }
12277
12551
  }
12552
+ async function readOptionalTokenCreator(publicClient, contract, tokenId) {
12553
+ try {
12554
+ return await publicClient.readContract({
12555
+ address: contract,
12556
+ abi: collectionOwnerAbi,
12557
+ functionName: "tokenCreator",
12558
+ args: [tokenId]
12559
+ });
12560
+ } catch (error) {
12561
+ if (isBestEffortReadError(error)) {
12562
+ return void 0;
12563
+ }
12564
+ throw error;
12565
+ }
12566
+ }
12278
12567
  async function readRoyaltyInfo(publicClient, contract, tokenId, salePrice) {
12279
12568
  try {
12280
12569
  return await publicClient.readContract({
@@ -12287,6 +12576,22 @@ async function readRoyaltyInfo(publicClient, contract, tokenId, salePrice) {
12287
12576
  throw contractSupportError("royaltyInfo", contract, error);
12288
12577
  }
12289
12578
  }
12579
+ async function readOptionalRoyaltyInfo(publicClient, contract, tokenId, salePrice) {
12580
+ try {
12581
+ const [receiver, amount] = await publicClient.readContract({
12582
+ address: contract,
12583
+ abi: collectionOwnerAbi,
12584
+ functionName: "royaltyInfo",
12585
+ args: [tokenId, salePrice]
12586
+ });
12587
+ return { salePrice, receiver, amount };
12588
+ } catch (error) {
12589
+ if (isBestEffortReadError(error)) {
12590
+ return void 0;
12591
+ }
12592
+ throw error;
12593
+ }
12594
+ }
12290
12595
  async function readDefaultRoyalty(publicClient, contract) {
12291
12596
  const defaultReceiver = await readOptionalDefaultRoyaltyReceiver(publicClient, contract);
12292
12597
  const defaultPercentage = await readOptionalDefaultRoyaltyPercentage(publicClient, contract);
@@ -12295,6 +12600,16 @@ async function readDefaultRoyalty(publicClient, contract) {
12295
12600
  ...defaultPercentage === void 0 ? {} : { defaultPercentage }
12296
12601
  };
12297
12602
  }
12603
+ async function readBestEffortDefaultRoyalty(publicClient, contract) {
12604
+ const [defaultReceiver, defaultPercentage] = await Promise.all([
12605
+ readBestEffortDefaultRoyaltyReceiver(publicClient, contract),
12606
+ readBestEffortDefaultRoyaltyPercentage(publicClient, contract)
12607
+ ]);
12608
+ return {
12609
+ ...defaultReceiver === void 0 ? {} : { defaultReceiver },
12610
+ ...defaultPercentage === void 0 ? {} : { defaultPercentage }
12611
+ };
12612
+ }
12298
12613
  async function readOptionalDefaultRoyaltyReceiver(publicClient, contract) {
12299
12614
  try {
12300
12615
  return await publicClient.readContract({
@@ -12312,6 +12627,29 @@ async function readOptionalDefaultRoyaltyReceiver(publicClient, contract) {
12312
12627
  function isUnsupportedOptionalRead(error) {
12313
12628
  return error instanceof ContractFunctionExecutionError4 && error.cause instanceof ContractFunctionZeroDataError4;
12314
12629
  }
12630
+ function isBestEffortReadError(error) {
12631
+ if (!(error instanceof Error)) {
12632
+ return false;
12633
+ }
12634
+ if (error instanceof ContractFunctionExecutionError4 || error instanceof ContractFunctionZeroDataError4) {
12635
+ return true;
12636
+ }
12637
+ return isBestEffortReadError(error.cause);
12638
+ }
12639
+ async function readBestEffortDefaultRoyaltyReceiver(publicClient, contract) {
12640
+ try {
12641
+ return await publicClient.readContract({
12642
+ address: contract,
12643
+ abi: collectionOwnerAbi,
12644
+ functionName: "getDefaultRoyaltyReceiver"
12645
+ });
12646
+ } catch (error) {
12647
+ if (isBestEffortReadError(error)) {
12648
+ return void 0;
12649
+ }
12650
+ throw error;
12651
+ }
12652
+ }
12315
12653
  async function readOptionalDefaultRoyaltyPercentage(publicClient, contract) {
12316
12654
  try {
12317
12655
  return await publicClient.readContract({
@@ -12326,6 +12664,20 @@ async function readOptionalDefaultRoyaltyPercentage(publicClient, contract) {
12326
12664
  throw contractSupportError("getDefaultRoyaltyPercentage", contract, error);
12327
12665
  }
12328
12666
  }
12667
+ async function readBestEffortDefaultRoyaltyPercentage(publicClient, contract) {
12668
+ try {
12669
+ return await publicClient.readContract({
12670
+ address: contract,
12671
+ abi: collectionOwnerAbi,
12672
+ functionName: "getDefaultRoyaltyPercentage"
12673
+ });
12674
+ } catch (error) {
12675
+ if (isBestEffortReadError(error)) {
12676
+ return void 0;
12677
+ }
12678
+ throw error;
12679
+ }
12680
+ }
12329
12681
  async function readMintConfig(publicClient, contract) {
12330
12682
  try {
12331
12683
  return await publicClient.readContract({
@@ -12337,6 +12689,134 @@ async function readMintConfig(publicClient, contract) {
12337
12689
  throw contractSupportError("getMintConfig", contract, error);
12338
12690
  }
12339
12691
  }
12692
+ async function readOptionalMintConfig(publicClient, contract) {
12693
+ try {
12694
+ return await readMintConfig(publicClient, contract);
12695
+ } catch (error) {
12696
+ if (isBestEffortReadError(error)) {
12697
+ return void 0;
12698
+ }
12699
+ throw error;
12700
+ }
12701
+ }
12702
+ async function readOptionalStatusString(publicClient, contract, functionName) {
12703
+ try {
12704
+ return await publicClient.readContract({
12705
+ address: contract,
12706
+ abi: collectionStatusAbi,
12707
+ functionName
12708
+ });
12709
+ } catch (error) {
12710
+ if (isBestEffortReadError(error)) {
12711
+ return void 0;
12712
+ }
12713
+ throw error;
12714
+ }
12715
+ }
12716
+ async function readOptionalStatusAddress(publicClient, contract, functionName) {
12717
+ try {
12718
+ return await publicClient.readContract({
12719
+ address: contract,
12720
+ abi: collectionStatusAbi,
12721
+ functionName
12722
+ });
12723
+ } catch (error) {
12724
+ if (isBestEffortReadError(error)) {
12725
+ return void 0;
12726
+ }
12727
+ throw error;
12728
+ }
12729
+ }
12730
+ async function readOptionalStatusBigint(publicClient, contract, functionName) {
12731
+ try {
12732
+ return await publicClient.readContract({
12733
+ address: contract,
12734
+ abi: collectionStatusAbi,
12735
+ functionName
12736
+ });
12737
+ } catch (error) {
12738
+ if (isBestEffortReadError(error)) {
12739
+ return void 0;
12740
+ }
12741
+ throw error;
12742
+ }
12743
+ }
12744
+ async function readOptionalStatusBoolean(publicClient, contract, functionName) {
12745
+ try {
12746
+ return await publicClient.readContract({
12747
+ address: contract,
12748
+ abi: collectionStatusAbi,
12749
+ functionName
12750
+ });
12751
+ } catch (error) {
12752
+ if (isBestEffortReadError(error)) {
12753
+ return void 0;
12754
+ }
12755
+ throw error;
12756
+ }
12757
+ }
12758
+ async function readOptionalTokenOwner(publicClient, contract, tokenId) {
12759
+ try {
12760
+ return await publicClient.readContract({
12761
+ address: contract,
12762
+ abi: collectionStatusAbi,
12763
+ functionName: "ownerOf",
12764
+ args: [tokenId]
12765
+ });
12766
+ } catch (error) {
12767
+ if (isBestEffortReadError(error)) {
12768
+ return void 0;
12769
+ }
12770
+ throw error;
12771
+ }
12772
+ }
12773
+ async function readOptionalTokenUri(publicClient, contract, tokenId) {
12774
+ try {
12775
+ return await publicClient.readContract({
12776
+ address: contract,
12777
+ abi: collectionStatusAbi,
12778
+ functionName: "tokenURI",
12779
+ args: [tokenId]
12780
+ });
12781
+ } catch (error) {
12782
+ if (isBestEffortReadError(error)) {
12783
+ return void 0;
12784
+ }
12785
+ throw error;
12786
+ }
12787
+ }
12788
+ async function readOptionalSupportsInterface(publicClient, contract, interfaceId) {
12789
+ try {
12790
+ return await publicClient.readContract({
12791
+ address: contract,
12792
+ abi: collectionStatusAbi,
12793
+ functionName: "supportsInterface",
12794
+ args: [interfaceId]
12795
+ });
12796
+ } catch (error) {
12797
+ if (isBestEffortReadError(error)) {
12798
+ return void 0;
12799
+ }
12800
+ throw error;
12801
+ }
12802
+ }
12803
+ async function readSupportedInterfaces(publicClient, contract) {
12804
+ const [erc165, erc721, erc721Metadata, erc2981] = await Promise.all([
12805
+ readOptionalSupportsInterface(publicClient, contract, "0x01ffc9a7"),
12806
+ readOptionalSupportsInterface(publicClient, contract, "0x80ac58cd"),
12807
+ readOptionalSupportsInterface(publicClient, contract, "0x5b5e139f"),
12808
+ readOptionalSupportsInterface(publicClient, contract, "0x2a55205a")
12809
+ ]);
12810
+ if (erc165 === void 0 && erc721 === void 0 && erc721Metadata === void 0 && erc2981 === void 0) {
12811
+ return void 0;
12812
+ }
12813
+ return {
12814
+ ...erc165 === void 0 ? {} : { erc165 },
12815
+ ...erc721 === void 0 ? {} : { erc721 },
12816
+ ...erc721Metadata === void 0 ? {} : { erc721Metadata },
12817
+ ...erc2981 === void 0 ? {} : { erc2981 }
12818
+ };
12819
+ }
12340
12820
  async function writeSetDefaultRoyaltyReceiver(opts) {
12341
12821
  try {
12342
12822
  await opts.publicClient.simulateContract({