paritytech / paritytech/polkadot-cli

Expand `<chain>.extensions <Name>` into a copy-pasteable `--ext` skeleton (recursive field expansion)

Open
#252 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10
Forks
2
Avg merge
12h 35m
Merged PRs (30d)
4

Description

Summary

Expand the dot <chain>.extensions <Name> detail view so it recursively unfolds the
value type's nested enum/struct fields and prints a copy-pasteable --ext skeleton
with a <placeholder> per field — instead of stopping at the variant names and a bare
<v>.

Split out from #251 (pain point #2, the "Discoverability" half). The documentation
additions from that point are already done; this is the UX/code change that remains.

Current behaviour

$ dot people.extensions AsCoinage
  Value type:       Option< AsCoin | AsUnloadTokenPeople | AsUnloadTokenLitePeople | … >
  Usage:
    dot people.tx.<Pallet>.<Call> --from <acc> --ext '{"AsCoinage":{"value":<v>}}'

The view stops at the variant names; <v> is opaque. To learn that
AsUnloadTokenPeople is { proof, period, counter, alias_proofs: Vec<Proof> } you have
to read the runtime source, even though the metadata already carries those field types.

Desired behaviour

AsCoinage → AsUnloadTokenPeople {
  proof:        BandersnatchRingVrfProof   // 0x… hex
  period:       u32
  counter:      u32
  alias_proofs: Vec<BandersnatchRingVrfProof>
}
--ext '{"AsCoinage":{"value":{"type":"AsUnloadTokenPeople","value":{
    "proof":"0x<…>","period":0,"counter":0,"alias_proofs":["0x<…>"]}}}}'

i.e. recursively expand the value type and emit a ready-to-edit --ext snippet using the
{"type":"…","value":{…}} tagged shape (the same shape dot uses for call args).

Why it's bounded, not a rewrite

The data and traversal already exist:

  • src/commands/focused-inspect.ts:828-849 renders the detail view. The <v> is a
    hardcoded literal at :846.
  • prettyTypeById (src/core/pretty-type.ts) already recursively expands struct/enum
    fields via expandStruct/expandEnum. Two things truncate the output today: the Usage
    line never consults it, and prettyType summarises large enums as enum(N variants)
    (AsCoinage is a big Option<enum>).

So the work is: (a) walk the value type to emit a JSON skeleton with per-field
placeholders, and (b) decide how to present large enums — likely one skeleton per variant
on request, or expand the variant named after <chain>.extensions <Name> <Variant>.

Scope notes / open questions

  • Recursion needs depth/width guards so a deeply nested or huge enum doesn't dump a wall
    of text — match the existing prettyType width heuristics.
  • For Option<T> value types, the skeleton should target T (the Some payload), since
    None is already the auto-default.
  • Pure presentation change — no effect on encoding/submission. --json output should keep
    its current structured shape (optionally add the expanded field tree).

Acceptance

  • dot <chain>.extensions <CustomExt> prints the nested field tree and a copy-pasteable
    --ext skeleton for at least one real custom extension (the coinage AsCoinage
    variants are the reference case).
  • Fieldless variants render without a value key; struct variants nest their fields.
  • README "Passing enum / struct values to --ext" cross-links the expanded view.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/commands/focused-inspect.ts:828-849, then read src/core/pretty-type.ts and its expandStruct/expandEnum traversal. Implement the bounded recursive field tree and copy-pasteable --ext skeleton for the extensions detail view, including Option payloads and fieldless variants; verify the acceptance cases for CustomExt and AsCoinage without changing --json output.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.