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.
This: Type.parse(type.base_type) feels kind of hacky. Please comment if it's acceptable
There was a problem hiding this comment.
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 |
| (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.
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.
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 |
q9f
left a comment
There was a problem hiding this comment.
Looks good to me and tests locally run through.
Could you run rufo . and check in the produced changes?
|
Done |
Before
After