Update websocket jsonrpc subscribe request parsing and response building #20
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the websocket jsonrpc subscription endpoint.
I found that the implementation was different than almost everything I have checked online (is there any RFC for the subscription part? I only found this).
The jsonrpc subscribe endpoints should return the subscription ID straight in the result field. Whereas in pyth-client we wrap the id in a an object with a
subscription
field containing the ID.Also, the parameter provided should be either an array or a null value, but we ask for an object containing the account field we are interested in.
Because of that, the usage of the rust jsonrpc library was impossible. I messed for hours until realising :P. All the online documentations about jsonrpc are all stating that the id should be straight in the result and that the arguments should be wrapped in an array. See:
With this patch, we are able to use the rust jsonrpc library without trouble. Please let me know whether I missed something or if my fix is wrong (I also fixed the absolute path used in the init script to make it more portable, as a NixOS user, it was impossible for me to run it).