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 50e24d9
Showing 1 changed file with 15 additions and 21 deletions.
36 changes: 15 additions & 21 deletions web3/_utils/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,27 +139,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 50e24d9

Please sign in to comment.