-
Notifications
You must be signed in to change notification settings - Fork 87
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
eth/abi: allow parsing numerics from string inputs #112
Conversation
hex number not work
|
1 similar comment
hex number not work
|
Makes sense 😮💨 |
You need to preprocess the JSON in this case. There is no way to know if a string is binary, octal, decimal, or hexadecimal. |
decimal is enough. I found you have hex string in test, so I have a try. do you run you test? |
test = "00000000000000000000000000000000000000000000021e19e0c9bab2400000".hex
=> 10000000000000000000000
test.to_s(16)
=> "21e19e0c9bab2400000" |
For hexadecimal numbers, the argument to_i() must be 16. irb(main):005:0> "00000000000000000000000000000000000000000000021e19e0c9bab2400000".to_i(16)
=> 10000000000000000000000 However, it is difficult to distinguish octal, decimal, or hexadecimal in the following pattern... 😢 irb(main):016:0> '000255'.to_i(8)
=> 173
irb(main):017:0> '000255'.to_i(10)
=> 255
irb(main):018:0> '000255'.to_i(16)
=> 597 |
decimal string is enough for most cases. |
* eth/abi: allow parsing numerics from string inputs * sepc: run rufo
fix #110