Skip to content

Conversation

@reedsa
Copy link
Contributor

@reedsa reedsa commented May 23, 2024

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.abi functions are included as part of the web3.utils module.

Todo:

  • Clean up commit history
  • Add or update documentation related to these changes
  • Add entry to the release notes

Cute Animal Picture

Put a link to a cute animal picture inside the parenthesis-->

@reedsa reedsa force-pushed the abi-function-utils branch 6 times, most recently from 6f13b94 to 3a6f31a Compare May 29, 2024 19:46
reedsa pushed a commit to reedsa/web3.py that referenced this pull request May 29, 2024
@reedsa reedsa marked this pull request as ready for review May 29, 2024 19:58
@reedsa reedsa requested review from fselmo, kclowes and pacrob May 29, 2024 19:59
reedsa pushed a commit to reedsa/web3.py that referenced this pull request May 31, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from 179f614 to 24faed3 Compare May 31, 2024 16:52
reedsa pushed a commit to reedsa/web3.py that referenced this pull request May 31, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from 24faed3 to 88cabbb Compare May 31, 2024 16:56
Copy link
Collaborator

@fselmo fselmo left a 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.

@reedsa reedsa force-pushed the abi-function-utils branch from b6c0dc8 to 23da131 Compare June 3, 2024 21:37
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jun 3, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from 23da131 to 6b7ab3a Compare June 3, 2024 21:45
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jun 3, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from 6b7ab3a to 57f2f96 Compare June 3, 2024 21:47
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jun 3, 2024
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jun 4, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from 57f2f96 to a0642d5 Compare June 4, 2024 16:16
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jun 4, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from a0642d5 to 8a0d5a8 Compare June 4, 2024 16:44
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jun 4, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from 8a0d5a8 to 83d55dd Compare June 4, 2024 21:42
@reedsa reedsa force-pushed the abi-function-utils branch from b09d81a to b1b5057 Compare July 26, 2024 21:48
reedsa pushed a commit to reedsa/web3.py that referenced this pull request Jul 26, 2024
@reedsa reedsa force-pushed the abi-function-utils branch from b1b5057 to b03eac2 Compare July 26, 2024 22:11
Copy link
Collaborator

@kclowes kclowes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 LGTM! Nice work!

Copy link
Collaborator

@fselmo fselmo left a 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.

fn_identifier: Union[str, Type[FallbackFn], Type[ReceiveFn]],
contract_abi: Optional[ABI] = None,
fn_abi: Optional[ABIFunction] = None,
fn_abi: Optional[ABIElement] = None,
Copy link
Collaborator

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?

Copy link
Contributor Author

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!

@reedsa reedsa force-pushed the abi-function-utils branch from b03eac2 to 9bac5d7 Compare July 29, 2024 19:13
@reedsa reedsa force-pushed the abi-function-utils branch from 9bac5d7 to cc2d5b7 Compare July 29, 2024 19:46
@reedsa reedsa force-pushed the abi-function-utils branch from cc2d5b7 to 4853df5 Compare July 29, 2024 20:26
@reedsa reedsa force-pushed the abi-function-utils branch from 4853df5 to 165f20f Compare July 29, 2024 21:36
@reedsa reedsa force-pushed the abi-function-utils branch from 165f20f to 689245a Compare July 29, 2024 22:24
@reedsa reedsa force-pushed the abi-function-utils branch from 689245a to 42665a1 Compare July 29, 2024 22:34
@reedsa reedsa force-pushed the abi-function-utils branch from 42665a1 to ecf6d77 Compare July 29, 2024 23:30
@reedsa reedsa requested a review from fselmo July 30, 2024 17:50
@reedsa reedsa force-pushed the abi-function-utils branch from 27d55b2 to be38b81 Compare July 30, 2024 18:54
Copy link
Collaborator

@fselmo fselmo left a 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.

args = args or tuple()
kwargs = kwargs or {}

fn_info = get_abi_element_info(
Copy link
Collaborator

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.

@reedsa reedsa force-pushed the abi-function-utils branch from be38b81 to e6a824c Compare July 31, 2024 15:36
Stuart Reed added 2 commits July 31, 2024 10:10
* 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``.
@reedsa reedsa force-pushed the abi-function-utils branch from e6a824c to 70340eb Compare July 31, 2024 16:10
@reedsa reedsa merged commit 90cb12c into ethereum:main Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants