Skip to content

feat(chain): dot chain properties <name> (slice 1 of #199) - #273

Open
peetzweg wants to merge 1 commit into
mainfrom
feat-chain-properties
Open

feat(chain): dot chain properties <name> (slice 1 of #199)#273
peetzweg wants to merge 1 commit into
mainfrom
feat-chain-properties

Conversation

@peetzweg

@peetzweg peetzweg commented Jul 7, 2026

Copy link
Copy Markdown
Member

Implements slice 1 of #199 — a thin, self-contained dot chain properties <name> command. (Deliberately not "Closes": #199 tracks slices 2–5 and open decisions, so it stays open.)

Why: dot doesn't surface a chain's properties block, so users and the dot-cli skill hardcode token decimals per chain (NATIVE_DECIMALS=12 vs 10). Run a script against the wrong network and every balance is off by orders of magnitude. The chain knows the answer — ask it.

How: New src/core/chain-properties.ts fetches via system_properties and falls back to chainSpec_v1_properties (see defaults below), normalizing to { tokenDecimals, tokenSymbol, ss58Format }. chain.ts adds a properties subcommand that resolves the chain by its saved name (like chain info/update) and prints JSON or a human-readable block.

Real output (dot chain properties polkadot --json):

{
  "tokenDecimals": 10,
  "tokenSymbol": "DOT",
  "ss58Format": 0
}

So scripts can do: NATIVE_DECIMALS=$(dot chain properties polkadot --json | jq .tokenDecimals).

Defaults chosen for the issue's open questions:

  • RPC source: try system_properties first (universally implemented → fewest failed round-trips), fall back to chainSpec_v1_properties. Both return the same shape.
  • Multi-token / array responses: preserved verbatim in the JSON (not collapsed to the first element).
  • Empty {} properties: each field degrades to null; no crash.

Out of scope / still open: slices 2–5 (persist to config.json, balance rendering, --from-spec, full chain-spec import) and the caching-policy decision remain in #199. The RPC-source and array-handling choices above are proposed defaults, not final rulings.

Tests: unit tests for the fetch/normalize logic (scalar, array, empty, fallback, all-fail) plus end-to-end command tests driving the real RPC client against a local WebSocket JSON-RPC server. Changeset + README + SKILL + scripting-patterns docs updated with executable examples.

Wraps `system_properties` (falling back to the modern
`chainSpec_v1_properties`) and returns the chain's
`{ tokenDecimals, tokenSymbol, ss58Format }`. Array-typed responses
from multi-token chains are preserved verbatim; empty `{}` properties
degrade to nulls. Lets scripts derive decimals via
`dot chain properties <name> --json | jq .tokenDecimals` instead of
hardcoding per-environment values.

Implements slice 1 of #199.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant