Skip to content

Commit

Permalink
Allow fixed sized arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
randoum committed Jan 12, 2023
1 parent 6714a14 commit aa5b790
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/eth/abi/decoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,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
nested_sub = type.nested_sub

# decoded static-size arrays
Expand Down
32 changes: 29 additions & 3 deletions spec/eth/abi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@

nested_types = [
"bool[]",
"bool[2]",
"address[]",
"address[2]",
"address[1][]",
"address[2][2]",
"bytes32[]",
"bytes[]",
"bytes[2]",
Expand All @@ -241,9 +245,31 @@
false,
],
[
"0x84ad87d794f867befc597ebae4200b607d0cd9bd",
"0xb8425e726762a40057a027a0cb7226b9fe6d7e9a",
"0xcf960c64b6bb464f30aa2e5a245176438b046e58",
false,
true,
],
[
"0x100087d794f867befc597ebae4200b607d0cd9bd",
"0x20005e726762a40057a027a0cb7226b9fe6d7e9a",
"0x30000c64b6bb464f30aa2e5a245176438b046e58",
],
[
"0x100087d794f867befc597ebae4200b607d0cd9bd",
"0x20005e726762a40057a027a0cb7226b9fe6d7e9a",
],
[
[
"0x30000c64b6bb464f30aa2e5a245176438b046e58",
],
],
[
[
"0x400087d794f867befc597ebae4200b607d0cd9bd",
"0x50005e726762a40057a027a0cb7226b9fe6d7e9a",
],
[
"0x600087d794f867befc597ebae4200b607d0cd9bd",
"0x70005e726762a40057a027a0cb7226b9fe6d7e9a",]
],
[
"\x13\xAE^]b\xD2\xDAD^\x05\b\e\xA8\xD5\x1DK\xBFO\xC7\xDA-ev!\xA1\xABxZ\xA2\x1CE\xEF",
Expand Down

0 comments on commit aa5b790

Please sign in to comment.