Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: subscribing to storage changes #479

Open
sander2 opened this issue Mar 18, 2022 · 3 comments
Open

Feature request: subscribing to storage changes #479

sander2 opened this issue Mar 18, 2022 · 3 comments

Comments

@sander2
Copy link
Contributor

sander2 commented Mar 18, 2022

Substrate provides state_subscribeStorage to subscribe to storage changes. It would be great if subxt could expose this. I'm not sure how the api would look - maybe something like api.subscribe_storage().timestamp().now(). It shouldn't be super difficult to implement, I think, although I'm not sure how listening only to finalized changes could best be implemented.

@jsdw
Copy link
Collaborator

jsdw commented Apr 6, 2023

This does come up from time to time, but one blocker for this is that the new RPC interface doesn't currently provide such a method, so I can imagine that the steps will be:

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented May 9, 2023

I do exactly this with smoldot light client. I used subxt only as decoder, not as RPC caller or subscriber.

    client
        .json_rpc_request(
r#"{"id":1,"jsonrpc":"2.0","method":"state_subscribeStorage","params": { "list": ["0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7", "0x26aa394eea5630e07c48ae0c9558cef7"] }}"#,
chain_id,
        )
        .unwrap();

So would be ideal if subxt to provide named prefix for each storage (pallet/storage/key1/key2). I took 0x26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7 from pd.js frontend.

#960

@jsdw
Copy link
Collaborator

jsdw commented Jun 6, 2023

@lexnv I wonder whether the recent V2 RPC spec changes have added something that lets us subscribe to storage changes? Maybe it's something to raise an issue on the RPC spec repo for because it could be pretty cool to have this sort of thing in Subxt :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants