paritytech / paritytech/polkadot-cli

feat: add `dot watch` command for real-time block, storage, and event streaming

Open
#69 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 watch command that streams real-time chain data as NDJSON, enabling agents to monitor blocks, storage changes, and events.

Usage

dot watch blocks --output json
dot watch storage System.Account 5FHn... --output json
dot watch events --output json
dot watch events Balances.Transfer --output json

Output (NDJSON)

Blocks:

{"blockNumber":12345,"blockHash":"0x...","parentHash":"0x...","extrinsicsCount":5}
{"blockNumber":12346,"blockHash":"0x...","parentHash":"0x...","extrinsicsCount":3}

Storage:

{"blockNumber":12345,"value":{"nonce":42,"data":{"free":"1000000000000"}}}
{"blockNumber":12350,"value":{"nonce":43,"data":{"free":"999000000000"}}}

Events:

{"blockNumber":12345,"pallet":"Balances","event":"Transfer","fields":{"from":"...","to":"...","amount":"1000"}}

Implementation

  • Use polkadot-api's client.finalizedBlock$ for block streaming (same RxJS pattern as watchTransaction in tx.ts)
  • Use polkadot-api's watchValue for storage subscriptions
  • Emit NDJSON lines using printJsonLine() from output.ts
  • Support Ctrl+C graceful shutdown

Files

  • src/commands/watch.tsNEW command with blocks, storage, events subcommands
  • src/cli.ts — register new command

Verification

  • Stream blocks for 30 seconds, verify each line is valid JSON
  • Watch a storage value, trigger a change via tx, verify the update appears
  • Filter events by pallet, verify only matching events are emitted

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 in src/commands/tx.ts at the watchTransaction RxJS pattern, then inspect src/output.ts for printJsonLine() and src/cli.ts for command registration. Implement the blocks, storage, and events subcommands in src/commands/watch.ts using finalizedBlock$ and watchValue, and verify valid NDJSON, storage updates, event filtering, and graceful Ctrl+C shutdown.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.