-
Notifications
You must be signed in to change notification settings - Fork 273
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
workaround serde deserializing incorrectly when arbitrary_precision enabled #521
workaround serde deserializing incorrectly when arbitrary_precision enabled #521
Conversation
serde deserializes incorrectly when arbitrary precision is enabled. Fix by first deserializing into `Value` before `ClientResponse`
It looks like @insipx signed our Contributor License Agreement. 👍 Many thanks, Parity Technologies CLA Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm! Would be cool to get an integration test for this.
add cfg! to other places JSON is being deserialized
there is now a generic fn Also made sure that |
@@ -81,7 +81,7 @@ impl RequestBuilder { | |||
pub fn parse_response( | |||
response: &str, | |||
) -> Result<(Id, Result<Value, RpcError>, Option<String>, Option<SubscriptionId>), RpcError> { | |||
serde_json::from_str::<ClientResponse>(&response) | |||
jsonrpc_core::serde_from_str::<ClientResponse>(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we now get rid of serde_json
dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serde_json
is still used for all to_string
serializations
Co-Authored-By: Tomasz Drwięga <[email protected]>
JSON serialization/deserialization of `i128`/`u128` can only be supported when the `arbitrary_precision` feature enabled. But `arbitrary_precision` numbers don't work with `serde(tag = ..)` and `serde(flatten)` syntax (serde-rs/json#505), as a result, the deserialization of structures in `jsonrpc-core` will be error. Fortunately, the crate `jsonrpc-core` provides a workround(paritytech/jsonrpc#521). Although this workround will cause more extra serialization/deserialization work, but I think it's worth it. Signed-off-by: koushiro <[email protected]>
serde deserializes incorrectly when arbitrary precision is enabled.
fixes #520
The workaround is to deserialize into
Value
beforeClientResponse
. This is gated under the featurearbitrary_precision
in core-client andtransports
.