polkadot-cli 0.6.1 → 0.6.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 +11 -1
- package/dist/cli.mjs +27 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -144,10 +144,20 @@ Both dry-run and submission display the encoded call hex and a decoded human-rea
|
|
|
144
144
|
Call: 0x0001076465616462656566
|
|
145
145
|
Decode: System.remark(remark: 0xdeadbeef)
|
|
146
146
|
Tx: 0xabc123...
|
|
147
|
-
Block: #12345678 (0xdef...)
|
|
148
147
|
Status: ok
|
|
149
148
|
```
|
|
150
149
|
|
|
150
|
+
#### Exit codes
|
|
151
|
+
|
|
152
|
+
The CLI exits with code **1** when a finalized transaction has a dispatch error (e.g. insufficient balance, bad origin). The full transaction output (events, explorer links) is still printed before the error so you can debug the failure. Module errors are formatted as `PalletName.ErrorVariant` (e.g. `Balances.InsufficientBalance`).
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
dot tx Balances.transferKeepAlive 5FHneW46... 999999999999999999 --from alice
|
|
156
|
+
# ... events and explorer links ...
|
|
157
|
+
# Error: Transaction dispatch error: Balances.InsufficientBalance
|
|
158
|
+
echo $? # 1
|
|
159
|
+
```
|
|
160
|
+
|
|
151
161
|
#### Custom signed extensions
|
|
152
162
|
|
|
153
163
|
Chains with non-standard signed extensions (e.g. `people-preview`) are auto-handled:
|
package/dist/cli.mjs
CHANGED
|
@@ -5,7 +5,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
|
5
5
|
// src/cli.ts
|
|
6
6
|
import cac from "cac";
|
|
7
7
|
// package.json
|
|
8
|
-
var version = "0.6.
|
|
8
|
+
var version = "0.6.2";
|
|
9
9
|
|
|
10
10
|
// src/config/accounts-store.ts
|
|
11
11
|
import { access as access2, mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "node:fs/promises";
|
|
@@ -216,6 +216,7 @@ var isTTY = process.stdout.isTTY ?? false;
|
|
|
216
216
|
var RESET = isTTY ? "\x1B[0m" : "";
|
|
217
217
|
var CYAN = isTTY ? "\x1B[36m" : "";
|
|
218
218
|
var GREEN = isTTY ? "\x1B[32m" : "";
|
|
219
|
+
var RED = isTTY ? "\x1B[31m" : "";
|
|
219
220
|
var YELLOW = isTTY ? "\x1B[33m" : "";
|
|
220
221
|
var MAGENTA = isTTY ? "\x1B[35m" : "";
|
|
221
222
|
var DIM = isTTY ? "\x1B[2m" : "";
|
|
@@ -1320,12 +1321,13 @@ function registerTxCommand(cli) {
|
|
|
1320
1321
|
console.log(` ${BOLD}Call:${RESET} ${callHex}`);
|
|
1321
1322
|
console.log(` ${BOLD}Decode:${RESET} ${decodedStr}`);
|
|
1322
1323
|
console.log(` ${BOLD}Tx:${RESET} ${result.txHash}`);
|
|
1323
|
-
|
|
1324
|
+
let dispatchErrorMsg;
|
|
1324
1325
|
if (result.ok) {
|
|
1325
1326
|
console.log(` ${BOLD}Status:${RESET} ${GREEN}ok${RESET}`);
|
|
1326
1327
|
} else {
|
|
1327
|
-
|
|
1328
|
-
console.log(` ${BOLD}
|
|
1328
|
+
dispatchErrorMsg = formatDispatchError(result.dispatchError);
|
|
1329
|
+
console.log(` ${BOLD}Status:${RESET} ${RED}dispatch error${RESET}`);
|
|
1330
|
+
console.log(` ${BOLD}Error:${RESET} ${dispatchErrorMsg}`);
|
|
1329
1331
|
}
|
|
1330
1332
|
if (result.events && result.events.length > 0) {
|
|
1331
1333
|
console.log(` ${BOLD}Events:${RESET}`);
|
|
@@ -1348,11 +1350,31 @@ function registerTxCommand(cli) {
|
|
|
1348
1350
|
console.log(` ${DIM}PAPI${RESET} ${papiLink(rpcUrl, blockHash)}`);
|
|
1349
1351
|
}
|
|
1350
1352
|
console.log();
|
|
1353
|
+
if (!result.ok) {
|
|
1354
|
+
throw new CliError(`Transaction dispatch error: ${dispatchErrorMsg}`);
|
|
1355
|
+
}
|
|
1351
1356
|
} finally {
|
|
1352
1357
|
clientHandle?.destroy();
|
|
1353
1358
|
}
|
|
1354
1359
|
});
|
|
1355
1360
|
}
|
|
1361
|
+
function formatDispatchError(err) {
|
|
1362
|
+
if (err.type === "Module" && err.value && typeof err.value === "object") {
|
|
1363
|
+
const mod = err.value;
|
|
1364
|
+
if (mod.type) {
|
|
1365
|
+
const inner = mod.value;
|
|
1366
|
+
if (inner && typeof inner === "object" && inner.type) {
|
|
1367
|
+
return `${mod.type}.${inner.type}`;
|
|
1368
|
+
}
|
|
1369
|
+
return mod.type;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
if (err.value !== undefined && err.value !== null) {
|
|
1373
|
+
const val = typeof err.value === "string" ? err.value : JSON.stringify(err.value);
|
|
1374
|
+
return `${err.type}: ${val}`;
|
|
1375
|
+
}
|
|
1376
|
+
return err.type;
|
|
1377
|
+
}
|
|
1356
1378
|
function decodeCall(meta, callHex) {
|
|
1357
1379
|
try {
|
|
1358
1380
|
const viewBuilder = getViewBuilder(meta.lookup);
|
|
@@ -1810,7 +1832,7 @@ function watchTransaction(observable) {
|
|
|
1810
1832
|
}
|
|
1811
1833
|
break;
|
|
1812
1834
|
case "finalized":
|
|
1813
|
-
spinner.
|
|
1835
|
+
spinner.succeed(`Finalized in block #${event.block.number}`);
|
|
1814
1836
|
resolve(event);
|
|
1815
1837
|
break;
|
|
1816
1838
|
}
|