paritytech / paritytech/polkadot-cli

feat: add `dot decode` command for hex call data, storage values, and events

Open
#66 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Parent Epic: #63

Summary

Add a decode command that decodes arbitrary hex-encoded data using chain metadata. Agents constantly encounter opaque hex (from block explorers, multisig proposals, governance, or their own tx results) and need to decode it.

Usage

dot decode call 0x0001076465616462656566 --output json
dot decode storage Balances.Account 0x... --output json

Proposed Implementation

Shared decode module (NEW: src/core/decode.ts)

Extract decodeCall() from tx.ts:267 into a shared module and add:

  • decodeCallData(meta, hex) — decode extrinsic call data using viewBuilder.callDecoder()
  • decodeStorageValue(meta, pallet, item, hex) — decode storage values using meta.builder.buildStorage()
Command (NEW: src/commands/decode.ts)

Subcommands:

  • dot decode call <hex> — decode call data
  • dot decode storage <Pallet.Item> <hex> — decode a storage value

Pretty output: Human-readable like Balances.transferKeepAlive { dest: 5FHn..., value: 1000000000000 }
JSON output: Full nested object with all fields

Reuse existing code
  • decodeCall() in tx.ts:267 — extract to shared module
  • formatDecoded() in tx.ts:284 — reuse for pretty output
  • replacer() in output.ts:14 — reuse for JSON serialization

Files

  • src/core/decode.tsNEW shared decode logic
  • src/commands/decode.tsNEW command registration
  • src/cli.ts — register new command
  • src/commands/tx.ts — refactor to use shared decode module

Verification

  • Encode a call: dot tx System.remark 0xaa --encode → get hex
  • Decode it: dot decode call <hex> --output json → verify round-trip
  • Decode a storage value from a known query result

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 with the existing decodeCall() and formatDecoded() in src/commands/tx.ts, plus replacer() in src/commands/output.ts. Review src/cli.ts and the proposed src/core/decode.ts and src/commands/decode.ts entry points, then verify the documented call round trip and decoding of a known storage value. Done means the call and storage subcommands support pretty and JSON output while tx decoding still works.

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
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.