@wasit-dev/cli 0.5.0 → 0.6.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/README.md +3 -2
- package/dist/index.js +2 -0
- package/dist/wallet-command.d.ts +17 -0
- package/dist/wallet-command.js +22 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Protocol-compliance testing for **x402** and **MPP** on Stellar, from your termi
|
|
|
4
4
|
|
|
5
5
|
`wasit` runs the real payment flow against a live service, not a mock of it, and it is not a schema validator: a response can have every field in the right place and still take money without settling it.
|
|
6
6
|
|
|
7
|
-
For MPP charge
|
|
7
|
+
For both MPP charge payments and x402 payments it verifies the settlement independently — via Stellar RPC and the token contract's own on-chain transfer event, rather than the response the service returns.
|
|
8
8
|
|
|
9
9
|
**Testnet only.** Several checks settle real transactions — do not point this at pubnet or use production keys.
|
|
10
10
|
|
|
@@ -19,7 +19,7 @@ npm install -g @wasit-dev/cli
|
|
|
19
19
|
wasit test --target <your-service-url> --read-only
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Requires Node.js `>=
|
|
22
|
+
Requires Node.js `>=22`.
|
|
23
23
|
|
|
24
24
|
Both lines carry `--read-only` deliberately: without it the payment checks
|
|
25
25
|
`X402-06`/`07` run as soon as a `STELLAR_PRIVATE_KEY` is available, and the CLI
|
|
@@ -50,6 +50,7 @@ wasit test --target <url> [options]
|
|
|
50
50
|
| `--target <url>` | required | Must include the scheme |
|
|
51
51
|
| `--network <id>` | `stellar:testnet` | CAIP-2 network id |
|
|
52
52
|
| `--payer-key <key>` | `STELLAR_PRIVATE_KEY` | Testnet secret key, `S...` |
|
|
53
|
+
| `--rpc-url <url>` | testnet default | Soroban RPC used to verify `X402-06`'s settlement |
|
|
53
54
|
| `--method <verb>` | `GET` | HTTP method the paid endpoint uses |
|
|
54
55
|
| `--body <json>` | — | Request body; implies `Content-Type: application/json` |
|
|
55
56
|
| `--header <name:value>` | — | Extra request header, repeatable |
|
package/dist/index.js
CHANGED
|
@@ -144,6 +144,7 @@ program
|
|
|
144
144
|
.description("Run x402 compliance checks against a target service")
|
|
145
145
|
.requiredOption("--target <url>", "URL of the service to test")
|
|
146
146
|
.option("--network <network>", "Network identifier", "stellar:testnet")
|
|
147
|
+
.option("--rpc-url <url>", "Override the Soroban RPC endpoint used to verify X402-06's settlement")
|
|
147
148
|
.option("--payer-key <key>", "Testnet payer secret key (overrides STELLAR_PRIVATE_KEY from .env)")
|
|
148
149
|
.option("--method <verb>", "HTTP method the paid endpoint uses (default: GET). Paid endpoints that " +
|
|
149
150
|
"compute something usually take POST.")
|
|
@@ -182,6 +183,7 @@ signature. See docs/CHECKS.md for what each check ID verifies.`)
|
|
|
182
183
|
target: opts.target,
|
|
183
184
|
network: opts.network,
|
|
184
185
|
payerSecretKey: payerKey,
|
|
186
|
+
...(opts.rpcUrl ? { rpcUrl: opts.rpcUrl } : {}),
|
|
185
187
|
...shape,
|
|
186
188
|
})));
|
|
187
189
|
}
|
package/dist/wallet-command.d.ts
CHANGED
|
@@ -11,4 +11,21 @@
|
|
|
11
11
|
* file ever has to inspect a Stellar SDK error type to decide which it is.
|
|
12
12
|
*/
|
|
13
13
|
import type { Command } from "commander";
|
|
14
|
+
/** One role's row in `wallet status`. */
|
|
15
|
+
export interface WalletStatusRow {
|
|
16
|
+
readonly configured: boolean;
|
|
17
|
+
readonly status?: unknown;
|
|
18
|
+
readonly error?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The exit code for `wallet status`.
|
|
22
|
+
*
|
|
23
|
+
* With `--role`, the command answers one question, so it exits 2 whenever it
|
|
24
|
+
* could not answer it: the key is not set, cannot be read, or its balance
|
|
25
|
+
* could not be looked up. Otherwise `wasit wallet status --role x402 && deploy`
|
|
26
|
+
* proceeds on a key that was never checked. An account that does not exist
|
|
27
|
+
* yet is an answer, and exits 0. Without `--role` it reports every role as a
|
|
28
|
+
* table, and one role it could not check is a row, not a failed command.
|
|
29
|
+
*/
|
|
30
|
+
export declare function walletStatusExitCode(explicitRole: boolean, rows: readonly WalletStatusRow[]): 0 | 2;
|
|
14
31
|
export declare function registerWalletCommand(program: Command): void;
|
package/dist/wallet-command.js
CHANGED
|
@@ -88,6 +88,22 @@ function formatBalance(balance) {
|
|
|
88
88
|
const note = balance.issuer === TESTNET_USDC_ISSUER ? " (Circle testnet USDC)" : "";
|
|
89
89
|
return ` ${balance.code.padEnd(10)} ${balance.balance}${note}`;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* The exit code for `wallet status`.
|
|
93
|
+
*
|
|
94
|
+
* With `--role`, the command answers one question, so it exits 2 whenever it
|
|
95
|
+
* could not answer it: the key is not set, cannot be read, or its balance
|
|
96
|
+
* could not be looked up. Otherwise `wasit wallet status --role x402 && deploy`
|
|
97
|
+
* proceeds on a key that was never checked. An account that does not exist
|
|
98
|
+
* yet is an answer, and exits 0. Without `--role` it reports every role as a
|
|
99
|
+
* table, and one role it could not check is a row, not a failed command.
|
|
100
|
+
*/
|
|
101
|
+
export function walletStatusExitCode(explicitRole, rows) {
|
|
102
|
+
if (!explicitRole)
|
|
103
|
+
return 0;
|
|
104
|
+
// Only a role that was actually looked up has a status.
|
|
105
|
+
return rows.every((row) => row.status !== undefined) ? 0 : 2;
|
|
106
|
+
}
|
|
91
107
|
function printWalletStatus(role, publicKey, status) {
|
|
92
108
|
console.log(`${role} ${publicKey}`);
|
|
93
109
|
if (!status.exists) {
|
|
@@ -112,6 +128,9 @@ Examples:
|
|
|
112
128
|
$ wasit wallet status
|
|
113
129
|
$ wasit wallet status --role mpp-charge --json
|
|
114
130
|
|
|
131
|
+
With --role, exits 2 if that role could not be checked (key not set,
|
|
132
|
+
unreadable, or lookup failed); without it, every role is a row and it exits 0.
|
|
133
|
+
|
|
115
134
|
Testnet only — there is no --network flag. mpp-channel is not accepted here
|
|
116
135
|
even when configured: COMMITMENT_SECRET_HEX only ever signs off-chain (see
|
|
117
136
|
docs/guides/configuration.md) and has no on-chain balance of its own.`)
|
|
@@ -149,9 +168,10 @@ docs/guides/configuration.md) and has no on-chain balance of its own.`)
|
|
|
149
168
|
rows.push({ role, configured: true, publicKey, error: messageOf(error) });
|
|
150
169
|
}
|
|
151
170
|
}
|
|
171
|
+
const exitCode = walletStatusExitCode(opts.role !== undefined, rows);
|
|
152
172
|
if (jsonMode) {
|
|
153
173
|
console.log(JSON.stringify(rows, null, 2));
|
|
154
|
-
|
|
174
|
+
process.exit(exitCode);
|
|
155
175
|
}
|
|
156
176
|
for (const row of rows) {
|
|
157
177
|
if (!row.configured) {
|
|
@@ -165,6 +185,7 @@ docs/guides/configuration.md) and has no on-chain balance of its own.`)
|
|
|
165
185
|
}
|
|
166
186
|
printWalletStatus(row.role, row.publicKey, row.status);
|
|
167
187
|
}
|
|
188
|
+
process.exit(exitCode);
|
|
168
189
|
});
|
|
169
190
|
wallet
|
|
170
191
|
.command("create")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wasit-dev/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
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": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "Muhammad Dzakwan Najmi",
|
|
31
31
|
"license": "Apache-2.0",
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=22"
|
|
34
34
|
},
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"typecheck": "tsc -p test/tsconfig.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@wasit-dev/core": "^0.
|
|
44
|
+
"@wasit-dev/core": "^0.6.0",
|
|
45
45
|
"cfonts": "^3.3.1",
|
|
46
46
|
"commander": "^15.0.0",
|
|
47
47
|
"dotenv": "^17.4.2",
|