web3-eth icon indicating copy to clipboard operation
web3-eth copied to clipboard

Fix getBlockByNumber "undefined method `each' for String" error when full is false

Open calvinlauyh opened this issue 6 years ago • 0 comments

Description of the problem

When trying to call

@web3.eth.getBlockByNumber(3000000, full=false)

It returns error

NoMethodError (undefined method `each' for #<String:0x0000556be1cd9c20>)

Clause of problem

Block constructor attempts to convert each element in the array of transaction @transactions to Transaction objects. When full is false, @transactions is an array of transaction hashes string, and cause the error.

What I think is the correct behaviour?

It should not try to instantiate a Transaction but to leave the array of transaction hashes untouched.


p.s. This is my first time creating PR on other developer's repository and I am quite new to Ruby. Please let me know if I made something wrong and I am always willing to learn. Thank you.

calvinlauyh avatar Apr 14 '18 01:04 calvinlauyh