Shelley genesis use serde json arbitrary precision #363
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.
I can't really explain why, but I've been having some weird issues with the
deserialize_string_from_number
from serde-aux.It seems to work when I run the tests in this repo, but it fails when I use it from carp (but it didn't at some point, which is the weird part).
The function itself uses this code inside
Which I think shouldn't work in the first place (serde-rs/serde#2661 (comment))
So I think it's better to just use https://github.com/serde-rs/json/blob/1faf3a1db661c7fb1f3a9a141efa30fb67e9ab3a/Cargo.toml#L70
I also think the current code doesn't do what the comments imply. Numbers get deserialized as strings if you put quotes around them in the json, in which case it is lossless, but otherwise they are just parsed as floats (or i64), which introduces an error anyway before making it a fraction. This probably doesn't matter as much since no one is really using these fields, but probably best to avoid the issue.
The only problem with this is that the Fraction type doesn't support parsing scientific notation, so I did implement that manually here.