paritytech / paritytech/polkadot-cli

Human-readable amounts: parse "100 DOT" and underscore separators

Open
#21 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

Problem

Every amount in the CLI is specified in plancks (the smallest unit). This is the single most error-prone aspect of using the CLI:

# What does this mean? Is it 100 DOT? 1000 DOT?
dot tx Balances.transferKeepAlive 5FHn... 1000000000000 --from alice

Proposal

Support human-readable amount syntax when the parameter type is u128/Compact<u128> and the chain's token info is available from metadata:

# Proposed: unit suffix
dot tx Balances.transferKeepAlive 5FHn... "100 DOT" --from alice

# Proposed: underscore separators for plancks
dot tx Balances.transferKeepAlive 5FHn... 100_000_000_000_0 --from alice

Implementation

  • In parseTypedArg() (tx.ts), when the type is u128 or Compact<u128>:
    • Parse "<number> <unit>" format (e.g., "100 DOT", "0.5 DOT")
    • Strip _ separators from numeric strings before parsing
  • Token decimals and symbol can be read from System.Properties in chain metadata (already cached)
  • Should work for any chain's native token (DOT, KSM, WND, etc.)

Acceptance Criteria

  • "100 DOT" is parsed as 100 * 10^decimals plancks
  • "0.5 DOT" works for fractional amounts
  • 1_000_000 is parsed as 1000000
  • Unknown units produce a clear error message
  • Works in both dot tx and anywhere numeric args are parsed

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 parseTypedArg() in tx.ts and inspect how cached chain metadata exposes token information through System.Properties. Verify parsing for u128 and Compact in dot tx and other numeric-argument paths, including fractional values, underscore separators, native units, and clear errors for unknown units.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.