-
Notifications
You must be signed in to change notification settings - Fork 501
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
protocols/horizon: Add custom UnmarshalJSON to struct with int64 fields. #1915
protocols/horizon: Add custom UnmarshalJSON to struct with int64 fields. #1915
Conversation
260cfc5
to
9771107
Compare
9771107
to
30c7754
Compare
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.
I'm wondering if this PR is only for horizon client release can we:
- Recreate it on top of
master
. - Set the base branch to a release branch of horizon client.
- Instead of creating custom
UnmarshalJSON
, just usejson.Number
where needed. - After releasing horizon client do not merge it into
master
(yet). - Merge the release branch when Horizon 0.25.0 is released.
This will make this code much less complicated, however, it will be easy to introduce regression bug (ex. new horizon client release from a branch branched off master
without this commit).
@abuiles should this PR be merged into the horizonclient 2.0.0 release branch instead of the 0.24.0 horizon release? |
If we use |
@abuiles You're obviously right! I though that |
We could make our own |
Exactly, that's what we are trying to achieve with this. We want to make it transparent to final users that the type changed in the payload, but keep it as an |
e5bb717
to
f6116b6
Compare
f6116b6
to
512fb74
Compare
@tamirms I squashed all the related commits and updated the branch, PTAL :) |
143f5c9
to
632e5e1
Compare
@tamirms updated the trade struct following your recommendation. Thanks! |
632e5e1
to
f8fb453
Compare
PR Checklist
PR Structure
otherwise).
services/friendbot
, orall
ordoc
if the changes are broad or impact manypackages.
Thoroughness
.md
files, etc... affected by this change). Take a look in the
docs
folder for a given service,like this one.
Release planning
needed with deprecations, added features, breaking changes, and DB schema changes.
semver, or if it's mainly a patch change. The PR is targeted at the next
release branch if it's not a patch change.
What
Add
UnmarshalJSON
toTrade
, this method supports parsing ofint64
fields as asjson.Number
which might be astring
orint64
. This will allow us to cut a new release for the horizon client which won't break once we change the data type on the JSON payload.Why
Using Int64 in JSON payloads produces inconsistent results in JS (see #1363).
We are in the process of updating all the int64 JSON fields to be of type string. The idea with this change is to extend the Unmarshal function to take either
int64
orstring
, that way we can release a version of the horizon client which won't break once the payload changes in the API.See #1609, #1909 and #1912
Known limitations
[TODO or N/A]