-
Notifications
You must be signed in to change notification settings - Fork 93
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
Abi.decoder handles arrays of string and bytes #207
Conversation
(1..l).map do |i| | ||
pointer = Util.deserialize_big_endian_to_int arg[i * 32, 32] # Pointer to the size of the array's element | ||
data_l = Util.deserialize_big_endian_to_int arg[32 + pointer, 32] # length of the element | ||
type(Type.parse(type.base_type), arg[pointer + 32, Util.ceil32(data_l) + 32]) |
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.
This: Type.parse(type.base_type)
feels kind of hacky. Please comment if it's acceptable
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.
That's ok. It might have a negative hit on the performance but nobody uses Ruby for performance anyways :)
Thanks. You can ignore the failing tests. I will take a look at this in a bit. |
Thanks. I've also fixed the decoding of fixed size arrays |
@@ -48,7 +61,7 @@ def type(type, arg) | |||
# decoded dynamic-sized arrays | |||
(0...l).map { |i| type(nested_sub, arg[32 + nested_sub.size * i, nested_sub.size]) } | |||
elsif !type.dimensions.empty? | |||
l = type.dimensions.last[0] | |||
l = type.dimensions.first |
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.
To be honest, I'm not sure what I did here 😅 but now all the tests pass, and it fixes the problem with static-size array decoding. I tried to check in git history why this was introduced but could not find anything understandable for me. Please share your feedback
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.
You would be surprised how old this line is.
Codecov Report
@@ Coverage Diff @@
## main #207 +/- ##
==========================================
- Coverage 99.77% 99.51% -0.26%
==========================================
Files 77 77
Lines 4361 4367 +6
==========================================
- Hits 4351 4346 -5
- Misses 10 21 +11
📣 We’re building smart automated test selection to slash your CI/CD build times. 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.
Looks good to me and tests locally run through.
Could you run rufo .
and check in the produced changes?
Done |
Before
After