polkadot-cli 1.4.0 → 1.5.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 +28 -0
- package/dist/cli.mjs +73 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -321,6 +321,8 @@ dot inspect kusama.System
|
|
|
321
321
|
dot inspect kusama.System.Account
|
|
322
322
|
```
|
|
323
323
|
|
|
324
|
+
All listings — pallets, storage items, constants, calls, events, and errors — are sorted alphabetically, making it easy to find a specific item at a glance.
|
|
325
|
+
|
|
324
326
|
The pallet listing view shows type information inline so you can understand item shapes at a glance:
|
|
325
327
|
|
|
326
328
|
- **Storage**: key/value types with `[map]` tag for map items (e.g. `Account: AccountId32 → { nonce: u32, ... } [map]`)
|
|
@@ -457,6 +459,31 @@ dot tx Balances.transferKeepAlive 5GrwvaEF... abc --encode
|
|
|
457
459
|
|
|
458
460
|
For struct-based calls, the error identifies the specific field that failed. For tuple-based calls, it shows the argument index. The original parse error is preserved as the `cause` for programmatic access.
|
|
459
461
|
|
|
462
|
+
#### Wait level
|
|
463
|
+
|
|
464
|
+
By default, `dot tx` waits for finalization (~30s on Polkadot). Use `--wait` / `-w` to return earlier:
|
|
465
|
+
|
|
466
|
+
```bash
|
|
467
|
+
# Return as soon as the tx is broadcast (fastest)
|
|
468
|
+
dot tx System.remark 0xdead --from alice --wait broadcast
|
|
469
|
+
|
|
470
|
+
# Return when included in a best block
|
|
471
|
+
dot tx System.remark 0xdead --from alice -w best-block
|
|
472
|
+
dot tx System.remark 0xdead --from alice -w best # alias
|
|
473
|
+
|
|
474
|
+
# Wait for finalization (default, unchanged)
|
|
475
|
+
dot tx System.remark 0xdead --from alice --wait finalized
|
|
476
|
+
dot tx System.remark 0xdead --from alice # same
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
| Level | Resolves when | Events shown | Explorer links |
|
|
480
|
+
|-------|---------------|:---:|:---:|
|
|
481
|
+
| `broadcast` | Tx is broadcast to the network | — | — |
|
|
482
|
+
| `best-block` / `best` | Tx is included in a best block | yes | yes |
|
|
483
|
+
| `finalized` (default) | Tx is finalized | yes | yes |
|
|
484
|
+
|
|
485
|
+
The `--wait` flag is silently ignored when combined with `--dry-run` or `--encode` (both return before submission).
|
|
486
|
+
|
|
460
487
|
#### Custom signed extensions
|
|
461
488
|
|
|
462
489
|
Chains with non-standard signed extensions (e.g. `people-preview`) are auto-handled:
|
|
@@ -534,6 +561,7 @@ dot tx.System.remark 0xdead # shows call help (no error)
|
|
|
534
561
|
| `--output json` | Raw JSON output (default: pretty) |
|
|
535
562
|
| `--dump` | Dump all entries of a storage map (required for keyless map queries) |
|
|
536
563
|
| `--limit <n>` | Max entries for map queries (0 = unlimited, default: 100) |
|
|
564
|
+
| `-w, --wait <level>` | Tx wait level: `broadcast`, `best-block` / `best`, `finalized` (default) |
|
|
537
565
|
|
|
538
566
|
### Pipe-safe output
|
|
539
567
|
|
package/dist/cli.mjs
CHANGED
|
@@ -447,26 +447,27 @@ async function getOrFetchMetadata(chainName, clientHandle) {
|
|
|
447
447
|
return parseMetadata(raw);
|
|
448
448
|
}
|
|
449
449
|
function listPallets(meta) {
|
|
450
|
-
|
|
450
|
+
const sortByName = (arr) => arr.sort((a, b) => a.name.localeCompare(b.name));
|
|
451
|
+
return sortByName(meta.unified.pallets.map((p) => ({
|
|
451
452
|
name: p.name,
|
|
452
453
|
index: p.index,
|
|
453
454
|
docs: p.docs ?? [],
|
|
454
|
-
storage: (p.storage?.items ?? []).map((s) => ({
|
|
455
|
+
storage: sortByName((p.storage?.items ?? []).map((s) => ({
|
|
455
456
|
name: s.name,
|
|
456
457
|
docs: s.docs ?? [],
|
|
457
458
|
type: s.type.tag,
|
|
458
459
|
keyTypeId: s.type.tag === "map" ? s.type.value.key : null,
|
|
459
460
|
valueTypeId: s.type.tag === "plain" ? s.type.value : s.type.value.value
|
|
460
|
-
})),
|
|
461
|
-
constants: (p.constants ?? []).map((c) => ({
|
|
461
|
+
}))),
|
|
462
|
+
constants: sortByName((p.constants ?? []).map((c) => ({
|
|
462
463
|
name: c.name,
|
|
463
464
|
docs: c.docs ?? [],
|
|
464
465
|
typeId: c.type
|
|
465
|
-
})),
|
|
466
|
-
calls: extractEnumVariants(meta, p.calls),
|
|
467
|
-
events: extractEnumVariants(meta, p.events),
|
|
468
|
-
errors: extractEnumVariants(meta, p.errors).map(({ name, docs }) => ({ name, docs }))
|
|
469
|
-
}));
|
|
466
|
+
}))),
|
|
467
|
+
calls: sortByName(extractEnumVariants(meta, p.calls)),
|
|
468
|
+
events: sortByName(extractEnumVariants(meta, p.events)),
|
|
469
|
+
errors: sortByName(extractEnumVariants(meta, p.errors).map(({ name, docs }) => ({ name, docs })))
|
|
470
|
+
})));
|
|
470
471
|
}
|
|
471
472
|
function extractEnumVariants(meta, ref) {
|
|
472
473
|
if (!ref)
|
|
@@ -505,7 +506,7 @@ function getSignedExtensions(meta) {
|
|
|
505
506
|
return byVersion[Number(versionKeys[0])] ?? [];
|
|
506
507
|
}
|
|
507
508
|
function getPalletNames(meta) {
|
|
508
|
-
return meta.unified.pallets.map((p) => p.name);
|
|
509
|
+
return meta.unified.pallets.map((p) => p.name).sort((a, b) => a.localeCompare(b));
|
|
509
510
|
}
|
|
510
511
|
function describeType(lookup, typeId) {
|
|
511
512
|
try {
|
|
@@ -766,6 +767,9 @@ async function generateCompletions(currentWord, precedingWords) {
|
|
|
766
767
|
const names = [...DEV_NAMES, ...accounts.accounts.map((a) => a.name)];
|
|
767
768
|
return filterPrefix(names, currentWord);
|
|
768
769
|
}
|
|
770
|
+
if (prevWord === "--wait" || prevWord === "-w") {
|
|
771
|
+
return filterPrefix(["broadcast", "best-block", "best", "finalized"], currentWord);
|
|
772
|
+
}
|
|
769
773
|
if (currentWord.startsWith("--")) {
|
|
770
774
|
const activeCategory = detectCategory(precedingWords, knownChains);
|
|
771
775
|
const options = [...GLOBAL_OPTIONS];
|
|
@@ -928,14 +932,14 @@ var init_complete = __esm(() => {
|
|
|
928
932
|
"inspect"
|
|
929
933
|
];
|
|
930
934
|
GLOBAL_OPTIONS = ["--chain", "--rpc", "--light-client", "--output", "--help", "--version"];
|
|
931
|
-
TX_OPTIONS = ["--from", "--dry-run", "--encode", "--ext"];
|
|
935
|
+
TX_OPTIONS = ["--from", "--dry-run", "--encode", "--ext", "--wait"];
|
|
932
936
|
QUERY_OPTIONS = ["--limit"];
|
|
933
937
|
});
|
|
934
938
|
|
|
935
939
|
// src/cli.ts
|
|
936
940
|
import cac from "cac";
|
|
937
941
|
// package.json
|
|
938
|
-
var version = "1.
|
|
942
|
+
var version = "1.5.0";
|
|
939
943
|
|
|
940
944
|
// src/commands/account.ts
|
|
941
945
|
init_accounts_store();
|
|
@@ -3486,6 +3490,20 @@ import { getViewBuilder as getViewBuilder2 } from "@polkadot-api/view-builder";
|
|
|
3486
3490
|
import { Binary as Binary3 } from "polkadot-api";
|
|
3487
3491
|
init_metadata();
|
|
3488
3492
|
init_errors();
|
|
3493
|
+
function parseWaitLevel(raw) {
|
|
3494
|
+
switch (raw) {
|
|
3495
|
+
case "broadcast":
|
|
3496
|
+
return "broadcast";
|
|
3497
|
+
case "best-block":
|
|
3498
|
+
case "best":
|
|
3499
|
+
return "best-block";
|
|
3500
|
+
case "finalized":
|
|
3501
|
+
case undefined:
|
|
3502
|
+
return "finalized";
|
|
3503
|
+
default:
|
|
3504
|
+
throw new CliError(`Invalid --wait value "${raw}". Valid: broadcast, best-block, best, finalized`);
|
|
3505
|
+
}
|
|
3506
|
+
}
|
|
3489
3507
|
async function handleTx(target, args, opts) {
|
|
3490
3508
|
if (!target) {
|
|
3491
3509
|
const config2 = await loadConfig();
|
|
@@ -3619,15 +3637,23 @@ async function handleTx(target, args, opts) {
|
|
|
3619
3637
|
}
|
|
3620
3638
|
return;
|
|
3621
3639
|
}
|
|
3622
|
-
const
|
|
3640
|
+
const waitLevel = parseWaitLevel(opts.wait);
|
|
3641
|
+
const result = await watchTransaction(tx.signSubmitAndWatch(signer, txOptions), waitLevel);
|
|
3623
3642
|
console.log();
|
|
3624
3643
|
console.log(` ${BOLD}Chain:${RESET} ${chainName}`);
|
|
3625
3644
|
console.log(` ${BOLD}Call:${RESET} ${callHex}`);
|
|
3626
3645
|
console.log(` ${BOLD}Decode:${RESET} ${decodedStr}`);
|
|
3627
3646
|
console.log(` ${BOLD}Tx:${RESET} ${result.txHash}`);
|
|
3647
|
+
if (result.type === "broadcasted") {
|
|
3648
|
+
console.log(` ${BOLD}Status:${RESET} ${GREEN}broadcasted${RESET}`);
|
|
3649
|
+
console.log(` ${DIM}Note: tx was broadcast but not yet included in a block${RESET}`);
|
|
3650
|
+
console.log();
|
|
3651
|
+
return;
|
|
3652
|
+
}
|
|
3628
3653
|
let dispatchErrorMsg;
|
|
3629
3654
|
if (result.ok) {
|
|
3630
|
-
|
|
3655
|
+
const hint = result.type === "txBestBlocksState" ? ` ${DIM}(best block, not yet finalized)${RESET}` : "";
|
|
3656
|
+
console.log(` ${BOLD}Status:${RESET} ${GREEN}ok${RESET}${hint}`);
|
|
3631
3657
|
} else {
|
|
3632
3658
|
dispatchErrorMsg = formatDispatchError(result.dispatchError);
|
|
3633
3659
|
console.log(` ${BOLD}Status:${RESET} ${RED}dispatch error${RESET}`);
|
|
@@ -4237,12 +4263,15 @@ function autoDefaultForType(entry) {
|
|
|
4237
4263
|
}
|
|
4238
4264
|
return NO_DEFAULT2;
|
|
4239
4265
|
}
|
|
4240
|
-
function watchTransaction(observable) {
|
|
4266
|
+
function watchTransaction(observable, level) {
|
|
4241
4267
|
const spinner = new Spinner;
|
|
4242
4268
|
return new Promise((resolve, reject) => {
|
|
4269
|
+
let settled = false;
|
|
4243
4270
|
spinner.start("Signing...");
|
|
4244
|
-
observable.subscribe({
|
|
4271
|
+
const subscription = observable.subscribe({
|
|
4245
4272
|
next(event) {
|
|
4273
|
+
if (settled)
|
|
4274
|
+
return;
|
|
4246
4275
|
switch (event.type) {
|
|
4247
4276
|
case "signed":
|
|
4248
4277
|
spinner.succeed("Signed");
|
|
@@ -4250,24 +4279,41 @@ function watchTransaction(observable) {
|
|
|
4250
4279
|
spinner.start("Broadcasting...");
|
|
4251
4280
|
break;
|
|
4252
4281
|
case "broadcasted":
|
|
4253
|
-
|
|
4254
|
-
|
|
4282
|
+
if (level === "broadcast") {
|
|
4283
|
+
spinner.succeed("Broadcasted");
|
|
4284
|
+
settled = true;
|
|
4285
|
+
subscription.unsubscribe();
|
|
4286
|
+
resolve(event);
|
|
4287
|
+
} else {
|
|
4288
|
+
spinner.succeed("Broadcasted");
|
|
4289
|
+
spinner.start("In best block...");
|
|
4290
|
+
}
|
|
4255
4291
|
break;
|
|
4256
4292
|
case "txBestBlocksState":
|
|
4257
4293
|
if (event.found) {
|
|
4258
|
-
|
|
4259
|
-
|
|
4294
|
+
if (level === "best-block") {
|
|
4295
|
+
spinner.succeed(`In best block #${event.block.number}`);
|
|
4296
|
+
settled = true;
|
|
4297
|
+
subscription.unsubscribe();
|
|
4298
|
+
resolve(event);
|
|
4299
|
+
} else {
|
|
4300
|
+
spinner.succeed(`In best block #${event.block.number}`);
|
|
4301
|
+
spinner.start("Finalizing...");
|
|
4302
|
+
}
|
|
4260
4303
|
} else {
|
|
4261
4304
|
spinner.start("In best block...");
|
|
4262
4305
|
}
|
|
4263
4306
|
break;
|
|
4264
4307
|
case "finalized":
|
|
4265
4308
|
spinner.succeed(`Finalized in block #${event.block.number}`);
|
|
4309
|
+
settled = true;
|
|
4266
4310
|
resolve(event);
|
|
4267
4311
|
break;
|
|
4268
4312
|
}
|
|
4269
4313
|
},
|
|
4270
4314
|
error(err) {
|
|
4315
|
+
if (settled)
|
|
4316
|
+
return;
|
|
4271
4317
|
spinner.stop();
|
|
4272
4318
|
reject(err);
|
|
4273
4319
|
}
|
|
@@ -4570,7 +4616,9 @@ if (process.argv[2] === "__complete") {
|
|
|
4570
4616
|
registerAccountCommands(cli);
|
|
4571
4617
|
registerHashCommand(cli);
|
|
4572
4618
|
registerCompletionsCommand(cli);
|
|
4573
|
-
cli.command("[dotpath] [...args]").option("--from <name>", "Account to sign with (for tx)").option("--dry-run", "Estimate fees without submitting (for tx)").option("--encode", "Encode call to hex without signing (for tx)").option("--ext <json>", "Custom signed extension values as JSON (for tx)").option("--
|
|
4619
|
+
cli.command("[dotpath] [...args]").option("--from <name>", "Account to sign with (for tx)").option("--dry-run", "Estimate fees without submitting (for tx)").option("--encode", "Encode call to hex without signing (for tx)").option("--ext <json>", "Custom signed extension values as JSON (for tx)").option("-w, --wait <level>", "Resolve at: broadcast, best-block (or best), finalized (for tx)", {
|
|
4620
|
+
default: "finalized"
|
|
4621
|
+
}).option("--limit <n>", "Max entries to return for map queries (0 = unlimited)", {
|
|
4574
4622
|
default: 100
|
|
4575
4623
|
}).option("--dump", "Dump all entries of a storage map (without specifying a key)").action(async (dotpath, args, opts) => {
|
|
4576
4624
|
if (!dotpath) {
|
|
@@ -4606,7 +4654,8 @@ if (process.argv[2] === "__complete") {
|
|
|
4606
4654
|
from: opts.from,
|
|
4607
4655
|
dryRun: opts.dryRun,
|
|
4608
4656
|
encode: opts.encode,
|
|
4609
|
-
ext: opts.ext
|
|
4657
|
+
ext: opts.ext,
|
|
4658
|
+
wait: opts.wait
|
|
4610
4659
|
});
|
|
4611
4660
|
} else {
|
|
4612
4661
|
await handleTx(target, args, {
|
|
@@ -4614,7 +4663,8 @@ if (process.argv[2] === "__complete") {
|
|
|
4614
4663
|
from: opts.from,
|
|
4615
4664
|
dryRun: opts.dryRun,
|
|
4616
4665
|
encode: opts.encode,
|
|
4617
|
-
ext: opts.ext
|
|
4666
|
+
ext: opts.ext,
|
|
4667
|
+
wait: opts.wait
|
|
4618
4668
|
});
|
|
4619
4669
|
}
|
|
4620
4670
|
break;
|