feat(chain): dot chain properties <name> (slice 1 of #199) - #273
Open
peetzweg wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
dotdoesn't surface a chain'spropertiesblock, so users and the dot-cli skill hardcode token decimals per chain (NATIVE_DECIMALS=12vs10). 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.tsfetches viasystem_propertiesand falls back tochainSpec_v1_properties(see defaults below), normalizing to{ tokenDecimals, tokenSymbol, ss58Format }.chain.tsadds apropertiessubcommand that resolves the chain by its saved name (likechain 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:
system_propertiesfirst (universally implemented → fewest failed round-trips), fall back tochainSpec_v1_properties. Both return the same shape.{}properties: each field degrades tonull; 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.