Skip to content

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
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!

@carver carver mentioned this pull request Feb 5, 2019
22 tasks
Copy link
Contributor

@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
Contributor

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
Contributor

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