@toon-protocol/rig 2.10.1 → 2.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/rig.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  setHeadSymref,
19
19
  updateRef,
20
20
  writeGitObjects
21
- } from "../chunk-PG5PUKDR.js";
21
+ } from "../chunk-EEUHZNWS.js";
22
22
  import {
23
23
  DEFAULT_KEYSTORE_PASSWORD,
24
24
  MissingIdentityError,
@@ -37,8 +37,9 @@ import {
37
37
  resolveConflictingPath
38
38
  } from "../chunk-FQXNLPUR.js";
39
39
  import {
40
- MAX_OBJECT_SIZE
41
- } from "../chunk-B5ISARMU.js";
40
+ MAX_OBJECT_SIZE,
41
+ flooredUploadFee
42
+ } from "../chunk-35ALWUDJ.js";
42
43
  import {
43
44
  COMMENT_KIND,
44
45
  authorizedStatusAuthors,
@@ -1073,7 +1074,7 @@ function loadPaidSession(deps, relayUrl) {
1073
1074
  });
1074
1075
  }
1075
1076
  var defaultLoadStandalone = async (options) => {
1076
- const mod = await import("../standalone-mode-T6H7OOBQ.js");
1077
+ const mod = await import("../standalone-mode-YMIY4GL3.js");
1077
1078
  return mod.createStandaloneContext(options);
1078
1079
  };
1079
1080
  function identityReport(ctx) {
@@ -1245,7 +1246,7 @@ function planRigPointer(args) {
1245
1246
  html,
1246
1247
  contentHash,
1247
1248
  bytes,
1248
- fee: BigInt(bytes) * args.uploadFeePerByte
1249
+ fee: flooredUploadFee(bytes, args.uploadFeePerByte, args.minUploadFee)
1249
1250
  };
1250
1251
  }
1251
1252
  async function runPush(args, deps) {
@@ -1365,7 +1366,8 @@ async function runPush(args, deps) {
1365
1366
  ownerPubkey: ctx.ownerPubkey,
1366
1367
  repoId,
1367
1368
  relay: relaysUsed[0],
1368
- uploadFeePerByte: feeRates.uploadFeePerByte
1369
+ uploadFeePerByte: feeRates.uploadFeePerByte,
1370
+ ...feeRates.minUploadFee !== void 0 ? { minUploadFee: feeRates.minUploadFee } : {}
1369
1371
  });
1370
1372
  }
1371
1373
  } else {
@@ -3818,21 +3820,35 @@ import { join as join3 } from "path";
3818
3820
  import { parseArgs as parseArgs9 } from "util";
3819
3821
  var DEVNET_FAUCET_URL = "https://faucet.devnet.toonprotocol.dev";
3820
3822
  var CHAINS = ["evm", "solana", "mina"];
3821
- var CHAIN_CHOICES = [...CHAINS, "all"];
3822
- var NATIVE_COIN = {
3823
- evm: "ETH",
3824
- solana: "SOL",
3825
- mina: "MINA"
3823
+ var CHAIN_ALIASES = {
3824
+ evm: "evm",
3825
+ eth: "evm",
3826
+ sol: "solana",
3827
+ solana: "solana",
3828
+ mina: "mina",
3829
+ all: "all"
3826
3830
  };
3827
- var FUND_USAGE = `Usage: rig fund [options]
3831
+ var CHAIN_ARG_LIST = "evm | sol | solana | mina | all";
3832
+ function resolveChainArg(raw) {
3833
+ if (raw === void 0) return void 0;
3834
+ const canonical = CHAIN_ALIASES[raw.toLowerCase()];
3835
+ if (!canonical) {
3836
+ throw new Error(
3837
+ `chain must be one of ${CHAIN_ARG_LIST}, got ${JSON.stringify(raw)}`
3838
+ );
3839
+ }
3840
+ return canonical;
3841
+ }
3842
+ var FUND_USAGE = `Usage: rig fund [chain] [options]
3828
3843
 
3829
- Drip devnet test funds to the active identity's wallet \u2014 free (the faucet
3830
- pays). By default funds ALL supported chains (evm + solana + mina), each drip
3831
- covering the native coin AND USDC, so the wallet matches the multi-chain
3832
- \`rig balance\` view in one run. The per-chain drips run in parallel and are
3833
- independent \u2014 one chain's faucet failing does not abort the others (exit 0
3834
- only when every targeted chain funded; exit 1 if any failed, with the
3835
- per-chain breakdown always shown).
3844
+ Drip devnet USDC to the active identity's wallet \u2014 free (the faucet pays). Each
3845
+ drip funds ONLY the settlement token (USDC) and assumes the wallet already holds
3846
+ enough native gas to transact. By default funds ALL supported chains (evm +
3847
+ solana + mina) so the wallet matches the multi-chain \`rig balance\` view in one
3848
+ run; name a chain \u2014 positional (\`rig fund sol\`) or \`--chain\` \u2014 to narrow to
3849
+ one. The per-chain drips run in parallel and are independent \u2014 one chain's
3850
+ faucet failing does not abort the others (exit 0 only when every targeted chain
3851
+ funded; exit 1 if any failed, with the per-chain breakdown always shown).
3836
3852
 
3837
3853
  The identity comes from RIG_MNEMONIC (env or a project .env) or the
3838
3854
  ~/.toon-client keystore/config; the faucet from TOON_CLIENT_FAUCET_URL, the
@@ -3844,10 +3860,11 @@ chain (there is no --amount). On a network without a faucet, prints the wallet
3844
3860
  address(es) to fund externally instead.
3845
3861
 
3846
3862
  Options:
3847
- --chain <chain> evm | solana | mina | all \u2014 fund one chain, or all
3848
- (default: all supported chains)
3863
+ [chain] evm | sol | solana | mina | all \u2014 positional chain to
3864
+ fund (default: all supported chains)
3865
+ --chain <chain> same as the positional chain argument
3849
3866
  --address <address> fund this address instead of the identity's own
3850
- (requires an explicit single --chain)
3867
+ (requires an explicit single chain)
3851
3868
  --json machine-readable envelope (per-chain results array)
3852
3869
  -h, --help show this help`;
3853
3870
  var SHARED_DEVNET_SUFFIX = ".devnet.toonprotocol.dev";
@@ -3922,12 +3939,13 @@ function readFundConfig(env) {
3922
3939
  }
3923
3940
  async function runFund(args, deps) {
3924
3941
  const { io: io2, env } = deps;
3925
- let chainFlag;
3942
+ let resolvedChain;
3926
3943
  let addressFlag;
3927
3944
  let json = false;
3928
3945
  try {
3929
- const { values } = parseArgs9({
3946
+ const { values, positionals } = parseArgs9({
3930
3947
  args,
3948
+ allowPositionals: true,
3931
3949
  options: {
3932
3950
  chain: { type: "string" },
3933
3951
  address: { type: "string" },
@@ -3939,17 +3957,23 @@ async function runFund(args, deps) {
3939
3957
  io2.out(FUND_USAGE);
3940
3958
  return 0;
3941
3959
  }
3942
- chainFlag = values.chain;
3943
- addressFlag = values.address;
3944
- json = values.json ?? false;
3945
- if (chainFlag !== void 0 && !CHAIN_CHOICES.includes(chainFlag)) {
3960
+ if (positionals.length > 1) {
3946
3961
  throw new Error(
3947
- `--chain must be one of ${CHAIN_CHOICES.join(" | ")}, got ${JSON.stringify(chainFlag)}`
3962
+ `rig fund takes at most one chain argument, got ${positionals.length}: ${positionals.join(" ")}`
3948
3963
  );
3949
3964
  }
3950
- if (addressFlag !== void 0 && (chainFlag === void 0 || chainFlag === "all")) {
3965
+ const positionalChain = positionals[0];
3966
+ if (positionalChain !== void 0 && values.chain !== void 0) {
3951
3967
  throw new Error(
3952
- "--address requires an explicit single --chain (evm | solana | mina) \u2014 a single address cannot fund every chain"
3968
+ "give the chain as a positional argument (`rig fund sol`) OR with --chain, not both"
3969
+ );
3970
+ }
3971
+ resolvedChain = resolveChainArg(positionalChain ?? values.chain);
3972
+ addressFlag = values.address;
3973
+ json = values.json ?? false;
3974
+ if (addressFlag !== void 0 && (resolvedChain === void 0 || resolvedChain === "all")) {
3975
+ throw new Error(
3976
+ `--address requires an explicit single chain (${CHAIN_ARG_LIST}) \u2014 a single address cannot fund every chain`
3953
3977
  );
3954
3978
  }
3955
3979
  } catch (err) {
@@ -3959,7 +3983,7 @@ async function runFund(args, deps) {
3959
3983
  }
3960
3984
  try {
3961
3985
  const { file } = readFundConfig(env);
3962
- const targetChains = chainFlag === void 0 || chainFlag === "all" ? [...CHAINS] : [chainFlag];
3986
+ const targetChains = resolvedChain === void 0 || resolvedChain === "all" ? [...CHAINS] : [resolvedChain];
3963
3987
  const network = env["TOON_CLIENT_NETWORK"] ?? file.network;
3964
3988
  const canInfer = network === void 0 || network === "custom";
3965
3989
  const originRelays = canInfer ? await resolveOriginRelays(deps.cwd) : [];
@@ -4022,7 +4046,7 @@ async function runFund(args, deps) {
4022
4046
  if (!json) {
4023
4047
  const list = targetChains.join(", ");
4024
4048
  io2.out(
4025
- `Requesting ${targetChains.length === 1 ? "" : "parallel "}drip${targetChains.length === 1 ? "" : "s"} from ${faucetUrl} for ${list} \u2026` + (targetChains.includes("mina") ? " (mina settles slowly; this can take ~2 minutes)" : "")
4049
+ `Requesting ${targetChains.length === 1 ? "" : "parallel "}USDC drip${targetChains.length === 1 ? "" : "s"} from ${faucetUrl} for ${list} \u2026` + (targetChains.includes("mina") ? " (mina settles slowly; this can take ~2 minutes)" : "")
4026
4050
  );
4027
4051
  }
4028
4052
  const singleChain = targetChains.length === 1;
@@ -4079,7 +4103,7 @@ async function runFund(args, deps) {
4079
4103
  if (r.funded) {
4080
4104
  const slow = r.elapsedMs !== void 0 && r.elapsedMs >= 5e3;
4081
4105
  const time = slow ? ` (${Math.round(r.elapsedMs / 1e3)}s)` : "";
4082
- io2.out(` ${label} \u2713 funded (${NATIVE_COIN[r.chain]} + USDC)${addr}${time}`);
4106
+ io2.out(` ${label} \u2713 funded (USDC)${addr}${time}`);
4083
4107
  } else {
4084
4108
  io2.out(` ${label} \u2717${addr} \u2014 ${r.error ?? "failed"}`);
4085
4109
  }
@@ -4691,7 +4715,7 @@ async function resolveProfileRelay(flagRelay, originRelay, toonRelays) {
4691
4715
  ].filter((u) => u !== void 0 && isWebSocketRelay2(u));
4692
4716
  if (candidates[0] !== void 0) return candidates[0];
4693
4717
  try {
4694
- const { loadGenesisSeed } = await import("../network-bootstrap-HV5VUZFU.js");
4718
+ const { loadGenesisSeed } = await import("../network-bootstrap-IHQ4PWUW.js");
4695
4719
  const seed = loadGenesisSeed();
4696
4720
  if (seed?.relayUrl && isWebSocketRelay2(seed.relayUrl)) return seed.relayUrl;
4697
4721
  } catch {
@@ -5632,6 +5656,11 @@ Commands:
5632
5656
  gas-station path (kind:5096) \u2014 you author and
5633
5657
  partial-sign, the DVM co-signs as fee payer and pays
5634
5658
  the lamports; needs ZERO SOL in this wallet.
5659
+ <txId> may instead be given via --tx-id <id> \u2014 use
5660
+ that instead of the positional when the txId leads
5661
+ with '-' or '_' (Arweave txids are base64url). For a
5662
+ leading '-' write --tx-id=<id> (the '=' form), since
5663
+ "--tx-id -XYZ..." is itself ambiguous to the parser.
5635
5664
  name status <name> FREE: registry record (lease/permabuy, expiry), ANT
5636
5665
  process id, current target txId(s), TTL, undernames.
5637
5666
 
@@ -5642,6 +5671,10 @@ Options:
5642
5671
  --undername <sub> target the undername <sub>_<name> instead of the base
5643
5672
  name (set)
5644
5673
  --ttl <seconds> record TTL in seconds (set; default 3600)
5674
+ --tx-id <id> set only: the Arweave txId to point at, as an
5675
+ explicit option instead of the positional (mutually
5676
+ exclusive with the positional <txId>). For a value
5677
+ leading with '-' use --tx-id=<id>.
5645
5678
  --network <net> cluster: mainnet | devnet (default mainnet; or
5646
5679
  RIG_ARIO_NETWORK). ar.io has no Solana-testnet
5647
5680
  deployment. Non-mainnet gateway resolution is
@@ -5710,6 +5743,7 @@ function parseNameFlags(args, env) {
5710
5743
  network: { type: "string" },
5711
5744
  "process-id": { type: "string" },
5712
5745
  via: { type: "string" },
5746
+ "tx-id": { type: "string" },
5713
5747
  yes: { type: "boolean", default: false },
5714
5748
  json: { type: "boolean", default: false },
5715
5749
  help: { type: "boolean", short: "h", default: false }
@@ -5775,6 +5809,7 @@ function parseNameFlags(args, env) {
5775
5809
  network: networkRaw,
5776
5810
  ...processId !== void 0 ? { processId } : {},
5777
5811
  ...via !== void 0 ? { via } : {},
5812
+ ...values["tx-id"] !== void 0 ? { txId: values["tx-id"] } : {},
5778
5813
  yes: values.yes ?? false,
5779
5814
  json: values.json ?? false
5780
5815
  }
@@ -6167,10 +6202,15 @@ async function runName(args, deps) {
6167
6202
  try {
6168
6203
  if (sub === "buy") return await runBuy(name, flags, deps);
6169
6204
  if (sub === "status") return await runStatus(name, flags, deps);
6170
- const txId = positionals[1];
6205
+ if (flags.txId !== void 0 && positionals[1] !== void 0) {
6206
+ io2.err("`--tx-id` and a positional <txId> are mutually exclusive");
6207
+ io2.err(NAME_USAGE);
6208
+ return 2;
6209
+ }
6210
+ const txId = flags.txId ?? positionals[1];
6171
6211
  if (txId === void 0) {
6172
6212
  io2.err(
6173
- "`rig name set` needs a <txId> (the Arweave transaction to point at)"
6213
+ "`rig name set` needs a <txId> (the Arweave transaction to point at) \u2014 as a positional or via --tx-id"
6174
6214
  );
6175
6215
  io2.err(NAME_USAGE);
6176
6216
  return 2;
@@ -6194,7 +6234,7 @@ function buildArweaveManifest(entries, indexPath = DEFAULT_INDEX, fallbackTxId)
6194
6234
  return {
6195
6235
  manifest: "arweave/paths",
6196
6236
  version: "0.2.0",
6197
- index: { path: indexPath },
6237
+ ...Object.hasOwn(paths, indexPath) ? { index: { path: indexPath } } : {},
6198
6238
  ...fallbackTxId ? { fallback: { id: fallbackTxId } } : {},
6199
6239
  paths
6200
6240
  };
@@ -6419,7 +6459,8 @@ async function runSitePublish(args, deps) {
6419
6459
  );
6420
6460
  }
6421
6461
  }
6422
- const { uploadFeePerByte } = await ctx.publisher.getFeeRates();
6462
+ const feeRates = await ctx.publisher.getFeeRates();
6463
+ const { uploadFeePerByte, minUploadFee } = feeRates;
6423
6464
  const previewEntries = blobs.map((b) => ({
6424
6465
  path: b.path,
6425
6466
  txId: known.get(b.sha) ?? PLACEHOLDER_TX
@@ -6431,12 +6472,20 @@ async function runSitePublish(args, deps) {
6431
6472
  );
6432
6473
  const manifestBytes = Buffer.byteLength(JSON.stringify(previewManifest));
6433
6474
  let reuploadBytes = 0;
6475
+ let reuploadFee = 0n;
6434
6476
  if (flags.forceReupload) {
6435
6477
  const { objects } = await reader.statObjects(uniqueShas);
6436
6478
  reuploadBytes = objects.reduce((sum, o) => sum + o.size, 0);
6479
+ reuploadFee = objects.reduce(
6480
+ (sum, o) => sum + flooredUploadFee(o.size, uploadFeePerByte, minUploadFee),
6481
+ 0n
6482
+ );
6437
6483
  }
6438
- const manifestFee = BigInt(manifestBytes) * uploadFeePerByte;
6439
- const reuploadFee = BigInt(reuploadBytes) * uploadFeePerByte;
6484
+ const manifestFee = flooredUploadFee(
6485
+ manifestBytes,
6486
+ uploadFeePerByte,
6487
+ minUploadFee
6488
+ );
6440
6489
  const totalFee = manifestFee + reuploadFee;
6441
6490
  const gateway = flags.gateway ?? deps.env["RIG_ARWEAVE_GATEWAY"] ?? DEFAULT_GATEWAY;
6442
6491
  const baseJson = () => ({