-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Function ABI Utilities #3408
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
Function ABI Utilities #3408
Conversation
6f13b94 to
3a6f31a
Compare
179f614 to
24faed3
Compare
24faed3 to
88cabbb
Compare
fselmo
left a comment
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.
At first pass the code looks good. I just have a big lingering question about the organization of utils methods. I think my inline comments will be clear enough but I was under the impression we were moving things to eth_utils and re-exposing them in a centralized spot where all abi utils can be located, even the in-house web3 ones.
I'll take a second pass once I'm caught up on that.
b6c0dc8 to
23da131
Compare
23da131 to
6b7ab3a
Compare
6b7ab3a to
57f2f96
Compare
57f2f96 to
a0642d5
Compare
a0642d5 to
8a0d5a8
Compare
8a0d5a8 to
83d55dd
Compare
b09d81a to
b1b5057
Compare
b1b5057 to
b03eac2
Compare
kclowes
left a comment
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.
🚀 LGTM! Nice work!
fselmo
left a comment
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.
lgtm overall. Some of these are things to think about and discuss before merging, others are minor tweaks / catches.
web3/_utils/contracts.py
Outdated
| fn_identifier: Union[str, Type[FallbackFn], Type[ReceiveFn]], | ||
| contract_abi: Optional[ABI] = None, | ||
| fn_abi: Optional[ABIFunction] = None, | ||
| fn_abi: Optional[ABIElement] = 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.
Is there a reason we opened this type up? Is that desirable / is there no way to keep it within the function scope as intended? Should this be ABICallable?
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 think I recall changing this to encompass constructor, fallback and receive but you are right this should be ABICallable. That will affect a couple parts of this function so I'll get those fixed!
b03eac2 to
9bac5d7
Compare
9bac5d7 to
cc2d5b7
Compare
cc2d5b7 to
4853df5
Compare
4853df5 to
165f20f
Compare
165f20f to
689245a
Compare
689245a to
42665a1
Compare
42665a1 to
ecf6d77
Compare
27d55b2 to
be38b81
Compare
fselmo
left a comment
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.
lgtm! Just left 1 rename nit.
web3/contract/base_contract.py
Outdated
| args = args or tuple() | ||
| kwargs = kwargs or {} | ||
|
|
||
| fn_info = get_abi_element_info( |
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 think this fn_info could be element_info for clarity, since we left the function filtering logic out of this method.
be38b81 to
e6a824c
Compare
* Filter elements in a contract's ``ABI``. * Extract function and event ``ABI`` attributes from a contract. * Validate arguments passed to a function match the types in the ``ABI`` * Refactor logic and variable naming - Replace arguments named ``fn_name`` with ``abi_element_name`` - Rename `FunctionIdentifier` to `ABIElementIdentifier` - Remove redundant logic and `Optional` types - Integrate new ABI types in ``eth-typing``.
e6a824c to
70340eb
Compare
What was wrong?
Function ABI utilties are needed for some use cases, so exposing them as public methods will allow people to work with ABIs and encode/decode function arguments.
Related to Issue #3036, #1596
Dependent upon ethereum/eth-utils#271.
How was it fixed?
Implement functions for parsing and validating contract data using the ABI spec.
Public ABI methods in
web3.utils.abi:check_if_arguments_can_be_encoded,get_abi_element_info,get_abi_element,get_event_abi,get_event_log_topics,log_topic_to_bytes,Additionally, all
eth_utils.abifunctions are included as part of theweb3.utilsmodule.Todo:
Cute Animal Picture