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

feat: replaces usages of deprecated eth_abi package methods #1639

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +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)
### Changed
### Fixed
- Removes `eth-abi` depreciation warnings
- Bump web3.py dep to support async provider in threaded applications

## [1.19.2](https://github.com/eth-brownie/brownie/tree/v1.19.2) - 2022-10-16
Expand Down
2 changes: 1 addition & 1 deletion brownie/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions brownie/network/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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:
"""
Expand All @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions brownie/network/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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()}"
Expand Down Expand Up @@ -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:
Expand Down