@rareprotocol/rare-cli 1.0.0 → 1.0.2
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/README.md +30 -4
- package/dist/client.d.ts +58 -4
- package/dist/client.js +801 -321
- package/dist/contracts.d.ts +28 -0
- package/dist/contracts.js +19 -4
- package/dist/index.js +1191 -394
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
// src/env.ts
|
|
4
|
-
import { existsSync } from "fs";
|
|
5
|
-
import { resolve } from "path";
|
|
6
|
-
function loadDotEnv(file = ".env") {
|
|
7
|
-
const path2 = resolve(process.cwd(), file);
|
|
8
|
-
if (existsSync(path2)) {
|
|
9
|
-
process.loadEnvFile(path2);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
3
|
// src/output.ts
|
|
14
4
|
import { formatEther } from "viem";
|
|
15
5
|
function isJsonMode() {
|
|
@@ -377,13 +367,11 @@ var contractAddresses = {
|
|
|
377
367
|
},
|
|
378
368
|
base: {
|
|
379
369
|
factory: getAddress("0xf776204233bfb52ba0ddff24810cbdbf3dbf94dd"),
|
|
380
|
-
auction: getAddress("0x51c36ffb05e17ed80ee5c02fa83d7677c5613de2")
|
|
381
|
-
batchAuctionHouse: getAddress("0xf776204233bfb52ba0ddff24810cbdbf3dbf94dd")
|
|
370
|
+
auction: getAddress("0x51c36ffb05e17ed80ee5c02fa83d7677c5613de2")
|
|
382
371
|
},
|
|
383
372
|
"base-sepolia": {
|
|
384
373
|
factory: getAddress("0x2b181ae0f1aea6fed75591b04991b1a3f9868d51"),
|
|
385
|
-
auction: getAddress("0x1f0c946f0ee87acb268d50ede6c9b4d010af65d2")
|
|
386
|
-
batchAuctionHouse: getAddress("0x2b181ae0f1aea6fed75591b04991b1a3f9868d51")
|
|
374
|
+
auction: getAddress("0x1f0c946f0ee87acb268d50ede6c9b4d010af65d2")
|
|
387
375
|
}
|
|
388
376
|
};
|
|
389
377
|
var canonicalV4Pools = {
|
|
@@ -571,9 +559,6 @@ function parseAddress(input, field) {
|
|
|
571
559
|
function parseOptionalAddress(input, field) {
|
|
572
560
|
return input === void 0 ? void 0 : parseAddress(input, field);
|
|
573
561
|
}
|
|
574
|
-
function isHexString(value) {
|
|
575
|
-
return value.startsWith("0x");
|
|
576
|
-
}
|
|
577
562
|
function isPrivateKeyString(value) {
|
|
578
563
|
return /^0x[0-9a-fA-F]{64}$/.test(value);
|
|
579
564
|
}
|
|
@@ -702,26 +687,30 @@ function parseConfig(value) {
|
|
|
702
687
|
}
|
|
703
688
|
function parseChainConfigs(value) {
|
|
704
689
|
return supportedChains.reduce((configs, chain) => {
|
|
705
|
-
const chainConfig = parseChainConfig(value[chain]);
|
|
690
|
+
const chainConfig = parseChainConfig(value[chain], chain);
|
|
706
691
|
return chainConfig === void 0 ? configs : { ...configs, [chain]: chainConfig };
|
|
707
692
|
}, {});
|
|
708
693
|
}
|
|
709
|
-
function parseChainConfig(value) {
|
|
694
|
+
function parseChainConfig(value, chain) {
|
|
710
695
|
if (!isRecord(value)) {
|
|
711
696
|
return void 0;
|
|
712
697
|
}
|
|
713
|
-
const privateKey = typeof value.privateKey === "string"
|
|
698
|
+
const privateKey = typeof value.privateKey === "string" ? parsePrivateKey(value.privateKey, `chains.${chain}.privateKey`) : void 0;
|
|
714
699
|
const privateKeyRef = typeof value.privateKeyRef === "string" && isPrivateKeyReference(value.privateKeyRef) ? value.privateKeyRef : void 0;
|
|
715
700
|
const accountAddress = parseAccountAddress(value);
|
|
716
701
|
const rpcUrl = typeof value.rpcUrl === "string" ? value.rpcUrl : void 0;
|
|
717
|
-
|
|
702
|
+
const uniswapApiKey = typeof value.uniswapApiKey === "string" && value.uniswapApiKey.trim().length > 0 ? value.uniswapApiKey.trim() : void 0;
|
|
703
|
+
const uniswapApiKeyRef = typeof value.uniswapApiKeyRef === "string" && isPrivateKeyReference(value.uniswapApiKeyRef) ? value.uniswapApiKeyRef : void 0;
|
|
704
|
+
if (privateKey === void 0 && privateKeyRef === void 0 && accountAddress === void 0 && rpcUrl === void 0 && uniswapApiKey === void 0 && uniswapApiKeyRef === void 0) {
|
|
718
705
|
return void 0;
|
|
719
706
|
}
|
|
720
707
|
return {
|
|
721
708
|
...privateKey === void 0 ? {} : { privateKey },
|
|
722
709
|
...privateKeyRef === void 0 ? {} : { privateKeyRef },
|
|
723
710
|
...accountAddress === void 0 ? {} : { accountAddress },
|
|
724
|
-
...rpcUrl === void 0 ? {} : { rpcUrl }
|
|
711
|
+
...rpcUrl === void 0 ? {} : { rpcUrl },
|
|
712
|
+
...uniswapApiKey === void 0 ? {} : { uniswapApiKey },
|
|
713
|
+
...uniswapApiKeyRef === void 0 ? {} : { uniswapApiKeyRef }
|
|
725
714
|
};
|
|
726
715
|
}
|
|
727
716
|
function parseAccountAddress(value) {
|
|
@@ -838,7 +827,7 @@ function configureCommand() {
|
|
|
838
827
|
const cmd = new Command("configure");
|
|
839
828
|
const supportedChainsText = supportedChains.join(", ");
|
|
840
829
|
cmd.description("Set or view configuration");
|
|
841
|
-
cmd.option("--chain <chain>", `chain to configure (${supportedChainsText})`).option("--chain-id <id>", `chain ID to use (${Object.entries(chainIds).map(([chain, id]) => `${id} (${chain})`).join(", ")})`).option("--private-key <key>", "private key for the specified chain").option("--private-key-ref <ref>", "1Password secret reference for the specified chain private key").option("--rpc-url <url>", "custom RPC URL for the specified chain").option("--default-chain <chain>", "set the default chain").option("--show", "display current configuration").action(async (opts) => {
|
|
830
|
+
cmd.option("--chain <chain>", `chain to configure (${supportedChainsText})`).option("--chain-id <id>", `chain ID to use (${Object.entries(chainIds).map(([chain, id]) => `${id} (${chain})`).join(", ")})`).option("--private-key <key>", "private key for the specified chain").option("--private-key-ref <ref>", "1Password secret reference for the specified chain private key").option("--uniswap-api-key <key>", "Uniswap API key for hosted fallback routes").option("--uniswap-api-key-ref <ref>", "1Password secret reference for the Uniswap API key").option("--rpc-url <url>", "custom RPC URL for the specified chain").option("--default-chain <chain>", "set the default chain").option("--show", "display current configuration").action(async (opts) => {
|
|
842
831
|
const config = readConfig();
|
|
843
832
|
if (opts.show) {
|
|
844
833
|
const display = {
|
|
@@ -851,7 +840,9 @@ function configureCommand() {
|
|
|
851
840
|
privateKey: chainCfg.privateKey !== void 0 ? `${chainCfg.privateKey.slice(0, 6)}...${chainCfg.privateKey.slice(-4)}` : void 0,
|
|
852
841
|
privateKeyRef: chainCfg.privateKeyRef,
|
|
853
842
|
accountAddress: getAccountAddress(chainCfg),
|
|
854
|
-
rpcUrl: chainCfg.rpcUrl
|
|
843
|
+
rpcUrl: chainCfg.rpcUrl,
|
|
844
|
+
uniswapApiKey: chainCfg.uniswapApiKey !== void 0 ? maskSecret(chainCfg.uniswapApiKey) : void 0,
|
|
845
|
+
uniswapApiKeyRef: chainCfg.uniswapApiKeyRef
|
|
855
846
|
}
|
|
856
847
|
])
|
|
857
848
|
)
|
|
@@ -901,7 +892,7 @@ function getSelectedChain(opts, config) {
|
|
|
901
892
|
return void 0;
|
|
902
893
|
}
|
|
903
894
|
function hasChainConfigUpdates(opts) {
|
|
904
|
-
return opts.privateKey !== void 0 || opts.privateKeyRef !== void 0 || opts.rpcUrl !== void 0;
|
|
895
|
+
return opts.privateKey !== void 0 || opts.privateKeyRef !== void 0 || opts.rpcUrl !== void 0 || opts.uniswapApiKey !== void 0 || opts.uniswapApiKeyRef !== void 0;
|
|
905
896
|
}
|
|
906
897
|
function deleteConfigCommand() {
|
|
907
898
|
const cmd = new Command("delete");
|
|
@@ -971,11 +962,46 @@ async function getChainConfigUpdates(opts) {
|
|
|
971
962
|
if (opts.privateKey !== void 0 && opts.privateKeyRef !== void 0) {
|
|
972
963
|
throw new Error("--private-key and --private-key-ref cannot be used together.");
|
|
973
964
|
}
|
|
965
|
+
if (opts.uniswapApiKey !== void 0 && opts.uniswapApiKeyRef !== void 0) {
|
|
966
|
+
throw new Error("--uniswap-api-key and --uniswap-api-key-ref cannot be used together.");
|
|
967
|
+
}
|
|
974
968
|
return {
|
|
975
969
|
...await getKeySourceUpdates(opts),
|
|
970
|
+
...await getUniswapApiKeyUpdates(opts),
|
|
976
971
|
...opts.rpcUrl === void 0 ? {} : { rpcUrl: opts.rpcUrl }
|
|
977
972
|
};
|
|
978
973
|
}
|
|
974
|
+
async function getUniswapApiKeyUpdates(opts) {
|
|
975
|
+
if (opts.uniswapApiKey !== void 0) {
|
|
976
|
+
const uniswapApiKey = parseUniswapApiKey(opts.uniswapApiKey, "--uniswap-api-key");
|
|
977
|
+
return {
|
|
978
|
+
uniswapApiKey,
|
|
979
|
+
uniswapApiKeyRef: void 0
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
if (opts.uniswapApiKeyRef !== void 0) {
|
|
983
|
+
const uniswapApiKeyRef = parsePrivateKeyReference(opts.uniswapApiKeyRef, "--uniswap-api-key-ref");
|
|
984
|
+
parseUniswapApiKey(
|
|
985
|
+
await readOnePasswordSecret(uniswapApiKeyRef),
|
|
986
|
+
`1Password Uniswap API key at ${uniswapApiKeyRef}`
|
|
987
|
+
);
|
|
988
|
+
return {
|
|
989
|
+
uniswapApiKey: void 0,
|
|
990
|
+
uniswapApiKeyRef
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
return {};
|
|
994
|
+
}
|
|
995
|
+
function parseUniswapApiKey(value, field) {
|
|
996
|
+
const trimmed = value.trim();
|
|
997
|
+
if (trimmed.length === 0) {
|
|
998
|
+
throw new Error(`${field} must not be empty.`);
|
|
999
|
+
}
|
|
1000
|
+
return trimmed;
|
|
1001
|
+
}
|
|
1002
|
+
function maskSecret(value) {
|
|
1003
|
+
return value.length <= 10 ? "[redacted]" : `${value.slice(0, 6)}...${value.slice(-4)}`;
|
|
1004
|
+
}
|
|
979
1005
|
async function confirmDeleteConfig(configPath) {
|
|
980
1006
|
console.log(`This will permanently delete rare config at ${configPath}.`);
|
|
981
1007
|
console.log("This cannot be undone.");
|
|
@@ -1054,6 +1080,20 @@ function getConfiguredAccountAddress(chain) {
|
|
|
1054
1080
|
}
|
|
1055
1081
|
return chainConfig.accountAddress;
|
|
1056
1082
|
}
|
|
1083
|
+
async function getConfiguredUniswapApiKey(chain) {
|
|
1084
|
+
const chainConfig = getChainConfig(chain);
|
|
1085
|
+
if (chainConfig.uniswapApiKey !== void 0) {
|
|
1086
|
+
return chainConfig.uniswapApiKey;
|
|
1087
|
+
}
|
|
1088
|
+
if (chainConfig.uniswapApiKeyRef !== void 0) {
|
|
1089
|
+
const apiKey = (await readOnePasswordSecret(chainConfig.uniswapApiKeyRef)).trim();
|
|
1090
|
+
if (apiKey.length === 0) {
|
|
1091
|
+
throw new Error(`1Password Uniswap API key at ${chainConfig.uniswapApiKeyRef} is empty.`);
|
|
1092
|
+
}
|
|
1093
|
+
return apiKey;
|
|
1094
|
+
}
|
|
1095
|
+
return void 0;
|
|
1096
|
+
}
|
|
1057
1097
|
function getWalletAccount(chainConfig) {
|
|
1058
1098
|
if (chainConfig.privateKey !== void 0) {
|
|
1059
1099
|
return privateKeyToAccount3(chainConfig.privateKey);
|
|
@@ -4402,7 +4442,7 @@ async function waitForApproval(publicClient, nftAddress, owner, operator, opts =
|
|
|
4402
4442
|
args: [owner, operator]
|
|
4403
4443
|
});
|
|
4404
4444
|
if (approved) return;
|
|
4405
|
-
await new Promise((
|
|
4445
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
4406
4446
|
}
|
|
4407
4447
|
throw new Error(
|
|
4408
4448
|
`setApprovalForAll did not propagate to readable state within ${timeoutMs}ms. The approval tx was mined but the marketplace still sees the old state. Retry the operation.`
|
|
@@ -4418,6 +4458,16 @@ var NftApprovalRequiredError = class extends Error {
|
|
|
4418
4458
|
this.operator = params.operator;
|
|
4419
4459
|
}
|
|
4420
4460
|
};
|
|
4461
|
+
var MinterApprovalRequiredError = class extends Error {
|
|
4462
|
+
collection;
|
|
4463
|
+
minter;
|
|
4464
|
+
constructor(params) {
|
|
4465
|
+
super(`Minter approval is required for collection ${params.collection} and minter ${params.minter}.`);
|
|
4466
|
+
this.name = "MinterApprovalRequiredError";
|
|
4467
|
+
this.collection = params.collection;
|
|
4468
|
+
this.minter = params.minter;
|
|
4469
|
+
}
|
|
4470
|
+
};
|
|
4421
4471
|
async function approveNftContractIfNeeded(opts) {
|
|
4422
4472
|
const isApproved = await opts.publicClient.readContract({
|
|
4423
4473
|
address: opts.nftAddress,
|
|
@@ -4518,17 +4568,14 @@ async function ensureTokenAllowance(publicClient, walletClient, account, owner,
|
|
|
4518
4568
|
if (isAddressEqual5(token, ETH_ADDRESS) || amount === 0n) {
|
|
4519
4569
|
return;
|
|
4520
4570
|
}
|
|
4521
|
-
|
|
4522
|
-
|
|
4523
|
-
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
return;
|
|
4530
|
-
}
|
|
4531
|
-
} catch {
|
|
4571
|
+
const allowance = await publicClient.readContract({
|
|
4572
|
+
address: token,
|
|
4573
|
+
abi: erc20Abi,
|
|
4574
|
+
functionName: "allowance",
|
|
4575
|
+
args: [owner, spender]
|
|
4576
|
+
});
|
|
4577
|
+
if (allowance >= amount) {
|
|
4578
|
+
return;
|
|
4532
4579
|
}
|
|
4533
4580
|
const approveTx = await walletClient.writeContract({
|
|
4534
4581
|
address: token,
|
|
@@ -4594,7 +4641,7 @@ async function preparePaymentAmountForSpender(opts) {
|
|
|
4594
4641
|
};
|
|
4595
4642
|
}
|
|
4596
4643
|
const allowance = await readAllowance(publicClient, currency, accountAddress, spenderAddress);
|
|
4597
|
-
if (allowance
|
|
4644
|
+
if (allowance >= requiredAmount) {
|
|
4598
4645
|
return {
|
|
4599
4646
|
value: 0n,
|
|
4600
4647
|
requiredAmount
|
|
@@ -4642,16 +4689,12 @@ async function calculateMarketplacePaymentAmountFromSettings(publicClient, marke
|
|
|
4642
4689
|
return amount + fee;
|
|
4643
4690
|
}
|
|
4644
4691
|
async function readAllowance(publicClient, currency, accountAddress, spenderAddress) {
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
});
|
|
4652
|
-
} catch {
|
|
4653
|
-
return void 0;
|
|
4654
|
-
}
|
|
4692
|
+
return publicClient.readContract({
|
|
4693
|
+
address: currency,
|
|
4694
|
+
abi: erc20Abi,
|
|
4695
|
+
functionName: "allowance",
|
|
4696
|
+
args: [accountAddress, spenderAddress]
|
|
4697
|
+
});
|
|
4655
4698
|
}
|
|
4656
4699
|
|
|
4657
4700
|
// src/sdk/validation-core.ts
|
|
@@ -6311,7 +6354,7 @@ function errorCauseText(error) {
|
|
|
6311
6354
|
return `${error.message} ${errorCauseText(error.cause)}`;
|
|
6312
6355
|
}
|
|
6313
6356
|
async function sleep(ms) {
|
|
6314
|
-
await new Promise((
|
|
6357
|
+
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
6315
6358
|
}
|
|
6316
6359
|
function uniqueRoots(roots) {
|
|
6317
6360
|
return [...new Set(roots.map((root) => normalizeBytes32(root, "candidate root")))];
|
|
@@ -9418,7 +9461,7 @@ function isUnavailableContractFunction2(error) {
|
|
|
9418
9461
|
var LIQUID_EDITION_ADDRESS_LOG_RETRY_ATTEMPTS = 3;
|
|
9419
9462
|
var LIQUID_EDITION_ADDRESS_LOG_RETRY_DELAY_MS = 1e3;
|
|
9420
9463
|
async function sleep2(ms) {
|
|
9421
|
-
return new Promise((
|
|
9464
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
9422
9465
|
}
|
|
9423
9466
|
async function fetchRarePriceUsd() {
|
|
9424
9467
|
const rarePriceUsd = (await getTokenPrice("rare")).priceUsd;
|
|
@@ -9848,11 +9891,12 @@ function getWrappedEthAddress(chain) {
|
|
|
9848
9891
|
}
|
|
9849
9892
|
function getKnownCanonicalEthPoolKey(chain, token) {
|
|
9850
9893
|
const normalizedToken = normalizeAddress(token);
|
|
9894
|
+
const pools = canonicalV4Pools[chain];
|
|
9851
9895
|
if (normalizedToken === normalizeAddress(getRareAddress(chain))) {
|
|
9852
|
-
return
|
|
9896
|
+
return pools?.rareEthPool ? poolToKey(pools.rareEthPool) : null;
|
|
9853
9897
|
}
|
|
9854
9898
|
if (normalizedToken === normalizeAddress(getUsdcAddress(chain))) {
|
|
9855
|
-
return
|
|
9899
|
+
return pools?.usdcEthPool ? poolToKey(pools.usdcEthPool) : null;
|
|
9856
9900
|
}
|
|
9857
9901
|
return null;
|
|
9858
9902
|
}
|
|
@@ -10483,9 +10527,11 @@ function getBaseUrl(options) {
|
|
|
10483
10527
|
return options?.baseUrl ?? process.env.UNISWAP_TRADE_API_BASE_URL ?? DEFAULT_UNISWAP_TRADE_API_BASE_URL;
|
|
10484
10528
|
}
|
|
10485
10529
|
function requireApiKey(options) {
|
|
10486
|
-
const apiKey = options?.apiKey
|
|
10530
|
+
const apiKey = options?.apiKey;
|
|
10487
10531
|
if (!apiKey) {
|
|
10488
|
-
throw new Error(
|
|
10532
|
+
throw new Error(
|
|
10533
|
+
"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://...>."
|
|
10534
|
+
);
|
|
10489
10535
|
}
|
|
10490
10536
|
return apiKey;
|
|
10491
10537
|
}
|
|
@@ -10833,12 +10879,14 @@ async function buildLocalTokenTradeQuote(publicClient, chain, addresses, params)
|
|
|
10833
10879
|
}
|
|
10834
10880
|
async function buildUniswapFallbackTradeQuote(publicClient, chainId, token, accountAddress, params) {
|
|
10835
10881
|
assertRecipientSupportedForUniswapFallback(params.recipient, accountAddress);
|
|
10882
|
+
const apiKey = await resolveUniswapApiKey(params);
|
|
10836
10883
|
const tokenIn = params.direction === "buy" ? ETH_ADDRESS : token;
|
|
10837
10884
|
const tokenOut = params.direction === "buy" ? token : ETH_ADDRESS;
|
|
10838
10885
|
const amountIn = params.direction === "buy" ? toWei(params.amountIn) : await toTokenAmount(publicClient, token, params.amountIn, "amountIn");
|
|
10839
10886
|
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;
|
|
10840
10887
|
const defaultSlippageBps = resolveSlippageBps(params.slippageBps);
|
|
10841
10888
|
const initialQuoteResponse = await requestUniswapQuote({
|
|
10889
|
+
apiKey,
|
|
10842
10890
|
chainId,
|
|
10843
10891
|
tokenIn,
|
|
10844
10892
|
tokenOut,
|
|
@@ -10854,13 +10902,15 @@ async function buildUniswapFallbackTradeQuote(publicClient, chainId, token, acco
|
|
|
10854
10902
|
tokenIn,
|
|
10855
10903
|
tokenOut,
|
|
10856
10904
|
amountIn,
|
|
10857
|
-
accountAddress
|
|
10905
|
+
accountAddress,
|
|
10906
|
+
uniswapApiKey: apiKey
|
|
10858
10907
|
});
|
|
10859
10908
|
return {
|
|
10860
10909
|
kind: "uniswap",
|
|
10861
10910
|
rawQuote: quoteResponse.quote,
|
|
10862
10911
|
tokenIn,
|
|
10863
10912
|
tokenOut,
|
|
10913
|
+
apiKey,
|
|
10864
10914
|
quote: buildUniswapTradeQuote({
|
|
10865
10915
|
amountIn,
|
|
10866
10916
|
quote: quoteResponse.quote,
|
|
@@ -10873,11 +10923,18 @@ async function buildUniswapFallbackTradeQuote(publicClient, chainId, token, acco
|
|
|
10873
10923
|
})
|
|
10874
10924
|
};
|
|
10875
10925
|
}
|
|
10926
|
+
async function resolveUniswapApiKey(params) {
|
|
10927
|
+
if (params.uniswapApiKey !== void 0) {
|
|
10928
|
+
return params.uniswapApiKey;
|
|
10929
|
+
}
|
|
10930
|
+
return params.resolveUniswapApiKey?.();
|
|
10931
|
+
}
|
|
10876
10932
|
async function requoteForRequestedMinAmountOut(params) {
|
|
10877
10933
|
const quotedAmounts = getQuotedRecipientAmount(params.initialQuoteResponse.quote, params.accountAddress);
|
|
10878
10934
|
assertRequestedMinAmountOut(quotedAmounts.estimatedAmountOut, params.requestedMinAmountOut);
|
|
10879
10935
|
const derivedSlippageBps = computeSlippageBpsFromAmounts(quotedAmounts.estimatedAmountOut, params.requestedMinAmountOut);
|
|
10880
10936
|
const quoteResponse = await requestUniswapQuote({
|
|
10937
|
+
apiKey: params.uniswapApiKey,
|
|
10881
10938
|
chainId: params.chainId,
|
|
10882
10939
|
tokenIn: params.tokenIn,
|
|
10883
10940
|
tokenOut: params.tokenOut,
|
|
@@ -11050,7 +11107,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11050
11107
|
minAmountOut: localInputs.minAmountOut,
|
|
11051
11108
|
slippageBps: localInputs.slippageBps,
|
|
11052
11109
|
recipient: params.recipient,
|
|
11053
|
-
route: params.route
|
|
11110
|
+
route: params.route,
|
|
11111
|
+
uniswapApiKey: config.uniswapApiKey,
|
|
11112
|
+
resolveUniswapApiKey: config.resolveUniswapApiKey
|
|
11054
11113
|
}
|
|
11055
11114
|
);
|
|
11056
11115
|
return quote.quote;
|
|
@@ -11091,7 +11150,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11091
11150
|
minAmountOut: localInputs.minAmountOut,
|
|
11092
11151
|
slippageBps: localInputs.slippageBps,
|
|
11093
11152
|
recipient: params.recipient,
|
|
11094
|
-
route: params.route
|
|
11153
|
+
route: params.route,
|
|
11154
|
+
uniswapApiKey: config.uniswapApiKey,
|
|
11155
|
+
resolveUniswapApiKey: config.resolveUniswapApiKey
|
|
11095
11156
|
});
|
|
11096
11157
|
if (quoteDetails.kind === "local") {
|
|
11097
11158
|
const router = requireConfiguredAddress(addresses.swapRouter, "Liquid router", chain);
|
|
@@ -11124,6 +11185,7 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11124
11185
|
};
|
|
11125
11186
|
}
|
|
11126
11187
|
const swapResponse = await requestUniswapSwap({
|
|
11188
|
+
apiKey: quoteDetails.apiKey,
|
|
11127
11189
|
quote: quoteDetails.rawQuote,
|
|
11128
11190
|
deadline: uniswapDeadline
|
|
11129
11191
|
});
|
|
@@ -11154,7 +11216,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11154
11216
|
minAmountOut: localInputs.minAmountOut,
|
|
11155
11217
|
slippageBps: localInputs.slippageBps,
|
|
11156
11218
|
recipient: params.recipient,
|
|
11157
|
-
route: params.route
|
|
11219
|
+
route: params.route,
|
|
11220
|
+
uniswapApiKey: config.uniswapApiKey,
|
|
11221
|
+
resolveUniswapApiKey: config.resolveUniswapApiKey
|
|
11158
11222
|
}
|
|
11159
11223
|
);
|
|
11160
11224
|
return quote.quote;
|
|
@@ -11195,7 +11259,9 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11195
11259
|
minAmountOut: localInputs.minAmountOut,
|
|
11196
11260
|
slippageBps: localInputs.slippageBps,
|
|
11197
11261
|
recipient: params.recipient,
|
|
11198
|
-
route: params.route
|
|
11262
|
+
route: params.route,
|
|
11263
|
+
uniswapApiKey: config.uniswapApiKey,
|
|
11264
|
+
resolveUniswapApiKey: config.resolveUniswapApiKey
|
|
11199
11265
|
});
|
|
11200
11266
|
if (quoteDetails.kind === "local") {
|
|
11201
11267
|
const router = requireConfiguredAddress(addresses.swapRouter, "Liquid router", chain);
|
|
@@ -11231,6 +11297,7 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11231
11297
|
};
|
|
11232
11298
|
}
|
|
11233
11299
|
const approval = await requestUniswapApproval({
|
|
11300
|
+
apiKey: quoteDetails.apiKey,
|
|
11234
11301
|
chainId,
|
|
11235
11302
|
walletAddress: accountAddress,
|
|
11236
11303
|
token: params.token,
|
|
@@ -11246,6 +11313,7 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11246
11313
|
chainId
|
|
11247
11314
|
})).txHash : void 0;
|
|
11248
11315
|
const swapResponse = await requestUniswapSwap({
|
|
11316
|
+
apiKey: quoteDetails.apiKey,
|
|
11249
11317
|
quote: quoteDetails.rawQuote,
|
|
11250
11318
|
deadline: uniswapDeadline
|
|
11251
11319
|
});
|
|
@@ -11295,10 +11363,153 @@ function createSwapNamespace(config, chain, chainId, addresses) {
|
|
|
11295
11363
|
// src/sdk/release.ts
|
|
11296
11364
|
import {
|
|
11297
11365
|
erc20Abi as erc20Abi2,
|
|
11366
|
+
hexToBigInt as hexToBigInt2,
|
|
11298
11367
|
isAddressEqual as isAddressEqual17,
|
|
11299
11368
|
parseEventLogs as parseEventLogs6
|
|
11300
11369
|
} from "viem";
|
|
11301
11370
|
|
|
11371
|
+
// src/contracts/abis/collection-owner.ts
|
|
11372
|
+
var collectionOwnerAbi = [
|
|
11373
|
+
{
|
|
11374
|
+
inputs: [{ internalType: "uint256", name: "_tokenId", type: "uint256" }],
|
|
11375
|
+
name: "tokenCreator",
|
|
11376
|
+
outputs: [{ internalType: "address payable", name: "", type: "address" }],
|
|
11377
|
+
stateMutability: "view",
|
|
11378
|
+
type: "function"
|
|
11379
|
+
},
|
|
11380
|
+
{
|
|
11381
|
+
inputs: [
|
|
11382
|
+
{ internalType: "uint256", name: "_tokenId", type: "uint256" },
|
|
11383
|
+
{ internalType: "uint256", name: "_salePrice", type: "uint256" }
|
|
11384
|
+
],
|
|
11385
|
+
name: "royaltyInfo",
|
|
11386
|
+
outputs: [
|
|
11387
|
+
{ internalType: "address", name: "receiver", type: "address" },
|
|
11388
|
+
{ internalType: "uint256", name: "royaltyAmount", type: "uint256" }
|
|
11389
|
+
],
|
|
11390
|
+
stateMutability: "view",
|
|
11391
|
+
type: "function"
|
|
11392
|
+
},
|
|
11393
|
+
{
|
|
11394
|
+
inputs: [],
|
|
11395
|
+
name: "getDefaultRoyaltyReceiver",
|
|
11396
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
11397
|
+
stateMutability: "view",
|
|
11398
|
+
type: "function"
|
|
11399
|
+
},
|
|
11400
|
+
{
|
|
11401
|
+
inputs: [],
|
|
11402
|
+
name: "getDefaultRoyaltyPercentage",
|
|
11403
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
11404
|
+
stateMutability: "view",
|
|
11405
|
+
type: "function"
|
|
11406
|
+
},
|
|
11407
|
+
{
|
|
11408
|
+
inputs: [{ internalType: "address", name: "_receiver", type: "address" }],
|
|
11409
|
+
name: "setDefaultRoyaltyReceiver",
|
|
11410
|
+
outputs: [],
|
|
11411
|
+
stateMutability: "nonpayable",
|
|
11412
|
+
type: "function"
|
|
11413
|
+
},
|
|
11414
|
+
{
|
|
11415
|
+
inputs: [{ internalType: "uint256", name: "_percentage", type: "uint256" }],
|
|
11416
|
+
name: "setDefaultRoyaltyPercentage",
|
|
11417
|
+
outputs: [],
|
|
11418
|
+
stateMutability: "nonpayable",
|
|
11419
|
+
type: "function"
|
|
11420
|
+
},
|
|
11421
|
+
{
|
|
11422
|
+
inputs: [
|
|
11423
|
+
{ internalType: "address", name: "_receiver", type: "address" },
|
|
11424
|
+
{ internalType: "uint256", name: "_tokenId", type: "uint256" }
|
|
11425
|
+
],
|
|
11426
|
+
name: "setRoyaltyReceiverForToken",
|
|
11427
|
+
outputs: [],
|
|
11428
|
+
stateMutability: "nonpayable",
|
|
11429
|
+
type: "function"
|
|
11430
|
+
},
|
|
11431
|
+
{
|
|
11432
|
+
inputs: [],
|
|
11433
|
+
name: "getMintConfig",
|
|
11434
|
+
outputs: [
|
|
11435
|
+
{
|
|
11436
|
+
components: [
|
|
11437
|
+
{ internalType: "uint256", name: "numberOfTokens", type: "uint256" },
|
|
11438
|
+
{ internalType: "string", name: "baseURI", type: "string" },
|
|
11439
|
+
{ internalType: "bool", name: "lockedMetadata", type: "bool" }
|
|
11440
|
+
],
|
|
11441
|
+
internalType: "struct LazySovereignNFT.MintConfig",
|
|
11442
|
+
name: "mintConfig",
|
|
11443
|
+
type: "tuple"
|
|
11444
|
+
}
|
|
11445
|
+
],
|
|
11446
|
+
stateMutability: "view",
|
|
11447
|
+
type: "function"
|
|
11448
|
+
},
|
|
11449
|
+
{
|
|
11450
|
+
inputs: [{ internalType: "address", name: "_address", type: "address" }],
|
|
11451
|
+
name: "isApprovedMinter",
|
|
11452
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
11453
|
+
stateMutability: "view",
|
|
11454
|
+
type: "function"
|
|
11455
|
+
},
|
|
11456
|
+
{
|
|
11457
|
+
inputs: [
|
|
11458
|
+
{ internalType: "address", name: "_minter", type: "address" },
|
|
11459
|
+
{ internalType: "bool", name: "_isMinter", type: "bool" }
|
|
11460
|
+
],
|
|
11461
|
+
name: "setMinterApproval",
|
|
11462
|
+
outputs: [],
|
|
11463
|
+
stateMutability: "nonpayable",
|
|
11464
|
+
type: "function"
|
|
11465
|
+
},
|
|
11466
|
+
{
|
|
11467
|
+
inputs: [{ internalType: "string", name: "_baseURI", type: "string" }],
|
|
11468
|
+
name: "updateBaseURI",
|
|
11469
|
+
outputs: [],
|
|
11470
|
+
stateMutability: "nonpayable",
|
|
11471
|
+
type: "function"
|
|
11472
|
+
},
|
|
11473
|
+
{
|
|
11474
|
+
inputs: [
|
|
11475
|
+
{ internalType: "uint256", name: "_tokenId", type: "uint256" },
|
|
11476
|
+
{ internalType: "string", name: "_metadataUri", type: "string" }
|
|
11477
|
+
],
|
|
11478
|
+
name: "updateTokenURI",
|
|
11479
|
+
outputs: [],
|
|
11480
|
+
stateMutability: "nonpayable",
|
|
11481
|
+
type: "function"
|
|
11482
|
+
},
|
|
11483
|
+
{
|
|
11484
|
+
inputs: [],
|
|
11485
|
+
name: "lockBaseURI",
|
|
11486
|
+
outputs: [],
|
|
11487
|
+
stateMutability: "nonpayable",
|
|
11488
|
+
type: "function"
|
|
11489
|
+
},
|
|
11490
|
+
{
|
|
11491
|
+
anonymous: false,
|
|
11492
|
+
inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
|
|
11493
|
+
name: "MetadataUpdated",
|
|
11494
|
+
type: "event"
|
|
11495
|
+
},
|
|
11496
|
+
{
|
|
11497
|
+
anonymous: false,
|
|
11498
|
+
inputs: [
|
|
11499
|
+
{ indexed: true, internalType: "uint256", name: "tokenId", type: "uint256" },
|
|
11500
|
+
{ indexed: false, internalType: "string", name: "metadataUri", type: "string" }
|
|
11501
|
+
],
|
|
11502
|
+
name: "TokenURIUpdated",
|
|
11503
|
+
type: "event"
|
|
11504
|
+
},
|
|
11505
|
+
{
|
|
11506
|
+
anonymous: false,
|
|
11507
|
+
inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
|
|
11508
|
+
name: "MetadataLocked",
|
|
11509
|
+
type: "event"
|
|
11510
|
+
}
|
|
11511
|
+
];
|
|
11512
|
+
|
|
11302
11513
|
// src/contracts/abis/rare-minter.ts
|
|
11303
11514
|
var rareMinterAbi = [
|
|
11304
11515
|
{
|
|
@@ -11474,57 +11685,239 @@ var rareMinterAbi = [
|
|
|
11474
11685
|
}
|
|
11475
11686
|
];
|
|
11476
11687
|
|
|
11477
|
-
// src/sdk/
|
|
11478
|
-
|
|
11479
|
-
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11486
|
-
|
|
11487
|
-
var ZERO_BYTES322 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
11488
|
-
var RELEASE_ALLOWLIST_ARTIFACT_KIND = "rare-release-allowlist-v1";
|
|
11489
|
-
var RELEASE_ALLOWLIST_LEAF_ENCODING = "keccak256(address)";
|
|
11490
|
-
var RELEASE_ALLOWLIST_TREE = "sorted-addresses-sort-pairs";
|
|
11491
|
-
var MAX_DIRECT_SALE_MINT_QUANTITY = 255n;
|
|
11492
|
-
function requireRareMinterAddress(address) {
|
|
11493
|
-
if (!address) {
|
|
11494
|
-
throw new Error("RareMinter is not configured for this chain. Supported RareMinter chains: mainnet, sepolia.");
|
|
11688
|
+
// src/sdk/collection-core.ts
|
|
11689
|
+
var lazySovereignCollectionContractTypes = [
|
|
11690
|
+
"lazy",
|
|
11691
|
+
"lazy-royalty-guard",
|
|
11692
|
+
"lazy-deadman-royalty-guard"
|
|
11693
|
+
];
|
|
11694
|
+
var defaultRoyaltyInfoSalePrice = 10000n;
|
|
11695
|
+
function normalizeLazySovereignCollectionContractType(input) {
|
|
11696
|
+
if (input === void 0) {
|
|
11697
|
+
return void 0;
|
|
11495
11698
|
}
|
|
11496
|
-
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
const { contract, accountAddress, owner } = opts;
|
|
11500
|
-
if (!isAddressEqual16(owner, accountAddress)) {
|
|
11501
|
-
throw new Error(
|
|
11502
|
-
`Connected wallet ${accountAddress} is not the owner of collection ${contract}. Contract owner is ${owner}.`
|
|
11503
|
-
);
|
|
11699
|
+
const normalized = input.trim().toLowerCase();
|
|
11700
|
+
if (normalized === "lazy" || normalized === "standard" || normalized === "lazy-sovereign" || normalized === "lazy-sovereign-nft") {
|
|
11701
|
+
return "lazy";
|
|
11504
11702
|
}
|
|
11505
|
-
|
|
11506
|
-
|
|
11507
|
-
const timestamp = value === void 0 ? requiredDefaultTimestamp(field, opts.defaultValue) : normalizeDefinedReleaseTimestamp(value, field);
|
|
11508
|
-
if (timestamp < 0n) {
|
|
11509
|
-
throw new Error(`${field} must be greater than or equal to 0.`);
|
|
11703
|
+
if (normalized === "lazy-royalty-guard" || normalized === "royalty-guard") {
|
|
11704
|
+
return "lazy-royalty-guard";
|
|
11510
11705
|
}
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
function requiredDefaultTimestamp(field, defaultValue) {
|
|
11514
|
-
if (defaultValue === void 0) {
|
|
11515
|
-
throw new Error(`${field} is required.`);
|
|
11706
|
+
if (normalized === "lazy-deadman-royalty-guard" || normalized === "lazy-royalty-guard-deadman" || normalized === "deadman-royalty-guard" || normalized === "royalty-guard-deadman" || normalized === "deadman") {
|
|
11707
|
+
return "lazy-deadman-royalty-guard";
|
|
11516
11708
|
}
|
|
11517
|
-
|
|
11709
|
+
throw new Error(
|
|
11710
|
+
`Unsupported Lazy Sovereign collection contract type "${input}". Supported: ${lazySovereignCollectionContractTypes.join(", ")}.`
|
|
11711
|
+
);
|
|
11518
11712
|
}
|
|
11519
|
-
function
|
|
11520
|
-
|
|
11521
|
-
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
|
|
11525
|
-
|
|
11526
|
-
|
|
11527
|
-
|
|
11713
|
+
function planCreateLazySovereignCollection(params) {
|
|
11714
|
+
const contractType = params.contractType ?? "lazy";
|
|
11715
|
+
return {
|
|
11716
|
+
name: params.name,
|
|
11717
|
+
symbol: params.symbol,
|
|
11718
|
+
maxTokens: toPositiveInteger(params.maxTokens, "maxTokens"),
|
|
11719
|
+
contractType,
|
|
11720
|
+
contractTypeReadName: lazyContractTypeReadName(contractType)
|
|
11721
|
+
};
|
|
11722
|
+
}
|
|
11723
|
+
function buildCreateLazySovereignCollectionWrite(plan, contractType) {
|
|
11724
|
+
return {
|
|
11725
|
+
functionName: "createSovereignNFTContract",
|
|
11726
|
+
args: [plan.name, plan.symbol, plan.maxTokens, contractType]
|
|
11727
|
+
};
|
|
11728
|
+
}
|
|
11729
|
+
function planCollectionMintBatch(params) {
|
|
11730
|
+
const amount = requireInput(params.amount, "amount");
|
|
11731
|
+
return {
|
|
11732
|
+
contract: params.contract,
|
|
11733
|
+
baseUri: params.baseUri,
|
|
11734
|
+
tokenCount: toPositiveInteger(amount, "amount")
|
|
11735
|
+
};
|
|
11736
|
+
}
|
|
11737
|
+
function planCollectionPrepareLazyMint(params) {
|
|
11738
|
+
const amount = requireInput(params.amount, "amount");
|
|
11739
|
+
const basePlan = {
|
|
11740
|
+
contract: params.contract,
|
|
11741
|
+
baseUri: params.baseUri,
|
|
11742
|
+
tokenCount: toPositiveInteger(amount, "amount")
|
|
11743
|
+
};
|
|
11744
|
+
if (params.minter === void 0) {
|
|
11745
|
+
return basePlan;
|
|
11746
|
+
}
|
|
11747
|
+
return {
|
|
11748
|
+
...basePlan,
|
|
11749
|
+
minter: params.minter
|
|
11750
|
+
};
|
|
11751
|
+
}
|
|
11752
|
+
function buildCollectionMintBatchWrite(plan) {
|
|
11753
|
+
return {
|
|
11754
|
+
functionName: "batchMint",
|
|
11755
|
+
args: [plan.baseUri, plan.tokenCount]
|
|
11756
|
+
};
|
|
11757
|
+
}
|
|
11758
|
+
function buildCollectionPrepareLazyMintWrite(plan) {
|
|
11759
|
+
if (plan.minter === void 0) {
|
|
11760
|
+
return {
|
|
11761
|
+
functionName: "prepareMint",
|
|
11762
|
+
args: [plan.baseUri, plan.tokenCount]
|
|
11763
|
+
};
|
|
11764
|
+
}
|
|
11765
|
+
return {
|
|
11766
|
+
functionName: "prepareMintWithMinter",
|
|
11767
|
+
args: [plan.baseUri, plan.tokenCount, plan.minter]
|
|
11768
|
+
};
|
|
11769
|
+
}
|
|
11770
|
+
function planCollectionMinterApproval(params) {
|
|
11771
|
+
return {
|
|
11772
|
+
contract: params.contract,
|
|
11773
|
+
minter: params.minter,
|
|
11774
|
+
approved: params.approved ?? true
|
|
11775
|
+
};
|
|
11776
|
+
}
|
|
11777
|
+
function buildCollectionMinterApprovalWrite(plan) {
|
|
11778
|
+
return {
|
|
11779
|
+
functionName: "setMinterApproval",
|
|
11780
|
+
args: [plan.minter, plan.approved]
|
|
11781
|
+
};
|
|
11782
|
+
}
|
|
11783
|
+
function shapeCollectionPrepareMintEvent(args) {
|
|
11784
|
+
if ("numberOfTokens" in args) {
|
|
11785
|
+
return {
|
|
11786
|
+
baseUri: args.baseURI,
|
|
11787
|
+
tokenCount: args.numberOfTokens
|
|
11788
|
+
};
|
|
11789
|
+
}
|
|
11790
|
+
if (args.endTokenId < args.startTokenId) {
|
|
11791
|
+
throw new Error("PrepareMint endTokenId must be greater than or equal to startTokenId.");
|
|
11792
|
+
}
|
|
11793
|
+
return {
|
|
11794
|
+
baseUri: args.baseURI,
|
|
11795
|
+
tokenCount: args.endTokenId - args.startTokenId + 1n,
|
|
11796
|
+
fromTokenId: args.startTokenId,
|
|
11797
|
+
toTokenId: args.endTokenId
|
|
11798
|
+
};
|
|
11799
|
+
}
|
|
11800
|
+
function planCollectionToken(params) {
|
|
11801
|
+
return {
|
|
11802
|
+
contract: params.contract,
|
|
11803
|
+
tokenId: toNonNegativeInteger(params.tokenId, "tokenId")
|
|
11804
|
+
};
|
|
11805
|
+
}
|
|
11806
|
+
function planCollectionRoyaltyInfo(params) {
|
|
11807
|
+
return {
|
|
11808
|
+
...planCollectionToken(params),
|
|
11809
|
+
salePrice: params.price === void 0 ? defaultRoyaltyInfoSalePrice : toNonNegativeInteger(params.price, "price")
|
|
11810
|
+
};
|
|
11811
|
+
}
|
|
11812
|
+
function planCollectionReceiver(params) {
|
|
11813
|
+
return {
|
|
11814
|
+
contract: params.contract,
|
|
11815
|
+
receiver: params.receiver
|
|
11816
|
+
};
|
|
11817
|
+
}
|
|
11818
|
+
function planCollectionTokenReceiver(params) {
|
|
11819
|
+
return {
|
|
11820
|
+
...planCollectionToken(params),
|
|
11821
|
+
receiver: params.receiver
|
|
11822
|
+
};
|
|
11823
|
+
}
|
|
11824
|
+
function planCollectionRoyaltyPercentage(params) {
|
|
11825
|
+
return {
|
|
11826
|
+
contract: params.contract,
|
|
11827
|
+
percentage: toRoyaltyPercentage(params.percentage)
|
|
11828
|
+
};
|
|
11829
|
+
}
|
|
11830
|
+
function buildCollectionRoyaltyPercentageWrite(plan) {
|
|
11831
|
+
return {
|
|
11832
|
+
functionName: "setDefaultRoyaltyPercentage",
|
|
11833
|
+
args: [BigInt(plan.percentage)]
|
|
11834
|
+
};
|
|
11835
|
+
}
|
|
11836
|
+
function planCollectionBaseUri(params) {
|
|
11837
|
+
return {
|
|
11838
|
+
contract: params.contract,
|
|
11839
|
+
baseUri: params.baseUri
|
|
11840
|
+
};
|
|
11841
|
+
}
|
|
11842
|
+
function planCollectionTokenUri(params) {
|
|
11843
|
+
return {
|
|
11844
|
+
...planCollectionToken(params),
|
|
11845
|
+
tokenUri: params.tokenUri
|
|
11846
|
+
};
|
|
11847
|
+
}
|
|
11848
|
+
function planCollectionContract(params) {
|
|
11849
|
+
return {
|
|
11850
|
+
contract: params.contract
|
|
11851
|
+
};
|
|
11852
|
+
}
|
|
11853
|
+
function lazyContractTypeReadName(contractType) {
|
|
11854
|
+
if (contractType === "lazy-royalty-guard") {
|
|
11855
|
+
return "LAZY_ROYALTY_GUARD";
|
|
11856
|
+
}
|
|
11857
|
+
if (contractType === "lazy-deadman-royalty-guard") {
|
|
11858
|
+
return "LAZY_ROYALTY_GUARD_DEADMAN";
|
|
11859
|
+
}
|
|
11860
|
+
return "LAZY_SOVEREIGN_NFT";
|
|
11861
|
+
}
|
|
11862
|
+
function toRoyaltyPercentage(value) {
|
|
11863
|
+
const percentage = toSafeIntegerNumber(value, "percentage");
|
|
11864
|
+
if (percentage < 0 || percentage > 100) {
|
|
11865
|
+
throw new Error("percentage must be between 0 and 100.");
|
|
11866
|
+
}
|
|
11867
|
+
return percentage;
|
|
11868
|
+
}
|
|
11869
|
+
|
|
11870
|
+
// src/sdk/release-core.ts
|
|
11871
|
+
import {
|
|
11872
|
+
getAddress as getAddress10,
|
|
11873
|
+
isAddress as isAddress6,
|
|
11874
|
+
isAddressEqual as isAddressEqual16,
|
|
11875
|
+
isHex as isHex4,
|
|
11876
|
+
keccak256 as keccak2562,
|
|
11877
|
+
parseEther as parseEther2,
|
|
11878
|
+
parseUnits as parseUnits7
|
|
11879
|
+
} from "viem";
|
|
11880
|
+
var ZERO_BYTES322 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
11881
|
+
var RELEASE_ALLOWLIST_ARTIFACT_KIND = "rare-release-allowlist-v1";
|
|
11882
|
+
var RELEASE_ALLOWLIST_LEAF_ENCODING = "keccak256(address)";
|
|
11883
|
+
var RELEASE_ALLOWLIST_TREE = "sorted-addresses-sort-pairs";
|
|
11884
|
+
var MAX_DIRECT_SALE_MINT_QUANTITY = 255n;
|
|
11885
|
+
function requireRareMinterAddress(address) {
|
|
11886
|
+
if (!address) {
|
|
11887
|
+
throw new Error("RareMinter is not configured for this chain. Supported RareMinter chains: mainnet, sepolia.");
|
|
11888
|
+
}
|
|
11889
|
+
return address;
|
|
11890
|
+
}
|
|
11891
|
+
function assertReleaseContractOwner(opts) {
|
|
11892
|
+
const { contract, accountAddress, owner } = opts;
|
|
11893
|
+
if (!isAddressEqual16(owner, accountAddress)) {
|
|
11894
|
+
throw new Error(
|
|
11895
|
+
`Connected wallet ${accountAddress} is not the owner of collection ${contract}. Contract owner is ${owner}.`
|
|
11896
|
+
);
|
|
11897
|
+
}
|
|
11898
|
+
}
|
|
11899
|
+
function normalizeReleaseTimestamp(value, field, opts = {}) {
|
|
11900
|
+
const timestamp = value === void 0 ? requiredDefaultTimestamp(field, opts.defaultValue) : normalizeDefinedReleaseTimestamp(value, field);
|
|
11901
|
+
if (timestamp < 0n) {
|
|
11902
|
+
throw new Error(`${field} must be greater than or equal to 0.`);
|
|
11903
|
+
}
|
|
11904
|
+
return timestamp;
|
|
11905
|
+
}
|
|
11906
|
+
function requiredDefaultTimestamp(field, defaultValue) {
|
|
11907
|
+
if (defaultValue === void 0) {
|
|
11908
|
+
throw new Error(`${field} is required.`);
|
|
11909
|
+
}
|
|
11910
|
+
return defaultValue;
|
|
11911
|
+
}
|
|
11912
|
+
function normalizeDefinedReleaseTimestamp(value, field) {
|
|
11913
|
+
if (value instanceof Date) {
|
|
11914
|
+
const milliseconds = value.getTime();
|
|
11915
|
+
if (!Number.isFinite(milliseconds)) {
|
|
11916
|
+
throw new Error(`${field} must be a valid date.`);
|
|
11917
|
+
}
|
|
11918
|
+
return BigInt(Math.floor(milliseconds / 1e3));
|
|
11919
|
+
}
|
|
11920
|
+
if (typeof value === "string") {
|
|
11528
11921
|
const trimmed = value.trim();
|
|
11529
11922
|
if (/^-?\d+$/.test(trimmed)) {
|
|
11530
11923
|
return BigInt(trimmed);
|
|
@@ -12159,11 +12552,65 @@ async function assertConfigurableReleaseContract(opts) {
|
|
|
12159
12552
|
});
|
|
12160
12553
|
} catch (error) {
|
|
12161
12554
|
throw new Error(
|
|
12162
|
-
`Collection ${contract} must expose mintTo(address) callable by RareMinter ${rareMinter}. Simulation failed: ${errorMessage2(error)}`,
|
|
12555
|
+
`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)}`,
|
|
12163
12556
|
{ cause: error }
|
|
12164
12557
|
);
|
|
12165
12558
|
}
|
|
12166
12559
|
}
|
|
12560
|
+
async function readReleaseMinterApproval(opts) {
|
|
12561
|
+
try {
|
|
12562
|
+
return await opts.publicClient.readContract({
|
|
12563
|
+
address: opts.contract,
|
|
12564
|
+
abi: collectionOwnerAbi,
|
|
12565
|
+
functionName: "isApprovedMinter",
|
|
12566
|
+
args: [opts.minter]
|
|
12567
|
+
});
|
|
12568
|
+
} catch {
|
|
12569
|
+
return null;
|
|
12570
|
+
}
|
|
12571
|
+
}
|
|
12572
|
+
async function approveReleaseMinterIfNeeded(opts) {
|
|
12573
|
+
const approved = await readReleaseMinterApproval({
|
|
12574
|
+
publicClient: opts.publicClient,
|
|
12575
|
+
contract: opts.contract,
|
|
12576
|
+
minter: opts.minter
|
|
12577
|
+
});
|
|
12578
|
+
if (approved !== false) {
|
|
12579
|
+
return void 0;
|
|
12580
|
+
}
|
|
12581
|
+
if (opts.autoApprove === false) {
|
|
12582
|
+
throw new MinterApprovalRequiredError({
|
|
12583
|
+
collection: opts.contract,
|
|
12584
|
+
minter: opts.minter
|
|
12585
|
+
});
|
|
12586
|
+
}
|
|
12587
|
+
const plan = planCollectionMinterApproval({
|
|
12588
|
+
contract: opts.contract,
|
|
12589
|
+
minter: opts.minter,
|
|
12590
|
+
approved: true
|
|
12591
|
+
});
|
|
12592
|
+
const write = buildCollectionMinterApprovalWrite(plan);
|
|
12593
|
+
const approvalTxHash = await opts.walletClient.writeContract({
|
|
12594
|
+
address: plan.contract,
|
|
12595
|
+
abi: collectionOwnerAbi,
|
|
12596
|
+
functionName: write.functionName,
|
|
12597
|
+
args: write.args,
|
|
12598
|
+
account: opts.account,
|
|
12599
|
+
chain: void 0
|
|
12600
|
+
});
|
|
12601
|
+
await opts.publicClient.waitForTransactionReceipt({ hash: approvalTxHash });
|
|
12602
|
+
const confirmed = await readReleaseMinterApproval({
|
|
12603
|
+
publicClient: opts.publicClient,
|
|
12604
|
+
contract: opts.contract,
|
|
12605
|
+
minter: opts.minter
|
|
12606
|
+
});
|
|
12607
|
+
if (confirmed !== true) {
|
|
12608
|
+
throw new Error(
|
|
12609
|
+
`Lazy Sovereign minter approval verification failed for ${opts.minter}. The approval tx was mined but the collection still does not report RareMinter as approved.`
|
|
12610
|
+
);
|
|
12611
|
+
}
|
|
12612
|
+
return approvalTxHash;
|
|
12613
|
+
}
|
|
12167
12614
|
async function optionalRead(read) {
|
|
12168
12615
|
try {
|
|
12169
12616
|
return await read();
|
|
@@ -12309,13 +12756,13 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
|
|
|
12309
12756
|
async setConfig(params) {
|
|
12310
12757
|
const rareMinter = requireRareMinterAddress(addresses.rareMinter);
|
|
12311
12758
|
const { walletClient, account, accountAddress } = requireWallet(config);
|
|
12312
|
-
const
|
|
12313
|
-
const plan = planReleaseAllowlistConfig(resolvedParams);
|
|
12759
|
+
const plan = planReleaseAllowlistConfig(params);
|
|
12314
12760
|
await assertCollectionOwnerForReleaseWrite({
|
|
12315
12761
|
publicClient,
|
|
12316
12762
|
contract: plan.contract,
|
|
12317
12763
|
accountAddress
|
|
12318
12764
|
});
|
|
12765
|
+
await uploadReleaseAllowlistArtifact(config, params, plan.root);
|
|
12319
12766
|
const txHash = await walletClient.writeContract({
|
|
12320
12767
|
address: rareMinter,
|
|
12321
12768
|
abi: rareMinterAbi,
|
|
@@ -12460,6 +12907,14 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
|
|
|
12460
12907
|
currencyDecimals: currencyDecimals2,
|
|
12461
12908
|
nowSeconds: currentUnixTimestamp3()
|
|
12462
12909
|
});
|
|
12910
|
+
const approvalTxHash = await approveReleaseMinterIfNeeded({
|
|
12911
|
+
publicClient,
|
|
12912
|
+
walletClient,
|
|
12913
|
+
account,
|
|
12914
|
+
contract: plan.contract,
|
|
12915
|
+
minter: rareMinter,
|
|
12916
|
+
autoApprove: params.autoApprove
|
|
12917
|
+
});
|
|
12463
12918
|
await assertConfigurableReleaseContract({
|
|
12464
12919
|
publicClient,
|
|
12465
12920
|
contract: plan.contract,
|
|
@@ -12493,7 +12948,8 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
|
|
|
12493
12948
|
startTime: plan.startTime,
|
|
12494
12949
|
maxMints: plan.maxMints,
|
|
12495
12950
|
splitRecipients: plan.splitRecipients,
|
|
12496
|
-
splitRatios: plan.splitRatios
|
|
12951
|
+
splitRatios: plan.splitRatios,
|
|
12952
|
+
approvalTxHash
|
|
12497
12953
|
};
|
|
12498
12954
|
},
|
|
12499
12955
|
async mint(params) {
|
|
@@ -12582,19 +13038,17 @@ function createReleaseNamespace(publicClient, config, chain, addresses) {
|
|
|
12582
13038
|
function currentUnixTimestamp3() {
|
|
12583
13039
|
return BigInt(Math.floor(Date.now() / 1e3));
|
|
12584
13040
|
}
|
|
12585
|
-
async function
|
|
13041
|
+
async function uploadReleaseAllowlistArtifact(config, params, expectedRoot) {
|
|
12586
13042
|
if (params.root !== void 0 || params.artifact === void 0) {
|
|
12587
|
-
return
|
|
13043
|
+
return;
|
|
12588
13044
|
}
|
|
12589
13045
|
const root = await generateApiAddressMerkleRoot(config, {
|
|
12590
13046
|
addresses: params.artifact.wallets.map((wallet) => wallet.address),
|
|
12591
13047
|
storageTarget: "collection-allowlist"
|
|
12592
13048
|
});
|
|
12593
|
-
|
|
12594
|
-
|
|
12595
|
-
|
|
12596
|
-
artifact: void 0
|
|
12597
|
-
};
|
|
13049
|
+
if (hexToBigInt2(root) !== hexToBigInt2(expectedRoot)) {
|
|
13050
|
+
throw new Error(`rare-api allowlist root ${root} does not match artifact root ${expectedRoot}.`);
|
|
13051
|
+
}
|
|
12598
13052
|
}
|
|
12599
13053
|
|
|
12600
13054
|
// src/sdk/collection.ts
|
|
@@ -12725,305 +13179,165 @@ var collectionMintAbi = [
|
|
|
12725
13179
|
}
|
|
12726
13180
|
];
|
|
12727
13181
|
|
|
12728
|
-
// src/contracts/abis/collection-
|
|
12729
|
-
var
|
|
13182
|
+
// src/contracts/abis/collection-status.ts
|
|
13183
|
+
var collectionStatusAbi = [
|
|
12730
13184
|
{
|
|
12731
|
-
inputs: [
|
|
12732
|
-
name: "
|
|
12733
|
-
outputs: [{ internalType: "
|
|
13185
|
+
inputs: [],
|
|
13186
|
+
name: "name",
|
|
13187
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
12734
13188
|
stateMutability: "view",
|
|
12735
13189
|
type: "function"
|
|
12736
13190
|
},
|
|
12737
13191
|
{
|
|
12738
|
-
inputs: [
|
|
12739
|
-
|
|
12740
|
-
|
|
12741
|
-
],
|
|
12742
|
-
name: "royaltyInfo",
|
|
12743
|
-
outputs: [
|
|
12744
|
-
{ internalType: "address", name: "receiver", type: "address" },
|
|
12745
|
-
{ internalType: "uint256", name: "royaltyAmount", type: "uint256" }
|
|
12746
|
-
],
|
|
13192
|
+
inputs: [],
|
|
13193
|
+
name: "symbol",
|
|
13194
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
12747
13195
|
stateMutability: "view",
|
|
12748
13196
|
type: "function"
|
|
12749
13197
|
},
|
|
12750
13198
|
{
|
|
12751
13199
|
inputs: [],
|
|
12752
|
-
name: "
|
|
13200
|
+
name: "owner",
|
|
12753
13201
|
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
12754
13202
|
stateMutability: "view",
|
|
12755
13203
|
type: "function"
|
|
12756
13204
|
},
|
|
12757
13205
|
{
|
|
12758
13206
|
inputs: [],
|
|
12759
|
-
name: "
|
|
13207
|
+
name: "totalSupply",
|
|
12760
13208
|
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
12761
13209
|
stateMutability: "view",
|
|
12762
13210
|
type: "function"
|
|
12763
13211
|
},
|
|
12764
13212
|
{
|
|
12765
|
-
inputs: [
|
|
12766
|
-
name: "
|
|
12767
|
-
outputs: [],
|
|
12768
|
-
stateMutability: "
|
|
13213
|
+
inputs: [],
|
|
13214
|
+
name: "maxTokens",
|
|
13215
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
13216
|
+
stateMutability: "view",
|
|
12769
13217
|
type: "function"
|
|
12770
13218
|
},
|
|
12771
13219
|
{
|
|
12772
|
-
inputs: [
|
|
12773
|
-
name: "
|
|
12774
|
-
outputs: [],
|
|
12775
|
-
stateMutability: "
|
|
13220
|
+
inputs: [],
|
|
13221
|
+
name: "disabled",
|
|
13222
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
13223
|
+
stateMutability: "view",
|
|
12776
13224
|
type: "function"
|
|
12777
13225
|
},
|
|
12778
13226
|
{
|
|
12779
|
-
inputs: [
|
|
12780
|
-
|
|
12781
|
-
|
|
12782
|
-
|
|
12783
|
-
name: "setRoyaltyReceiverForToken",
|
|
12784
|
-
outputs: [],
|
|
12785
|
-
stateMutability: "nonpayable",
|
|
13227
|
+
inputs: [],
|
|
13228
|
+
name: "areTokenURIsLocked",
|
|
13229
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
13230
|
+
stateMutability: "view",
|
|
12786
13231
|
type: "function"
|
|
12787
13232
|
},
|
|
12788
13233
|
{
|
|
12789
13234
|
inputs: [],
|
|
12790
|
-
name: "
|
|
12791
|
-
outputs: [
|
|
12792
|
-
{
|
|
12793
|
-
components: [
|
|
12794
|
-
{ internalType: "uint256", name: "numberOfTokens", type: "uint256" },
|
|
12795
|
-
{ internalType: "string", name: "baseURI", type: "string" },
|
|
12796
|
-
{ internalType: "bool", name: "lockedMetadata", type: "bool" }
|
|
12797
|
-
],
|
|
12798
|
-
internalType: "struct LazySovereignNFT.MintConfig",
|
|
12799
|
-
name: "mintConfig",
|
|
12800
|
-
type: "tuple"
|
|
12801
|
-
}
|
|
12802
|
-
],
|
|
13235
|
+
name: "getBatchCount",
|
|
13236
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
12803
13237
|
stateMutability: "view",
|
|
12804
13238
|
type: "function"
|
|
12805
13239
|
},
|
|
12806
13240
|
{
|
|
12807
|
-
inputs: [{ internalType: "
|
|
12808
|
-
name: "
|
|
12809
|
-
outputs: [],
|
|
12810
|
-
stateMutability: "
|
|
13241
|
+
inputs: [{ internalType: "uint256", name: "tokenId", type: "uint256" }],
|
|
13242
|
+
name: "ownerOf",
|
|
13243
|
+
outputs: [{ internalType: "address", name: "", type: "address" }],
|
|
13244
|
+
stateMutability: "view",
|
|
12811
13245
|
type: "function"
|
|
12812
13246
|
},
|
|
12813
13247
|
{
|
|
12814
|
-
inputs: [
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
name: "updateTokenURI",
|
|
12819
|
-
outputs: [],
|
|
12820
|
-
stateMutability: "nonpayable",
|
|
13248
|
+
inputs: [{ internalType: "uint256", name: "tokenId", type: "uint256" }],
|
|
13249
|
+
name: "tokenURI",
|
|
13250
|
+
outputs: [{ internalType: "string", name: "", type: "string" }],
|
|
13251
|
+
stateMutability: "view",
|
|
12821
13252
|
type: "function"
|
|
12822
13253
|
},
|
|
12823
13254
|
{
|
|
12824
|
-
inputs: [],
|
|
12825
|
-
name: "
|
|
12826
|
-
outputs: [],
|
|
12827
|
-
stateMutability: "
|
|
13255
|
+
inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }],
|
|
13256
|
+
name: "supportsInterface",
|
|
13257
|
+
outputs: [{ internalType: "bool", name: "", type: "bool" }],
|
|
13258
|
+
stateMutability: "view",
|
|
12828
13259
|
type: "function"
|
|
12829
|
-
},
|
|
12830
|
-
{
|
|
12831
|
-
anonymous: false,
|
|
12832
|
-
inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
|
|
12833
|
-
name: "MetadataUpdated",
|
|
12834
|
-
type: "event"
|
|
12835
|
-
},
|
|
12836
|
-
{
|
|
12837
|
-
anonymous: false,
|
|
12838
|
-
inputs: [
|
|
12839
|
-
{ indexed: true, internalType: "uint256", name: "tokenId", type: "uint256" },
|
|
12840
|
-
{ indexed: false, internalType: "string", name: "metadataUri", type: "string" }
|
|
12841
|
-
],
|
|
12842
|
-
name: "TokenURIUpdated",
|
|
12843
|
-
type: "event"
|
|
12844
|
-
},
|
|
12845
|
-
{
|
|
12846
|
-
anonymous: false,
|
|
12847
|
-
inputs: [{ indexed: false, internalType: "string", name: "baseURI", type: "string" }],
|
|
12848
|
-
name: "MetadataLocked",
|
|
12849
|
-
type: "event"
|
|
12850
13260
|
}
|
|
12851
13261
|
];
|
|
12852
13262
|
|
|
12853
|
-
// src/sdk/collection-core.ts
|
|
12854
|
-
var lazySovereignCollectionContractTypes = [
|
|
12855
|
-
"lazy",
|
|
12856
|
-
"lazy-royalty-guard",
|
|
12857
|
-
"lazy-deadman-royalty-guard"
|
|
12858
|
-
];
|
|
12859
|
-
var defaultRoyaltyInfoSalePrice = 10000n;
|
|
12860
|
-
function normalizeLazySovereignCollectionContractType(input) {
|
|
12861
|
-
if (input === void 0) {
|
|
12862
|
-
return void 0;
|
|
12863
|
-
}
|
|
12864
|
-
const normalized = input.trim().toLowerCase();
|
|
12865
|
-
if (normalized === "lazy" || normalized === "standard" || normalized === "lazy-sovereign" || normalized === "lazy-sovereign-nft") {
|
|
12866
|
-
return "lazy";
|
|
12867
|
-
}
|
|
12868
|
-
if (normalized === "lazy-royalty-guard" || normalized === "royalty-guard") {
|
|
12869
|
-
return "lazy-royalty-guard";
|
|
12870
|
-
}
|
|
12871
|
-
if (normalized === "lazy-deadman-royalty-guard" || normalized === "lazy-royalty-guard-deadman" || normalized === "deadman-royalty-guard" || normalized === "royalty-guard-deadman" || normalized === "deadman") {
|
|
12872
|
-
return "lazy-deadman-royalty-guard";
|
|
12873
|
-
}
|
|
12874
|
-
throw new Error(
|
|
12875
|
-
`Unsupported Lazy Sovereign collection contract type "${input}". Supported: ${lazySovereignCollectionContractTypes.join(", ")}.`
|
|
12876
|
-
);
|
|
12877
|
-
}
|
|
12878
|
-
function planCreateLazySovereignCollection(params) {
|
|
12879
|
-
const contractType = params.contractType ?? "lazy";
|
|
12880
|
-
return {
|
|
12881
|
-
name: params.name,
|
|
12882
|
-
symbol: params.symbol,
|
|
12883
|
-
maxTokens: toPositiveInteger(params.maxTokens, "maxTokens"),
|
|
12884
|
-
contractType,
|
|
12885
|
-
contractTypeReadName: lazyContractTypeReadName(contractType)
|
|
12886
|
-
};
|
|
12887
|
-
}
|
|
12888
|
-
function buildCreateLazySovereignCollectionWrite(plan, contractType) {
|
|
12889
|
-
return {
|
|
12890
|
-
functionName: "createSovereignNFTContract",
|
|
12891
|
-
args: [plan.name, plan.symbol, plan.maxTokens, contractType]
|
|
12892
|
-
};
|
|
12893
|
-
}
|
|
12894
|
-
function planCollectionMintBatch(params) {
|
|
12895
|
-
const amount = requireInput(params.amount, "amount");
|
|
12896
|
-
return {
|
|
12897
|
-
contract: params.contract,
|
|
12898
|
-
baseUri: params.baseUri,
|
|
12899
|
-
tokenCount: toPositiveInteger(amount, "amount")
|
|
12900
|
-
};
|
|
12901
|
-
}
|
|
12902
|
-
function planCollectionPrepareLazyMint(params) {
|
|
12903
|
-
const amount = requireInput(params.amount, "amount");
|
|
12904
|
-
const basePlan = {
|
|
12905
|
-
contract: params.contract,
|
|
12906
|
-
baseUri: params.baseUri,
|
|
12907
|
-
tokenCount: toPositiveInteger(amount, "amount")
|
|
12908
|
-
};
|
|
12909
|
-
if (params.minter === void 0) {
|
|
12910
|
-
return basePlan;
|
|
12911
|
-
}
|
|
12912
|
-
return {
|
|
12913
|
-
...basePlan,
|
|
12914
|
-
minter: params.minter
|
|
12915
|
-
};
|
|
12916
|
-
}
|
|
12917
|
-
function buildCollectionMintBatchWrite(plan) {
|
|
12918
|
-
return {
|
|
12919
|
-
functionName: "batchMint",
|
|
12920
|
-
args: [plan.baseUri, plan.tokenCount]
|
|
12921
|
-
};
|
|
12922
|
-
}
|
|
12923
|
-
function buildCollectionPrepareLazyMintWrite(plan) {
|
|
12924
|
-
if (plan.minter === void 0) {
|
|
12925
|
-
return {
|
|
12926
|
-
functionName: "prepareMint",
|
|
12927
|
-
args: [plan.baseUri, plan.tokenCount]
|
|
12928
|
-
};
|
|
12929
|
-
}
|
|
12930
|
-
return {
|
|
12931
|
-
functionName: "prepareMintWithMinter",
|
|
12932
|
-
args: [plan.baseUri, plan.tokenCount, plan.minter]
|
|
12933
|
-
};
|
|
12934
|
-
}
|
|
12935
|
-
function shapeCollectionPrepareMintEvent(args) {
|
|
12936
|
-
if ("numberOfTokens" in args) {
|
|
12937
|
-
return {
|
|
12938
|
-
baseUri: args.baseURI,
|
|
12939
|
-
tokenCount: args.numberOfTokens
|
|
12940
|
-
};
|
|
12941
|
-
}
|
|
12942
|
-
if (args.endTokenId < args.startTokenId) {
|
|
12943
|
-
throw new Error("PrepareMint endTokenId must be greater than or equal to startTokenId.");
|
|
12944
|
-
}
|
|
12945
|
-
return {
|
|
12946
|
-
baseUri: args.baseURI,
|
|
12947
|
-
tokenCount: args.endTokenId - args.startTokenId + 1n,
|
|
12948
|
-
fromTokenId: args.startTokenId,
|
|
12949
|
-
toTokenId: args.endTokenId
|
|
12950
|
-
};
|
|
12951
|
-
}
|
|
12952
|
-
function planCollectionToken(params) {
|
|
12953
|
-
return {
|
|
12954
|
-
contract: params.contract,
|
|
12955
|
-
tokenId: toNonNegativeInteger(params.tokenId, "tokenId")
|
|
12956
|
-
};
|
|
12957
|
-
}
|
|
12958
|
-
function planCollectionRoyaltyInfo(params) {
|
|
12959
|
-
return {
|
|
12960
|
-
...planCollectionToken(params),
|
|
12961
|
-
salePrice: params.price === void 0 ? defaultRoyaltyInfoSalePrice : toNonNegativeInteger(params.price, "price")
|
|
12962
|
-
};
|
|
12963
|
-
}
|
|
12964
|
-
function planCollectionReceiver(params) {
|
|
12965
|
-
return {
|
|
12966
|
-
contract: params.contract,
|
|
12967
|
-
receiver: params.receiver
|
|
12968
|
-
};
|
|
12969
|
-
}
|
|
12970
|
-
function planCollectionTokenReceiver(params) {
|
|
12971
|
-
return {
|
|
12972
|
-
...planCollectionToken(params),
|
|
12973
|
-
receiver: params.receiver
|
|
12974
|
-
};
|
|
12975
|
-
}
|
|
12976
|
-
function planCollectionRoyaltyPercentage(params) {
|
|
12977
|
-
return {
|
|
12978
|
-
contract: params.contract,
|
|
12979
|
-
percentage: toRoyaltyPercentage(params.percentage)
|
|
12980
|
-
};
|
|
12981
|
-
}
|
|
12982
|
-
function buildCollectionRoyaltyPercentageWrite(plan) {
|
|
12983
|
-
return {
|
|
12984
|
-
functionName: "setDefaultRoyaltyPercentage",
|
|
12985
|
-
args: [BigInt(plan.percentage)]
|
|
12986
|
-
};
|
|
12987
|
-
}
|
|
12988
|
-
function planCollectionBaseUri(params) {
|
|
12989
|
-
return {
|
|
12990
|
-
contract: params.contract,
|
|
12991
|
-
baseUri: params.baseUri
|
|
12992
|
-
};
|
|
12993
|
-
}
|
|
12994
|
-
function planCollectionTokenUri(params) {
|
|
12995
|
-
return {
|
|
12996
|
-
...planCollectionToken(params),
|
|
12997
|
-
tokenUri: params.tokenUri
|
|
12998
|
-
};
|
|
12999
|
-
}
|
|
13000
|
-
function planCollectionContract(params) {
|
|
13001
|
-
return {
|
|
13002
|
-
contract: params.contract
|
|
13003
|
-
};
|
|
13004
|
-
}
|
|
13005
|
-
function lazyContractTypeReadName(contractType) {
|
|
13006
|
-
if (contractType === "lazy-royalty-guard") {
|
|
13007
|
-
return "LAZY_ROYALTY_GUARD";
|
|
13008
|
-
}
|
|
13009
|
-
if (contractType === "lazy-deadman-royalty-guard") {
|
|
13010
|
-
return "LAZY_ROYALTY_GUARD_DEADMAN";
|
|
13011
|
-
}
|
|
13012
|
-
return "LAZY_SOVEREIGN_NFT";
|
|
13013
|
-
}
|
|
13014
|
-
function toRoyaltyPercentage(value) {
|
|
13015
|
-
const percentage = toSafeIntegerNumber(value, "percentage");
|
|
13016
|
-
if (percentage < 0 || percentage > 100) {
|
|
13017
|
-
throw new Error("percentage must be between 0 and 100.");
|
|
13018
|
-
}
|
|
13019
|
-
return percentage;
|
|
13020
|
-
}
|
|
13021
|
-
|
|
13022
13263
|
// src/sdk/collection.ts
|
|
13023
13264
|
function createCollectionNamespace(publicClient, config, chain, baseCollection, collectionDeploy, collectionMint) {
|
|
13024
13265
|
return {
|
|
13025
13266
|
...baseCollection,
|
|
13026
13267
|
mint: collectionMint,
|
|
13268
|
+
async status(params) {
|
|
13269
|
+
const plan = planCollectionContract(params);
|
|
13270
|
+
const tokenPlan = params.tokenId === void 0 ? void 0 : planCollectionToken({ contract: plan.contract, tokenId: params.tokenId });
|
|
13271
|
+
const royaltyPlan = params.tokenId === void 0 ? void 0 : planCollectionRoyaltyInfo({ contract: plan.contract, tokenId: params.tokenId, price: params.price });
|
|
13272
|
+
const [
|
|
13273
|
+
name,
|
|
13274
|
+
symbol,
|
|
13275
|
+
owner,
|
|
13276
|
+
totalSupply,
|
|
13277
|
+
maxTokens,
|
|
13278
|
+
disabled,
|
|
13279
|
+
tokenUrisLocked,
|
|
13280
|
+
batchCount,
|
|
13281
|
+
defaultRoyalty,
|
|
13282
|
+
mintConfig,
|
|
13283
|
+
interfaces,
|
|
13284
|
+
tokenOwner,
|
|
13285
|
+
tokenUri,
|
|
13286
|
+
tokenCreator,
|
|
13287
|
+
tokenRoyalty
|
|
13288
|
+
] = await Promise.all([
|
|
13289
|
+
readOptionalStatusString(publicClient, plan.contract, "name"),
|
|
13290
|
+
readOptionalStatusString(publicClient, plan.contract, "symbol"),
|
|
13291
|
+
readOptionalStatusAddress(publicClient, plan.contract, "owner"),
|
|
13292
|
+
readOptionalStatusBigint(publicClient, plan.contract, "totalSupply"),
|
|
13293
|
+
readOptionalStatusBigint(publicClient, plan.contract, "maxTokens"),
|
|
13294
|
+
readOptionalStatusBoolean(publicClient, plan.contract, "disabled"),
|
|
13295
|
+
readOptionalStatusBoolean(publicClient, plan.contract, "areTokenURIsLocked"),
|
|
13296
|
+
readOptionalStatusBigint(publicClient, plan.contract, "getBatchCount"),
|
|
13297
|
+
readBestEffortDefaultRoyalty(publicClient, plan.contract),
|
|
13298
|
+
readOptionalMintConfig(publicClient, plan.contract),
|
|
13299
|
+
readSupportedInterfaces(publicClient, plan.contract),
|
|
13300
|
+
tokenPlan === void 0 ? Promise.resolve(void 0) : readOptionalTokenOwner(publicClient, plan.contract, tokenPlan.tokenId),
|
|
13301
|
+
tokenPlan === void 0 ? Promise.resolve(void 0) : readOptionalTokenUri(publicClient, plan.contract, tokenPlan.tokenId),
|
|
13302
|
+
tokenPlan === void 0 ? Promise.resolve(void 0) : readOptionalTokenCreator(publicClient, plan.contract, tokenPlan.tokenId),
|
|
13303
|
+
royaltyPlan === void 0 ? Promise.resolve(void 0) : readOptionalRoyaltyInfo(publicClient, plan.contract, royaltyPlan.tokenId, royaltyPlan.salePrice)
|
|
13304
|
+
]);
|
|
13305
|
+
return {
|
|
13306
|
+
contract: plan.contract,
|
|
13307
|
+
...name === void 0 ? {} : { name },
|
|
13308
|
+
...symbol === void 0 ? {} : { symbol },
|
|
13309
|
+
...owner === void 0 ? {} : { owner },
|
|
13310
|
+
...totalSupply === void 0 ? {} : { totalSupply },
|
|
13311
|
+
...maxTokens === void 0 ? {} : { maxTokens },
|
|
13312
|
+
...disabled === void 0 ? {} : { disabled },
|
|
13313
|
+
...tokenUrisLocked === void 0 ? {} : { tokenUrisLocked },
|
|
13314
|
+
...batchCount === void 0 ? {} : { batchCount },
|
|
13315
|
+
...defaultRoyalty,
|
|
13316
|
+
...mintConfig === void 0 ? {} : {
|
|
13317
|
+
mintConfig: {
|
|
13318
|
+
tokenCount: mintConfig.numberOfTokens,
|
|
13319
|
+
baseUri: mintConfig.baseURI,
|
|
13320
|
+
lockedMetadata: mintConfig.lockedMetadata
|
|
13321
|
+
}
|
|
13322
|
+
},
|
|
13323
|
+
...interfaces === void 0 ? {} : { interfaces },
|
|
13324
|
+
...tokenPlan === void 0 ? {} : {
|
|
13325
|
+
token: {
|
|
13326
|
+
tokenId: tokenPlan.tokenId,
|
|
13327
|
+
...tokenOwner === void 0 ? {} : { owner: tokenOwner },
|
|
13328
|
+
...tokenUri === void 0 ? {} : { tokenUri },
|
|
13329
|
+
...tokenCreator === void 0 ? {} : { creator: tokenCreator },
|
|
13330
|
+
...tokenRoyalty === void 0 ? {} : {
|
|
13331
|
+
royalty: {
|
|
13332
|
+
salePrice: tokenRoyalty.salePrice,
|
|
13333
|
+
receiver: tokenRoyalty.receiver,
|
|
13334
|
+
amount: tokenRoyalty.amount
|
|
13335
|
+
}
|
|
13336
|
+
}
|
|
13337
|
+
}
|
|
13338
|
+
}
|
|
13339
|
+
};
|
|
13340
|
+
},
|
|
13027
13341
|
deploy: {
|
|
13028
13342
|
...collectionDeploy,
|
|
13029
13343
|
async lazyErc721(params) {
|
|
@@ -13060,7 +13374,7 @@ function createCollectionNamespace(publicClient, config, chain, baseCollection,
|
|
|
13060
13374
|
contract: createdLog.args.contractAddress,
|
|
13061
13375
|
factory: factoryAddress,
|
|
13062
13376
|
contractType: plan.contractType,
|
|
13063
|
-
nextStep: "Configure release sale and mint settings
|
|
13377
|
+
nextStep: "Prepare lazy mint metadata, approve RareMinter, then Configure release sale and mint settings."
|
|
13064
13378
|
};
|
|
13065
13379
|
}
|
|
13066
13380
|
},
|
|
@@ -13214,12 +13528,14 @@ function createCollectionNamespace(publicClient, config, chain, baseCollection,
|
|
|
13214
13528
|
metadata: {
|
|
13215
13529
|
async status(params) {
|
|
13216
13530
|
const plan = planCollectionContract(params);
|
|
13217
|
-
const mintConfig = await
|
|
13531
|
+
const mintConfig = await readOptionalMintConfig(publicClient, plan.contract);
|
|
13218
13532
|
return {
|
|
13219
13533
|
contract: plan.contract,
|
|
13220
|
-
|
|
13221
|
-
|
|
13222
|
-
|
|
13534
|
+
...mintConfig === void 0 ? {} : {
|
|
13535
|
+
tokenCount: mintConfig.numberOfTokens,
|
|
13536
|
+
baseUri: mintConfig.baseURI,
|
|
13537
|
+
lockedMetadata: mintConfig.lockedMetadata
|
|
13538
|
+
}
|
|
13223
13539
|
};
|
|
13224
13540
|
}
|
|
13225
13541
|
},
|
|
@@ -13343,6 +13659,21 @@ async function readTokenCreator(publicClient, contract, tokenId) {
|
|
|
13343
13659
|
throw contractSupportError("tokenCreator", contract, error);
|
|
13344
13660
|
}
|
|
13345
13661
|
}
|
|
13662
|
+
async function readOptionalTokenCreator(publicClient, contract, tokenId) {
|
|
13663
|
+
try {
|
|
13664
|
+
return await publicClient.readContract({
|
|
13665
|
+
address: contract,
|
|
13666
|
+
abi: collectionOwnerAbi,
|
|
13667
|
+
functionName: "tokenCreator",
|
|
13668
|
+
args: [tokenId]
|
|
13669
|
+
});
|
|
13670
|
+
} catch (error) {
|
|
13671
|
+
if (isBestEffortReadError(error)) {
|
|
13672
|
+
return void 0;
|
|
13673
|
+
}
|
|
13674
|
+
throw error;
|
|
13675
|
+
}
|
|
13676
|
+
}
|
|
13346
13677
|
async function readRoyaltyInfo(publicClient, contract, tokenId, salePrice) {
|
|
13347
13678
|
try {
|
|
13348
13679
|
return await publicClient.readContract({
|
|
@@ -13355,6 +13686,22 @@ async function readRoyaltyInfo(publicClient, contract, tokenId, salePrice) {
|
|
|
13355
13686
|
throw contractSupportError("royaltyInfo", contract, error);
|
|
13356
13687
|
}
|
|
13357
13688
|
}
|
|
13689
|
+
async function readOptionalRoyaltyInfo(publicClient, contract, tokenId, salePrice) {
|
|
13690
|
+
try {
|
|
13691
|
+
const [receiver, amount] = await publicClient.readContract({
|
|
13692
|
+
address: contract,
|
|
13693
|
+
abi: collectionOwnerAbi,
|
|
13694
|
+
functionName: "royaltyInfo",
|
|
13695
|
+
args: [tokenId, salePrice]
|
|
13696
|
+
});
|
|
13697
|
+
return { salePrice, receiver, amount };
|
|
13698
|
+
} catch (error) {
|
|
13699
|
+
if (isBestEffortReadError(error)) {
|
|
13700
|
+
return void 0;
|
|
13701
|
+
}
|
|
13702
|
+
throw error;
|
|
13703
|
+
}
|
|
13704
|
+
}
|
|
13358
13705
|
async function readDefaultRoyalty(publicClient, contract) {
|
|
13359
13706
|
const defaultReceiver = await readOptionalDefaultRoyaltyReceiver(publicClient, contract);
|
|
13360
13707
|
const defaultPercentage = await readOptionalDefaultRoyaltyPercentage(publicClient, contract);
|
|
@@ -13363,6 +13710,16 @@ async function readDefaultRoyalty(publicClient, contract) {
|
|
|
13363
13710
|
...defaultPercentage === void 0 ? {} : { defaultPercentage }
|
|
13364
13711
|
};
|
|
13365
13712
|
}
|
|
13713
|
+
async function readBestEffortDefaultRoyalty(publicClient, contract) {
|
|
13714
|
+
const [defaultReceiver, defaultPercentage] = await Promise.all([
|
|
13715
|
+
readBestEffortDefaultRoyaltyReceiver(publicClient, contract),
|
|
13716
|
+
readBestEffortDefaultRoyaltyPercentage(publicClient, contract)
|
|
13717
|
+
]);
|
|
13718
|
+
return {
|
|
13719
|
+
...defaultReceiver === void 0 ? {} : { defaultReceiver },
|
|
13720
|
+
...defaultPercentage === void 0 ? {} : { defaultPercentage }
|
|
13721
|
+
};
|
|
13722
|
+
}
|
|
13366
13723
|
async function readOptionalDefaultRoyaltyReceiver(publicClient, contract) {
|
|
13367
13724
|
try {
|
|
13368
13725
|
return await publicClient.readContract({
|
|
@@ -13380,6 +13737,29 @@ async function readOptionalDefaultRoyaltyReceiver(publicClient, contract) {
|
|
|
13380
13737
|
function isUnsupportedOptionalRead(error) {
|
|
13381
13738
|
return error instanceof ContractFunctionExecutionError4 && error.cause instanceof ContractFunctionZeroDataError4;
|
|
13382
13739
|
}
|
|
13740
|
+
function isBestEffortReadError(error) {
|
|
13741
|
+
if (!(error instanceof Error)) {
|
|
13742
|
+
return false;
|
|
13743
|
+
}
|
|
13744
|
+
if (error instanceof ContractFunctionExecutionError4 || error instanceof ContractFunctionZeroDataError4) {
|
|
13745
|
+
return true;
|
|
13746
|
+
}
|
|
13747
|
+
return isBestEffortReadError(error.cause);
|
|
13748
|
+
}
|
|
13749
|
+
async function readBestEffortDefaultRoyaltyReceiver(publicClient, contract) {
|
|
13750
|
+
try {
|
|
13751
|
+
return await publicClient.readContract({
|
|
13752
|
+
address: contract,
|
|
13753
|
+
abi: collectionOwnerAbi,
|
|
13754
|
+
functionName: "getDefaultRoyaltyReceiver"
|
|
13755
|
+
});
|
|
13756
|
+
} catch (error) {
|
|
13757
|
+
if (isBestEffortReadError(error)) {
|
|
13758
|
+
return void 0;
|
|
13759
|
+
}
|
|
13760
|
+
throw error;
|
|
13761
|
+
}
|
|
13762
|
+
}
|
|
13383
13763
|
async function readOptionalDefaultRoyaltyPercentage(publicClient, contract) {
|
|
13384
13764
|
try {
|
|
13385
13765
|
return await publicClient.readContract({
|
|
@@ -13394,6 +13774,20 @@ async function readOptionalDefaultRoyaltyPercentage(publicClient, contract) {
|
|
|
13394
13774
|
throw contractSupportError("getDefaultRoyaltyPercentage", contract, error);
|
|
13395
13775
|
}
|
|
13396
13776
|
}
|
|
13777
|
+
async function readBestEffortDefaultRoyaltyPercentage(publicClient, contract) {
|
|
13778
|
+
try {
|
|
13779
|
+
return await publicClient.readContract({
|
|
13780
|
+
address: contract,
|
|
13781
|
+
abi: collectionOwnerAbi,
|
|
13782
|
+
functionName: "getDefaultRoyaltyPercentage"
|
|
13783
|
+
});
|
|
13784
|
+
} catch (error) {
|
|
13785
|
+
if (isBestEffortReadError(error)) {
|
|
13786
|
+
return void 0;
|
|
13787
|
+
}
|
|
13788
|
+
throw error;
|
|
13789
|
+
}
|
|
13790
|
+
}
|
|
13397
13791
|
async function readMintConfig(publicClient, contract) {
|
|
13398
13792
|
try {
|
|
13399
13793
|
return await publicClient.readContract({
|
|
@@ -13405,6 +13799,134 @@ async function readMintConfig(publicClient, contract) {
|
|
|
13405
13799
|
throw contractSupportError("getMintConfig", contract, error);
|
|
13406
13800
|
}
|
|
13407
13801
|
}
|
|
13802
|
+
async function readOptionalMintConfig(publicClient, contract) {
|
|
13803
|
+
try {
|
|
13804
|
+
return await readMintConfig(publicClient, contract);
|
|
13805
|
+
} catch (error) {
|
|
13806
|
+
if (isBestEffortReadError(error)) {
|
|
13807
|
+
return void 0;
|
|
13808
|
+
}
|
|
13809
|
+
throw error;
|
|
13810
|
+
}
|
|
13811
|
+
}
|
|
13812
|
+
async function readOptionalStatusString(publicClient, contract, functionName) {
|
|
13813
|
+
try {
|
|
13814
|
+
return await publicClient.readContract({
|
|
13815
|
+
address: contract,
|
|
13816
|
+
abi: collectionStatusAbi,
|
|
13817
|
+
functionName
|
|
13818
|
+
});
|
|
13819
|
+
} catch (error) {
|
|
13820
|
+
if (isBestEffortReadError(error)) {
|
|
13821
|
+
return void 0;
|
|
13822
|
+
}
|
|
13823
|
+
throw error;
|
|
13824
|
+
}
|
|
13825
|
+
}
|
|
13826
|
+
async function readOptionalStatusAddress(publicClient, contract, functionName) {
|
|
13827
|
+
try {
|
|
13828
|
+
return await publicClient.readContract({
|
|
13829
|
+
address: contract,
|
|
13830
|
+
abi: collectionStatusAbi,
|
|
13831
|
+
functionName
|
|
13832
|
+
});
|
|
13833
|
+
} catch (error) {
|
|
13834
|
+
if (isBestEffortReadError(error)) {
|
|
13835
|
+
return void 0;
|
|
13836
|
+
}
|
|
13837
|
+
throw error;
|
|
13838
|
+
}
|
|
13839
|
+
}
|
|
13840
|
+
async function readOptionalStatusBigint(publicClient, contract, functionName) {
|
|
13841
|
+
try {
|
|
13842
|
+
return await publicClient.readContract({
|
|
13843
|
+
address: contract,
|
|
13844
|
+
abi: collectionStatusAbi,
|
|
13845
|
+
functionName
|
|
13846
|
+
});
|
|
13847
|
+
} catch (error) {
|
|
13848
|
+
if (isBestEffortReadError(error)) {
|
|
13849
|
+
return void 0;
|
|
13850
|
+
}
|
|
13851
|
+
throw error;
|
|
13852
|
+
}
|
|
13853
|
+
}
|
|
13854
|
+
async function readOptionalStatusBoolean(publicClient, contract, functionName) {
|
|
13855
|
+
try {
|
|
13856
|
+
return await publicClient.readContract({
|
|
13857
|
+
address: contract,
|
|
13858
|
+
abi: collectionStatusAbi,
|
|
13859
|
+
functionName
|
|
13860
|
+
});
|
|
13861
|
+
} catch (error) {
|
|
13862
|
+
if (isBestEffortReadError(error)) {
|
|
13863
|
+
return void 0;
|
|
13864
|
+
}
|
|
13865
|
+
throw error;
|
|
13866
|
+
}
|
|
13867
|
+
}
|
|
13868
|
+
async function readOptionalTokenOwner(publicClient, contract, tokenId) {
|
|
13869
|
+
try {
|
|
13870
|
+
return await publicClient.readContract({
|
|
13871
|
+
address: contract,
|
|
13872
|
+
abi: collectionStatusAbi,
|
|
13873
|
+
functionName: "ownerOf",
|
|
13874
|
+
args: [tokenId]
|
|
13875
|
+
});
|
|
13876
|
+
} catch (error) {
|
|
13877
|
+
if (isBestEffortReadError(error)) {
|
|
13878
|
+
return void 0;
|
|
13879
|
+
}
|
|
13880
|
+
throw error;
|
|
13881
|
+
}
|
|
13882
|
+
}
|
|
13883
|
+
async function readOptionalTokenUri(publicClient, contract, tokenId) {
|
|
13884
|
+
try {
|
|
13885
|
+
return await publicClient.readContract({
|
|
13886
|
+
address: contract,
|
|
13887
|
+
abi: collectionStatusAbi,
|
|
13888
|
+
functionName: "tokenURI",
|
|
13889
|
+
args: [tokenId]
|
|
13890
|
+
});
|
|
13891
|
+
} catch (error) {
|
|
13892
|
+
if (isBestEffortReadError(error)) {
|
|
13893
|
+
return void 0;
|
|
13894
|
+
}
|
|
13895
|
+
throw error;
|
|
13896
|
+
}
|
|
13897
|
+
}
|
|
13898
|
+
async function readOptionalSupportsInterface(publicClient, contract, interfaceId) {
|
|
13899
|
+
try {
|
|
13900
|
+
return await publicClient.readContract({
|
|
13901
|
+
address: contract,
|
|
13902
|
+
abi: collectionStatusAbi,
|
|
13903
|
+
functionName: "supportsInterface",
|
|
13904
|
+
args: [interfaceId]
|
|
13905
|
+
});
|
|
13906
|
+
} catch (error) {
|
|
13907
|
+
if (isBestEffortReadError(error)) {
|
|
13908
|
+
return void 0;
|
|
13909
|
+
}
|
|
13910
|
+
throw error;
|
|
13911
|
+
}
|
|
13912
|
+
}
|
|
13913
|
+
async function readSupportedInterfaces(publicClient, contract) {
|
|
13914
|
+
const [erc165, erc721, erc721Metadata, erc2981] = await Promise.all([
|
|
13915
|
+
readOptionalSupportsInterface(publicClient, contract, "0x01ffc9a7"),
|
|
13916
|
+
readOptionalSupportsInterface(publicClient, contract, "0x80ac58cd"),
|
|
13917
|
+
readOptionalSupportsInterface(publicClient, contract, "0x5b5e139f"),
|
|
13918
|
+
readOptionalSupportsInterface(publicClient, contract, "0x2a55205a")
|
|
13919
|
+
]);
|
|
13920
|
+
if (erc165 === void 0 && erc721 === void 0 && erc721Metadata === void 0 && erc2981 === void 0) {
|
|
13921
|
+
return void 0;
|
|
13922
|
+
}
|
|
13923
|
+
return {
|
|
13924
|
+
...erc165 === void 0 ? {} : { erc165 },
|
|
13925
|
+
...erc721 === void 0 ? {} : { erc721 },
|
|
13926
|
+
...erc721Metadata === void 0 ? {} : { erc721Metadata },
|
|
13927
|
+
...erc2981 === void 0 ? {} : { erc2981 }
|
|
13928
|
+
};
|
|
13929
|
+
}
|
|
13408
13930
|
async function writeSetDefaultRoyaltyReceiver(opts) {
|
|
13409
13931
|
try {
|
|
13410
13932
|
await opts.publicClient.simulateContract({
|
|
@@ -14181,9 +14703,11 @@ async function runWithPaymentApprovalConsent(params) {
|
|
|
14181
14703
|
log(params.approvalMessage);
|
|
14182
14704
|
log(` Spender: ${error.spenderAddress}`);
|
|
14183
14705
|
log(` Required payment: ${error.requiredAmount.toString()} raw units`);
|
|
14706
|
+
if (!process.stdin.isTTY) {
|
|
14707
|
+
throw new Error(`${params.commandName} requires --yes when an ERC20 approval is required in non-interactive mode.`);
|
|
14708
|
+
}
|
|
14184
14709
|
if (!await confirmApproval()) {
|
|
14185
|
-
|
|
14186
|
-
return void 0;
|
|
14710
|
+
throw new Error("Aborted.");
|
|
14187
14711
|
}
|
|
14188
14712
|
return params.runWithApproval();
|
|
14189
14713
|
}
|
|
@@ -14201,9 +14725,33 @@ async function runWithNftApprovalConsent(params) {
|
|
|
14201
14725
|
log(params.approvalMessage);
|
|
14202
14726
|
log(` NFT contract: ${error.nftAddress}`);
|
|
14203
14727
|
log(` Operator: ${error.operator}`);
|
|
14728
|
+
if (!process.stdin.isTTY) {
|
|
14729
|
+
throw new Error(`${params.commandName} requires --yes when an NFT approval is required in non-interactive mode.`);
|
|
14730
|
+
}
|
|
14204
14731
|
if (!await confirmApproval()) {
|
|
14205
|
-
|
|
14206
|
-
|
|
14732
|
+
throw new Error("Aborted.");
|
|
14733
|
+
}
|
|
14734
|
+
return params.runWithApproval();
|
|
14735
|
+
}
|
|
14736
|
+
}
|
|
14737
|
+
async function runWithMinterApprovalConsent(params) {
|
|
14738
|
+
try {
|
|
14739
|
+
return await params.runWithoutApproval();
|
|
14740
|
+
} catch (error) {
|
|
14741
|
+
if (!(error instanceof MinterApprovalRequiredError)) {
|
|
14742
|
+
throw error;
|
|
14743
|
+
}
|
|
14744
|
+
if (isJsonMode()) {
|
|
14745
|
+
throw new Error(`${params.commandName} requires --yes when a minter approval is required.`);
|
|
14746
|
+
}
|
|
14747
|
+
log(params.approvalMessage);
|
|
14748
|
+
log(` Collection: ${error.collection}`);
|
|
14749
|
+
log(` Minter: ${error.minter}`);
|
|
14750
|
+
if (!process.stdin.isTTY) {
|
|
14751
|
+
throw new Error(`${params.commandName} requires --yes when a minter approval is required in non-interactive mode.`);
|
|
14752
|
+
}
|
|
14753
|
+
if (!await confirmApproval()) {
|
|
14754
|
+
throw new Error("Aborted.");
|
|
14207
14755
|
}
|
|
14208
14756
|
return params.runWithApproval();
|
|
14209
14757
|
}
|
|
@@ -14258,7 +14806,7 @@ function formatSplitLines(splits) {
|
|
|
14258
14806
|
}
|
|
14259
14807
|
|
|
14260
14808
|
// src/commands/batch.ts
|
|
14261
|
-
import { existsSync
|
|
14809
|
+
import { existsSync } from "fs";
|
|
14262
14810
|
import { readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
14263
14811
|
import { createInterface as createInterface3 } from "readline/promises";
|
|
14264
14812
|
import { Command as Command3 } from "commander";
|
|
@@ -14301,7 +14849,7 @@ async function formatBatchAmount(publicClient, chain, currency, amount) {
|
|
|
14301
14849
|
// src/commands/batch.ts
|
|
14302
14850
|
async function resolveRootInput(input) {
|
|
14303
14851
|
if (isHex6(input) && input.length === 66) return input;
|
|
14304
|
-
if (
|
|
14852
|
+
if (existsSync(input)) {
|
|
14305
14853
|
const artifact = await loadMerkleRootArtifact(input);
|
|
14306
14854
|
return artifact.root;
|
|
14307
14855
|
}
|
|
@@ -15779,7 +16327,7 @@ function walletCommand() {
|
|
|
15779
16327
|
const supportedChainsText = supportedChains.join(", ");
|
|
15780
16328
|
cmd.description("Wallet management");
|
|
15781
16329
|
cmd.command("generate").description("Generate a new Ethereum wallet and optionally save it to config").option("--chain <chain>", `chain to save the key to (${supportedChainsText})`).option("--chain-id <id>", `chain ID to use (${Object.entries(chainIds).map(([chain, id]) => `${id} (${chain})`).join(", ")})`).option("--save", "save the generated key to config for the specified chain").action((opts) => {
|
|
15782
|
-
const selectedChain =
|
|
16330
|
+
const selectedChain = getActiveChain(opts.chain, opts.chainId);
|
|
15783
16331
|
const privateKey = generatePrivateKey2();
|
|
15784
16332
|
const account = privateKeyToAccount4(privateKey);
|
|
15785
16333
|
if (opts.save) {
|
|
@@ -16387,7 +16935,7 @@ function releaseCommand() {
|
|
|
16387
16935
|
"--split <addr=ratio>",
|
|
16388
16936
|
"payout split recipient (repeatable). Format: 0xADDR=RATIO. Ratios must sum to 100. If omitted, 100% goes to the connected wallet.",
|
|
16389
16937
|
collectSplit
|
|
16390
|
-
).option("--chain <chain>", "chain to use (mainnet, sepolia)").option("--chain-id <id>", "chain ID (1, 11155111)").action(async (opts) => {
|
|
16938
|
+
).option("--yes", "yes to all prompts and required approvals").option("--chain <chain>", "chain to use (mainnet, sepolia)").option("--chain-id <id>", "chain ID (1, 11155111)").action(async (opts) => {
|
|
16391
16939
|
try {
|
|
16392
16940
|
const splits = finalizeSplits(opts.split);
|
|
16393
16941
|
assertAddressOption(opts.contract, "contract");
|
|
@@ -16422,7 +16970,7 @@ function releaseCommand() {
|
|
|
16422
16970
|
} else {
|
|
16423
16971
|
log(` Splits: ${account.address} = 100%`);
|
|
16424
16972
|
}
|
|
16425
|
-
const
|
|
16973
|
+
const configureParams = {
|
|
16426
16974
|
contract: opts.contract,
|
|
16427
16975
|
currency,
|
|
16428
16976
|
price: opts.price,
|
|
@@ -16430,7 +16978,22 @@ function releaseCommand() {
|
|
|
16430
16978
|
maxMints: normalizedMaxMints,
|
|
16431
16979
|
splitAddresses: splits?.addresses,
|
|
16432
16980
|
splitRatios: splits?.ratios
|
|
16981
|
+
};
|
|
16982
|
+
const result = await runWithMinterApprovalConsent({
|
|
16983
|
+
commandName: "rare listing release configure",
|
|
16984
|
+
approvalMessage: "RareMinter minter approval is required before configuring this release.",
|
|
16985
|
+
runWithoutApproval: async () => rare.listing.release.configure({
|
|
16986
|
+
...configureParams,
|
|
16987
|
+
autoApprove: opts.yes === true
|
|
16988
|
+
}),
|
|
16989
|
+
runWithApproval: async () => rare.listing.release.configure({
|
|
16990
|
+
...configureParams,
|
|
16991
|
+
autoApprove: true
|
|
16992
|
+
})
|
|
16433
16993
|
});
|
|
16994
|
+
if (result === void 0) {
|
|
16995
|
+
return;
|
|
16996
|
+
}
|
|
16434
16997
|
output(
|
|
16435
16998
|
{
|
|
16436
16999
|
txHash: result.txHash,
|
|
@@ -16442,9 +17005,13 @@ function releaseCommand() {
|
|
|
16442
17005
|
startTime: result.startTime,
|
|
16443
17006
|
maxMints: result.maxMints,
|
|
16444
17007
|
splitRecipients: result.splitRecipients,
|
|
16445
|
-
splitRatios: result.splitRatios
|
|
17008
|
+
splitRatios: result.splitRatios,
|
|
17009
|
+
approvalTxHash: result.approvalTxHash ?? null
|
|
16446
17010
|
},
|
|
16447
17011
|
() => {
|
|
17012
|
+
if (result.approvalTxHash !== void 0) {
|
|
17013
|
+
console.log(`Approval transaction sent: ${result.approvalTxHash}`);
|
|
17014
|
+
}
|
|
16448
17015
|
console.log(`
|
|
16449
17016
|
Transaction sent: ${result.txHash}`);
|
|
16450
17017
|
console.log(`Release configured! Block: ${result.receipt.blockNumber}`);
|
|
@@ -17921,16 +18488,21 @@ Minted token range: ${result.fromTokenId.toString()}-${result.toTokenId.toString
|
|
|
17921
18488
|
function createPrepareLazyMintCommand() {
|
|
17922
18489
|
const cmd = new Command15("prepare-lazy-mint");
|
|
17923
18490
|
cmd.description("Prepare a Lazy Sovereign collection mint batch");
|
|
17924
|
-
cmd.requiredOption("--contract <address>", "collection contract address").requiredOption("--base-uri <uri>", "base URI for token metadata").requiredOption("--amount <number>", "number of tokens to prepare").option("--minter <address>", "optional approved minter address").option("--chain <chain>", "chain to use (mainnet, sepolia, base, base-sepolia)").option("--chain-id <id>", "chain ID (1, 11155111, 8453, 84532)").action(async (opts) => {
|
|
18491
|
+
cmd.requiredOption("--contract <address>", "collection contract address").requiredOption("--base-uri <uri>", "base URI for token metadata").requiredOption("--amount <number>", "number of tokens to prepare").option("--minter <address|rare-minter>", "optional approved minter address").option("--chain <chain>", "chain to use (mainnet, sepolia, base, base-sepolia)").option("--chain-id <id>", "chain ID (1, 11155111, 8453, 84532)").action(async (opts) => {
|
|
17925
18492
|
try {
|
|
17926
18493
|
const contract = parseAddressOption2(opts.contract, "--contract");
|
|
17927
18494
|
const amount = opts.amount;
|
|
17928
18495
|
if (amount === void 0) {
|
|
17929
18496
|
throw new Error("collection prepare-lazy-mint requires --amount.");
|
|
17930
18497
|
}
|
|
17931
|
-
const minter = opts.minter === void 0 ? void 0 : parseAddressOption2(opts.minter, "--minter");
|
|
17932
|
-
const plan = planCollectionPrepareLazyMint({ contract, baseUri: opts.baseUri, amount, minter });
|
|
17933
18498
|
const chain = getActiveChain(opts.chain, opts.chainId);
|
|
18499
|
+
const minter = resolveOptionalCollectionMinter(
|
|
18500
|
+
opts.minter,
|
|
18501
|
+
getContractAddresses(chain).rareMinter,
|
|
18502
|
+
chain,
|
|
18503
|
+
"--minter"
|
|
18504
|
+
);
|
|
18505
|
+
const plan = planCollectionPrepareLazyMint({ contract, baseUri: opts.baseUri, amount, minter });
|
|
17934
18506
|
const { client } = getWalletClient(chain);
|
|
17935
18507
|
const publicClient = getPublicClient(chain);
|
|
17936
18508
|
const rare = createRareClient({ publicClient, walletClient: client });
|
|
@@ -18152,9 +18724,80 @@ function createRoyaltyCommand() {
|
|
|
18152
18724
|
cmd.addCommand(createSetTokenRoyaltyReceiverCommand());
|
|
18153
18725
|
return cmd;
|
|
18154
18726
|
}
|
|
18727
|
+
function createCollectionStatusCommand() {
|
|
18728
|
+
const cmd = new Command15("status");
|
|
18729
|
+
cmd.description("Read best-effort status from any supported NFT collection contract");
|
|
18730
|
+
cmd.requiredOption("--contract <address>", "collection contract address").option("--token-id <id>", "optional token ID for token-specific status").option("--price <raw>", "raw sale price units used for the token royalty quote").option("--chain <chain>", "chain to use (mainnet, sepolia, base, base-sepolia)").option("--chain-id <id>", "chain ID (1, 11155111, 8453, 84532)").action(async (opts) => {
|
|
18731
|
+
try {
|
|
18732
|
+
const contract = parseAddressOption2(opts.contract, "--contract");
|
|
18733
|
+
const { chain, rare } = createReadCollectionClient(opts.chain, opts.chainId);
|
|
18734
|
+
const result = await rare.collection.status({
|
|
18735
|
+
contract,
|
|
18736
|
+
tokenId: opts.tokenId,
|
|
18737
|
+
price: opts.price
|
|
18738
|
+
});
|
|
18739
|
+
output(
|
|
18740
|
+
{
|
|
18741
|
+
chain,
|
|
18742
|
+
...result
|
|
18743
|
+
},
|
|
18744
|
+
() => {
|
|
18745
|
+
console.log(`Contract: ${result.contract}`);
|
|
18746
|
+
if (result.name !== void 0) console.log(`Name: ${result.name}`);
|
|
18747
|
+
if (result.symbol !== void 0) console.log(`Symbol: ${result.symbol}`);
|
|
18748
|
+
if (result.owner !== void 0) console.log(`Owner: ${result.owner}`);
|
|
18749
|
+
if (result.totalSupply !== void 0) console.log(`Total supply: ${result.totalSupply.toString()}`);
|
|
18750
|
+
if (result.maxTokens !== void 0) console.log(`Max tokens: ${result.maxTokens.toString()}`);
|
|
18751
|
+
if (result.disabled !== void 0) console.log(`Disabled: ${result.disabled ? "yes" : "no"}`);
|
|
18752
|
+
if (result.tokenUrisLocked !== void 0) {
|
|
18753
|
+
console.log(`Token URIs locked: ${result.tokenUrisLocked ? "yes" : "no"}`);
|
|
18754
|
+
}
|
|
18755
|
+
if (result.batchCount !== void 0) console.log(`Batch count: ${result.batchCount.toString()}`);
|
|
18756
|
+
if (result.defaultReceiver !== void 0) console.log(`Default royalty receiver: ${result.defaultReceiver}`);
|
|
18757
|
+
if (result.defaultPercentage !== void 0) {
|
|
18758
|
+
console.log(`Default royalty percentage: ${result.defaultPercentage.toString()}%`);
|
|
18759
|
+
}
|
|
18760
|
+
if (result.mintConfig !== void 0) {
|
|
18761
|
+
console.log(`Mint config token count: ${result.mintConfig.tokenCount.toString()}`);
|
|
18762
|
+
console.log(`Mint config base URI: ${result.mintConfig.baseUri}`);
|
|
18763
|
+
console.log(`Mint config locked metadata: ${result.mintConfig.lockedMetadata ? "yes" : "no"}`);
|
|
18764
|
+
}
|
|
18765
|
+
if (result.interfaces !== void 0) {
|
|
18766
|
+
if (result.interfaces.erc165 !== void 0) {
|
|
18767
|
+
console.log(`ERC-165: ${result.interfaces.erc165 ? "yes" : "no"}`);
|
|
18768
|
+
}
|
|
18769
|
+
if (result.interfaces.erc721 !== void 0) {
|
|
18770
|
+
console.log(`ERC-721: ${result.interfaces.erc721 ? "yes" : "no"}`);
|
|
18771
|
+
}
|
|
18772
|
+
if (result.interfaces.erc721Metadata !== void 0) {
|
|
18773
|
+
console.log(`ERC-721 metadata: ${result.interfaces.erc721Metadata ? "yes" : "no"}`);
|
|
18774
|
+
}
|
|
18775
|
+
if (result.interfaces.erc2981 !== void 0) {
|
|
18776
|
+
console.log(`ERC-2981 royalties: ${result.interfaces.erc2981 ? "yes" : "no"}`);
|
|
18777
|
+
}
|
|
18778
|
+
}
|
|
18779
|
+
if (result.token !== void 0) {
|
|
18780
|
+
console.log(`Token ID: ${result.token.tokenId.toString()}`);
|
|
18781
|
+
if (result.token.owner !== void 0) console.log(`Token owner: ${result.token.owner}`);
|
|
18782
|
+
if (result.token.tokenUri !== void 0) console.log(`Token URI: ${result.token.tokenUri}`);
|
|
18783
|
+
if (result.token.creator !== void 0) console.log(`Token creator: ${result.token.creator}`);
|
|
18784
|
+
if (result.token.royalty !== void 0) {
|
|
18785
|
+
console.log(`Token royalty receiver: ${result.token.royalty.receiver}`);
|
|
18786
|
+
console.log(`Token royalty amount: ${result.token.royalty.amount.toString()}`);
|
|
18787
|
+
console.log(`Token royalty sale price: ${result.token.royalty.salePrice.toString()}`);
|
|
18788
|
+
}
|
|
18789
|
+
}
|
|
18790
|
+
}
|
|
18791
|
+
);
|
|
18792
|
+
} catch (error) {
|
|
18793
|
+
printError(error);
|
|
18794
|
+
}
|
|
18795
|
+
});
|
|
18796
|
+
return cmd;
|
|
18797
|
+
}
|
|
18155
18798
|
function createMetadataStatusCommand() {
|
|
18156
18799
|
const cmd = new Command15("status");
|
|
18157
|
-
cmd.description("Read Lazy Sovereign mint metadata configuration");
|
|
18800
|
+
cmd.description("Read Lazy Sovereign mint metadata configuration when available");
|
|
18158
18801
|
cmd.requiredOption("--contract <address>", "collection contract address").option("--chain <chain>", "chain to use (mainnet, sepolia, base, base-sepolia)").option("--chain-id <id>", "chain ID (1, 11155111, 8453, 84532)").action(async (opts) => {
|
|
18159
18802
|
try {
|
|
18160
18803
|
const contract = parseAddressOption2(opts.contract, "--contract");
|
|
@@ -18169,9 +18812,14 @@ function createMetadataStatusCommand() {
|
|
|
18169
18812
|
lockedMetadata: result.lockedMetadata
|
|
18170
18813
|
},
|
|
18171
18814
|
() => {
|
|
18172
|
-
console.log(`Base URI: ${result.baseUri}`);
|
|
18173
|
-
console.log(`Token count: ${result.tokenCount.toString()}`);
|
|
18174
|
-
|
|
18815
|
+
if (result.baseUri !== void 0) console.log(`Base URI: ${result.baseUri}`);
|
|
18816
|
+
if (result.tokenCount !== void 0) console.log(`Token count: ${result.tokenCount.toString()}`);
|
|
18817
|
+
if (result.lockedMetadata !== void 0) {
|
|
18818
|
+
console.log(`Locked metadata: ${result.lockedMetadata ? "yes" : "no"}`);
|
|
18819
|
+
}
|
|
18820
|
+
if (result.baseUri === void 0 && result.tokenCount === void 0 && result.lockedMetadata === void 0) {
|
|
18821
|
+
console.log("Lazy mint metadata: not available");
|
|
18822
|
+
}
|
|
18175
18823
|
}
|
|
18176
18824
|
);
|
|
18177
18825
|
} catch (error) {
|
|
@@ -18300,6 +18948,7 @@ function collectionCommand() {
|
|
|
18300
18948
|
const cmd = new Command15("collection");
|
|
18301
18949
|
cmd.description("Create and manage NFT collections");
|
|
18302
18950
|
cmd.addCommand(createCollectionGetCommand());
|
|
18951
|
+
cmd.addCommand(createCollectionStatusCommand());
|
|
18303
18952
|
cmd.addCommand(createCollectionListCommand());
|
|
18304
18953
|
cmd.addCommand(createCollectionDeployCommand());
|
|
18305
18954
|
cmd.addCommand(mintCommand());
|
|
@@ -18350,6 +18999,27 @@ function parseAddressOption2(value, optionName) {
|
|
|
18350
18999
|
}
|
|
18351
19000
|
return getAddress13(value);
|
|
18352
19001
|
}
|
|
19002
|
+
function resolveOptionalCollectionMinter(value, rareMinter, chain, optionName) {
|
|
19003
|
+
if (value === void 0) {
|
|
19004
|
+
return void 0;
|
|
19005
|
+
}
|
|
19006
|
+
return resolveCollectionMinter(value, rareMinter, chain, optionName);
|
|
19007
|
+
}
|
|
19008
|
+
function resolveCollectionMinter(value, rareMinter, chain, optionName) {
|
|
19009
|
+
if (value === void 0 || isRareMinterAlias(value)) {
|
|
19010
|
+
if (rareMinter === void 0) {
|
|
19011
|
+
throw new Error(
|
|
19012
|
+
`${optionName} must be a valid 0x address because RareMinter is not configured on "${chain}".`
|
|
19013
|
+
);
|
|
19014
|
+
}
|
|
19015
|
+
return rareMinter;
|
|
19016
|
+
}
|
|
19017
|
+
return parseAddressOption2(value, optionName);
|
|
19018
|
+
}
|
|
19019
|
+
function isRareMinterAlias(value) {
|
|
19020
|
+
const normalized = value.trim().toLowerCase();
|
|
19021
|
+
return normalized === "rare-minter" || normalized === "rareminter";
|
|
19022
|
+
}
|
|
18353
19023
|
|
|
18354
19024
|
// src/commands/currencies.ts
|
|
18355
19025
|
import { Command as Command16 } from "commander";
|
|
@@ -18502,7 +19172,6 @@ import { formatEther as formatEther3 } from "viem";
|
|
|
18502
19172
|
|
|
18503
19173
|
// src/commands/swap-core.ts
|
|
18504
19174
|
import { formatEther as formatEther2, formatUnits as formatUnits9, getAddress as getAddress14, isHex as isHex7 } from "viem";
|
|
18505
|
-
var tokenTradeExecutionRoutes = ["auto", "local", "uniswap", "raw"];
|
|
18506
19175
|
function parseInputsJson(raw, label) {
|
|
18507
19176
|
const parsed = parseJson4(raw, label);
|
|
18508
19177
|
if (!Array.isArray(parsed)) {
|
|
@@ -18542,8 +19211,12 @@ function parseTokenTradeExecutionRoute(value) {
|
|
|
18542
19211
|
if (value === void 0) {
|
|
18543
19212
|
return "auto";
|
|
18544
19213
|
}
|
|
18545
|
-
|
|
18546
|
-
|
|
19214
|
+
switch (value) {
|
|
19215
|
+
case "auto":
|
|
19216
|
+
case "local":
|
|
19217
|
+
case "uniswap":
|
|
19218
|
+
case "raw":
|
|
19219
|
+
return value;
|
|
18547
19220
|
}
|
|
18548
19221
|
throw new Error("--route must be one of: auto, local, uniswap, raw.");
|
|
18549
19222
|
}
|
|
@@ -18726,7 +19399,13 @@ function swapBuyTokenCommand() {
|
|
|
18726
19399
|
return;
|
|
18727
19400
|
}
|
|
18728
19401
|
const wallet = quoteOnly ? void 0 : getWalletClient(chain);
|
|
18729
|
-
const
|
|
19402
|
+
const resolveUniswapApiKey2 = async () => getConfiguredUniswapApiKey(chain);
|
|
19403
|
+
const configuredAccount = wallet === void 0 ? getConfiguredAccountAddress(chain) : void 0;
|
|
19404
|
+
const rare = wallet === void 0 ? createRareClient({
|
|
19405
|
+
publicClient,
|
|
19406
|
+
...configuredAccount === void 0 ? {} : { account: configuredAccount },
|
|
19407
|
+
resolveUniswapApiKey: resolveUniswapApiKey2
|
|
19408
|
+
}) : createRareClient({ publicClient, walletClient: wallet.client, resolveUniswapApiKey: resolveUniswapApiKey2 });
|
|
18730
19409
|
const recipient = explicitRecipient ?? wallet?.account.address;
|
|
18731
19410
|
const quote = await rare.swap.quoteBuyToken({
|
|
18732
19411
|
token,
|
|
@@ -18872,7 +19551,13 @@ function swapSellTokenCommand() {
|
|
|
18872
19551
|
return;
|
|
18873
19552
|
}
|
|
18874
19553
|
const wallet = quoteOnly ? void 0 : getWalletClient(chain);
|
|
18875
|
-
const
|
|
19554
|
+
const resolveUniswapApiKey2 = async () => getConfiguredUniswapApiKey(chain);
|
|
19555
|
+
const configuredAccount = wallet === void 0 ? getConfiguredAccountAddress(chain) : void 0;
|
|
19556
|
+
const rare = wallet === void 0 ? createRareClient({
|
|
19557
|
+
publicClient,
|
|
19558
|
+
...configuredAccount === void 0 ? {} : { account: configuredAccount },
|
|
19559
|
+
resolveUniswapApiKey: resolveUniswapApiKey2
|
|
19560
|
+
}) : createRareClient({ publicClient, walletClient: wallet.client, resolveUniswapApiKey: resolveUniswapApiKey2 });
|
|
18876
19561
|
const recipient = explicitRecipient ?? wallet?.account.address;
|
|
18877
19562
|
const quote = await rare.swap.quoteSellToken({
|
|
18878
19563
|
token,
|
|
@@ -19106,10 +19791,123 @@ function requiresExplicitConfirmation(commandPath2) {
|
|
|
19106
19791
|
return confirmationRequiredCommands.has(commandPath2.join(" "));
|
|
19107
19792
|
}
|
|
19108
19793
|
|
|
19794
|
+
// package.json
|
|
19795
|
+
var package_default = {
|
|
19796
|
+
name: "@rareprotocol/rare-cli",
|
|
19797
|
+
version: "1.0.2",
|
|
19798
|
+
description: "CLI tool for interacting with the RARE protocol smart contracts",
|
|
19799
|
+
type: "module",
|
|
19800
|
+
license: "MIT",
|
|
19801
|
+
repository: {
|
|
19802
|
+
type: "git",
|
|
19803
|
+
url: "https://github.com/superrare/rare-cli.git"
|
|
19804
|
+
},
|
|
19805
|
+
homepage: "https://github.com/superrare/rare-cli#readme",
|
|
19806
|
+
keywords: [
|
|
19807
|
+
"rare",
|
|
19808
|
+
"superrare",
|
|
19809
|
+
"nft",
|
|
19810
|
+
"ethereum",
|
|
19811
|
+
"cli",
|
|
19812
|
+
"auction",
|
|
19813
|
+
"erc721"
|
|
19814
|
+
],
|
|
19815
|
+
engines: {
|
|
19816
|
+
node: ">=22"
|
|
19817
|
+
},
|
|
19818
|
+
publishConfig: {
|
|
19819
|
+
access: "public"
|
|
19820
|
+
},
|
|
19821
|
+
files: [
|
|
19822
|
+
"dist",
|
|
19823
|
+
"LICENSE"
|
|
19824
|
+
],
|
|
19825
|
+
exports: {
|
|
19826
|
+
"./client": {
|
|
19827
|
+
import: "./dist/client.js",
|
|
19828
|
+
types: "./dist/client.d.ts"
|
|
19829
|
+
},
|
|
19830
|
+
"./contracts": {
|
|
19831
|
+
import: "./dist/contracts.js",
|
|
19832
|
+
types: "./dist/contracts.d.ts"
|
|
19833
|
+
},
|
|
19834
|
+
"./utils": {
|
|
19835
|
+
import: "./dist/utils.js",
|
|
19836
|
+
types: "./dist/utils.d.ts"
|
|
19837
|
+
}
|
|
19838
|
+
},
|
|
19839
|
+
typesVersions: {
|
|
19840
|
+
"*": {
|
|
19841
|
+
client: [
|
|
19842
|
+
"dist/client.d.ts"
|
|
19843
|
+
],
|
|
19844
|
+
contracts: [
|
|
19845
|
+
"dist/contracts.d.ts"
|
|
19846
|
+
],
|
|
19847
|
+
utils: [
|
|
19848
|
+
"dist/utils.d.ts"
|
|
19849
|
+
]
|
|
19850
|
+
}
|
|
19851
|
+
},
|
|
19852
|
+
bin: {
|
|
19853
|
+
rare: "./dist/index.js"
|
|
19854
|
+
},
|
|
19855
|
+
scripts: {
|
|
19856
|
+
typecheck: "tsc --noEmit",
|
|
19857
|
+
build: "npm run typecheck && tsup",
|
|
19858
|
+
dev: "tsup --watch",
|
|
19859
|
+
"docs:generate": "typedoc && tsx scripts/postprocess-sdk-docs.ts && tsx scripts/generate-sdk-method-docs.ts && tsx scripts/generate-cli-docs.ts",
|
|
19860
|
+
"docs:serve": "npm run docs:generate && docusaurus start docs-site --no-open",
|
|
19861
|
+
"docs:build": "npm run docs:generate && docusaurus build docs-site --out-dir ../.docs-build",
|
|
19862
|
+
"docs:preview": "npm run docs:build && docusaurus serve docs-site --dir ../.docs-build --no-open",
|
|
19863
|
+
"generate:types": "set -a; [ -f .env ] && . ./.env; set +a; openapi-typescript ${RARE_API_BASE_URL:-https://api.superrare.com}/doc -o src/data-access/schema.d.ts",
|
|
19864
|
+
knip: "knip",
|
|
19865
|
+
lint: "eslint .",
|
|
19866
|
+
"lint:fix": "eslint . --fix",
|
|
19867
|
+
"test:typecheck": "tsc -p tsconfig.test.json --noEmit",
|
|
19868
|
+
test: "npm run build && npm run test:typecheck && vitest run test/unit test/integration test/e2e --config vitest.config.ts",
|
|
19869
|
+
"test:live": "npm run build && npm run test:typecheck && vitest run test/unit test/integration test/e2e test/e2e-live --config vitest.config.ts",
|
|
19870
|
+
"test:clear-locks": "node scripts/clear-locks.mjs",
|
|
19871
|
+
"test:coverage": "npm run build && npm run test:typecheck && vitest run test/unit test/integration test/e2e --coverage --config vitest.config.ts",
|
|
19872
|
+
prepare: "npm run build",
|
|
19873
|
+
prepublishOnly: "npm run build"
|
|
19874
|
+
},
|
|
19875
|
+
dependencies: {
|
|
19876
|
+
commander: "12.1.0",
|
|
19877
|
+
merkletreejs: "0.6.0",
|
|
19878
|
+
"openapi-fetch": "0.17.0",
|
|
19879
|
+
viem: "2.48.8"
|
|
19880
|
+
},
|
|
19881
|
+
devDependencies: {
|
|
19882
|
+
"@docusaurus/core": "^3.10.1",
|
|
19883
|
+
"@docusaurus/preset-classic": "^3.10.1",
|
|
19884
|
+
"@eslint/js": "10.0.1",
|
|
19885
|
+
"@types/node": "25.6.0",
|
|
19886
|
+
"@typescript-eslint/parser": "8.59.3",
|
|
19887
|
+
"@typescript-eslint/rule-tester": "8.59.2",
|
|
19888
|
+
"@typescript-eslint/utils": "8.59.2",
|
|
19889
|
+
"@vitest/coverage-v8": "4.1.5",
|
|
19890
|
+
eslint: "10.3.0",
|
|
19891
|
+
"eslint-plugin-functional": "9.0.4",
|
|
19892
|
+
globals: "17.6.0",
|
|
19893
|
+
knip: "5.88.1",
|
|
19894
|
+
"openapi-typescript": "7.13.0",
|
|
19895
|
+
tslib: "^2.8.1",
|
|
19896
|
+
tsup: "8.5.1",
|
|
19897
|
+
tsx: "^4.22.3",
|
|
19898
|
+
typedoc: "^0.28.19",
|
|
19899
|
+
"typedoc-plugin-markdown": "^4.11.0",
|
|
19900
|
+
typescript: "5.9.3",
|
|
19901
|
+
"typescript-eslint": "8.59.2",
|
|
19902
|
+
vitest: "4.1.5",
|
|
19903
|
+
webpack: "5.95.0"
|
|
19904
|
+
}
|
|
19905
|
+
};
|
|
19906
|
+
|
|
19109
19907
|
// src/program.ts
|
|
19110
19908
|
function createRareProgram() {
|
|
19111
19909
|
const program2 = new Command21();
|
|
19112
|
-
program2.name("rare").description("CLI tool for interacting with the RARE protocol smart contracts").version(
|
|
19910
|
+
program2.name("rare").description("CLI tool for interacting with the RARE protocol smart contracts").version(package_default.version).option("--json", "output results as JSON");
|
|
19113
19911
|
program2.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
19114
19912
|
const decision = confirmationDecision(program2, actionCommand);
|
|
19115
19913
|
if (decision === "reject-json") {
|
|
@@ -19176,7 +19974,6 @@ async function confirmProceed2() {
|
|
|
19176
19974
|
}
|
|
19177
19975
|
|
|
19178
19976
|
// src/index.ts
|
|
19179
|
-
loadDotEnv();
|
|
19180
19977
|
var program = createRareProgram();
|
|
19181
19978
|
program.parseAsync(process.argv).catch((err) => {
|
|
19182
19979
|
printError(err);
|