Skip to content

Commit

Permalink
Support eth-abi >=2
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjw committed Jul 30, 2018
1 parent a80025f commit 2041b5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
7 changes: 7 additions & 0 deletions tests/core/contracts/test_contract_call_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@
Decimal,
getcontext,
)
from distutils.version import (
LooseVersion,
)
import json
import pytest

import eth_abi
from hexbytes import (
HexBytes,
)
Expand Down Expand Up @@ -184,6 +188,9 @@ def test_call_get_string_value(string_contract, call):
assert result == "Caqalai"


@pytest.mark.skipif(
LooseVersion(eth_abi.__version__) >= LooseVersion("2"),
reason="eth-abi >=2 does utf-8 string decoding")
def test_call_read_string_variable(string_contract, call):
result = call(contract=string_contract,
contract_function='constValue')
Expand Down
11 changes: 9 additions & 2 deletions web3/utils/normalizers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@

import codecs
from distutils.version import (
LooseVersion,
)
import functools
import json

import eth_abi
from eth_abi.abi import (
process_type,
)
Expand Down Expand Up @@ -140,11 +144,14 @@ def abi_ens_resolver(w3, abi_type, val):


BASE_RETURN_NORMALIZERS = [
addresses_checksummed,
decode_abi_strings,
addresses_checksummed
]


if LooseVersion(eth_abi.__version__) < LooseVersion("2"):
BASE_RETURN_NORMALIZERS.append(decode_abi_strings)


#
# Property Normalizers
#
Expand Down

0 comments on commit 2041b5d

Please sign in to comment.