Skip to content
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

Merged
merged 30 commits into from
Feb 11, 2019
Merged

Contract Caller Cleaned up #1227

merged 30 commits into from
Feb 11, 2019

Conversation

kclowes
Copy link
Collaborator

@kclowes kclowes commented Jan 30, 2019

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

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

@kclowes kclowes mentioned this pull request Jan 30, 2019
3 tasks
docs/contracts.rst Outdated Show resolved Hide resolved
ens/utils.py Outdated Show resolved Hide resolved
web3/contract.py Show resolved Hide resolved
web3/contract.py Show resolved Hide resolved
web3/contract.py Outdated Show resolved Hide resolved
web3/contract.py Outdated Show resolved Hide resolved
web3/contract.py Outdated Show resolved Hide resolved
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']:
Copy link
Member

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

Copy link
Collaborator Author

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!

web3/contract.py Outdated Show resolved Hide resolved
web3/contract.py Show resolved Hide resolved
@carver carver mentioned this pull request Feb 5, 2019
22 tasks
Copy link
Collaborator

@carver carver left a comment

Choose a reason for hiding this comment

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

Looks great!

>>> twentyone = myContract.caller({'from': from_address}).multiply7(3)
>>> twentyone
21
>>> twentyone = myContract.caller(transaction_dict={'from': from_address}).multiply7(3)
Copy link
Collaborator

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)
Copy link
Collaborator

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.

Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

:shipit:

@kclowes kclowes merged commit b5de1a3 into ethereum:master Feb 11, 2019
@kclowes kclowes deleted the cc branch February 11, 2019 17:55
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.

3 participants