paritytech / paritytech/polkadot-cli

Refactor tx.ts: split into tx-parse, tx-submit, tx-display modules

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

tx.ts is ~850 lines and handles parsing, submission, and display — three distinct concerns in one file. This makes it harder to navigate, test, and reuse individual pieces (e.g., parseTypedArg is needed by query.ts too).

Proposal

Split into focused modules:

New file Responsibility Key exports
tx-parse.ts Argument parsing & type coercion parseCallArgs, parseTypedArg, normalizeValue, parsePrimitive
tx-submit.ts Transaction signing & submission watchTransaction, signed extension handling
tx-display.ts Output formatting decodeCall, formatDecoded, formatEventValue, formatDispatchError
tx.ts Command registration & orchestration CAC command definition, wiring the above together

Benefits

  • parseTypedArg becomes importable by query.ts (see type-aware query keys issue)
  • Each module is independently testable
  • Easier to navigate and review
  • Clear separation of concerns

Acceptance Criteria

  • tx.ts reduced to command registration and orchestration (~100-150 lines)
  • Parsing, submission, and display logic extracted to separate files
  • No behavior changes — all existing tests pass
  • parseTypedArg is importable from tx-parse.ts for reuse

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 by reading tx.ts to map the parsing, submission, display, and CAC orchestration responsibilities, then check query.ts for the planned parseTypedArg reuse. Extract the listed exports into tx-parse.ts, tx-submit.ts, and tx-display.ts while keeping tx.ts focused on registration and wiring. Done means tx.ts is about 100–150 lines, parseTypedArg is importable, and all existing tests pass without behavior changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.