paritytech / paritytech/polkadot-cli
Human-readable amounts: parse "100 DOT" and underscore separators
Nobody has claimed this yet.
- 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 isu128orCompact<u128>:- Parse
"<number> <unit>"format (e.g.,"100 DOT","0.5 DOT") - Strip
_separators from numeric strings before parsing
- Parse
- Token decimals and symbol can be read from
System.Propertiesin chain metadata (already cached) - Should work for any chain's native token (DOT, KSM, WND, etc.)
Acceptance Criteria
-
"100 DOT"is parsed as100 * 10^decimalsplancks -
"0.5 DOT"works for fractional amounts -
1_000_000is parsed as1000000 - Unknown units produce a clear error message
- Works in both
dot txand anywhere numeric args are parsed
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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