polkadot-cli 1.21.0 → 1.23.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 +67 -2
- package/dist/cli.mjs +191 -55
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -81,6 +81,24 @@ To pull the latest skill updates:
|
|
|
81
81
|
/plugin marketplace update polkadot-cli
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
## Plugins
|
|
85
|
+
|
|
86
|
+
`dot` supports git/cargo-style external subcommands: any executable named `dot-<name>` on your PATH runs as `dot <name>`, with the remaining arguments forwarded verbatim, stdio inherited, and the plugin's exit code passed through.
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install -g dot-example # ships a `dot-example` binary
|
|
90
|
+
dot example status --json # runs: dot-example status --json
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
This is how domain-specific tooling extends `dot` without the CLI loading third-party code into its own process. Plugins are ordinary child processes — the intended pattern is that a plugin invokes `dot` itself for anything chain- or signing-related (e.g. `dot tx.… --from <account>`), so key handling stays inside `dot`.
|
|
94
|
+
|
|
95
|
+
Plugins receive a `DOT_BIN` environment variable pointing at the entry script of the `dot` that dispatched them (the same convention as cargo's `CARGO`), so they can invoke the exact same installation rather than whatever `dot` is first on PATH.
|
|
96
|
+
|
|
97
|
+
Notes:
|
|
98
|
+
|
|
99
|
+
- Only a bare first token dispatches: `dot foo.bar` is always dot-path syntax, `./file.yaml` is always file input — neither will hit the plugin lookup.
|
|
100
|
+
- Built-in commands and categories always win over a plugin of the same name.
|
|
101
|
+
|
|
84
102
|
## Usage
|
|
85
103
|
|
|
86
104
|
### Manage chains
|
|
@@ -97,7 +115,8 @@ dot chain add kusama --rpc wss://kusama-rpc.polkadot.io
|
|
|
97
115
|
dot chain add kusama --rpc wss://kusama-rpc.polkadot.io --rpc wss://kusama-rpc.dwellir.com
|
|
98
116
|
|
|
99
117
|
# Add a parachain under a relay (auto-detects parachain ID)
|
|
100
|
-
|
|
118
|
+
# Name parachains `{relay}-{parachain}` — see "Naming convention" below
|
|
119
|
+
dot chain add local-relay-asset-hub --rpc ws://localhost:9945 --relay local-relay
|
|
101
120
|
|
|
102
121
|
# Add a parachain with explicit parachain ID
|
|
103
122
|
dot chain add my-para --rpc wss://rpc.example.com --relay polkadot --parachain-id 2000
|
|
@@ -119,6 +138,24 @@ dot chain update --all # updates all configured chains in parallel
|
|
|
119
138
|
dot chain remove kusama
|
|
120
139
|
```
|
|
121
140
|
|
|
141
|
+
#### Naming convention
|
|
142
|
+
|
|
143
|
+
Name chains `{relay}-{parachain}`: the parent relay's name, a hyphen, then the parachain's role. Every preconfigured chain already follows this pattern (`polkadot-asset-hub`, `polkadot-bridge-hub`, `paseo-people`, …), and reusing it for chains you add keeps the relay/parachain topology readable.
|
|
144
|
+
|
|
145
|
+
| Chain kind | Recommended name | Examples |
|
|
146
|
+
|------------|------------------|----------|
|
|
147
|
+
| Relay chain | `{relay}` | `polkadot`, `kusama`, `paseo` |
|
|
148
|
+
| Parachain | `{relay}-{parachain}` | `polkadot-asset-hub`, `kusama-bridge-hub`, `paseo-people` |
|
|
149
|
+
|
|
150
|
+
The relay prefix is what keeps chains distinct: parachain IDs collide across relays (Asset Hub is `1000` on both Polkadot and Paseo), so the name — not the ID — is how you select a chain (`dot polkadot-asset-hub.query…`). A relay-prefixed name also mirrors the `dot chain list` tree, which groups parachains under their relay.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Recommended — relay-prefixed name
|
|
154
|
+
dot chain add kusama-asset-hub --rpc wss://asset-hub-kusama-rpc.polkadot.io --relay kusama --parachain-id 1000
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Use lowercase, hyphen-separated names (chain names resolve case-insensitively).
|
|
158
|
+
|
|
122
159
|
#### Chain topology
|
|
123
160
|
|
|
124
161
|
`dot chain list` displays chains as a tree, grouping parachains under their parent relay:
|
|
@@ -297,9 +334,10 @@ dot account derive treasury treasury-staking --path //staking
|
|
|
297
334
|
# Use it — the env var is read at signing time
|
|
298
335
|
MY_SECRET="word1 word2 ..." dot polkadot.tx.System.remark 0xdead --from ci-signer
|
|
299
336
|
|
|
300
|
-
# Remove one or more accounts
|
|
337
|
+
# Remove one or more accounts (delete and rm are aliases for remove)
|
|
301
338
|
dot account remove my-validator
|
|
302
339
|
dot account delete my-validator stale-key
|
|
340
|
+
dot account rm my-validator stale-key
|
|
303
341
|
|
|
304
342
|
# Export accounts (secrets redacted by default)
|
|
305
343
|
dot account export
|
|
@@ -777,6 +815,8 @@ dot polkadot.const.Balances.ExistentialDeposit --json | jq
|
|
|
777
815
|
|
|
778
816
|
Works offline from cached metadata after the first fetch. The chain is required. Prefer the chain-prefix-on-target form (`dot inspect polkadot.System`); `--chain` is equivalent. Note that `dot polkadot.inspect.X` does **not** parse — `inspect` is a top-level command, not a dotpath category.
|
|
779
817
|
|
|
818
|
+
`inspect` is **forgiving**: it accepts the same dot-paths you use to invoke a call and degrades to discovery rather than erroring. A `kind` segment (`tx`/`query`/`const`/`events`/`errors`/…) is tolerated and ignored — so `dot inspect polkadot.tx.System.remark` describes the `System.remark` call just like `dot inspect polkadot.System.remark` does. Partial paths list rather than fail: `dot inspect polkadot.query.System` (and the bare `dot inspect System`) list the pallet's items.
|
|
819
|
+
|
|
780
820
|
Output is **width-aware**: short type signatures stay on a single line, longer ones expand across multiple lines with field names aligned. Composite struct fields, enum variants, and call arguments are color-coded (cyan field names, yellow primitives, magenta container keywords like `Vec`/`Option`, green enum variants) when stdout is a TTY; piped output stays plain.
|
|
781
821
|
|
|
782
822
|
```bash
|
|
@@ -1200,6 +1240,13 @@ dot polkadot.tx.Balances.transfer_keep_alive bob 1000000000000 --from alice --dr
|
|
|
1200
1240
|
# Submit (omit --dry-run)
|
|
1201
1241
|
dot polkadot.tx.System.remark 0xdeadbeef --from alice
|
|
1202
1242
|
|
|
1243
|
+
# Force every tx to dry-run via the global DOT_DRY_RUN env var — a safety net
|
|
1244
|
+
# for scripts and demos. A hint is printed to stderr; the command behaves
|
|
1245
|
+
# exactly as if --dry-run had been passed.
|
|
1246
|
+
DOT_DRY_RUN=1 dot polkadot.tx.System.remark 0xdeadbeef --from alice
|
|
1247
|
+
# stderr: ⚠ DOT_DRY_RUN is set — extrinsics will be simulated, not submitted.
|
|
1248
|
+
# stdout: (the dry-run output above — no broadcast)
|
|
1249
|
+
|
|
1203
1250
|
# Submit a raw SCALE-encoded call (e.g. from a multisig proposal or another tool)
|
|
1204
1251
|
dot polkadot.tx 0x000010deadbeef --from alice --dry-run
|
|
1205
1252
|
|
|
@@ -2192,6 +2239,24 @@ cd - && rm -rf "$tmp" # nothing ever touched ~/.polkadot
|
|
|
2192
2239
|
|
|
2193
2240
|
For secrets that should never hit disk at all, combine workspaces with `--env` secret sources (see [Manage accounts](#manage-accounts)).
|
|
2194
2241
|
|
|
2242
|
+
### `DOT_DRY_RUN` — force every extrinsic to dry-run
|
|
2243
|
+
|
|
2244
|
+
Set `DOT_DRY_RUN` to a truthy value (`1`, `true`, `yes`, or `on`, case-insensitive) to make **every** extrinsic-submitting command behave as if `--dry-run` had been passed: the transaction is simulated (call decoded, fees estimated) and **never broadcast**. This is a global safety net for scripts, demos, and CI dry-runs where you want to be sure nothing lands on-chain.
|
|
2245
|
+
|
|
2246
|
+
When active, the CLI prints a one-line hint to **stderr** (so it never corrupts `--json` or piped stdout):
|
|
2247
|
+
|
|
2248
|
+
```bash
|
|
2249
|
+
DOT_DRY_RUN=1 dot polkadot.tx.Balances.transfer_keep_alive bob 1000000000000 --from alice
|
|
2250
|
+
# stderr: ⚠ DOT_DRY_RUN is set — extrinsics will be simulated, not submitted.
|
|
2251
|
+
# stdout: the usual dry-run report (Chain / From / Call / Decode / Estimated fees)
|
|
2252
|
+
|
|
2253
|
+
# Set it for a whole shell session as a safety net:
|
|
2254
|
+
export DOT_DRY_RUN=1
|
|
2255
|
+
dot polkadot.tx.System.remark 0xdeadbeef --from alice # simulated, not submitted
|
|
2256
|
+
```
|
|
2257
|
+
|
|
2258
|
+
**Precedence:** an explicit per-command flag always wins. `--dry-run` forces a dry-run; `--no-dry-run` forces a real submission even when `DOT_DRY_RUN` is set. The env var only supplies the default when no flag is given. Decode-only paths (`--encode`, `--to-yaml`, `--to-json`) never submit anything, so `DOT_DRY_RUN` leaves them untouched.
|
|
2259
|
+
|
|
2195
2260
|
### `DOT_TRUST_CACHED_METADATA` — skip the staleness check
|
|
2196
2261
|
|
|
2197
2262
|
Set `DOT_TRUST_CACHED_METADATA=1` to disable the post-failure stale-metadata check on `dot tx`, `dot tx --dry-run`, and `dot query`. When set, errors propagate exactly as the runtime / RPC reported them, with no extra `state_getRuntimeVersion` / `state_getStorageHash` round-trip. Useful in CI loops where you've just refreshed metadata manually and don't want the overhead.
|
package/dist/cli.mjs
CHANGED
|
@@ -917,6 +917,31 @@ var init_output = __esm(() => {
|
|
|
917
917
|
SPINNER_FRAMES = ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
|
|
918
918
|
});
|
|
919
919
|
|
|
920
|
+
// src/platform/cli.ts
|
|
921
|
+
function withHelp(command, printHelp) {
|
|
922
|
+
command[HELP_PRINTER] = printHelp ?? (() => command.outputHelp());
|
|
923
|
+
return command;
|
|
924
|
+
}
|
|
925
|
+
function readRawOptionValue(name, argv = process.argv) {
|
|
926
|
+
const flag = `--${name}`;
|
|
927
|
+
const prefix = `${flag}=`;
|
|
928
|
+
let value;
|
|
929
|
+
for (let i = 0;i < argv.length; i++) {
|
|
930
|
+
const arg = argv[i];
|
|
931
|
+
if (arg === "--")
|
|
932
|
+
break;
|
|
933
|
+
if (arg === flag && i + 1 < argv.length)
|
|
934
|
+
value = argv[i + 1];
|
|
935
|
+
else if (arg.startsWith(prefix))
|
|
936
|
+
value = arg.slice(prefix.length);
|
|
937
|
+
}
|
|
938
|
+
return value;
|
|
939
|
+
}
|
|
940
|
+
var HELP_PRINTER;
|
|
941
|
+
var init_cli = __esm(() => {
|
|
942
|
+
HELP_PRINTER = Symbol.for("polkadot-cli.helpPrinter");
|
|
943
|
+
});
|
|
944
|
+
|
|
920
945
|
// src/features/verifiable/lib.ts
|
|
921
946
|
var exports_lib = {};
|
|
922
947
|
__export(exports_lib, {
|
|
@@ -3490,23 +3515,6 @@ var init_input = __esm(() => {
|
|
|
3490
3515
|
init_hash();
|
|
3491
3516
|
});
|
|
3492
3517
|
|
|
3493
|
-
// src/platform/cli.ts
|
|
3494
|
-
function readRawOptionValue(name, argv = process.argv) {
|
|
3495
|
-
const flag = `--${name}`;
|
|
3496
|
-
const prefix = `${flag}=`;
|
|
3497
|
-
let value;
|
|
3498
|
-
for (let i = 0;i < argv.length; i++) {
|
|
3499
|
-
const arg = argv[i];
|
|
3500
|
-
if (arg === "--")
|
|
3501
|
-
break;
|
|
3502
|
-
if (arg === flag && i + 1 < argv.length)
|
|
3503
|
-
value = argv[i + 1];
|
|
3504
|
-
else if (arg.startsWith(prefix))
|
|
3505
|
-
value = arg.slice(prefix.length);
|
|
3506
|
-
}
|
|
3507
|
-
return value;
|
|
3508
|
-
}
|
|
3509
|
-
|
|
3510
3518
|
// src/platform/index.ts
|
|
3511
3519
|
var init_platform = __esm(() => {
|
|
3512
3520
|
init_accounts_store();
|
|
@@ -3515,6 +3523,7 @@ var init_platform = __esm(() => {
|
|
|
3515
3523
|
init_input();
|
|
3516
3524
|
init_output();
|
|
3517
3525
|
init_errors();
|
|
3526
|
+
init_cli();
|
|
3518
3527
|
});
|
|
3519
3528
|
|
|
3520
3529
|
// src/features/verifiable/commands.ts
|
|
@@ -3810,8 +3819,8 @@ var exports_complete = {};
|
|
|
3810
3819
|
__export(exports_complete, {
|
|
3811
3820
|
generateCompletions: () => generateCompletions
|
|
3812
3821
|
});
|
|
3813
|
-
function
|
|
3814
|
-
return
|
|
3822
|
+
function matchCategory3(s) {
|
|
3823
|
+
return CATEGORY_ALIASES3[s.toLowerCase()];
|
|
3815
3824
|
}
|
|
3816
3825
|
async function loadPallets(_config, chainName) {
|
|
3817
3826
|
const raw = await loadMetadata(chainName);
|
|
@@ -3942,7 +3951,7 @@ function detectCategory(words, _knownChains) {
|
|
|
3942
3951
|
continue;
|
|
3943
3952
|
const parts = w.split(".");
|
|
3944
3953
|
for (const part of parts) {
|
|
3945
|
-
const cat =
|
|
3954
|
+
const cat = matchCategory3(part);
|
|
3946
3955
|
if (cat)
|
|
3947
3956
|
return cat;
|
|
3948
3957
|
}
|
|
@@ -3964,11 +3973,11 @@ async function completeDotpath(currentWord, config, knownChains, precedingWords)
|
|
|
3964
3973
|
return filterPrefix(candidates, partial);
|
|
3965
3974
|
}
|
|
3966
3975
|
const first = completeSegments[0] ?? "";
|
|
3967
|
-
const firstIsCategory =
|
|
3976
|
+
const firstIsCategory = matchCategory3(first) !== undefined;
|
|
3968
3977
|
const firstIsChain = knownChains.some((c) => c.toLowerCase() === first.toLowerCase());
|
|
3969
3978
|
const chainFromFlag = resolveChainFromArgs(precedingWords, config);
|
|
3970
3979
|
if (firstIsCategory) {
|
|
3971
|
-
const category =
|
|
3980
|
+
const category = matchCategory3(first);
|
|
3972
3981
|
if (category === "apis") {
|
|
3973
3982
|
return completeApisCategory(first, numComplete, endsWithDot, completeSegments, currentWord, config, chainFromFlag);
|
|
3974
3983
|
}
|
|
@@ -4028,7 +4037,7 @@ async function completeDotpath(currentWord, config, knownChains, precedingWords)
|
|
|
4028
4037
|
return filterPrefix(candidates, currentWord);
|
|
4029
4038
|
}
|
|
4030
4039
|
if (numComplete === 2) {
|
|
4031
|
-
const category =
|
|
4040
|
+
const category = matchCategory3(completeSegments[1]);
|
|
4032
4041
|
if (!category)
|
|
4033
4042
|
return [];
|
|
4034
4043
|
if (category === "apis") {
|
|
@@ -4049,7 +4058,7 @@ async function completeDotpath(currentWord, config, knownChains, precedingWords)
|
|
|
4049
4058
|
return filterPrefix(candidates, endsWithDot ? currentWord.slice(0, -1) : currentWord);
|
|
4050
4059
|
}
|
|
4051
4060
|
if (numComplete === 3) {
|
|
4052
|
-
const category =
|
|
4061
|
+
const category = matchCategory3(completeSegments[1]);
|
|
4053
4062
|
if (!category)
|
|
4054
4063
|
return [];
|
|
4055
4064
|
if (category === "apis") {
|
|
@@ -4131,7 +4140,7 @@ async function completeRpcCategory(prefix, numComplete, endsWithDot, currentWord
|
|
|
4131
4140
|
}
|
|
4132
4141
|
return [];
|
|
4133
4142
|
}
|
|
4134
|
-
var CATEGORIES2,
|
|
4143
|
+
var CATEGORIES2, CATEGORY_ALIASES3, NAMED_COMMANDS, CHAIN_SUBCOMMANDS, ACCOUNT_SUBCOMMANDS, GLOBAL_OPTIONS, TX_OPTIONS, QUERY_OPTIONS;
|
|
4135
4144
|
var init_complete = __esm(() => {
|
|
4136
4145
|
init_accounts_store();
|
|
4137
4146
|
init_store();
|
|
@@ -4149,7 +4158,7 @@ var init_complete = __esm(() => {
|
|
|
4149
4158
|
"extensions",
|
|
4150
4159
|
"rpc"
|
|
4151
4160
|
];
|
|
4152
|
-
|
|
4161
|
+
CATEGORY_ALIASES3 = {
|
|
4153
4162
|
query: "query",
|
|
4154
4163
|
tx: "tx",
|
|
4155
4164
|
const: "const",
|
|
@@ -4207,7 +4216,7 @@ var init_complete = __esm(() => {
|
|
|
4207
4216
|
// src/cli.ts
|
|
4208
4217
|
import cac from "cac";
|
|
4209
4218
|
// package.json
|
|
4210
|
-
var version = "1.
|
|
4219
|
+
var version = "1.23.0";
|
|
4211
4220
|
|
|
4212
4221
|
// src/commands/account.ts
|
|
4213
4222
|
init_accounts_store();
|
|
@@ -4341,6 +4350,7 @@ function isValidParaId(value) {
|
|
|
4341
4350
|
}
|
|
4342
4351
|
|
|
4343
4352
|
// src/commands/account.ts
|
|
4353
|
+
init_cli();
|
|
4344
4354
|
var ACCOUNT_HELP = `
|
|
4345
4355
|
${BOLD}Usage:${RESET}
|
|
4346
4356
|
$ dot account add <name> <ss58|hex> Add a watch-only address (no secret)
|
|
@@ -4357,7 +4367,7 @@ ${BOLD}Usage:${RESET}
|
|
|
4357
4367
|
$ dot account inspect --pallet-id <id> [--prefix <N>] Derive a pallet sovereign (no save — script-friendly)
|
|
4358
4368
|
$ dot account inspect --parachain <id> --parachain-type <t> Derive a parachain sovereign (no save — script-friendly)
|
|
4359
4369
|
$ dot account list List all accounts
|
|
4360
|
-
$ dot account remove|delete <name> [name2] ...
|
|
4370
|
+
$ dot account remove|delete|rm <name> [name2] ... Remove stored account(s)
|
|
4361
4371
|
|
|
4362
4372
|
${BOLD}Examples:${RESET}
|
|
4363
4373
|
$ dot account add treasury 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
|
|
@@ -4395,7 +4405,7 @@ ${YELLOW}Note: Secrets are stored unencrypted in ~/.polkadot/accounts.json.
|
|
|
4395
4405
|
Raw private keys cannot be HD-derived, so --path is rejected for them.${RESET}
|
|
4396
4406
|
`.trimStart();
|
|
4397
4407
|
function registerAccountCommands(cli) {
|
|
4398
|
-
cli.command("account [action] [...names]", "Manage local accounts (create, import, list, remove, export)").alias("accounts").option("--secret <value>", "Secret for import: BIP39 mnemonic, 0x 32-byte hex seed, or 0x 64-byte raw private key").option("--env <varName>", "Environment variable name holding the secret").option("--path <derivation>", "Derivation path (e.g. //staking, //polkadot//0/wallet)").option("--parachain <id>", "Derive a parachain sovereign account (requires --parachain-type)").option("--parachain-type <type>", "Parachain sovereign type: child or sibling").option("--pallet-id <id>", "Derive a pallet sovereign account from an 8-byte PalletId").option("--prefix <number>", "SS58 prefix for address encoding (default: 42)").option("--file <path>", "Input/output file for batch import/export").option("--overwrite", "Overwrite existing accounts on batch import").option("--dry-run", "Preview batch import without applying changes").option("--include-secrets", "Include secrets in export (redacted by default)").option("--watch-only", "Export only watch-only accounts").option("--show-secret", "Reveal the 64-byte sr25519 expanded private key (inspect only)").action(async (action, names, opts) => {
|
|
4408
|
+
const command = cli.command("account [action] [...names]", "Manage local accounts (create, import, list, remove, export)").alias("accounts").option("--secret <value>", "Secret for import: BIP39 mnemonic, 0x 32-byte hex seed, or 0x 64-byte raw private key").option("--env <varName>", "Environment variable name holding the secret").option("--path <derivation>", "Derivation path (e.g. //staking, //polkadot//0/wallet)").option("--parachain <id>", "Derive a parachain sovereign account (requires --parachain-type)").option("--parachain-type <type>", "Parachain sovereign type: child or sibling").option("--pallet-id <id>", "Derive a pallet sovereign account from an 8-byte PalletId").option("--prefix <number>", "SS58 prefix for address encoding (default: 42)").option("--file <path>", "Input/output file for batch import/export").option("--overwrite", "Overwrite existing accounts on batch import").option("--dry-run", "Preview batch import without applying changes").option("--include-secrets", "Include secrets in export (redacted by default)").option("--watch-only", "Export only watch-only accounts").option("--show-secret", "Reveal the 64-byte sr25519 expanded private key (inspect only)").action(async (action, names, opts) => {
|
|
4399
4409
|
if (!action) {
|
|
4400
4410
|
if (process.argv[2] === "accounts")
|
|
4401
4411
|
return accountList(opts);
|
|
@@ -4428,6 +4438,7 @@ function registerAccountCommands(cli) {
|
|
|
4428
4438
|
return accountList(opts);
|
|
4429
4439
|
case "delete":
|
|
4430
4440
|
case "remove":
|
|
4441
|
+
case "rm":
|
|
4431
4442
|
return accountRemove(names, opts);
|
|
4432
4443
|
case "inspect":
|
|
4433
4444
|
return accountInspect(names[0], opts);
|
|
@@ -4435,6 +4446,7 @@ function registerAccountCommands(cli) {
|
|
|
4435
4446
|
return accountInspect(action, opts);
|
|
4436
4447
|
}
|
|
4437
4448
|
});
|
|
4449
|
+
withHelp(command, () => console.log(ACCOUNT_HELP));
|
|
4438
4450
|
}
|
|
4439
4451
|
async function accountCreate(name, opts) {
|
|
4440
4452
|
if (!name) {
|
|
@@ -5528,6 +5540,7 @@ async function fetchRpcMethods(rpcUrl) {
|
|
|
5528
5540
|
|
|
5529
5541
|
// src/commands/chain.ts
|
|
5530
5542
|
init_rpc_registry();
|
|
5543
|
+
init_cli();
|
|
5531
5544
|
var CHAIN_HELP = `
|
|
5532
5545
|
${BOLD}Usage:${RESET}
|
|
5533
5546
|
$ dot chain add <name> --rpc <url> Add a chain via WebSocket RPC
|
|
@@ -5561,7 +5574,7 @@ ${BOLD}Examples:${RESET}
|
|
|
5561
5574
|
$ dot chain import my-chains.json --no-metadata
|
|
5562
5575
|
`.trimStart();
|
|
5563
5576
|
function registerChainCommands(cli) {
|
|
5564
|
-
cli.command("chain [action] [...names]", "Manage chains (add, remove, update, list, export, import)").alias("chains").option("--all", "Update/export all configured chains").option("--relay <name>", "Parent relay chain for this parachain").option("--parachain-id <id>", "Parachain ID (auto-detected if omitted with --relay)").option("--file <path>", "Output/input file for export/import").option("--overwrite", "Overwrite existing chains on import").option("--dry-run", "Preview import without applying changes").option("--no-metadata", "Skip automatic metadata fetch after import").option("-v, --verbose", "Show RPC endpoints in `chains` list output").action(async (action, names, opts) => {
|
|
5577
|
+
const command = cli.command("chain [action] [...names]", "Manage chains (add, remove, update, list, export, import)").alias("chains").option("--all", "Update/export all configured chains").option("--relay <name>", "Parent relay chain for this parachain").option("--parachain-id <id>", "Parachain ID (auto-detected if omitted with --relay)").option("--file <path>", "Output/input file for export/import").option("--overwrite", "Overwrite existing chains on import").option("--dry-run", "Preview import without applying changes").option("--no-metadata", "Skip automatic metadata fetch after import").option("-v, --verbose", "Show RPC endpoints in `chains` list output").action(async (action, names, opts) => {
|
|
5565
5578
|
if (!action) {
|
|
5566
5579
|
if (process.argv[2] === "chains")
|
|
5567
5580
|
return chainList(opts);
|
|
@@ -5595,6 +5608,7 @@ function registerChainCommands(cli) {
|
|
|
5595
5608
|
}
|
|
5596
5609
|
}
|
|
5597
5610
|
});
|
|
5611
|
+
withHelp(command, () => console.log(CHAIN_HELP));
|
|
5598
5612
|
}
|
|
5599
5613
|
async function refreshRpcMethods(chainName, rpcUrl, silent = false) {
|
|
5600
5614
|
try {
|
|
@@ -6036,6 +6050,7 @@ async function chainImport(filePath, opts) {
|
|
|
6036
6050
|
}
|
|
6037
6051
|
|
|
6038
6052
|
// src/commands/completions.ts
|
|
6053
|
+
init_cli();
|
|
6039
6054
|
var ZSH_SCRIPT = `_dot_completions() {
|
|
6040
6055
|
emulate -L zsh
|
|
6041
6056
|
local -a completions
|
|
@@ -6104,7 +6119,7 @@ var SCRIPTS = {
|
|
|
6104
6119
|
fish: FISH_SCRIPT
|
|
6105
6120
|
};
|
|
6106
6121
|
function registerCompletionsCommand(cli) {
|
|
6107
|
-
cli.command("completions <shell>", "Generate shell completion script (zsh, bash, fish)").action((shell) => {
|
|
6122
|
+
const command = cli.command("completions <shell>", "Generate shell completion script (zsh, bash, fish)").action((shell) => {
|
|
6108
6123
|
const script = SCRIPTS[shell];
|
|
6109
6124
|
if (!script) {
|
|
6110
6125
|
console.error(`Unsupported shell "${shell}". Supported: ${Object.keys(SCRIPTS).join(", ")}`);
|
|
@@ -6117,6 +6132,7 @@ function registerCompletionsCommand(cli) {
|
|
|
6117
6132
|
}
|
|
6118
6133
|
console.log(script);
|
|
6119
6134
|
});
|
|
6135
|
+
withHelp(command);
|
|
6120
6136
|
}
|
|
6121
6137
|
|
|
6122
6138
|
// src/commands/const.ts
|
|
@@ -6894,6 +6910,7 @@ async function handleExtensions(target, opts) {
|
|
|
6894
6910
|
init_hash();
|
|
6895
6911
|
init_input();
|
|
6896
6912
|
init_output();
|
|
6913
|
+
init_cli();
|
|
6897
6914
|
init_errors();
|
|
6898
6915
|
function printAlgorithmHelp() {
|
|
6899
6916
|
console.log(`${BOLD}Usage:${RESET} dot hash <algorithm> <data> [options]
|
|
@@ -6915,7 +6932,7 @@ ${BOLD}Examples:${RESET}`);
|
|
|
6915
6932
|
console.log(` ${DIM}$ echo -n "hello" | dot hash sha256 --stdin${RESET}`);
|
|
6916
6933
|
}
|
|
6917
6934
|
function registerHashCommand(cli) {
|
|
6918
|
-
cli.command("hash [algorithm] [data]", "Compute cryptographic hashes").option("--file <path>", "Hash file contents (raw bytes)").option("--stdin", "Read data from stdin").action(async (algorithm, data, opts) => {
|
|
6935
|
+
const command = cli.command("hash [algorithm] [data]", "Compute cryptographic hashes").option("--file <path>", "Hash file contents (raw bytes)").option("--stdin", "Read data from stdin").action(async (algorithm, data, opts) => {
|
|
6919
6936
|
if (!algorithm) {
|
|
6920
6937
|
printAlgorithmHelp();
|
|
6921
6938
|
return;
|
|
@@ -6936,6 +6953,7 @@ function registerHashCommand(cli) {
|
|
|
6936
6953
|
console.log(hexHash);
|
|
6937
6954
|
}
|
|
6938
6955
|
});
|
|
6956
|
+
withHelp(command, printAlgorithmHelp);
|
|
6939
6957
|
}
|
|
6940
6958
|
|
|
6941
6959
|
// src/commands/inspect.ts
|
|
@@ -6944,11 +6962,44 @@ init_client();
|
|
|
6944
6962
|
init_metadata();
|
|
6945
6963
|
init_output();
|
|
6946
6964
|
init_pretty_type();
|
|
6965
|
+
init_cli();
|
|
6966
|
+
|
|
6967
|
+
// src/utils/parse-dot-path.ts
|
|
6968
|
+
var CATEGORY_ALIASES = {
|
|
6969
|
+
query: "query",
|
|
6970
|
+
tx: "tx",
|
|
6971
|
+
const: "const",
|
|
6972
|
+
consts: "const",
|
|
6973
|
+
constants: "const",
|
|
6974
|
+
events: "events",
|
|
6975
|
+
event: "events",
|
|
6976
|
+
errors: "errors",
|
|
6977
|
+
error: "errors",
|
|
6978
|
+
apis: "apis",
|
|
6979
|
+
api: "apis",
|
|
6980
|
+
extensions: "extensions",
|
|
6981
|
+
extension: "extensions",
|
|
6982
|
+
ext: "extensions",
|
|
6983
|
+
rpc: "rpc"
|
|
6984
|
+
};
|
|
6985
|
+
function matchCategory(segment) {
|
|
6986
|
+
return CATEGORY_ALIASES[segment.toLowerCase()];
|
|
6987
|
+
}
|
|
6947
6988
|
|
|
6948
6989
|
// src/utils/parse-target.ts
|
|
6990
|
+
function stripKindSegment(parts, knownChains) {
|
|
6991
|
+
if (parts.length >= 3 && parts[0] && knownChains.some((c) => c.toLowerCase() === parts[0].toLowerCase()) && parts[1] && matchCategory(parts[1])) {
|
|
6992
|
+
return [parts[0], ...parts.slice(2)];
|
|
6993
|
+
}
|
|
6994
|
+
if (parts.length >= 2 && parts[0] && matchCategory(parts[0])) {
|
|
6995
|
+
return parts.slice(1);
|
|
6996
|
+
}
|
|
6997
|
+
return parts;
|
|
6998
|
+
}
|
|
6949
6999
|
function parseTarget(input, options) {
|
|
6950
|
-
|
|
7000
|
+
let parts = input.split(".");
|
|
6951
7001
|
if (options?.allowPalletOnly) {
|
|
7002
|
+
parts = stripKindSegment(parts, options.knownChains ?? []);
|
|
6952
7003
|
switch (parts.length) {
|
|
6953
7004
|
case 1:
|
|
6954
7005
|
if (!parts[0]) {
|
|
@@ -6969,7 +7020,7 @@ function parseTarget(input, options) {
|
|
|
6969
7020
|
}
|
|
6970
7021
|
return { chain: parts[0], pallet: parts[1], item: parts[2] };
|
|
6971
7022
|
default:
|
|
6972
|
-
throw new Error(`Invalid target "${input}". Expected format: Pallet, Pallet.Item,
|
|
7023
|
+
throw new Error(`Invalid target "${input}". Expected format: Pallet, Pallet.Item, Chain.Pallet.Item, ` + `or a dot-path with a kind segment (e.g. polkadot.tx.System.remark)`);
|
|
6973
7024
|
}
|
|
6974
7025
|
}
|
|
6975
7026
|
switch (parts.length) {
|
|
@@ -6996,7 +7047,7 @@ function resolveTargetChain(target, chainFlag) {
|
|
|
6996
7047
|
|
|
6997
7048
|
// src/commands/inspect.ts
|
|
6998
7049
|
function registerInspectCommand(cli) {
|
|
6999
|
-
cli.command("inspect [target]", "Inspect chain metadata (pallets, storage, constants, calls, events, errors)").alias("explore").option("--chain <name>", "Target chain").option("--rpc <url>", "Override RPC endpoint").action(async (target, opts) => {
|
|
7050
|
+
const command = cli.command("inspect [target]", "Inspect chain metadata (pallets, storage, constants, calls, events, errors)").alias("explore").option("--chain <name>", "Target chain").option("--rpc <url>", "Override RPC endpoint").action(async (target, opts) => {
|
|
7000
7051
|
const config = await loadConfig();
|
|
7001
7052
|
const knownChains = Object.keys(config.chains);
|
|
7002
7053
|
let effectiveChain = opts.chain;
|
|
@@ -7364,6 +7415,7 @@ function registerInspectCommand(cli) {
|
|
|
7364
7415
|
];
|
|
7365
7416
|
throw new Error(suggestMessage(`item in ${pallet.name}`, itemName, allItems));
|
|
7366
7417
|
});
|
|
7418
|
+
withHelp(command);
|
|
7367
7419
|
}
|
|
7368
7420
|
|
|
7369
7421
|
// src/commands/metadata.ts
|
|
@@ -7371,6 +7423,7 @@ init_store();
|
|
|
7371
7423
|
init_client();
|
|
7372
7424
|
init_metadata();
|
|
7373
7425
|
init_output();
|
|
7426
|
+
init_cli();
|
|
7374
7427
|
init_errors();
|
|
7375
7428
|
function buildMetadataPayload(chainName, meta, fingerprint) {
|
|
7376
7429
|
return {
|
|
@@ -7413,12 +7466,14 @@ async function handleMetadata(chain, opts) {
|
|
|
7413
7466
|
`);
|
|
7414
7467
|
}
|
|
7415
7468
|
function registerMetadataCommand(cli) {
|
|
7416
|
-
cli.command("metadata <chain>", "Fetch chain metadata (decoded JSON; --raw for SCALE hex)").option("--raw", "Print SCALE-encoded metadata bytes as hex instead of decoded JSON").option("--cached", "Use cached metadata instead of fetching fresh from the chain").option("--rpc <url>", "Override RPC endpoint(s)").action((chain, opts) => handleMetadata(chain, opts));
|
|
7469
|
+
const command = cli.command("metadata <chain>", "Fetch chain metadata (decoded JSON; --raw for SCALE hex)").option("--raw", "Print SCALE-encoded metadata bytes as hex instead of decoded JSON").option("--cached", "Use cached metadata instead of fetching fresh from the chain").option("--rpc <url>", "Override RPC endpoint(s)").action((chain, opts) => handleMetadata(chain, opts));
|
|
7470
|
+
withHelp(command);
|
|
7417
7471
|
}
|
|
7418
7472
|
|
|
7419
7473
|
// src/commands/parachain.ts
|
|
7420
7474
|
init_accounts();
|
|
7421
7475
|
init_output();
|
|
7476
|
+
init_cli();
|
|
7422
7477
|
init_errors();
|
|
7423
7478
|
function printParachainHelp() {
|
|
7424
7479
|
console.log(`${BOLD}Usage:${RESET} dot parachain <paraId> [options]
|
|
@@ -7447,7 +7502,7 @@ function validateType(type) {
|
|
|
7447
7502
|
throw new CliError(`Unknown account type "${type}". Valid types: child, sibling.`);
|
|
7448
7503
|
}
|
|
7449
7504
|
function registerParachainCommand(cli) {
|
|
7450
|
-
cli.command("parachain [paraId]", "Derive parachain sovereign accounts").option("--type <type>", "Account type: child, sibling (default: both)").option("--prefix <number>", "SS58 prefix for address encoding (default: 42)").action(async (paraIdStr, opts) => {
|
|
7505
|
+
const command = cli.command("parachain [paraId]", "Derive parachain sovereign accounts").option("--type <type>", "Account type: child, sibling (default: both)").option("--prefix <number>", "SS58 prefix for address encoding (default: 42)").action(async (paraIdStr, opts) => {
|
|
7451
7506
|
console.error("Warning: `dot parachain` is deprecated; use `dot account inspect --parachain <id> --parachain-type <child|sibling>` instead. Will be removed in a future release.");
|
|
7452
7507
|
if (!paraIdStr) {
|
|
7453
7508
|
printParachainHelp();
|
|
@@ -7487,6 +7542,7 @@ function registerParachainCommand(cli) {
|
|
|
7487
7542
|
}
|
|
7488
7543
|
}
|
|
7489
7544
|
});
|
|
7545
|
+
withHelp(command, printParachainHelp);
|
|
7490
7546
|
}
|
|
7491
7547
|
|
|
7492
7548
|
// src/commands/query.ts
|
|
@@ -7831,6 +7887,7 @@ init_accounts();
|
|
|
7831
7887
|
init_hash();
|
|
7832
7888
|
init_input();
|
|
7833
7889
|
init_output();
|
|
7890
|
+
init_cli();
|
|
7834
7891
|
init_errors();
|
|
7835
7892
|
var SUPPORTED_TYPES = ["sr25519"];
|
|
7836
7893
|
function isSupportedType(type) {
|
|
@@ -7863,7 +7920,7 @@ ${BOLD}Examples:${RESET}`);
|
|
|
7863
7920
|
console.log(` ${DIM}$ dot sign "hello" --from alice --output json${RESET}`);
|
|
7864
7921
|
}
|
|
7865
7922
|
function registerSignCommand(cli) {
|
|
7866
|
-
cli.command("sign [message]", "Sign a message with an account keypair").option("--from <name>", "Account to sign with").option("--type <algo>", "Signature type (default: sr25519)").option("--file <path>", "Sign file contents (raw bytes)").option("--stdin", "Read data from stdin").action(async (message, opts) => {
|
|
7923
|
+
const command = cli.command("sign [message]", "Sign a message with an account keypair").option("--from <name>", "Account to sign with").option("--type <algo>", "Signature type (default: sr25519)").option("--file <path>", "Sign file contents (raw bytes)").option("--stdin", "Read data from stdin").action(async (message, opts) => {
|
|
7867
7924
|
if (!message && !opts.file && !opts.stdin) {
|
|
7868
7925
|
printSignHelp();
|
|
7869
7926
|
return;
|
|
@@ -7897,6 +7954,7 @@ function registerSignCommand(cli) {
|
|
|
7897
7954
|
console.log(` ${BOLD}Enum:${RESET} ${result.enum}`);
|
|
7898
7955
|
}
|
|
7899
7956
|
});
|
|
7957
|
+
withHelp(command, printSignHelp);
|
|
7900
7958
|
}
|
|
7901
7959
|
|
|
7902
7960
|
// src/commands/tx.ts
|
|
@@ -9354,6 +9412,7 @@ function watchTransactionJson(observable, level, options) {
|
|
|
9354
9412
|
init_store();
|
|
9355
9413
|
init_workspace();
|
|
9356
9414
|
init_output();
|
|
9415
|
+
init_cli();
|
|
9357
9416
|
init_errors();
|
|
9358
9417
|
import { mkdir as mkdir3, stat } from "node:fs/promises";
|
|
9359
9418
|
import { homedir as homedir3 } from "node:os";
|
|
@@ -9407,8 +9466,10 @@ Source: ${SOURCE_LABELS[resolved.source]}
|
|
|
9407
9466
|
`);
|
|
9408
9467
|
}
|
|
9409
9468
|
function registerWorkspaceCommands(cli) {
|
|
9410
|
-
cli.command("init", "Initialize a local .polkadot workspace in the current directory").action(() => handleInit());
|
|
9411
|
-
|
|
9469
|
+
const initCommand = cli.command("init", "Initialize a local .polkadot workspace in the current directory").action(() => handleInit());
|
|
9470
|
+
withHelp(initCommand);
|
|
9471
|
+
const whichCommand = cli.command("which", "Show the active config root (workspace, DOT_HOME, or global)").action((opts) => handleWhich(opts));
|
|
9472
|
+
withHelp(whichCommand);
|
|
9412
9473
|
}
|
|
9413
9474
|
|
|
9414
9475
|
// src/config/store.ts
|
|
@@ -9469,6 +9530,48 @@ async function saveConfig2(config) {
|
|
|
9469
9530
|
`);
|
|
9470
9531
|
}
|
|
9471
9532
|
|
|
9533
|
+
// src/core/dry-run.ts
|
|
9534
|
+
init_output();
|
|
9535
|
+
function isGlobalDryRun() {
|
|
9536
|
+
const raw = process.env.DOT_DRY_RUN?.trim().toLowerCase();
|
|
9537
|
+
if (raw === undefined || raw === "")
|
|
9538
|
+
return false;
|
|
9539
|
+
return raw === "1" || raw === "true" || raw === "yes" || raw === "on";
|
|
9540
|
+
}
|
|
9541
|
+
function resolveDryRun(explicitFlag, decodeOnly = false) {
|
|
9542
|
+
if (explicitFlag !== undefined)
|
|
9543
|
+
return explicitFlag;
|
|
9544
|
+
if (decodeOnly)
|
|
9545
|
+
return false;
|
|
9546
|
+
return isGlobalDryRun();
|
|
9547
|
+
}
|
|
9548
|
+
var hintPrinted = false;
|
|
9549
|
+
function printGlobalDryRunHint() {
|
|
9550
|
+
if (hintPrinted)
|
|
9551
|
+
return;
|
|
9552
|
+
hintPrinted = true;
|
|
9553
|
+
process.stderr.write(`${YELLOW}${BOLD}⚠ DOT_DRY_RUN is set${RESET}${YELLOW} — extrinsics will be simulated, not submitted.${RESET}
|
|
9554
|
+
`);
|
|
9555
|
+
}
|
|
9556
|
+
|
|
9557
|
+
// src/core/external-command.ts
|
|
9558
|
+
var PLUGIN_PREFIX = "dot-";
|
|
9559
|
+
function isExternalCommandCandidate(name) {
|
|
9560
|
+
return /^[A-Za-z0-9][A-Za-z0-9_-]*$/.test(name);
|
|
9561
|
+
}
|
|
9562
|
+
function findExternalCommand(name) {
|
|
9563
|
+
if (!isExternalCommandCandidate(name))
|
|
9564
|
+
return null;
|
|
9565
|
+
return Bun.which(`${PLUGIN_PREFIX}${name}`, { PATH: process.env.PATH ?? "" });
|
|
9566
|
+
}
|
|
9567
|
+
function runExternalCommand(binPath, args) {
|
|
9568
|
+
const result = Bun.spawnSync([binPath, ...args], {
|
|
9569
|
+
stdio: ["inherit", "inherit", "inherit"],
|
|
9570
|
+
env: { ...process.env, DOT_BIN: process.argv[1] ?? "dot" }
|
|
9571
|
+
});
|
|
9572
|
+
return result.exitCode ?? 1;
|
|
9573
|
+
}
|
|
9574
|
+
|
|
9472
9575
|
// src/core/file-loader.ts
|
|
9473
9576
|
init_errors();
|
|
9474
9577
|
import { access as access4, readFile as readFile7 } from "node:fs/promises";
|
|
@@ -9796,7 +9899,7 @@ var RAW_STRING_FLAGS = [
|
|
|
9796
9899
|
["member", "member"]
|
|
9797
9900
|
];
|
|
9798
9901
|
function registerVerifiableCommands(cli) {
|
|
9799
|
-
cli.command("verifiable [action] [...rest]", "Bandersnatch member keys, ring-VRF proofs, signing and verification").option("--entropy-key <key>", "Entropy-derivation key (omit = lite, 'candidate' = full)").option("--context <value>", "32-byte ring/proof context (alias/prove/verify)").option("--message <data>", "Message to sign/bind/verify (text or 0x hex)").option("--file <path>", "Read message from a file (raw bytes)").option("--stdin", "Read message from stdin").option("--members <hex|file>", "SCALE-encoded Vec<[u8;32]> ring (prove/verify)").option("--root <hex>", "768-byte ring root/commitment (verify)").option("--proof <hex>", "Ring-VRF proof bytes (verify)").option("--signature <hex>", "Bandersnatch signature (verify-sig)").option("--member <hex>", "32-byte member public key (verify-sig)").option("--ring-exponent <n>", "Ring exponent: 9 (default), 10, or 14").action(async (action, rest, opts) => {
|
|
9902
|
+
const command = cli.command("verifiable [action] [...rest]", "Bandersnatch member keys, ring-VRF proofs, signing and verification").option("--entropy-key <key>", "Entropy-derivation key (omit = lite, 'candidate' = full)").option("--context <value>", "32-byte ring/proof context (alias/prove/verify)").option("--message <data>", "Message to sign/bind/verify (text or 0x hex)").option("--file <path>", "Read message from a file (raw bytes)").option("--stdin", "Read message from stdin").option("--members <hex|file>", "SCALE-encoded Vec<[u8;32]> ring (prove/verify)").option("--root <hex>", "768-byte ring root/commitment (verify)").option("--proof <hex>", "Ring-VRF proof bytes (verify)").option("--signature <hex>", "Bandersnatch signature (verify-sig)").option("--member <hex>", "32-byte member public key (verify-sig)").option("--ring-exponent <n>", "Ring exponent: 9 (default), 10, or 14").action(async (action, rest, opts) => {
|
|
9800
9903
|
if (!action) {
|
|
9801
9904
|
console.log(VERIFIABLE_HELP);
|
|
9802
9905
|
return;
|
|
@@ -9809,9 +9912,19 @@ function registerVerifiableCommands(cli) {
|
|
|
9809
9912
|
const { runVerifiable: runVerifiable2 } = await Promise.resolve().then(() => (init_commands(), exports_commands));
|
|
9810
9913
|
return runVerifiable2(action, rest, opts);
|
|
9811
9914
|
});
|
|
9915
|
+
withHelp(command, () => console.log(VERIFIABLE_HELP));
|
|
9812
9916
|
}
|
|
9813
9917
|
|
|
9814
9918
|
// src/platform/cli.ts
|
|
9919
|
+
var HELP_PRINTER2 = Symbol.for("polkadot-cli.helpPrinter");
|
|
9920
|
+
function printMatchedCommandHelp(cli) {
|
|
9921
|
+
const matched = cli.matchedCommand;
|
|
9922
|
+
const printer = matched?.[HELP_PRINTER2];
|
|
9923
|
+
if (!printer)
|
|
9924
|
+
return false;
|
|
9925
|
+
printer();
|
|
9926
|
+
return true;
|
|
9927
|
+
}
|
|
9815
9928
|
function registerGlobalOptions(cli) {
|
|
9816
9929
|
cli.option("--chain <name>", "Target chain (required)");
|
|
9817
9930
|
cli.option("--rpc <url>", "Override RPC endpoint for this call");
|
|
@@ -9873,7 +9986,7 @@ function formatRuntimeError2(err) {
|
|
|
9873
9986
|
}
|
|
9874
9987
|
|
|
9875
9988
|
// src/utils/parse-dot-path.ts
|
|
9876
|
-
var
|
|
9989
|
+
var CATEGORY_ALIASES2 = {
|
|
9877
9990
|
query: "query",
|
|
9878
9991
|
tx: "tx",
|
|
9879
9992
|
const: "const",
|
|
@@ -9890,8 +10003,8 @@ var CATEGORY_ALIASES = {
|
|
|
9890
10003
|
ext: "extensions",
|
|
9891
10004
|
rpc: "rpc"
|
|
9892
10005
|
};
|
|
9893
|
-
function
|
|
9894
|
-
return
|
|
10006
|
+
function matchCategory2(segment) {
|
|
10007
|
+
return CATEGORY_ALIASES2[segment.toLowerCase()];
|
|
9895
10008
|
}
|
|
9896
10009
|
function matchChain(segment, knownChains) {
|
|
9897
10010
|
return knownChains.some((c) => c.toLowerCase() === segment.toLowerCase());
|
|
@@ -9900,35 +10013,35 @@ function parseDotPath(input, knownChains = []) {
|
|
|
9900
10013
|
const parts = input.split(".");
|
|
9901
10014
|
switch (parts.length) {
|
|
9902
10015
|
case 1: {
|
|
9903
|
-
const cat =
|
|
10016
|
+
const cat = matchCategory2(parts[0]);
|
|
9904
10017
|
if (cat)
|
|
9905
10018
|
return { category: cat };
|
|
9906
10019
|
throw new Error(`Unknown command "${parts[0]}". Expected a category (query, tx, const, events, errors, apis, extensions, rpc) or a named command.`);
|
|
9907
10020
|
}
|
|
9908
10021
|
case 2: {
|
|
9909
|
-
const cat =
|
|
10022
|
+
const cat = matchCategory2(parts[0]);
|
|
9910
10023
|
if (cat) {
|
|
9911
10024
|
return { category: cat, pallet: parts[1] };
|
|
9912
10025
|
}
|
|
9913
|
-
const cat2 =
|
|
10026
|
+
const cat2 = matchCategory2(parts[1]);
|
|
9914
10027
|
if (cat2 && matchChain(parts[0], knownChains)) {
|
|
9915
10028
|
return { chain: parts[0], category: cat2 };
|
|
9916
10029
|
}
|
|
9917
10030
|
throw new Error(`Unknown command "${input}". Expected format: category.Pallet or Chain.category (e.g. query.System or polkadot.query)`);
|
|
9918
10031
|
}
|
|
9919
10032
|
case 3: {
|
|
9920
|
-
const cat =
|
|
10033
|
+
const cat = matchCategory2(parts[0]);
|
|
9921
10034
|
if (cat) {
|
|
9922
10035
|
return { category: cat, pallet: parts[1], item: parts[2] };
|
|
9923
10036
|
}
|
|
9924
|
-
const cat2 =
|
|
10037
|
+
const cat2 = matchCategory2(parts[1]);
|
|
9925
10038
|
if (cat2 && matchChain(parts[0], knownChains)) {
|
|
9926
10039
|
return { chain: parts[0], category: cat2, pallet: parts[2] };
|
|
9927
10040
|
}
|
|
9928
10041
|
throw new Error(`Unknown command "${input}". Expected format: category.Pallet.Item or Chain.category.Pallet`);
|
|
9929
10042
|
}
|
|
9930
10043
|
case 4: {
|
|
9931
|
-
const cat =
|
|
10044
|
+
const cat = matchCategory2(parts[1]);
|
|
9932
10045
|
if (cat && matchChain(parts[0], knownChains)) {
|
|
9933
10046
|
return { chain: parts[0], category: cat, pallet: parts[2], item: parts[3] };
|
|
9934
10047
|
}
|
|
@@ -10019,6 +10132,9 @@ if (process.argv[2] === "__complete") {
|
|
|
10019
10132
|
console.log(" init Initialize a local .polkadot workspace in this directory");
|
|
10020
10133
|
console.log(" which Show the active config root (workspace, DOT_HOME, or global)");
|
|
10021
10134
|
console.log();
|
|
10135
|
+
console.log("Plugins:");
|
|
10136
|
+
console.log(' dot <name> \u2026 Runs a "dot-<name>" executable found on PATH (git/cargo-style)');
|
|
10137
|
+
console.log();
|
|
10022
10138
|
console.log("Global options:");
|
|
10023
10139
|
console.log(" --chain <name> Target chain (required)");
|
|
10024
10140
|
console.log(" --rpc <url> Override RPC endpoint");
|
|
@@ -10060,12 +10176,17 @@ if (process.argv[2] === "__complete") {
|
|
|
10060
10176
|
};
|
|
10061
10177
|
const target2 = `${cmd.pallet}.${cmd.item}`;
|
|
10062
10178
|
switch (cmd.category) {
|
|
10063
|
-
case "tx":
|
|
10179
|
+
case "tx": {
|
|
10180
|
+
const fileDecodeOnly = Boolean(opts.encode || opts.toYaml || opts.toJson);
|
|
10181
|
+
const fileDryRun = resolveDryRun(opts.dryRun, fileDecodeOnly);
|
|
10182
|
+
if (fileDryRun && isGlobalDryRun() && opts.dryRun === undefined) {
|
|
10183
|
+
printGlobalDryRunHint();
|
|
10184
|
+
}
|
|
10064
10185
|
await handleTx(target2, args, {
|
|
10065
10186
|
...handlerOpts2,
|
|
10066
10187
|
from: opts.from,
|
|
10067
10188
|
unsigned: opts.unsigned ?? cmd.unsigned,
|
|
10068
|
-
dryRun:
|
|
10189
|
+
dryRun: fileDryRun,
|
|
10069
10190
|
encode: opts.encode,
|
|
10070
10191
|
toYaml: opts.toYaml,
|
|
10071
10192
|
toJson: opts.toJson,
|
|
@@ -10079,6 +10200,7 @@ if (process.argv[2] === "__complete") {
|
|
|
10079
10200
|
parsedArgs: cmd.args
|
|
10080
10201
|
});
|
|
10081
10202
|
break;
|
|
10203
|
+
}
|
|
10082
10204
|
case "query":
|
|
10083
10205
|
await handleQuery(target2, args, {
|
|
10084
10206
|
...handlerOpts2,
|
|
@@ -10106,7 +10228,14 @@ if (process.argv[2] === "__complete") {
|
|
|
10106
10228
|
try {
|
|
10107
10229
|
parsed = parseDotPath(dotpath, knownChains);
|
|
10108
10230
|
} catch {
|
|
10109
|
-
|
|
10231
|
+
if (process.argv[2] === dotpath) {
|
|
10232
|
+
const externalBin = findExternalCommand(dotpath);
|
|
10233
|
+
if (externalBin) {
|
|
10234
|
+
process.exit(runExternalCommand(externalBin, process.argv.slice(3)));
|
|
10235
|
+
}
|
|
10236
|
+
}
|
|
10237
|
+
const pluginHint = isExternalCommandCandidate(dotpath) ? ` No "dot-${dotpath}" plugin found on PATH.` : "";
|
|
10238
|
+
throw new CliError2(`Unknown command "${dotpath}". Run "dot --help" for available commands.${pluginHint}`);
|
|
10110
10239
|
}
|
|
10111
10240
|
const isFlatCategory = parsed.category === "rpc" || parsed.category === "extensions";
|
|
10112
10241
|
if (!parsed.pallet && args.length > 0) {
|
|
@@ -10135,11 +10264,16 @@ if (process.argv[2] === "__complete") {
|
|
|
10135
10264
|
await handleQuery(target, args, { ...handlerOpts, dump: opts.dump, at: atRaw });
|
|
10136
10265
|
break;
|
|
10137
10266
|
case "tx": {
|
|
10267
|
+
const decodeOnly = Boolean(opts.encode || opts.toYaml || opts.toJson);
|
|
10268
|
+
const dryRun = resolveDryRun(opts.dryRun, decodeOnly);
|
|
10269
|
+
if (dryRun && isGlobalDryRun() && opts.dryRun === undefined) {
|
|
10270
|
+
printGlobalDryRunHint();
|
|
10271
|
+
}
|
|
10138
10272
|
const txOpts = {
|
|
10139
10273
|
...handlerOpts,
|
|
10140
10274
|
from: opts.from,
|
|
10141
10275
|
unsigned: opts.unsigned,
|
|
10142
|
-
dryRun
|
|
10276
|
+
dryRun,
|
|
10143
10277
|
encode: opts.encode,
|
|
10144
10278
|
toYaml: opts.toYaml,
|
|
10145
10279
|
toJson: opts.toJson,
|
|
@@ -10224,7 +10358,9 @@ if (process.argv[2] === "__complete") {
|
|
|
10224
10358
|
if (cli.options.version) {
|
|
10225
10359
|
await showUpdateAndExit(0);
|
|
10226
10360
|
} else if (cli.options.help) {
|
|
10227
|
-
if (cli
|
|
10361
|
+
if (printMatchedCommandHelp(cli)) {
|
|
10362
|
+
await showUpdateAndExit(0);
|
|
10363
|
+
} else if (cli.matchedCommand) {
|
|
10228
10364
|
const result = cli.runMatchedCommand();
|
|
10229
10365
|
if (result && typeof result.then === "function") {
|
|
10230
10366
|
await result.then(() => showUpdateAndExit(0), handleError);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0",
|
|
4
4
|
"description": "CLI tool for querying Polkadot-ecosystem on-chain state",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
"test:coverage": "bun test --concurrent --coverage --coverage-reporter=lcov --coverage-dir=coverage",
|
|
22
22
|
"prepare": "husky",
|
|
23
23
|
"changeset": "changeset",
|
|
24
|
-
"version": "changeset version"
|
|
25
|
-
"release": "changeset publish"
|
|
24
|
+
"version": "changeset version"
|
|
26
25
|
},
|
|
27
26
|
"license": "MIT",
|
|
28
27
|
"keywords": [
|
|
@@ -34,7 +33,7 @@
|
|
|
34
33
|
],
|
|
35
34
|
"repository": {
|
|
36
35
|
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/
|
|
36
|
+
"url": "git+https://github.com/paritytech/polkadot-cli.git"
|
|
38
37
|
},
|
|
39
38
|
"dependencies": {
|
|
40
39
|
"@noble/hashes": "^2.0.1",
|
|
@@ -45,9 +44,9 @@
|
|
|
45
44
|
"@polkadot-labs/hdkd": "^0.0.28",
|
|
46
45
|
"@polkadot-labs/hdkd-helpers": "^0.0.29",
|
|
47
46
|
"@scure/sr25519": "^1.0.0",
|
|
48
|
-
"cac": "^
|
|
49
|
-
"polkadot-api": "^2.1.
|
|
50
|
-
"verifiablejs": "1.
|
|
47
|
+
"cac": "^7.0.0",
|
|
48
|
+
"polkadot-api": "^2.1.7",
|
|
49
|
+
"verifiablejs": "1.4.0",
|
|
51
50
|
"yaml": "^2.8.3"
|
|
52
51
|
},
|
|
53
52
|
"devDependencies": {
|