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

Support for Python 3.10, 3.11 #111

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.DS_Store

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import os
import platform

from setuptools import (
find_packages,
setup,
Expand Down Expand Up @@ -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',
Expand All @@ -100,7 +101,6 @@
with open(readme_filename) as f:
PACKAGE_LONG_DESCRIPTION = f.read()


setup(
name='tronapi',
version=PACKAGE_VERSION,
Expand Down
2 changes: 1 addition & 1 deletion tronapi/common/contracts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
11 changes: 4 additions & 7 deletions tronapi/common/datastructures.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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__
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tronapi/common/encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion tronapi/common/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions tronapi/contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion tronapi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions tronapi/transactionbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
List
)

from eth_abi import encode_abi
from eth_abi import encode
from trx_utils import (
is_string,
is_integer,
Expand Down Expand Up @@ -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)

Expand Down