q9f / eth.rb

a straightforward library to build, sign, and broadcast ethereum transactions anywhere you can run ruby.
https://q9f.github.io/eth.rb
Apache License 2.0
200 stars 86 forks source link

Abi.decoder handles arrays of string and bytes #207

Closed randoum closed 1 year ago

randoum commented 1 year ago

Before

> enc = Eth::Abi.encode ["string[]"], [["This is", "a test"]]
=> "\x00\x00\...
> Eth::Abi.decode ["string[]"], enc
.../gems/eth-0.5.10/lib/eth/abi.rb:232:in `decode_type': Wrong data size for string/bytes object (Eth::Abi::DecodingError)

After

> enc = Eth::Abi.encode ["string[]"], [["This is", "a test"]]
=> "\x00\x00\...
> Eth::Abi.decode ["string[]"], enc
=> [["This is", "a test"]]
q9f commented 1 year ago

Thanks. You can ignore the failing tests.

I will take a look at this in a bit.

randoum commented 1 year ago

Thanks.

I've also fixed the decoding of fixed size arrays

codecov-commenter commented 1 year ago

Codecov Report

Merging #207 (aa5b790) into main (5f37cd4) will decrease coverage by 0.25%. The diff coverage is 100.00%.

@@            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     
Impacted Files Coverage Δ
spec/eth/abi_spec.rb 100.00% <ø> (ø)
lib/eth/abi/decoder.rb 100.00% <100.00%> (ø)
spec/eth/ens/resolver_spec.rb 83.78% <0.00%> (-16.22%) :arrow_down:
lib/eth/ens/resolver.rb 85.29% <0.00%> (-14.71%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

randoum commented 1 year ago

Done