-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Initialize contracts having function or event overrides #3476
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
Conversation
bdc2282
to
4b2adad
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.
LGTM! Just left a few nits!
The ambiguity with functions is also an issue unfortunately. Taking a look at how to disambiguate since right now it uses the "first" one. |
7b15976
to
4354b1a
Compare
__getattr__ now uses the ABI to look up the function class by signature Additional fixes for ens
Refactoring and docs update for ``get_abi_element`` and ``_build_filters`` Rename ``get_abi_element_identifier`` -> ``get_abi_element_signature``
…ith_name`` Further cleanup and refactoring
Fix contract compilation and naming
Remove docs from events iter Fix docstring formatting
1b05ab8
to
e1d16e5
Compare
054b8e5
to
233fa23
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.
🐑
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.
Sweet! I didn't see anything major, just left a few small comments.
Filter by type prior to getting an ABI element
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.
🐑
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! Since this is such a core component of our library, it's probably worth some manual testing to make sure old functionality still works as expected. I did some myself and have fairly high confidence in the tests, but it's probably worth one more run through!
What was wrong?
Closes #1704, #3482
The
Contract
class cannot initialize if the contract contains overloaded functions or events. Currently only the function/event name is used to filter ABI events from the contract ABI, so an exception is raised. Currently, events raise a ValueError when_get_event_abi
is called on the Contract or ContractEvent class. Functions raise a MismatchedABI error.Example:
BaseContractEvent._get_event_abi()
calls eth-utilsget_event_abi()
and expects to return the ABI for the event class. The event classes are not created for every overloaded function. When there are contract events with the same name, only one is ever created and used.How was it fixed?
Initialize the
ContractFunctions
orContractEvents
class with every ABI found in the contract, storing the abi signature in the class name. Along with the signature, theabi
property is set for each class within the__init__
method. This ensures the correct instance is found and used for subsequent functions likeget_logs()
.get_abi_element
now handles both functions and events using the ABI signature to find a unique ABI. The signature is represented by a string that includes it's name and list of input types within parentheses.name(arg1Type,arg2Type,...)
Exceptions are now shared between functions and events for consistency.
Todo:
Cute Animal Picture