From a2826b095cc449feadbf2733011599a4b7d8fd6e Mon Sep 17 00:00:00 2001 From: Michal Baranowski Date: Fri, 25 Nov 2022 16:12:58 +0100 Subject: [PATCH 1/2] feat: replaces usages of deprecated eth_abi package methods --- brownie/exceptions.py | 2 +- brownie/network/contract.py | 14 +++++++------- brownie/network/transaction.py | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/brownie/exceptions.py b/brownie/exceptions.py index b04b664d1..7b28d428f 100644 --- a/brownie/exceptions.py +++ b/brownie/exceptions.py @@ -107,7 +107,7 @@ def __init__(self, exc: ValueError) -> None: self.revert_type = "revert" err_msg = exc["data"][len(ERROR_SIG) :] - (err_msg,) = eth_abi.decode_abi(["string"], HexBytes(err_msg)) + (err_msg,) = eth_abi.decode(["string"], HexBytes(err_msg)) self.revert_msg = err_msg return diff --git a/brownie/network/contract.py b/brownie/network/contract.py index 0d28b1996..cd4e4eccf 100644 --- a/brownie/network/contract.py +++ b/brownie/network/contract.py @@ -156,7 +156,7 @@ def decode_input(self, calldata: Union[str, bytes]) -> Tuple[str, Any]: function_sig = build_function_signature(abi) types_list = get_type_strings(abi["inputs"]) - result = eth_abi.decode_abi(types_list, calldata[4:]) + result = eth_abi.decode(types_list, calldata[4:]) input_args = format_input(abi, result) return function_sig, input_args @@ -578,7 +578,7 @@ def encode_input(self, *args: tuple) -> str: data = format_input(self.abi, args) types_list = get_type_strings(self.abi["inputs"]) - return bytecode + eth_abi.encode_abi(types_list, data).hex() + return bytecode + eth_abi.encode(types_list, data).hex() def estimate_gas(self, *args: Tuple) -> int: """ @@ -680,7 +680,7 @@ def decode_input(self, calldata: Union[str, bytes]) -> Tuple[str, Any]: function_sig = build_function_signature(abi) types_list = get_type_strings(abi["inputs"]) - result = eth_abi.decode_abi(types_list, calldata[4:]) + result = eth_abi.decode(types_list, calldata[4:]) input_args = format_input(abi, result) return function_sig, input_args @@ -1698,7 +1698,7 @@ def call( selector = HexBytes(data)[:4].hex() if selector == "0x08c379a0": - revert_str = eth_abi.decode_abi(["string"], HexBytes(data)[4:])[0] + revert_str = eth_abi.decode(["string"], HexBytes(data)[4:])[0] raise ValueError(f"Call reverted: {revert_str}") elif selector == "0x4e487b71": error_code = int(HexBytes(data)[4:].hex(), 16) @@ -1762,7 +1762,7 @@ def decode_input(self, hexstr: str) -> List: Decoded values """ types_list = get_type_strings(self.abi["inputs"]) - result = eth_abi.decode_abi(types_list, HexBytes(hexstr)[4:]) + result = eth_abi.decode(types_list, HexBytes(hexstr)[4:]) return format_input(self.abi, result) def encode_input(self, *args: Tuple) -> str: @@ -1781,7 +1781,7 @@ def encode_input(self, *args: Tuple) -> str: """ data = format_input(self.abi, args) types_list = get_type_strings(self.abi["inputs"]) - return self.signature + eth_abi.encode_abi(types_list, data).hex() + return self.signature + eth_abi.encode(types_list, data).hex() def decode_output(self, hexstr: str) -> Tuple: """ @@ -1797,7 +1797,7 @@ def decode_output(self, hexstr: str) -> Tuple: Decoded values """ types_list = get_type_strings(self.abi["outputs"]) - result = eth_abi.decode_abi(types_list, HexBytes(hexstr)) + result = eth_abi.decode(types_list, HexBytes(hexstr)) result = format_output(self.abi, result) if len(result) == 1: result = result[0] diff --git a/brownie/network/transaction.py b/brownie/network/transaction.py index 71215b223..a2530b0c5 100644 --- a/brownie/network/transaction.py +++ b/brownie/network/transaction.py @@ -14,7 +14,7 @@ import black import requests -from eth_abi import decode_abi +from eth_abi import decode from hexbytes import HexBytes from web3.exceptions import TransactionNotFound @@ -722,7 +722,7 @@ def _reverted_trace(self, trace: Sequence) -> None: else: self._revert_msg = f"Panic (error code: {error_code})" elif selector == "0x08c379a0": # keccak of Error(string) - self._revert_msg = decode_abi(["string"], data[4:])[0] + self._revert_msg = decode(["string"], data[4:])[0] else: # TODO: actually parse the data self._revert_msg = f"typed error: {data.hex()}" @@ -945,7 +945,7 @@ def _expand_trace(self) -> None: data = _get_memory(trace[i], -1) if len(data) > 4: try: - subcall["revert_msg"] = decode_abi(["string"], data[4:])[0] + subcall["revert_msg"] = decode(["string"], data[4:])[0] except Exception: subcall["revert_msg"] = data.hex() if "revert_msg" not in subcall and "dev" in pc: From eb7b341c1ba2145616de089f13d9a34837bd2cb0 Mon Sep 17 00:00:00 2001 From: Michal Baranowski Date: Fri, 25 Nov 2022 16:31:58 +0100 Subject: [PATCH 2/2] docs: updates CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbd72a310..ee33b2c4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ This changelog format is based on [Keep a Changelog](https://keepachangelog.com/ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased](https://github.com/eth-brownie/brownie) +## Fixed +- Removes `eth-abi` depreciation warnings ## [1.19.2](https://github.com/eth-brownie/brownie/tree/v1.19.2) - 2022-10-16 ### Added