-
Notifications
You must be signed in to change notification settings - Fork 30
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
Render asset codes as strings in JSON #324
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dmkozh
approved these changes
Nov 27, 2023
leighmcculloch
commented
Nov 27, 2023
dmkozh
approved these changes
Nov 30, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Render asset codes in JSON as UTF-8 strings, where any bytes are not printable ASCII are escaped using the rules defined by https://docs.rs/escape-bytes.
Why
Valid asset codes are some subset of ASCII, but they're currently rendered as hex. It creates a poor and difficult experience when a developer is expecting to see their asset code in the JSON and instead see hex.
The codes are rendered to a subset of UTF-8 because JSON strings must be Unicode.
XDR defines its strings to be ASCII, but can otherwise hold any byte sequences, even invalid ASCII.
Because the data can be any byte sequence, escaping any non-printable ASCII characters means that the majority of valid and meaningful data will be human readable, while all data is still roundtrippable.
Another option would have been to only escape invalid UTF-8 byte sequences, however reproducing that behavior exactly the same in a variety of SDKs would be more challenging.
Discussion at https://discord.com/channels/897514728459468821/1179194134783868988
Close stellar/xdrgen#175
Follow ups