polkadot-cli 1.14.0 → 1.14.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/README.md CHANGED
@@ -554,6 +554,62 @@ dot chain update people-paseo # specific chain
554
554
  dot chain update --all # all configured chains
555
555
  ```
556
556
 
557
+ #### Argument formats
558
+
559
+ Runtime API arguments accept the same shorthand as `dot tx` arguments:
560
+
561
+ | Type | Pass as | Example |
562
+ |------|---------|---------|
563
+ | Integers (`u8` … `u32`, `i8` … `i32`) | decimal | `0`, `42` |
564
+ | Big integers (`u64`, `u128`, `u256`, `i64` …) | decimal | `1000000000000` |
565
+ | `bool` | `true` / `false` | `true` |
566
+ | `AccountId32` | dev name, stored account, SS58, or `0x` + 64 hex pubkey | `alice`, `5GrwvaEF…` |
567
+ | `Vec<u8>` (unsized bytes) | `0x…` hex or text | `0xdeadbeef`, `hello` |
568
+ | `[u8; N]` (sized bytes, e.g. `H160`/`H256`/raw `AccountId`) | `0x` + exactly `2 * N` hex chars (recommended), or text | `0x970951a12f975e6762482aca81e57d5a2a4e73f4` |
569
+ | `Option<T>` | `null` (recommended), `none`, `undefined` — or a `T` value for `Some(value)` | `null` |
570
+ | `Vec<T>` (non-byte) | JSON array or comma-separated | `[1,2,3]`, `1,2,3` |
571
+ | Structs / nested enums | JSON | `{"type":"X1","value":{…}}` |
572
+
573
+ For sized byte arrays (`[u8; N]`) — common for Ethereum-style addresses (`H160`, `[u8; 20]`), 32-byte hashes (`H256`), and raw `AccountId32` bytes — pass a `0x`-prefixed hex string. Example: a contract call against the `pallet-revive` runtime API:
574
+
575
+ ```bash
576
+ ALICE=5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
577
+ CONTRACT=0x970951a12f975e6762482aca81e57d5a2a4e73f4 # H160, [u8; 20]
578
+ CALLDATA=$(cast calldata "set(uint256)" 42)
579
+
580
+ dot --chain paseo-asset-hub apis.ReviveApi.call \
581
+ "$ALICE" "$CONTRACT" 0 null null "$CALLDATA"
582
+ # ^ origin ^ dest ^ value ^ gas_limit (Option, none) ^ deposit (Option, none) ^ input_data (Vec<u8>)
583
+ ```
584
+
585
+ ##### Passing `Option<T>`
586
+
587
+ Absent options (`None`) can be written three ways, all equivalent:
588
+
589
+ ```bash
590
+ dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 null null "$CALLDATA"
591
+ dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 none none "$CALLDATA"
592
+ dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 undefined undefined "$CALLDATA"
593
+ ```
594
+
595
+ `null` is the **recommended** form — it matches JSON / YAML semantics, so args read identically on the CLI and inside [file-based command](#file-based-commands) YAML/JSON inputs.
596
+
597
+ A present option (`Some(value)`) is just the value itself — no wrapping:
598
+
599
+ ```bash
600
+ # gas_limit = Some({ ref_time: 1_000_000, proof_size: 100_000 })
601
+ dot apis.ReviveApi.call "$ALICE" "$CONTRACT" 0 \
602
+ '{"ref_time":1000000,"proof_size":100000}' \
603
+ null \
604
+ "$CALLDATA"
605
+ ```
606
+
607
+ Notes:
608
+ - The `null` / `none` / `undefined` literals are case-sensitive (lowercase only).
609
+ - There is no `Some(value)` prefix — bare values are already treated as `Some`.
610
+
611
+ Use `dot apis.<ApiName>.<method> --help` to see the exact argument signature for any method.
612
+
557
613
  ### Focused commands
558
614
 
559
615
  Browse specific metadata categories directly without using `dot inspect`:
package/dist/cli.mjs CHANGED
@@ -1262,7 +1262,10 @@ async function parseTypedArg(meta, entry, arg) {
1262
1262
  case "array": {
1263
1263
  const inner = entry.value;
1264
1264
  if (inner.type === "primitive" && inner.value === "u8") {
1265
- if (/^0x[0-9a-fA-F]*$/.test(arg))
1265
+ const isHex = /^0x[0-9a-fA-F]*$/.test(arg);
1266
+ if (entry.type === "array" && isHex)
1267
+ return arg;
1268
+ if (isHex)
1266
1269
  return Binary2.fromHex(arg);
1267
1270
  return Binary2.fromText(arg);
1268
1271
  }
@@ -2423,7 +2426,7 @@ var init_complete = __esm(() => {
2423
2426
  // src/cli.ts
2424
2427
  import cac from "cac";
2425
2428
  // package.json
2426
- var version = "1.14.0";
2429
+ var version = "1.14.1";
2427
2430
 
2428
2431
  // src/commands/account.ts
2429
2432
  init_accounts_store();
@@ -6260,7 +6263,10 @@ async function parseTypedArg2(meta, entry, arg) {
6260
6263
  case "array": {
6261
6264
  const inner = entry.value;
6262
6265
  if (inner.type === "primitive" && inner.value === "u8") {
6263
- if (/^0x[0-9a-fA-F]*$/.test(arg))
6266
+ const isHex = /^0x[0-9a-fA-F]*$/.test(arg);
6267
+ if (entry.type === "array" && isHex)
6268
+ return arg;
6269
+ if (isHex)
6264
6270
  return Binary3.fromHex(arg);
6265
6271
  return Binary3.fromText(arg);
6266
6272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-cli",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "CLI tool for querying Polkadot-ecosystem on-chain state",
5
5
  "type": "module",
6
6
  "bin": {