Skip to content

Commit

Permalink
Remove unnecessary exception catching
Browse files Browse the repository at this point in the history
Exceptions generated by eth-abi are fairly descriptive.  It seems a bit
redundant to wrap encoding exceptions with this extra message and also
filter out the original exception type.
  • Loading branch information
davesque committed Jan 24, 2019
1 parent 70bf829 commit 503564b
Showing 1 changed file with 15 additions and 24 deletions.
39 changes: 15 additions & 24 deletions web3/_utils/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from eth_abi import (
encode_abi as eth_abi_encode_abi,
)
from eth_abi.exceptions import (
EncodingError,
)
from eth_utils import (
add_0x_prefix,
encode_hex,
Expand Down Expand Up @@ -139,27 +136,21 @@ def encode_abi(web3, abi, arguments, data=None):
)
)

try:
normalizers = [
abi_ens_resolver(web3),
abi_address_to_hex,
abi_bytes_to_bytes,
abi_string_to_text,
]
normalized_arguments = map_abi_data(
normalizers,
argument_types,
arguments,
)
encoded_arguments = eth_abi_encode_abi(
argument_types,
normalized_arguments,
)
except EncodingError as e:
raise TypeError(
"One or more arguments could not be encoded to the necessary "
"ABI type: {0}".format(str(e))
)
normalizers = [
abi_ens_resolver(web3),
abi_address_to_hex,
abi_bytes_to_bytes,
abi_string_to_text,
]
normalized_arguments = map_abi_data(
normalizers,
argument_types,
arguments,
)
encoded_arguments = eth_abi_encode_abi(
argument_types,
normalized_arguments,
)

if data:
return to_hex(HexBytes(data) + encoded_arguments)
Expand Down

0 comments on commit 503564b

Please sign in to comment.