paritytech / paritytech/polkadot-cli
feat: add --watch flag to stream live storage changes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 10
- Forks
- 2
- Avg merge
- 12h 35m
- Merged PRs (30d)
- 4
Description
Problem
Users monitoring on-chain state must repeatedly re-run queries manually. There's no way to subscribe to live storage changes from the CLI.
Related
- #69 (watch command)
Proposed Solution
Add a --watch flag to the query command that streams storage updates in real-time.
Implementation
polkadot-api provides watchValue() and watchEntries() Observables that emit on every storage change for the subscribed key.
if (options.watch) {
const observable = storage.watchValue(...keys)
observable.subscribe({
next: (value) => printResult(value, options),
error: (err) => { console.error(err); process.exit(1) },
})
// Keep process alive until SIGINT
} else {
const value = await storage.getValue(...keys)
printResult(value, options)
}
Behavior
- Each update emits a new result via
printResult - Graceful SIGINT (Ctrl+C) handling to cleanly unsubscribe and disconnect
- Pairs naturally with
--output ndjson(see #64) — one JSON line per update - Pretty output shows a timestamp separator between updates
Priority
MEDIUM
Files
src/commands/query.ts
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 in src/commands/query.ts and trace the existing query path, including printResult and storage.getValue. Add the --watch path using the described storage observable, then verify that updates are emitted, SIGINT unsubscribes and disconnects cleanly, and ndjson output remains one line per update.
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
- 62/100