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

eth_abi deprecation warning for abi.encode_abi #2621

Closed
Polsaker opened this issue Aug 25, 2022 · 2 comments · Fixed by #2626
Closed

eth_abi deprecation warning for abi.encode_abi #2621

Polsaker opened this issue Aug 25, 2022 · 2 comments · Fixed by #2626

Comments

@Polsaker
Copy link
Contributor

  • Version: 6.0.0b4
  • Python: 3.10
  • OS: osx

What was wrong?

Contract calls raise a DeprecationWarning due to encode_abi being renamed to encode in eth_abi:

    return self.contract.functions.decimals().call()
[snip]/lib/python3.10/site-packages/web3/contract.py:1228: in call
    return call_contract_function(
[snip]/lib/python3.10/site-packages/web3/contract.py:1982: in call_contract_function
    call_transaction = prepare_transaction(
[snip]/lib/python3.10/site-packages/web3/_utils/contracts.py:263: in prepare_transaction
    prepared_transaction["data"] = encode_transaction_data(
[snip]/lib/python3.10/site-packages/web3/_utils/contracts.py:303: in encode_transaction_data
    return add_0x_prefix(encode_abi(w3, fn_abi, fn_arguments, fn_selector))
[snip]/lib/python3.10/site-packages/web3/_utils/contracts.py:218: in encode_abi
    encoded_arguments = w3.codec.encode_abi(
-------
    def encode_abi(self, types: Iterable[TypeStr], args: Iterable[Any]) -> bytes:
        """
        Encodes the python values in ``args`` as a sequence of binary values of
        the ABI types in ``types`` via the head-tail mechanism.

        :param types: An iterable of string representations of the ABI types
            that will be used for encoding e.g.  ``('uint256', 'bytes[]',
            '(int,int)')``
        :param args: An iterable of python values to be encoded.

        :returns: The head-tail encoded binary representation of the python
            values in ``args`` as values of the ABI types in ``types``.
        """
>       warnings.warn(
            "abi.encode_abi() and abi.encode_abi_packed() are deprecated and will be "
            "removed in version 4.0.0 in favor of abi.encode() and "
            "abi.encode_packed(), respectively",
            category=DeprecationWarning,
        )
E       DeprecationWarning: abi.encode_abi() and abi.encode_abi_packed() are deprecated and will be removed in version 4.0.0 in favor of abi.encode() and abi.encode_packed(), respectively

How can it be fixed?

Call encode instead of encode_abi as directed by the eth_abi warning.


Note: We prefer to use issues to track our work. If you think you've encountered a bug in web3py or
have a feature request, you're in the right place. If you have implementation or usage questions,
please refer to our documentation and/or join the conversation
on discord.

@pacrob
Copy link
Contributor

pacrob commented Aug 31, 2022

Thanks for the heads up!

@Polsaker
Copy link
Contributor Author

Polsaker commented Sep 8, 2022

There are a bunch of decode_abi calls left in https://github.com/ethereum/web3.py/blob/master/web3/contract.py

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 a pull request may close this issue.

2 participants