-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
feat: add U256
support
#1014
feat: add U256
support
#1014
Conversation
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.
The JSON serialization of U256
seems a bit unexpected.
Take the following example:
let num: U256 = U256::from(123);
let serialized: String = serde_json::to_string(&num).unwrap();
eprintln!("{num} serialized is: '{serialized}'");
let num: u128 = 123;
let serialized: String = serde_json::to_string(&num).unwrap();
eprintln!("{num} serialized is: '{serialized}'");
Which prints out:
123 serialized is: '"0x7b"'
123 serialized is: '123'
The U256 is serialized as hex while u128 is a stringified decimal number. Might take somebody by surprise.
Although it is probably faster to do the hex dump, I'd sacrifice the speed and go with the least surprising approach.
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.
👍
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.
Perfect on the first try!
closes: #1013
Adds support for sway's
U256
type.Checklist