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

Update methods to return type Hash32 where appropriate

Open carver opened this issue 4 years ago • 2 comments

What was wrong?

A number of methods return a value from keccak which is guaranteed to be 32 bytes. For example, see: https://github.com/ethereum/eth-utils/blob/d05279c6af22b9e7defc0d7a5df0d7d3422e2061/eth_utils/abi.py#L54-L60

Other methods that require the 32-byte input type Hash32 currently require a cast when output from something like event_signature_to_log_topic() is already guaranteed.

How can it be fixed?

Update the return type signature to use Hash32 for all methods that apply keccak before returning.

carver avatar May 14 '20 17:05 carver

@carver as you mentioned in fix, it wont be true for the method function_signature_to_4byte_selector as it applies keccak before return but only returns 4-Bytes. Is my understanding correct or there is other reason to it.

pratik-vii avatar Oct 02 '20 05:10 pratik-vii

Ah yes, that's a typo. Thanks for pointing it out! :+1: I just fixed it above.

Note that I did not do a thorough search for all methods that should be updated, so part of the task is to identify all functions that should be updated.

carver avatar Oct 05 '20 16:10 carver