@toon-protocol/client 3.3.0 → 4.1.0

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/main.js CHANGED
@@ -3,14 +3,14 @@ import {
3
3
  generateKeystore,
4
4
  importKeystore,
5
5
  openKeystore
6
- } from "../chunk-PTTRHLYV.js";
6
+ } from "../chunk-2DGVNDKA.js";
7
7
  import {
8
8
  DEVNET,
9
9
  deriveFullIdentity,
10
10
  evmDerivationPath,
11
11
  generateRandomIdentity,
12
12
  isHiddenServiceUrl
13
- } from "../chunk-O6KX7MHD.js";
13
+ } from "../chunk-WJKJ6Y4N.js";
14
14
 
15
15
  // src/cli/main.ts
16
16
  import { homedir as homedir3 } from "os";
@@ -80,6 +80,21 @@ var GLOBAL_OPTIONS = {
80
80
  arg: "URL",
81
81
  help: "SOCKS5h proxy for a .anyone connector, e.g. socks5h://127.0.0.1:9050. Env TOON_SOCKS. Default: start a managed anon daemon."
82
82
  },
83
+ facilitator: {
84
+ type: "string",
85
+ arg: "URL",
86
+ help: "The x402 facilitator that relays a Base channel deposit and pays its gas. Env TOON_FACILITATOR. Default: the one the connector names, else the devnet Onboarder on Base Sepolia."
87
+ },
88
+ "deposit-gas": {
89
+ type: "string",
90
+ arg: "auto|facilitator|self",
91
+ help: "Who pays a Base deposit's gas. auto: the facilitator, else your own ETH; facilitator: never your ETH; self: always your ETH, no facilitator. Env TOON_DEPOSIT_GAS. Default auto."
92
+ },
93
+ "deposit-method": {
94
+ type: "string",
95
+ arg: "eip3009|permit2",
96
+ help: "How a Base deposit moves the token: eip3009 for USDC-style tokens, permit2 for any ERC-20. Env TOON_DEPOSIT_METHOD. Default: what the connector names."
97
+ },
83
98
  json: { type: "boolean", help: "Print one JSON document on stdout and nothing else." },
84
99
  quiet: { type: "boolean", help: "Suppress progress and warnings on stderr." },
85
100
  help: { type: "boolean", short: "h", help: "Show this help." },
@@ -95,11 +110,10 @@ var COMMAND_OPTIONS = {
95
110
  type: "boolean",
96
111
  help: "Show the addresses of every derivation scheme, not just the one in use."
97
112
  },
98
- deposit: { type: "string", arg: "BASE_UNITS", help: "Collateral to lock, in base units." },
99
- "settlement-timeout": {
113
+ deposit: {
100
114
  type: "string",
101
- arg: "SECONDS",
102
- help: "Challenge period. Default 86400; EVM floors it at 3600."
115
+ arg: "BASE_UNITS",
116
+ help: "What a channel is opened with, in base units. Default 100000 (0.10 USDC)."
103
117
  },
104
118
  "connector-view": {
105
119
  type: "boolean",
@@ -180,7 +194,7 @@ var COMMANDS = {
180
194
  options: [],
181
195
  minPositionals: 1,
182
196
  maxPositionals: 1,
183
- details: ["Needs an open channel: a probe carries a claim, it just does not spend it."]
197
+ details: ["Needs a channel already paid on: a probe resends the last voucher, which spends nothing."]
184
198
  },
185
199
  send: {
186
200
  summary: "Pay for one HTTP request and print the answer.",
@@ -199,12 +213,14 @@ var COMMANDS = {
199
213
  channel: {
200
214
  summary: "Open, fund, inspect, close and settle the payment channel.",
201
215
  usage: "channel open|deposit <amount>|close|settle|status [--deposit BASE_UNITS] [--connector-view]",
202
- options: ["deposit", "settlement-timeout", "connector-view"],
216
+ options: ["deposit", "connector-view"],
203
217
  minPositionals: 1,
204
218
  maxPositionals: 2,
205
219
  details: [
206
- "Every one of these is your transaction, on your gas. `close` starts the",
207
- "challenge period; `settle` pays out once it has elapsed."
220
+ "Opening and depositing cost no gas: a facilitator relays the deposit on Base,",
221
+ "the connector sponsors the open on Solana. `close` and `settle` are your own",
222
+ "transactions, on your gas: `close` starts the exit window, and `settle` takes",
223
+ "the unspent deposit back once it has elapsed."
208
224
  ]
209
225
  },
210
226
  "claim-state": {
@@ -332,7 +348,7 @@ function usage(command) {
332
348
  return parts.join("\n");
333
349
  }
334
350
  return [
335
- "toon \u2014 pay for an HTTP request, per request, over a payment channel.",
351
+ "toon \u2014 pay for an HTTP request, per request, from an x402 payment channel.",
336
352
  "",
337
353
  "Usage: toon <command> [options]",
338
354
  "",
@@ -346,7 +362,7 @@ function usage(command) {
346
362
  "",
347
363
  "Environment: TOON_CONNECTOR, TOON_MNEMONIC, TOON_KEYSTORE,",
348
364
  " TOON_KEYSTORE_PASSWORD, TOON_CHAIN, TOON_RPC_URL, TOON_CHANNEL_STORE,",
349
- " TOON_SOCKS.",
365
+ " TOON_SOCKS, TOON_FACILITATOR, TOON_DEPOSIT_GAS, TOON_DEPOSIT_METHOD.",
350
366
  "",
351
367
  "Run 'toon help <command>' for one command in detail."
352
368
  ].join("\n");
@@ -428,6 +444,9 @@ var CHAIN_ENV = "TOON_CHAIN";
428
444
  var RPC_ENV = "TOON_RPC_URL";
429
445
  var CHANNEL_STORE_ENV = "TOON_CHANNEL_STORE";
430
446
  var SOCKS_ENV = "TOON_SOCKS";
447
+ var FACILITATOR_ENV = "TOON_FACILITATOR";
448
+ var DEPOSIT_GAS_ENV = "TOON_DEPOSIT_GAS";
449
+ var DEPOSIT_METHOD_ENV = "TOON_DEPOSIT_METHOD";
431
450
  function defaultChannelStorePath(home = homedir2()) {
432
451
  return join2(home, ".toon", "channels.json");
433
452
  }
@@ -436,6 +455,11 @@ function parseChain(value, from) {
436
455
  if (value === "evm" || value === "solana") return value;
437
456
  throw new UsageError(`${from} must be 'evm' or 'solana'; got '${value}'`);
438
457
  }
458
+ function parseChoice(value, from, choices) {
459
+ if (value === void 0 || value.length === 0) return void 0;
460
+ if (choices.includes(value)) return value;
461
+ throw new UsageError(`${from} must be ${choices.map((c) => `'${c}'`).join(", ")}; got '${value}'`);
462
+ }
439
463
  function parseTransport(value, from) {
440
464
  if (value === void 0 || value.length === 0) return "auto";
441
465
  if (value === "auto" || value === "http" || value === "btp") return value;
@@ -469,9 +493,27 @@ function resolveSettings(values, env, options = {}) {
469
493
  const socksFlag = stringOption(values, "socks");
470
494
  const socksEnv = env[SOCKS_ENV];
471
495
  const socksProxy = socksFlag !== void 0 && socksFlag.length > 0 ? socksFlag : socksEnv !== void 0 && socksEnv.length > 0 ? socksEnv : void 0;
496
+ const facilitator = stringOption(values, "facilitator") ?? env[FACILITATOR_ENV];
497
+ const deposit = stringOption(values, "deposit");
498
+ const depositGasFlag = stringOption(values, "deposit-gas");
499
+ const depositGas = parseChoice(
500
+ depositGasFlag ?? env[DEPOSIT_GAS_ENV],
501
+ depositGasFlag !== void 0 ? "--deposit-gas" : DEPOSIT_GAS_ENV,
502
+ ["auto", "facilitator", "self"]
503
+ );
504
+ const depositMethodFlag = stringOption(values, "deposit-method");
505
+ const depositMethod = parseChoice(
506
+ depositMethodFlag ?? env[DEPOSIT_METHOD_ENV],
507
+ depositMethodFlag !== void 0 ? "--deposit-method" : DEPOSIT_METHOD_ENV,
508
+ ["eip3009", "permit2"]
509
+ );
472
510
  const settings = {
473
511
  connector,
474
512
  connectorSource,
513
+ ...facilitator !== void 0 && facilitator.length > 0 ? { facilitatorUrl: facilitator } : {},
514
+ ...deposit !== void 0 ? { deposit } : {},
515
+ ...depositGas !== void 0 ? { depositGas } : {},
516
+ ...depositMethod !== void 0 ? { depositMethod } : {},
475
517
  ...chain !== void 0 ? { chain } : {},
476
518
  ...rpcUrl !== void 0 && rpcUrl.length > 0 ? { rpcUrl } : {},
477
519
  channelStore,
@@ -529,7 +571,11 @@ function buildClientConfig(settings, keys) {
529
571
  // See this module's docs: a command never opens a channel as a side effect.
530
572
  autoOpenChannel: false,
531
573
  ...settings.chain !== void 0 ? { chain: settings.chain } : {},
532
- ...settings.rpcUrl !== void 0 ? { rpcUrl: settings.rpcUrl } : {}
574
+ ...settings.rpcUrl !== void 0 ? { rpcUrl: settings.rpcUrl } : {},
575
+ ...settings.facilitatorUrl !== void 0 ? { facilitatorUrl: settings.facilitatorUrl } : {},
576
+ ...settings.deposit !== void 0 ? { deposit: settings.deposit } : {},
577
+ ...settings.depositGas !== void 0 ? { depositGas: settings.depositGas } : {},
578
+ ...settings.depositMethod !== void 0 ? { depositMethod: settings.depositMethod } : {}
533
579
  };
534
580
  if (keys.kind === "mnemonic") {
535
581
  return { ...base, mnemonic: keys.mnemonic, keyDerivation: keys.derivation };
@@ -542,7 +588,7 @@ function buildClientConfig(settings, keys) {
542
588
  };
543
589
  }
544
590
  async function defaultCreateClient(config) {
545
- const module = await import("../client-FFEFAMJ4.js");
591
+ const module = await import("../client-GAU5TOT4.js");
546
592
  const factory = module.ToonClient;
547
593
  if (factory === void 0) {
548
594
  throw new Error(
@@ -612,20 +658,23 @@ async function defaultStartAnon(log) {
612
658
 
613
659
  // src/cli/output.ts
614
660
  import { formatUnits } from "viem";
615
- function assetSymbol(tokenAddress) {
616
- if (tokenAddress === void 0) return void 0;
617
- const t = tokenAddress.toLowerCase();
618
- if (t === DEVNET.evm.tokenAddress.toLowerCase()) return "USDC";
619
- if (t === DEVNET.solana.tokenAddress.toLowerCase()) return "USDC";
620
- return void 0;
661
+ var KNOWN_USDC = new Set(
662
+ [
663
+ DEVNET.evm.tokenAddress,
664
+ DEVNET.solana.tokenAddress,
665
+ "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
666
+ "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
667
+ ].map((a) => a.startsWith("0x") ? a.toLowerCase() : a)
668
+ );
669
+ function known(asset) {
670
+ if (asset === void 0) return false;
671
+ return KNOWN_USDC.has(asset.startsWith("0x") ? asset.toLowerCase() : asset);
621
672
  }
622
- function assetFromSettlement(settlement) {
623
- if (settlement === void 0) return {};
624
- return { decimals: settlement.decimals, symbol: assetSymbol(settlement.tokenAddress) };
673
+ function assetInfo(asset) {
674
+ return known(asset) ? { decimals: 6, symbol: "USDC" } : {};
625
675
  }
626
- function assetFromTerms(terms) {
627
- if (terms === void 0) return {};
628
- return { decimals: terms.decimals, symbol: assetSymbol(terms.token) };
676
+ function assetFromSettlement(terms) {
677
+ return assetInfo(terms?.asset);
629
678
  }
630
679
  function formatAmount(amount, asset = {}) {
631
680
  const base = typeof amount === "bigint" ? amount : BigInt(amount);
@@ -750,21 +799,23 @@ async function run(ctx) {
750
799
  // src/cli/commands/channel.ts
751
800
  function stateRows(state, asset) {
752
801
  const rows = [
753
- ["channel", state.channelId],
754
- ["chain", state.domain.chain],
755
- ["counterparty", state.counterparty],
756
- ["status", state.status],
802
+ ["channel", state.channel.channelId],
803
+ ["network", state.channel.network],
757
804
  ["deposit", formatAmount(state.depositTotal, asset)],
758
- ["spent", formatAmount(state.spent, asset)],
759
- ["available", formatAmount(state.available, asset)],
760
- ["nonce", String(state.nonce)]
805
+ ["signed", formatAmount(state.signed, asset)],
806
+ [
807
+ "available",
808
+ formatAmount(
809
+ state.depositTotal > state.signed ? state.depositTotal - state.signed : 0n,
810
+ asset
811
+ )
812
+ ]
761
813
  ];
762
- if (state.onChain?.closedAt !== void 0) {
763
- rows.push(["closed at", `${state.onChain.closedAt.toString()} (unix seconds)`]);
764
- }
765
- if (state.onChain?.settleableAt !== void 0) {
766
- rows.push(["settleable at", `${state.onChain.settleableAt.toString()} (unix seconds)`]);
814
+ if (state.closedAt !== void 0) rows.push(["closed at", `${state.closedAt.toString()} (unix seconds)`]);
815
+ if (state.settleableAt !== void 0) {
816
+ rows.push(["settleable at", `${state.settleableAt.toString()} (unix seconds)`]);
767
817
  }
818
+ if (state.settledAt !== void 0) rows.push(["settled at", `${state.settledAt.toString()} (unix seconds)`]);
768
819
  return rows;
769
820
  }
770
821
  function connectorRows(entry, asset) {
@@ -772,39 +823,34 @@ function connectorRows(entry, asset) {
772
823
  return [["connector", `cannot report this channel (${entry.error})`]];
773
824
  }
774
825
  return [
775
- ["connector nonce", String(entry.nonce)],
776
826
  ["connector claimed", formatAmount(entry.cumulativeClaimed, asset)],
777
- [
778
- "connector deposit",
779
- entry.depositTotal === null ? "declared only" : formatAmount(entry.depositTotal, asset)
780
- ],
781
- [
782
- "connector available",
783
- entry.available === null ? "unknown" : formatAmount(entry.available, asset)
784
- ]
827
+ ["connector max", formatAmount(entry.maxCumulative, asset)],
828
+ ["connector available", formatAmount(entry.available, asset)]
785
829
  ];
786
830
  }
831
+ function exitRows(result) {
832
+ const rows = [["channel", result.channelId]];
833
+ if (result.transaction !== void 0) rows.push(["tx", result.transaction]);
834
+ if (result.settleableAt !== void 0) rows.push(["settleable at", result.settleableAt.toString()]);
835
+ if (result.error !== void 0) rows.push(["error", result.error]);
836
+ if (result.transaction === void 0 && result.error === void 0 && result.settleableAt === void 0) {
837
+ rows.push(["status", "nothing left to take back"]);
838
+ }
839
+ return rows;
840
+ }
787
841
  async function run2(ctx) {
788
842
  const sub = ctx.positionals[0];
789
843
  if (sub === void 0 || !CHANNEL_SUBCOMMANDS.includes(sub)) {
790
- throw new UsageError(
791
- `channel needs one of: ${CHANNEL_SUBCOMMANDS.join(", ")}`,
792
- "channel"
793
- );
844
+ throw new UsageError(`channel needs one of: ${CHANNEL_SUBCOMMANDS.join(", ")}`, "channel");
794
845
  }
795
846
  const client = await ctx.client();
796
847
  const channel = client.channel;
797
848
  if (sub === "open") {
798
- const deposit = stringOption(ctx.values, "deposit");
799
- const timeout = stringOption(ctx.values, "settlement-timeout");
800
- const state2 = await channel.open({
801
- ...deposit !== void 0 ? { deposit } : {},
802
- ...timeout !== void 0 ? { settlementTimeout: Number(timeout) } : {}
803
- });
804
- const asset2 = assetFromTerms(state2.domain);
805
- ctx.out.render(state2, () => {
849
+ const state = await channel.open();
850
+ const asset = assetInfo(state.channel.config.token);
851
+ ctx.out.render(state, () => {
806
852
  ctx.out.line("Channel open.");
807
- ctx.out.rows(stateRows(state2, asset2));
853
+ ctx.out.rows(stateRows(state, asset));
808
854
  });
809
855
  return 0;
810
856
  }
@@ -813,48 +859,52 @@ async function run2(ctx) {
813
859
  if (amount === void 0) {
814
860
  throw new UsageError("channel deposit needs an amount in base units", "channel");
815
861
  }
816
- const state2 = await channel.deposit(amount);
817
- const asset2 = assetFromTerms(state2.domain);
818
- ctx.out.render(state2, () => {
862
+ let value;
863
+ try {
864
+ value = BigInt(amount);
865
+ } catch {
866
+ throw new UsageError(`'${amount}' is not a whole number of base units`, "channel");
867
+ }
868
+ const state = await channel.deposit(value);
869
+ const asset = assetInfo(state.channel.config.token);
870
+ ctx.out.render(state, () => {
819
871
  ctx.out.line("Deposit confirmed.");
820
- ctx.out.rows(stateRows(state2, asset2));
872
+ ctx.out.rows(stateRows(state, asset));
821
873
  });
822
874
  return 0;
823
875
  }
824
- if (sub === "close") {
825
- const result = await channel.close();
826
- ctx.out.render(result, () => {
827
- ctx.out.line("Challenge period started. Settle once it has elapsed.");
828
- const rows = [];
829
- if (result.txHash !== void 0) rows.push(["tx", result.txHash]);
830
- if (result.closedAt !== void 0) rows.push(["closed at", result.closedAt.toString()]);
831
- if (result.settleableAt !== void 0) {
832
- rows.push(["settleable at", result.settleableAt.toString()]);
876
+ if (sub === "close" || sub === "settle") {
877
+ const results = sub === "close" ? await channel.close() : await channel.settle();
878
+ ctx.out.render(results, () => {
879
+ if (results.length === 0) {
880
+ ctx.out.line("No channel is ready to settle yet.");
881
+ return;
833
882
  }
834
- ctx.out.rows(rows);
835
- });
836
- return 0;
837
- }
838
- if (sub === "settle") {
839
- const result = await channel.settle();
840
- ctx.out.render(result, () => {
841
- ctx.out.line("Channel settled; the collateral is released.");
842
- if (result.txHash !== void 0) ctx.out.rows([["tx", result.txHash]]);
883
+ const noneWorked = results.every((r) => r.error !== void 0);
884
+ ctx.out.line(
885
+ noneWorked ? sub === "close" ? "No channel was left." : "No deposit was returned." : sub === "close" ? "Leaving every open channel. Settle each once its window has elapsed." : "Unspent deposits returned where each window had elapsed."
886
+ );
887
+ for (const r of results) ctx.out.rows(exitRows(r));
843
888
  });
844
- return 0;
889
+ return results.some((r) => r.error !== void 0) ? 1 : 0;
845
890
  }
846
- const state = await channel.state({ onChain: true });
847
- const asset = assetFromTerms(state.domain);
891
+ const channels = channel.channels();
848
892
  let connectorView;
849
- if (boolOption(ctx.values, "connector-view")) {
850
- const entries = await client.claimState([state.channelId]);
851
- connectorView = entries[0];
893
+ if (boolOption(ctx.values, "connector-view") && channels.length > 0) {
894
+ connectorView = await client.claimState(channels.map((c) => c.channel.channelId));
852
895
  }
853
- ctx.out.render({ ...state, ...connectorView !== void 0 ? { connectorView } : {} }, () => {
854
- ctx.out.rows(stateRows(state, asset));
855
- if (connectorView !== void 0) {
896
+ ctx.out.render(connectorView === void 0 ? channels : { channels, connector: connectorView }, () => {
897
+ if (channels.length === 0) {
898
+ ctx.out.line("No channel with this node yet. Open one with 'toon channel open', or pay for a request.");
899
+ return;
900
+ }
901
+ for (const state of channels) {
902
+ const asset = assetInfo(state.channel.config.token);
903
+ const rows = stateRows(state, asset);
904
+ const theirs = connectorView?.find((e) => e.channelId === state.channel.channelId);
905
+ if (theirs !== void 0) rows.push(...connectorRows(theirs, asset));
906
+ ctx.out.rows(rows);
856
907
  ctx.out.line();
857
- ctx.out.rows(connectorRows(connectorView, asset));
858
908
  }
859
909
  });
860
910
  return 0;
@@ -865,15 +915,15 @@ async function run3(ctx) {
865
915
  const client = await ctx.client();
866
916
  const entries = await client.claimState();
867
917
  const description = await client.describe();
868
- const asset = assetFromSettlement(description.settlements[0]);
918
+ const asset = assetFromSettlement(description.batchSettlements[0]);
869
919
  ctx.out.render({ connector: client.connector, channels: entries }, () => {
870
920
  if (entries.length === 0) {
871
921
  ctx.out.line("This connector reports no channels for your account.");
872
- ctx.out.line("Open one with 'toon channel open --deposit 100000'.");
922
+ ctx.out.line("Open one with 'toon channel open', or pay for a request.");
873
923
  return;
874
924
  }
875
925
  for (const entry of entries) {
876
- const id = entry.channelId ?? entry.channelAccount ?? "(unnamed)";
926
+ const id = entry.channelId ?? "(unnamed)";
877
927
  if (!entry.ok) {
878
928
  ctx.out.rows([
879
929
  ["channel", id],
@@ -886,13 +936,9 @@ async function run3(ctx) {
886
936
  ctx.out.rows([
887
937
  ["channel", id],
888
938
  ["chain", entry.blockchain],
889
- ["nonce", String(entry.nonce)],
890
939
  ["claimed", formatAmount(entry.cumulativeClaimed, asset)],
891
- [
892
- "deposit",
893
- entry.depositTotal === null ? "declared only" : formatAmount(entry.depositTotal, asset)
894
- ],
895
- ["available", entry.available === null ? "unknown" : formatAmount(entry.available, asset)],
940
+ ["max cumulative", formatAmount(entry.maxCumulative, asset)],
941
+ ["available", formatAmount(entry.available, asset)],
896
942
  [
897
943
  // Printed as the connector gave it, unconverted: the field is
898
944
  // best-effort and non-durable, and `null` means "unknown", never
@@ -915,7 +961,7 @@ async function run4(ctx) {
915
961
  ...url !== void 0 ? { connector: url } : {}
916
962
  });
917
963
  const description = await client.describe();
918
- const asset = assetFromSettlement(description.settlements[0]);
964
+ const asset = assetFromSettlement(description.batchSettlements[0]);
919
965
  const payload = {
920
966
  connector: client.connector,
921
967
  ilpAddresses: description.ilpAddresses,
@@ -923,7 +969,8 @@ async function run4(ctx) {
923
969
  btpEndpoint: description.btpEndpoint,
924
970
  peerCarriages: description.peerCarriages,
925
971
  edgeIdentity: description.edgeIdentity,
926
- settlements: description.settlements,
972
+ batchSettlements: description.batchSettlements,
973
+ voucherSigners: description.voucherSigners,
927
974
  routes: description.routes,
928
975
  requiredTransport: description.requiredTransport,
929
976
  supportedVersions: description.supportedVersions,
@@ -951,18 +998,19 @@ async function run4(ctx) {
951
998
  ]);
952
999
  ctx.out.rows(head);
953
1000
  ctx.out.line();
954
- if (description.settlements.length === 0) {
955
- ctx.out.line("Settlements: none \u2014 this node cannot be paid.");
1001
+ if (description.batchSettlements.length === 0) {
1002
+ ctx.out.line("Channels: none offered \u2014 this node cannot be paid.");
956
1003
  } else {
957
- ctx.out.line("Settlements:");
1004
+ ctx.out.line("Channels (x402 batch-settlement):");
958
1005
  ctx.out.rows(
959
- description.settlements.map((s) => [
960
- s.chain,
1006
+ description.batchSettlements.map((t) => [
1007
+ t.network,
961
1008
  [
962
- `counterparty ${s.settlementAddress}`,
963
- `token ${s.tokenAddress} (${String(s.decimals)}dp)`,
964
- s.kind === "evm" ? `tokenNetwork ${s.tokenNetwork}` : `program ${s.programId}`
965
- ].join(" ")
1009
+ `payTo ${t.payTo}`,
1010
+ `token ${t.asset}`,
1011
+ `min delay ${String(t.extra.withdrawDelay)}s`,
1012
+ t.chain === "solana" ? `sponsor ${t.extra.feePayer}` : ""
1013
+ ].filter((x) => x !== "").join(" ")
966
1014
  ])
967
1015
  );
968
1016
  }
@@ -1143,7 +1191,7 @@ async function run8(ctx) {
1143
1191
  });
1144
1192
  const terms = await client.routePrice(destination);
1145
1193
  const description = await client.describe();
1146
- const asset = assetFromSettlement(description.settlements[0]);
1194
+ const asset = assetFromSettlement(description.batchSettlements[0]);
1147
1195
  const perKib = terms?.pricePerKib;
1148
1196
  ctx.out.render(
1149
1197
  {
@@ -1176,7 +1224,7 @@ async function run9(ctx) {
1176
1224
  const client = await ctx.client();
1177
1225
  const result = await client.probe(destination);
1178
1226
  const description = await client.describe();
1179
- const asset = assetFromSettlement(description.settlements[0]);
1227
+ const asset = assetFromSettlement(description.batchSettlements[0]);
1180
1228
  ctx.out.render({ destination, ...result }, () => {
1181
1229
  ctx.out.rows([
1182
1230
  ["destination", destination],
@@ -1274,8 +1322,14 @@ function refusalHint(result, asset) {
1274
1322
  "'toon channel deposit <base units>', then send again."
1275
1323
  ];
1276
1324
  case "F01":
1325
+ if (result.refusedBy === "path") {
1326
+ return [
1327
+ "A node past the connector could not use the packet, so the app never saw it. Your",
1328
+ "voucher was accepted and the path cost is spent; the message above names what failed."
1329
+ ];
1330
+ }
1277
1331
  return [
1278
- "The connector would not take the claim: it names a channel it cannot see, or a nonce",
1332
+ "The connector would not take the voucher: it names a channel it cannot see, or an amount",
1279
1333
  "it has already banked. Compare the two watermarks with 'toon channel status --connector-view'."
1280
1334
  ];
1281
1335
  case "F02":
@@ -1321,7 +1375,7 @@ function payloadFor(result) {
1321
1375
  httpEndpoint: terms.httpEndpoint,
1322
1376
  btpEndpoint: terms.btpEndpoint,
1323
1377
  requiredTransport: terms.requiredTransport,
1324
- settlements: terms.settlements,
1378
+ batchSettlements: terms.batchSettlements,
1325
1379
  sessionLeaseTtlMs: terms.sessionLeaseTtlMs
1326
1380
  }
1327
1381
  } : {}
@@ -1344,20 +1398,20 @@ async function run10(ctx) {
1344
1398
  amountFlag === void 0 ? void 0 : { amount: BigInt(amountFlag) }
1345
1399
  );
1346
1400
  const description = await client.describe();
1347
- const asset = assetFromSettlement(description.settlements[0]);
1401
+ const asset = assetFromSettlement(description.batchSettlements[0]);
1348
1402
  ctx.out.render(payloadFor(result), () => {
1349
1403
  if (result.fulfilled) {
1350
1404
  ctx.out.line(`FULFILL ${String(result.status)} (${result.transport})`);
1351
1405
  const claim = result.claim;
1352
1406
  ctx.out.rows(
1353
1407
  claim === void 0 ? (
1354
- // A route priced at zero takes no claim, so there is no channel,
1355
- // nonce or amount to show. Saying so beats printing zeroes.
1408
+ // A route priced at zero takes no voucher, so there is no channel
1409
+ // or amount to show. Saying so beats printing zeroes.
1356
1410
  [["paid", "nothing \u2014 this route is free"]]
1357
1411
  ) : [
1358
1412
  [
1359
1413
  "paid",
1360
- `${formatAmount(claim.amount, asset)} channel ${claim.channelId} nonce ${String(claim.nonce)}`
1414
+ `${formatAmount(claim.amount, asset)} channel ${claim.channelId}`
1361
1415
  ],
1362
1416
  ["cumulative", formatAmount(claim.cumulative, asset)]
1363
1417
  ]
@@ -1527,7 +1581,9 @@ var FUNDING_CODES = /* @__PURE__ */ new Set([
1527
1581
  "CHANNEL_RESUME",
1528
1582
  "CHANNEL_NOT_OPEN",
1529
1583
  "INSUFFICIENT_BALANCE",
1530
- "TRANSFER_NOT_DELIVERED"
1584
+ "TRANSFER_NOT_DELIVERED",
1585
+ "FACILITATOR",
1586
+ "SPONSOR_REFUSED"
1531
1587
  ]);
1532
1588
  var NETWORK_CODES = /* @__PURE__ */ new Set(["NETWORK_ERROR", "CONNECTOR_ERROR", "STALE_RPC_READ"]);
1533
1589
  var PAYMENT_CODES = /* @__PURE__ */ new Set([