Skip to content

Commit fc0bf7f

Browse files
committed
fix
1 parent a4e7743 commit fc0bf7f

File tree

7 files changed

+78
-31
lines changed

7 files changed

+78
-31
lines changed

tronapi/base/abi.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# --------------------------------------------------------------------
2+
# Copyright (c) iEXBase. All rights reserved.
3+
# Licensed under the MIT License.
4+
# See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------
6+
17
import itertools
28
import re
39

@@ -380,15 +386,15 @@ def normalizer(datatype, data):
380386

381387
@curry
382388
def abi_data_tree(types, data):
383-
'''
384-
Decorate the data tree with pairs of (type, data). The pair tuple is actually an
389+
"""Decorate the data tree with pairs of (type, data). The pair tuple is actually an
385390
ABITypedData, but can be accessed as a tuple.
386391
387-
As an example:
392+
Examples:
393+
>>> abi_data_tree(types=["bool[2]", "uint"], data=[[True, False], 0])
388394
389-
>>> abi_data_tree(types=["bool[2]", "uint"], data=[[True, False], 0])
390-
[("bool[2]", [("bool", True), ("bool", False)]), ("uint256", 0)]
391-
'''
395+
Returns:
396+
[("bool[2]", [("bool", True), ("bool", False)]), ("uint256", 0)]
397+
"""
392398
return [
393399
abi_sub_tree(data_type, data_value)
394400
for data_type, data_value

tronapi/base/contracts.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
# --------------------------------------------------------------------
2+
# Copyright (c) iEXBase. All rights reserved.
3+
# Licensed under the MIT License.
4+
# See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------
6+
17
import functools
28

3-
from tronapi.base.abi import filter_by_name, filter_by_encodability, filter_by_argument_count, get_fallback_func_abi, \
9+
from tronapi.base.abi import (
10+
filter_by_name,
11+
filter_by_encodability,
12+
filter_by_argument_count,
13+
get_fallback_func_abi,
414
abi_to_signature
15+
)
16+
517
from tronapi.base.function_identifiers import FallbackFn
618
from tronapi.base.toolz import (
719
pipe,

tronapi/base/datatypes.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1+
# --------------------------------------------------------------------
2+
# Copyright (c) iEXBase. All rights reserved.
3+
# Licensed under the MIT License.
4+
# See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------
6+
17
from tronapi.base.formatters import apply_formatters_to_dict
28
from tronapi.base.toolz import (
39
concat,
410
curry,
511
)
612

713

8-
@curry
9-
def verify_attr(class_name, key, namespace):
10-
if key not in namespace:
11-
raise AttributeError(
12-
"Property {0} not found on {1} class. "
13-
"`{1}.factory` only accepts keyword arguments which are "
14-
"present on the {1} class".format(key, class_name)
15-
)
16-
17-
1814
class PropertyCheckingFactory(type):
19-
def __init__(cls, name, bases, namespace, **kargs):
15+
def __init__(cls, name, bases, namespace):
2016
# see PEP487. To accept kwargs in __new__, they need to be
2117
# filtered out here.
2218
super().__init__(name, bases, namespace)
@@ -35,3 +31,13 @@ def __new__(mcs, name, bases, namespace, normalizers=None):
3531
processed_namespace = namespace
3632

3733
return super().__new__(mcs, name, bases, processed_namespace)
34+
35+
36+
@curry
37+
def verify_attr(class_name, key, namespace):
38+
if key not in namespace:
39+
raise AttributeError(
40+
"Property {0} not found on {1} class. "
41+
"`{1}.factory` only accepts keyword arguments which are "
42+
"present on the {1} class".format(key, class_name)
43+
)

tronapi/base/formatters.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
# --------------------------------------------------------------------
2+
# Copyright (c) iEXBase. All rights reserved.
3+
# Licensed under the MIT License.
4+
# See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------
6+
17
from collections import Mapping, Iterable
28

39
from eth_utils import to_dict
410

511
from tronapi.base.decorators import reject_recursive_repeats
612
from tronapi.base.toolz import (
7-
compose,
8-
curry,
9-
dissoc,
13+
curry
1014
)
1115
from tronapi.utils.types import is_string
1216

tronapi/base/validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
def _prepare_selector_collision_msg(duplicates):
2727
dup_sel = valmap(apply_formatter_to_array(abi_to_signature), duplicates)
28-
joined_funcs = valmap(lambda funcs: ', '.join(funcs), dup_sel)
28+
joined_funcs = valmap(lambda f: ', '.join(f), dup_sel)
2929
func_sel_msg_list = [funcs + ' have selector ' + sel for sel, funcs in joined_funcs.items()]
3030
return ' and\n'.join(func_sel_msg_list)
3131

tronapi/contract.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,39 @@
1+
# --------------------------------------------------------------------
2+
# Copyright (c) iEXBase. All rights reserved.
3+
# Licensed under the MIT License.
4+
# See License.txt in the project root for license information.
5+
# --------------------------------------------------------------------
6+
17
import copy
2-
from typing import Dict, Any
38

49
from eth_utils import function_abi_to_4byte_selector, to_hex
510

6-
from tronapi.base.abi import filter_by_type, merge_args_and_kwargs, abi_to_signature, get_constructor_abi, \
7-
fallback_func_abi_exists, check_if_arguments_can_be_encoded
11+
from tronapi.base.abi import (
12+
filter_by_type,
13+
merge_args_and_kwargs,
14+
abi_to_signature,
15+
fallback_func_abi_exists,
16+
check_if_arguments_can_be_encoded
17+
)
818
from tronapi.base.contracts import find_matching_fn_abi
919
from tronapi.base.datatypes import PropertyCheckingFactory
10-
from tronapi.base.decorators import combomethod, deprecated_for
20+
from tronapi.base.decorators import (
21+
combomethod,
22+
deprecated_for
23+
)
1124
from tronapi.base.encoding import to_4byte_hex
1225
from tronapi.base.function_identifiers import FallbackFn
13-
from tronapi.base.normalizers import normalize_abi, normalize_bytecode
14-
from tronapi.exceptions import NoABIFunctionsFound, MismatchedABI, InvalidAddress, FallbackNotFound
15-
from tronapi.utils.hexadecimal import encode_hex, add_0x_prefix
26+
from tronapi.base.normalizers import (
27+
normalize_abi,
28+
normalize_bytecode
29+
)
30+
from tronapi.exceptions import (
31+
NoABIFunctionsFound,
32+
MismatchedABI,
33+
InvalidAddress,
34+
FallbackNotFound
35+
)
36+
from tronapi.utils.hexadecimal import encode_hex
1637
from tronapi.utils.types import is_text, is_integer
1738

1839

tronapi/manager.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
:license: MIT License
1616
"""
1717

18-
import logging
19-
2018
from tronapi import HttpProvider
2119
from tronapi.utils.types import is_string
2220

0 commit comments

Comments
 (0)