-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Contract Caller Cleaned up #1227
Conversation
rename transaction_dict for consistency
Remove unneeded args and kwargs
web3/contract.py
Outdated
"The abi for this contract contains no function definitions. ", | ||
"Are you sure you provided the correct contract abi?" | ||
) | ||
elif function_name not in self.__dict__['_functions']: |
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.
These conditionals can get away from accessing self.__dict__
if we instead define these attributes to default to None
on the class which should also have the benefit of being more precise checks.
if self.abi is None:
# no abi
elif len(self._functions) == 0:
# no functions in the abi
elif function_name not in self._functions:
# no matching function
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 that. I think it's updated to what you recommended, but let me know if it's not!
Change none_or_zero_address to is_none_or_zero_address
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.
Looks great!
docs/contracts.rst
Outdated
>>> twentyone = myContract.caller({'from': from_address}).multiply7(3) | ||
>>> twentyone | ||
21 | ||
>>> twentyone = myContract.caller(transaction_dict={'from': from_address}).multiply7(3) |
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.
Maybe one more example that includes block_identifier
?
'gasPrice': web3.toWei(.001, 'ether'), | ||
'value': 12345, | ||
} | ||
contract = return_args_contract.caller(transaction_dict=transaction_dict) |
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.
This dict
has been called transaction
in enough other places that I think it's more consistent to just use transaction
instead of transaction_dict
as the keyword argument name.
Make caller tests better
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.
This should be the same diff as the original Contract Caller PR (#1157), but branched off of the tip of master since the original had been open so long. There were some really nasty merge conflicts that made for ugly history
What was wrong?
Want to deprecate ConciseContract and ImplicitContract in favor of a ContractCaller. There are more details in the issue linked below.
Related to Issue #
#1025
How was it fixed?
Added a new ContractCaller class and added deprecation methods to ConciseContract and ImplicitContract.
See #1157
Cute Animal Picture