Skip to content

Commit c5f8655

Browse files
committed
update contract
1 parent b3c40dc commit c5f8655

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

tronapi/common/contracts.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ def find_matching_fn_abi(abi, fn_identifier=None, args=None, kwargs=None):
7070
encoding_filter,
7171
])
7272
function_candidates = pipe(abi, *filters)
73+
7374
if len(function_candidates) == 1:
7475
return function_candidates[0]
7576
else:
7677
matching_identifiers = name_filter(abi)
7778
matching_function_signatures = [abi_to_signature(func) for func in matching_identifiers]
79+
7880
arg_count_matches = len(arg_count_filter(matching_identifiers))
7981
encoding_matches = len(encoding_filter(matching_identifiers))
82+
8083
if arg_count_matches == 0:
8184
diagnosis = "\nFunction invocation failed due to improper number of arguments."
8285
elif encoding_matches == 0:

tronapi/contract.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ def factory(cls, tron, class_name=None, **kwargs):
208208
class_name or cls.__name__,
209209
(cls,),
210210
kwargs,
211-
normalizers=normalizers)
211+
normalizers=normalizers
212+
)
212213

213214
setattr(contract, 'functions', ContractFunctions(contract.abi, contract.tron))
214215
setattr(contract, 'fallback', Contract.get_fallback_function(contract.abi, contract.tron))

tronapi/trx.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,14 +805,18 @@ def get_contract(self, contract_address):
805805
})
806806

807807
def contract(self, address=None, **kwargs):
808-
contract_factory_class = kwargs.pop('contract_factory_class',
809-
self.default_contract_factory)
810-
contract_factory = contract_factory_class.factory(self.tron, **kwargs)
808+
"""Work with a contract
809+
810+
Args:
811+
address (str): TRON Address
812+
**kwargs (any): details (bytecode, abi)
813+
"""
814+
factory_class = kwargs.pop('contract_factory_class', self.default_contract_factory)
815+
contract_factory = factory_class.factory(self.tron, **kwargs)
811816

812817
if address:
813818
return contract_factory(address)
814-
else:
815-
return contract_factory
819+
return contract_factory
816820

817821
def validate_address(self, address, _is_hex=False):
818822
"""Validate address

0 commit comments

Comments
 (0)