@wasit-dev/cli 0.6.0 → 0.8.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/style.js ADDED
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Colours and line layout for a person watching the terminal (Najmi,
3
+ * 2026-11-19): Wasit's own look, in the palette the site and the dashboard use
4
+ * (`dashboard/theme.ts`), a spinner while a check runs, and the run's duration.
5
+ *
6
+ * Colour is a layer over the plain text, never a second wording: every line is
7
+ * sanitised first (`sanitizeText`), then styled, so nothing a service sent can
8
+ * carry an escape sequence of its own. Output that a program reads stays plain:
9
+ * `--json`, a pipe, CI and `NO_COLOR` all get the exact text Wasit printed
10
+ * before colours existed.
11
+ */
12
+ import { THEME } from "./dashboard/theme.js";
13
+ function set(value) {
14
+ return value !== undefined && value !== "";
15
+ }
16
+ /**
17
+ * True when lines may carry colour: `NO_COLOR` set turns it off, `FORCE_COLOR`
18
+ * set (and not "0") turns it on, a dumb terminal and CI are plain, otherwise a
19
+ * TTY is coloured and anything else is not.
20
+ */
21
+ export function colorEnabled(stream, env) {
22
+ if (set(env["NO_COLOR"]))
23
+ return false;
24
+ if (set(env["FORCE_COLOR"]) && env["FORCE_COLOR"] !== "0")
25
+ return true;
26
+ if (env["TERM"] === "dumb")
27
+ return false;
28
+ if (set(env["CI"]) || set(env["GITHUB_ACTIONS"]))
29
+ return false;
30
+ return stream.isTTY === true;
31
+ }
32
+ /**
33
+ * True when a line may be rewritten in place (the running line and its
34
+ * spinner): colour on, and a real terminal. A forced colour into a pipe gets
35
+ * colour but no cursor movement.
36
+ */
37
+ export function liveEnabled(stream, env) {
38
+ return colorEnabled(stream, env) && stream.isTTY === true && !set(env["CI"]) && !set(env["GITHUB_ACTIONS"]);
39
+ }
40
+ /** True when the terminal says it shows 24-bit colour; the brand colours are then exact. */
41
+ export function truecolorEnabled(env) {
42
+ const value = (env["COLORTERM"] ?? "").toLowerCase();
43
+ return value === "truecolor" || value === "24bit";
44
+ }
45
+ export function colorDepth(env) {
46
+ if (truecolorEnabled(env))
47
+ return 24;
48
+ if ((env["TERM"] ?? "").includes("256"))
49
+ return 256;
50
+ return 16;
51
+ }
52
+ /** Each role: its brand colour, and the 16-colour code a plain terminal gets instead. */
53
+ const ROLES = {
54
+ accent: { hex: THEME.accent, basic: 35 },
55
+ muted: { hex: THEME.muted, basic: 90 },
56
+ success: { hex: THEME.success, basic: 32 },
57
+ warning: { hex: THEME.warning, basic: 33 },
58
+ danger: { hex: THEME.danger, basic: 31 },
59
+ error: { hex: "#d946ef", basic: 95 },
60
+ };
61
+ function rgb(hex) {
62
+ const value = Number.parseInt(hex.slice(1), 16);
63
+ return `${(value >> 16) & 255};${(value >> 8) & 255};${value & 255}`;
64
+ }
65
+ /** Black ink on the light backgrounds (green, yellow), white on the dark ones (red, magenta). */
66
+ const BADGE_DARK_INK = { success: true, warning: true, danger: false, error: false };
67
+ /** The 256-colour backgrounds nearest the brand colours. */
68
+ const BADGE_256 = { success: 41, warning: 214, danger: 203, error: 171 };
69
+ const BADGE_16 = { success: 42, warning: 43, danger: 41, error: 45 };
70
+ /**
71
+ * The SGR parameters of a badge. The ink is given exactly (24-bit or 256-colour
72
+ * black and white), never as a bold colour of the 16: a terminal that draws bold
73
+ * text in bright colours (VS Code and iTerm2 by default) turns bold black into
74
+ * grey, which melts into a green or yellow background. On a 16-colour terminal
75
+ * black ink is not bold, for the same reason.
76
+ */
77
+ function badgeParams(role, depth) {
78
+ const dark = BADGE_DARK_INK[role];
79
+ if (depth === 24)
80
+ return `1;${dark ? "38;2;0;0;0" : "38;2;255;255;255"};48;2;${rgb(ROLES[role].hex)}`;
81
+ if (depth === 256)
82
+ return `1;${dark ? "38;5;16" : "38;5;231"};48;5;${BADGE_256[role]}`;
83
+ return dark ? `30;${BADGE_16[role]}` : `1;97;${BADGE_16[role]}`;
84
+ }
85
+ /**
86
+ * A styler. `depth` is the terminal's colour depth (`colorDepth`); `true` is
87
+ * read as 24-bit, `false` or nothing as the 16 colours of every terminal.
88
+ */
89
+ export function styler(enabled, depth = 16) {
90
+ const bits = depth === true ? 24 : depth === false ? 16 : depth;
91
+ const truecolor = bits === 24;
92
+ return {
93
+ enabled,
94
+ badge(label, role) {
95
+ if (!enabled)
96
+ return label;
97
+ return `\u001b[${badgeParams(role, bits)}m ${label} \u001b[22;39;49m`;
98
+ },
99
+ paint(text, ...roles) {
100
+ if (!enabled || roles.length === 0 || text === "")
101
+ return text;
102
+ let open = "";
103
+ let close = "";
104
+ for (const role of roles) {
105
+ if (role === "bold" || role === "dim") {
106
+ open += role === "bold" ? "\u001b[1m" : "\u001b[2m";
107
+ close = `\u001b[22m${close}`;
108
+ continue;
109
+ }
110
+ const { hex, basic } = ROLES[role];
111
+ open += truecolor ? `\u001b[38;2;${rgb(hex)}m` : `\u001b[${basic}m`;
112
+ close = `\u001b[39m${close}`;
113
+ }
114
+ return `${open}${text}${close}`;
115
+ },
116
+ };
117
+ }
118
+ /** The SGR sequences this module writes, and only those, for measuring a line. */
119
+ const SGR = /\u001b\[[0-9;]*m/g;
120
+ /** The width a line takes on screen: its length without the colour codes. */
121
+ export function visibleLength(text) {
122
+ return [...text.replace(SGR, "")].length;
123
+ }
124
+ /**
125
+ * A check's status as a mark and a badge that agree (Najmi, 2026-11-20):
126
+ * ✓ PASS, ✗ FAIL, ○ SKIP, ! ERROR (the check could not run). Text marks, not
127
+ * emoji: an emoji takes two columns in many terminals and breaks the columns.
128
+ */
129
+ export const MARKS = {
130
+ PASS: { mark: "✓", markRole: "success", badge: "PASS", badgeRole: "success" },
131
+ FAIL: { mark: "✗", markRole: "danger", badge: "FAIL", badgeRole: "danger" },
132
+ SKIP: { mark: "○", markRole: "warning", badge: "SKIP", badgeRole: "warning" },
133
+ ERROR: { mark: "!", markRole: "error", badge: "ERROR", badgeRole: "error" },
134
+ };
135
+ /** The spinner's frames, as the dashboard draws them, one every 80 ms. */
136
+ export const SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
137
+ export const SPINNER_MS = 80;
138
+ /** "12ms" under a second, "6.82s" from a second on. */
139
+ export function duration(ms) {
140
+ if (ms < 1000)
141
+ return `${Math.max(0, Math.round(ms))}ms`;
142
+ return `${(ms / 1000).toFixed(2)}s`;
143
+ }
144
+ /**
145
+ * `left` and `right` on one line, `right` flush with the width. A line that
146
+ * does not fit keeps two spaces between them and runs over.
147
+ */
148
+ export function spread(left, right, width) {
149
+ if (right === "")
150
+ return left;
151
+ const gap = Math.max(2, width - visibleLength(left) - visibleLength(right));
152
+ return `${left}${" ".repeat(gap)}${right}`;
153
+ }
154
+ /** Cuts plain text to `max` characters, ending in "…". */
155
+ export function truncate(text, max) {
156
+ const chars = [...text];
157
+ if (chars.length <= max)
158
+ return text;
159
+ if (max <= 1)
160
+ return "…".slice(0, Math.max(0, max));
161
+ return `${chars.slice(0, max - 1).join("")}…`;
162
+ }
163
+ /**
164
+ * Plain text wrapped to `width` columns, every line after `indent`. A word
165
+ * longer than a line (a URL, a hash) is kept whole and runs over.
166
+ */
167
+ export function wrap(text, width, indent) {
168
+ const room = Math.max(20, width - [...indent].length);
169
+ const lines = [];
170
+ let current = "";
171
+ for (const word of text.split(/\s+/).filter((part) => part !== "")) {
172
+ if (current === "")
173
+ current = word;
174
+ else if ([...current].length + 1 + [...word].length <= room)
175
+ current += ` ${word}`;
176
+ else {
177
+ lines.push(current);
178
+ current = word;
179
+ }
180
+ }
181
+ if (current !== "")
182
+ lines.push(current);
183
+ return lines.map((line) => `${indent}${line}`);
184
+ }
185
+ /**
186
+ * The width lines are laid out to: one column less than the terminal's (a line
187
+ * as wide as the screen makes some terminals start a new line), at most 100,
188
+ * 80 when unknown.
189
+ */
190
+ export function lineWidth(stream) {
191
+ const columns = stream.columns;
192
+ if (columns === undefined || !Number.isFinite(columns) || columns <= 0)
193
+ return 80;
194
+ return Math.max(20, Math.min(100, Math.floor(columns) - 1));
195
+ }
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * `wasit wallet` — testnet-only convenience commands for the payer keys the
3
- * other subcommands already read from .env. Deliberately has no --network
4
- * flag: Friendbot, the printed USDC issuer, and the whole idea of a
5
- * throwaway generated key only make sense on testnet, so there is nothing
6
- * here that could be pointed at pubnet by mistake.
3
+ * other subcommands already read from .env. `--network` takes testnets only
4
+ * (the ones `wasit serve` poses on): Friendbot, the printed USDC issuer, and
5
+ * the whole idea of a throwaway generated key only make sense on testnet, so
6
+ * there is nothing here that could be pointed at a mainnet by mistake.
7
+ * Stellar testnet is the default and the only network for the MPP roles; on
8
+ * Base Sepolia and Solana devnet the x402 payer needs USDC from Circle's
9
+ * faucet and no native token, since the facilitator pays the fee.
7
10
  *
8
11
  * Every failure path here exits 2 (configuration) or 1 (the operation ran and
9
12
  * failed) with a single-line message, the same contract the check subcommands
@@ -11,6 +14,18 @@
11
14
  * file ever has to inspect a Stellar SDK error type to decide which it is.
12
15
  */
13
16
  import type { Command } from "commander";
17
+ type WalletRole = "x402" | "mpp-charge" | "mpp-channel";
18
+ /** The testnets `wasit wallet` takes: the ones `wasit serve` poses on. */
19
+ export declare const WALLET_NETWORKS: readonly string[];
20
+ /**
21
+ * Checks --network against the testnets, and the role against the network:
22
+ * the MPP roles are Stellar only. Returns the problem, or undefined.
23
+ */
24
+ export declare function walletNetworkProblem(network: string, role: WalletRole): string | undefined;
25
+ /** Base units as a decimal amount, e.g. 19970000 with 6 decimals as 19.97. */
26
+ export declare function formatUnits(units: bigint, decimals: number): string;
27
+ /** What `wallet create --role x402 --network <not Stellar>` prints. */
28
+ export declare function generatedKeyLines(network: string, secret: string): string[];
14
29
  /** One role's row in `wallet status`. */
15
30
  export interface WalletStatusRow {
16
31
  readonly configured: boolean;
@@ -29,3 +44,4 @@ export interface WalletStatusRow {
29
44
  */
30
45
  export declare function walletStatusExitCode(explicitRole: boolean, rows: readonly WalletStatusRow[]): 0 | 2;
31
46
  export declare function registerWalletCommand(program: Command): void;
47
+ export {};
@@ -1,9 +1,12 @@
1
1
  /**
2
2
  * `wasit wallet` — testnet-only convenience commands for the payer keys the
3
- * other subcommands already read from .env. Deliberately has no --network
4
- * flag: Friendbot, the printed USDC issuer, and the whole idea of a
5
- * throwaway generated key only make sense on testnet, so there is nothing
6
- * here that could be pointed at pubnet by mistake.
3
+ * other subcommands already read from .env. `--network` takes testnets only
4
+ * (the ones `wasit serve` poses on): Friendbot, the printed USDC issuer, and
5
+ * the whole idea of a throwaway generated key only make sense on testnet, so
6
+ * there is nothing here that could be pointed at a mainnet by mistake.
7
+ * Stellar testnet is the default and the only network for the MPP roles; on
8
+ * Base Sepolia and Solana devnet the x402 payer needs USDC from Circle's
9
+ * faucet and no native token, since the facilitator pays the fee.
7
10
  *
8
11
  * Every failure path here exits 2 (configuration) or 1 (the operation ran and
9
12
  * failed) with a single-line message, the same contract the check subcommands
@@ -11,7 +14,8 @@
11
14
  * file ever has to inspect a Stellar SDK error type to decide which it is.
12
15
  */
13
16
  import { oraPromise } from "ora";
14
- import { createUsdcTrustline, fundWithFriendbot, generateCommitmentKey, generateTestnetWallet, getTestnetWalletStatus, publicKeyFromSecret, sendUsdcFromDistributor, TESTNET_USDC_ISSUER, } from "@wasit-dev/core";
17
+ import { createUsdcTrustline, fundWithFriendbot, generateCommitmentKey, generateTestnetWallet, getTestnetWalletStatus, paymentChainFor, publicKeyFromSecret, sendUsdcFromDistributor, TESTNET_USDC_ISSUER, } from "@wasit-dev/core";
18
+ import { DEFAULT_SERVE_NETWORK, SERVE_NETWORKS } from "./serve.js";
15
19
  /** Every role a key can be generated for. */
16
20
  const ROLES = ["x402", "mpp-charge", "mpp-channel"];
17
21
  /**
@@ -75,6 +79,64 @@ function resolvePublicKey(role) {
75
79
  process.exit(2);
76
80
  }
77
81
  }
82
+ /** The testnets `wasit wallet` takes: the ones `wasit serve` poses on. */
83
+ export const WALLET_NETWORKS = Object.keys(SERVE_NETWORKS);
84
+ /**
85
+ * Checks --network against the testnets, and the role against the network:
86
+ * the MPP roles are Stellar only. Returns the problem, or undefined.
87
+ */
88
+ export function walletNetworkProblem(network, role) {
89
+ if (!WALLET_NETWORKS.includes(network)) {
90
+ return `Unknown --network "${network}". Expected a testnet: ${WALLET_NETWORKS.join(", ")}.`;
91
+ }
92
+ if (network !== DEFAULT_SERVE_NETWORK && role !== "x402") {
93
+ return `--role ${role} is Stellar only: MPP runs on Stellar. Only --role x402 takes --network ${network}.`;
94
+ }
95
+ return undefined;
96
+ }
97
+ function requireNetwork(value, role) {
98
+ const network = value ?? DEFAULT_SERVE_NETWORK;
99
+ const problem = walletNetworkProblem(network, role);
100
+ if (problem !== undefined) {
101
+ console.error(problem);
102
+ process.exit(2);
103
+ }
104
+ return network;
105
+ }
106
+ /** Base units as a decimal amount, e.g. 19970000 with 6 decimals as 19.97. */
107
+ export function formatUnits(units, decimals) {
108
+ const scale = 10n ** BigInt(decimals);
109
+ const fraction = (units % scale).toString().padStart(decimals, "0").replace(/0+$/, "");
110
+ return `${units / scale}${fraction === "" ? "" : `.${fraction}`}`;
111
+ }
112
+ /** Where a payer on `network` gets its USDC, and what it does not need. */
113
+ function faucetLines(network, address) {
114
+ const profile = SERVE_NETWORKS[network];
115
+ return [
116
+ `Fund it with USDC at https://faucet.circle.com (network ${profile.faucetNetwork}),`,
117
+ `pasting ${address}.`,
118
+ `It needs no ${profile.nativeToken}: the facilitator pays the fee.`,
119
+ ];
120
+ }
121
+ /** What `wallet create --role x402 --network <not Stellar>` prints. */
122
+ export function generatedKeyLines(network, secret) {
123
+ const chain = paymentChainFor(network);
124
+ const address = chain.payerAddress(secret);
125
+ return [
126
+ `Generated a new ${SERVE_NETWORKS[network].name} key for x402:`,
127
+ "",
128
+ `Address: ${address}`,
129
+ `Secret: ${secret}`,
130
+ "",
131
+ "Paste into .env:",
132
+ "",
133
+ `${chain.payerKeyEnv}=${secret}`,
134
+ "",
135
+ ...faucetLines(network, address),
136
+ "",
137
+ "Testnet only — never reuse this key, and never put a mainnet key here.",
138
+ ];
139
+ }
78
140
  function messageOf(error) {
79
141
  return error instanceof Error ? error.message : String(error);
80
142
  }
@@ -114,28 +176,90 @@ function printWalletStatus(role, publicKey, status) {
114
176
  console.log(formatBalance(balance));
115
177
  }
116
178
  }
179
+ /**
180
+ * The configured x402 payer on a network other than Stellar testnet, exiting
181
+ * 2 when its key is unset or is not a key for that chain. The message never
182
+ * echoes the key.
183
+ */
184
+ function resolvePayer(network) {
185
+ const chain = paymentChainFor(network);
186
+ const secret = process.env[chain.payerKeyEnv];
187
+ if (!secret) {
188
+ console.error(`${chain.payerKeyEnv} is not set. Run \`wasit wallet create --role x402 --network ${network}\` first.`);
189
+ process.exit(2);
190
+ }
191
+ try {
192
+ return { address: chain.payerAddress(secret) };
193
+ }
194
+ catch {
195
+ console.error(`${chain.payerKeyEnv} is not a ${chain.name} key.`);
196
+ process.exit(2);
197
+ }
198
+ }
199
+ /**
200
+ * Prints the x402 payer's USDC balance on a network other than Stellar
201
+ * testnet, and returns the exit code: 2 when it could not be read, since
202
+ * `wallet status` must not pass on a balance it never saw.
203
+ */
204
+ async function printPayerStatus(network, jsonMode) {
205
+ const chain = paymentChainFor(network);
206
+ const profile = SERVE_NETWORKS[network];
207
+ const { address } = resolvePayer(network);
208
+ let balance;
209
+ let error;
210
+ try {
211
+ const read = chain.payerBalance(network, chain.resolveRpcUrl(network), address, profile.asset);
212
+ balance = jsonMode ? await read : await oraPromise(read, `Checking x402 on ${profile.name}...`);
213
+ if (balance === undefined)
214
+ error = "the chain gave no balance";
215
+ }
216
+ catch (caught) {
217
+ error = messageOf(caught);
218
+ }
219
+ if (jsonMode) {
220
+ console.log(JSON.stringify([{ role: "x402", network, address, usdc: balance === undefined ? undefined : formatUnits(balance, profile.decimals), error }], null, 2));
221
+ }
222
+ else {
223
+ console.log(`x402 ${address} (${profile.name})`);
224
+ console.log(balance === undefined
225
+ ? ` Could not check: ${error}`
226
+ : ` ${"USDC".padEnd(10)} ${formatUnits(balance, profile.decimals)}`);
227
+ if (balance === 0n)
228
+ for (const line of faucetLines(network, address))
229
+ console.log(` ${line}`);
230
+ }
231
+ return balance === undefined ? 2 : 0;
232
+ }
117
233
  export function registerWalletCommand(program) {
118
234
  const wallet = program
119
235
  .command("wallet")
120
- .description("Generate, fund, and inspect disposable Stellar testnet wallets");
236
+ .description("Generate, fund, and inspect disposable testnet wallets: Stellar's payers, and the x402 payer on Base Sepolia, Ethereum Sepolia and Solana devnet");
121
237
  wallet
122
238
  .command("status")
123
239
  .description("Show balances for the configured payer role(s)")
124
240
  .option("--role <role>", `One of: ${ACCOUNT_ROLES.join(", ")}. Default: check both.`)
241
+ .option("--network <network>", `Testnet: ${WALLET_NETWORKS.join(", ")}`, DEFAULT_SERVE_NETWORK)
125
242
  .option("--json", "Print as JSON instead of formatted text", false)
126
243
  .addHelpText("after", `
127
244
  Examples:
128
245
  $ wasit wallet status
129
246
  $ wasit wallet status --role mpp-charge --json
247
+ $ wasit wallet status --network eip155:84532
130
248
 
131
249
  With --role, exits 2 if that role could not be checked (key not set,
132
250
  unreadable, or lookup failed); without it, every role is a row and it exits 0.
133
251
 
134
- Testnet only — there is no --network flag. mpp-channel is not accepted here
252
+ Testnet only. On a network other than Stellar testnet it shows the x402
253
+ payer's USDC balance. mpp-channel is not accepted here
135
254
  even when configured: COMMITMENT_SECRET_HEX only ever signs off-chain (see
136
255
  docs/guides/configuration.md) and has no on-chain balance of its own.`)
137
256
  .action(async (opts) => {
138
257
  const jsonMode = opts.json === true;
258
+ if (opts.network !== DEFAULT_SERVE_NETWORK) {
259
+ const role = opts.role === undefined ? "x402" : requireRole(opts.role, ACCOUNT_ROLES);
260
+ const network = requireNetwork(opts.network, role);
261
+ process.exit(await printPayerStatus(network, jsonMode));
262
+ }
139
263
  const roles = opts.role !== undefined ? [requireRole(opts.role, ACCOUNT_ROLES)] : ACCOUNT_ROLES;
140
264
  const rows = [];
141
265
  for (const role of roles) {
@@ -191,11 +315,14 @@ docs/guides/configuration.md) and has no on-chain balance of its own.`)
191
315
  .command("create")
192
316
  .description("Generate a new testnet key for a payer role")
193
317
  .requiredOption("--role <role>", `One of: ${ROLES.join(", ")}`)
194
- .option("--fund", "Immediately fund the new key with testnet XLM", false)
318
+ .option("--network <network>", `Testnet: ${WALLET_NETWORKS.join(", ")}`, DEFAULT_SERVE_NETWORK)
319
+ .option("--fund", "Immediately fund the new key with testnet XLM (Stellar only)", false)
195
320
  .addHelpText("after", `
196
321
  Examples:
197
322
  $ wasit wallet create --role mpp-charge --fund
198
323
  $ wasit wallet create --role mpp-channel
324
+ $ wasit wallet create --role x402 --network eip155:84532
325
+ $ wasit wallet create --role x402 --network solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1
199
326
 
200
327
  Testnet only. Prints the exact .env line(s) to paste — never writes to .env
201
328
  itself, so it can never silently overwrite something already there.
@@ -204,6 +331,18 @@ The generated secret is printed to stdout: do not run this on a screen you
204
331
  are recording, and never paste a pubnet key into these variables.`)
205
332
  .action(async (opts) => {
206
333
  const role = requireRole(opts.role, ROLES);
334
+ const network = requireNetwork(opts.network, role);
335
+ if (network !== DEFAULT_SERVE_NETWORK) {
336
+ if (opts.fund === true) {
337
+ console.error(`--fund is Stellar only (Friendbot). On ${SERVE_NETWORKS[network].name} the payer ` +
338
+ "needs USDC from https://faucet.circle.com and nothing else.");
339
+ process.exit(2);
340
+ }
341
+ for (const line of generatedKeyLines(network, paymentChainFor(network).generatePayerKey())) {
342
+ console.log(line);
343
+ }
344
+ return;
345
+ }
207
346
  if (role === "mpp-channel") {
208
347
  const key = generateCommitmentKey();
209
348
  console.log("Generated a new MPP commitment key (a signing key, not a funded account " +
@@ -244,6 +383,7 @@ are recording, and never paste a pubnet key into these variables.`)
244
383
  .command("fund")
245
384
  .description("Fund a configured payer role with testnet XLM or USDC")
246
385
  .requiredOption("--role <role>", `One of: ${ACCOUNT_ROLES.join(", ")}`)
386
+ .option("--network <network>", `Testnet: ${WALLET_NETWORKS.join(", ")}`, DEFAULT_SERVE_NETWORK)
247
387
  .option("--asset <asset>", "xlm or usdc", "xlm")
248
388
  .option("--amount <amount>", "USDC amount to request from the distributor account", "50")
249
389
  .addHelpText("after", `
@@ -256,9 +396,20 @@ Examples:
256
396
  actually receiving a balance needs either a manual visit to
257
397
  https://faucet.circle.com (paste the printed public key) or
258
398
  WASIT_USDC_DISTRIBUTOR_SECRET set in .env, naming an account you already
259
- funded that way once — there is no scriptable USDC faucet for Stellar.`)
399
+ funded that way once — there is no scriptable USDC faucet for Stellar.
400
+
401
+ On another network (--network) there is nothing to do on-chain first: it
402
+ prints where to get USDC for the configured x402 payer.`)
260
403
  .action(async (opts) => {
261
404
  const role = requireRole(opts.role, ACCOUNT_ROLES);
405
+ const network = requireNetwork(opts.network, role);
406
+ if (network !== DEFAULT_SERVE_NETWORK) {
407
+ const { address } = resolvePayer(network);
408
+ console.log(`No faucet can be called for ${SERVE_NETWORKS[network].name} from here.`);
409
+ for (const line of faucetLines(network, address))
410
+ console.log(line);
411
+ return;
412
+ }
262
413
  const { secret, publicKey } = resolvePublicKey(role);
263
414
  const asset = opts.asset;
264
415
  if (asset !== "xlm" && asset !== "usdc") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wasit-dev/cli",
3
- "version": "0.6.0",
3
+ "version": "0.8.0-beta.1",
4
4
  "description": "CLI for x402/MPP protocol-conformance testing on Stellar — verifies a service's payment flow settles on-chain per spec.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -37,11 +37,11 @@
37
37
  },
38
38
  "scripts": {
39
39
  "build": "tsc -p tsconfig.json",
40
- "test": "node --import tsx --test \"test/unit/**/*.test.ts*\"",
40
+ "test": "node --import tsx --test --test-timeout=120000 \"test/unit/**/*.test.ts*\"",
41
41
  "typecheck": "tsc -p test/tsconfig.json"
42
42
  },
43
43
  "dependencies": {
44
- "@wasit-dev/core": "^0.6.0",
44
+ "@wasit-dev/core": "^0.8.0-beta.1",
45
45
  "cfonts": "^3.3.1",
46
46
  "commander": "^15.0.0",
47
47
  "dotenv": "^17.4.2",