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

Subscription handler should not be limited by params count #266

Open
sergpsu opened this issue Nov 15, 2022 · 4 comments
Open

Subscription handler should not be limited by params count #266

sergpsu opened this issue Nov 15, 2022 · 4 comments

Comments

@sergpsu
Copy link

sergpsu commented Nov 15, 2022

I'd like to be able to track any account balance change, so trying

query('System', 'Account', subscription_handler=...)

but the following happens

if len(params) != len(param_types):
    raise ValueError(f'Storage function requires {len(param_types)} parameters, {len(params)} given')

Tried to subscribe to Substrate events by calling "state_subscribeStorage" directly and it works, so it seems that SubstrateInterface limitation on params length is not correct

@arjanz
Copy link
Member

arjanz commented Nov 15, 2022

System.Account needs a parameter to be able to add a subscription, as far as I know it won't be possible to create a storage subscription an a Mapped storage function without the required parameters.

@arjanz
Copy link
Member

arjanz commented Nov 15, 2022

System.Events is not a Mapped storage function and that's why it can be subscribed without parameters. Actually I was curious as well and commented out the restriction to see what happens, but no updates are received from the RPC.

@sergpsu
Copy link
Author

sergpsu commented Nov 16, 2022

You partially right: subscription does not work if passing storage_hash which was created only with "System" + "Account" and without param. But if send data to websocket without "params" completely then all storage changes returned and System.Account changes can be fetched

{"jsonrpc":"2.0", "method":"state_subscribeStorage", "id":1}

@sergpsu
Copy link
Author

sergpsu commented Nov 16, 2022

I'm wrong. Though it is possible to see that some account balance changed, but it is not possible to know which one exactly

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

2 participants