diff --git a/.gitignore b/.gitignore index f4e6946..346fea2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea +.DS_Store # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/setup.py b/setup.py index c278cfa..520b931 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ import os import platform + from setuptools import ( find_packages, setup, @@ -79,16 +80,16 @@ "toolz>=0.9.0,<1.0.0;implementation_name=='pypy'", "cytoolz>=0.9.0,<1.0.0;implementation_name=='cpython'", - "eth-abi>=2.0.0b6,<3.0.0", - "eth-account==0.4.0", - "eth-utils>=1.3.0,<2.0.0", - "eth-hash[pycryptodome]>=0.2.0,<1.0.0", + "eth-abi", + "eth-account", + "eth-utils", + "eth-hash[pycryptodome]", - "trx-utils", + "trx-utils @ git+https://github.com/const-tmp/trx-utils.git", "hexbytes>=0.1.0,<1.0.0", - "requests>=2.16.0,<3.0.0", + "requests", "base58", "ecdsa", 'attrdict', @@ -100,7 +101,6 @@ with open(readme_filename) as f: PACKAGE_LONG_DESCRIPTION = f.read() - setup( name='tronapi', version=PACKAGE_VERSION, diff --git a/tronapi/common/contracts.py b/tronapi/common/contracts.py index a83961a..c33e5f3 100644 --- a/tronapi/common/contracts.py +++ b/tronapi/common/contracts.py @@ -36,7 +36,7 @@ valmap, ) from eth_abi import ( - encode_abi as eth_abi_encode_abi, + encode as eth_abi_encode_abi, ) from eth_abi.exceptions import ( diff --git a/tronapi/common/datastructures.py b/tronapi/common/datastructures.py index 834d3b1..d43494c 100644 --- a/tronapi/common/datastructures.py +++ b/tronapi/common/datastructures.py @@ -1,10 +1,5 @@ -from collections import ( - Hashable, - Mapping, - MutableMapping, - OrderedDict, - Sequence, -) +from collections import OrderedDict +from collections.abc import Hashable, Mapping, MutableMapping, Sequence from trx_utils import ( is_integer, @@ -14,6 +9,7 @@ recursive_map, ) + # Hashable must be immutable: # "the implementation of hashable collections requires that a key's hash value is immutable" # https://docs.python.org/3/reference/datamodel.html#object.__hash__ @@ -101,6 +97,7 @@ class NamedElementOnion(Mapping): Add layers to an onion-shaped structure. Optionally, inject to a specific layer. This structure is iterable, where the outermost layer is first, and innermost is last. """ + def __init__(self, init_elements, valid_element=callable): self._queue = OrderedDict() for element in reversed(init_elements): diff --git a/tronapi/common/encoding.py b/tronapi/common/encoding.py index e5512c7..d578253 100644 --- a/tronapi/common/encoding.py +++ b/tronapi/common/encoding.py @@ -2,7 +2,7 @@ import re from typing import Union -from eth_account.datastructures import AttributeDict +from tronapi.common.datastructures import AttributeDict from hexbytes import HexBytes from eth_utils import ( diff --git a/tronapi/common/formatters.py b/tronapi/common/formatters.py index 571af89..62e9710 100644 --- a/tronapi/common/formatters.py +++ b/tronapi/common/formatters.py @@ -4,7 +4,7 @@ # See License.txt in the project root for license information. # -------------------------------------------------------------------- -from collections import Mapping, Iterable +from collections.abc import Mapping, Iterable from eth_utils import to_dict from trx_utils import ( diff --git a/tronapi/contract.py b/tronapi/contract.py index 775410a..e31fdc5 100644 --- a/tronapi/contract.py +++ b/tronapi/contract.py @@ -6,7 +6,7 @@ import copy -from eth_abi import decode_abi +from eth_abi import decode from eth_utils import ( function_abi_to_4byte_selector, to_hex @@ -329,7 +329,7 @@ def decode_function_input(self, data): func = self.get_function_by_selector(selector) names = [x['name'] for x in func.abi['inputs']] types = [x['type'] for x in func.abi['inputs']] - decoded = decode_abi(types, params) + decoded = decode(types, params) normalized = map_abi_data(BASE_RETURN_NORMALIZERS, types, decoded) return func, dict(zip(names, normalized)) diff --git a/tronapi/main.py b/tronapi/main.py index a1bf985..f7f72be 100644 --- a/tronapi/main.py +++ b/tronapi/main.py @@ -15,7 +15,7 @@ :license: MIT License """ -from eth_account.datastructures import AttributeDict +from tronapi.common.datastructures import AttributeDict from urllib.parse import urlencode from eth_utils import ( apply_to_return_value, diff --git a/tronapi/transactionbuilder.py b/tronapi/transactionbuilder.py index 959fca2..1250531 100644 --- a/tronapi/transactionbuilder.py +++ b/tronapi/transactionbuilder.py @@ -11,7 +11,7 @@ List ) -from eth_abi import encode_abi +from eth_abi import encode from trx_utils import ( is_string, is_integer, @@ -572,7 +572,7 @@ def trigger_smart_contract(self, **kwargs): values.append(abi['value']) try: - parameters = encode_hex(encode_abi(types, values)).replace('0x', '', 2) + parameters = encode_hex(encode(types, values)).replace('0x', '', 2) except ValueError as ex: print(ex)