-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Handle ambiguous event names in contracts #3457
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
reedsa
added a commit
to reedsa/web3.py
that referenced
this pull request
Aug 22, 2024
reedsa
force-pushed
the
abi-event-arguments
branch
from
August 22, 2024 17:28
7a89c90
to
476fbba
Compare
reedsa
added a commit
to reedsa/web3.py
that referenced
this pull request
Aug 22, 2024
reedsa
force-pushed
the
abi-event-arguments
branch
from
August 22, 2024 17:43
476fbba
to
9ad25ff
Compare
reedsa
added a commit
to reedsa/web3.py
that referenced
this pull request
Aug 22, 2024
reedsa
force-pushed
the
abi-event-arguments
branch
from
August 22, 2024 20:09
9ad25ff
to
a01afd8
Compare
reedsa
added a commit
to reedsa/web3.py
that referenced
this pull request
Aug 22, 2024
reedsa
force-pushed
the
abi-event-arguments
branch
from
August 22, 2024 22:18
a01afd8
to
f48fb1d
Compare
reedsa
added a commit
to reedsa/web3.py
that referenced
this pull request
Aug 22, 2024
reedsa
force-pushed
the
abi-event-arguments
branch
from
August 22, 2024 22:46
f48fb1d
to
4e286b7
Compare
New ``get_abi_element_by_name_and_type`` function to find unique ABIs based on argument names and types. ContractEvent class method ``_get_abi_event()`` now allows passing argument names and types to match unique elements.
…s_by_identifier``
reedsa
force-pushed
the
abi-event-arguments
branch
from
August 28, 2024 15:52
caa7fc8
to
a274a8f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What was wrong?
Closes #964, #1704
The
Contract
class breaks down if a contract contains overloaded event names.BaseContractEvent._get_event_abi()
calls eth-utilsget_event_abi()
but if any contract event shares the same name there is a problem with initialization of the Contract class.Currently only the event name is used to filter ABI events from the contract ABI, so an exception is raised for "multiple events are found" when
_get_event_abi
is called on the Contract or ContractEvent class.There are inconsistencies between Contract Functions and Events. The APIs should be the same for each so that there are methods to retrieve the ABI on the ContractFunction or ContractEvent. Exception messages can be shared across both and incorporate the same behaviors when a Function or Event cannot be matched with the ABI.
How was it fixed?
Add
_get_abi
methods to bothBaseContractFunction
andBaseContractEvent
.Modify
get_abi_element
to allowargument_names
as an argument.ContractEvent
andContractFunction
initialized with anabi_element_identifier
andabi
. Theabi_element_identifier
stores the string signature representation of the event or function.Also refactored
_mismatched_abi_error_diagnosis
so that messaging is clear for all ABI types, not just functions. MismatchedABI error messages are created based on the number of matches for specific filters. Error messages for MismatchedABI exceptions were using "encoding" terminology when the argument values were not encodable. Now that lookups can be made using the argument names and types (rather than values), the messages now state the arguments do not match the ABI.Todo:
Cute Animal Picture