paritytech / paritytech/polkadot-cli
Support inline call-type parameter syntax for Sudo, Utility.batch, and Proxy wrappers
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 2
- Avg merge
- 12h 35m
- Merged PRs (30d)
- 4
Description
Problem
Pallets that wrap other calls — Sudo.sudo, Utility.batch/batchAll, Proxy.proxy — currently require the inner call to be passed as verbose JSON enum syntax:
dot tx Sudo.sudo \
'{"type":"ParasSudoWrapper","value":{"type":"sudo_establish_hrmp_channel","value":{"sender":1000,"recipient":1004,"max_capacity":8,"max_message_size":10000}}}' \
--from alice
This pattern is repeated throughout the scripting workflows. For example in scripts/setup-pusd.sh:
run_tx "Create foreign PUSD asset on People Chain" Sudo.sudo \
'{"type":"Assets","value":{"type":"force_create","value":{"id":'"$PUSD_FOREIGN_ASSET_ID"',"owner":"'"$ALICE_SS58"'","is_sufficient":true,"min_balance":10}}}' \
--from "$SUDO_ACCOUNT" --chain "$PEOPLE_CHAIN"
And in scripts/setup-hrmp-channels.sh:
run_tx "$label" Sudo.sudo \
'{"type":"ParasSudoWrapper","value":{"type":"sudo_establish_hrmp_channel","value":{"sender":'"$sender"',"recipient":'"$recipient"',"max_capacity":'"$HRMP_MAX_CAPACITY"',"max_message_size":'"$HRMP_MAX_MESSAGE_SIZE"'}}}' \
--from "$SUDO_ACCOUNT" --chain "$RELAY_CHAIN"
The triple-nested {"type":"...","value":{"type":"...","value":{...}}} is error-prone, hard to read, and painful with shell variable interpolation.
Proposed Solution
Support two additional input formats alongside the existing JSON syntax:
1. Inline Pallet.call notation
For single-Call wrappers (Sudo.sudo, Proxy.proxy), detect when a positional argument matches Pallet.call syntax and consume subsequent positional args as parameters for the inner call:
# Before
dot tx Sudo.sudo \
'{"type":"ParasSudoWrapper","value":{"type":"sudo_establish_hrmp_channel","value":{"sender":1000,"recipient":1004,"max_capacity":8,"max_message_size":10000}}}' \
--from alice
# After
dot tx Sudo.sudo ParasSudoWrapper.sudo_establish_hrmp_channel 1000 1004 8 10000 \
--from alice
# Before
dot tx Sudo.sudo \
'{"type":"Assets","value":{"type":"force_create","value":{"id":1984,"owner":"5GrwvaE...","is_sufficient":true,"min_balance":10}}}' \
--from alice --chain ws://localhost:9910
# After
dot tx Sudo.sudo Assets.force_create 1984 "5GrwvaE..." true 10 \
--from alice --chain ws://localhost:9910
For Vec<Call> wrappers (Utility.batch, Utility.batchAll), use a separator (e.g. -- or ,) between calls:
dot tx Utility.batchAll \
Balances.transfer_keep_alive "5FHneW46..." 1000000000000 , \
Balances.transfer_keep_alive "5FLSigC9..." 2000000000000 \
--from alice
2. Hex-encoded SCALE call data
Accept a 0x-prefixed hex string as a pre-encoded call:
dot tx Sudo.sudo 0x<scale-encoded-call-data> --from alice
This is useful for cross-tool workflows where call data is generated externally.
Detection & Parsing Approach
- When to activate: The metadata lookup for the parameter will have
RuntimeCallas its type ID (or equivalent). Use the metadata to detect when a parameter expects aCalltype. - Inline notation: When the arg matches
Word.wordand the expected type is a Call enum, resolve the pallet variant and call variant from metadata, then use cursor-based consumption of subsequent positional args to fill the inner call's fields (same logic already used byparseCallArgsfor top-level calls). - Hex-encoded: When the arg starts with
0xand the expected type is a Call, pass the raw bytes through. - JSON: Existing
{"type":"...","value":{...}}syntax continues to work unchanged (backwards compatible).
Scope
- Single-level nesting (Sudo wrapping one call, Utility.batch wrapping a flat list) covers the vast majority of real-world usage.
- Deep nesting (e.g.
Sudo.sudo Utility.batchAll Balances.transfer ...) would be nice-to-have but is not required for the initial implementation.
Backwards Compatibility
The existing JSON object syntax ('{"type":"...","value":{...}}') continues to work. The new formats are detected by shape — Pallet.call pattern or 0x prefix — and only apply when the expected parameter type is a Call.
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 by locating the existing parseCallArgs logic and the metadata lookup for parameters typed as RuntimeCall. Implement and verify inline Pallet.call arguments, 0x-encoded call data, and separated Utility.batch calls while preserving the existing JSON syntax; done means the Sudo, Proxy, batch, and batchAll examples work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100