-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Utilities for Contract ABIs #271
base: main
Are you sure you want to change the base?
Conversation
0c6d60f
to
615e3d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new test functions, very nice! I didn't go through with a fine tooth comb, but looks good overall!
The only outstanding things I saw are:
- the comment around which exceptions to raise, and where they live
- I left a comment about raising vs returning an empty list. let me know what you think!
1d18a64
to
9e2a2da
Compare
eth_utils/abi.py
Outdated
if function_identifier is None or not is_text(function_identifier): | ||
raise TypeError("Unsupported function identifier") | ||
|
||
if abi_codec is None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where and how to document this feature. Maybe the docstring should point to the codec docs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense to me.
8d65e46
to
b76e640
Compare
03fe5b4
to
6e44918
Compare
6e44918
to
4b6df2c
Compare
1599e85
to
761d1c8
Compare
adfc679
to
854a6a5
Compare
Usage question - I pulled an ABI from web3 (
Same for |
This is still a WIP. Keeping the ABI methods but codec utils will move into |
* Utility moved to `web3.utils.abi` module * Expose `get_normalized_abi_inputs` and `get_aligned_abi_inputs` * Docs improvements for `get_aligned_abi_inputs`
Doctests added to the following: `collapse_if_tuple` `function_signature_to_4byte_selector` `function_abi_to_4byte_selector` `event_signature_to_log_topic` `event_abi_to_log_topic` `get_normalized_abi_arg_type`
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a couple small comments, but nothing major!
""" | ||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a warning in the doctests about line 94 where you use collapse_if_tuple
Remove unused `_filter_by_encodability` method Remove `_abi_to_signature` and related methods Move `abi_to_signature` with public methods. Doctest for `abi_to_signature` Fix doctest in `collapse_if_tuple`
Cleaning up a few more items on this and I will request reviews when it's good to go! |
What was wrong?
Contract ABI utilities are useful for encoding and decoding contract transactions. Many utilities are implemented in web3.py as private methods.
Related to ethereum/web3.py#3036
These changes will be utilized in web3.py function/event utils:
ethereum/web3.py#3408
ethereum/web3.py#3401
How was it fixed?
Implements a public API for ABI utilities.
Todo:
Clean up commit history
Add or update documentation related to these changes
Add entry to the release notes
Cute Animal Picture