Skip to content

Commit

Permalink
Type hints fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Badiboy authored and andelf committed Jan 24, 2021
1 parent bd78499 commit a3db288
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ dmypy.json

# Pyre type checker
.pyre/

# PyCharm project settings
.idea/
13 changes: 9 additions & 4 deletions tronpy/tron.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def __init__(self, tron):
def client(self) -> "Tron":
return self._tron

def _build_transaction(self, type_: str, obj: dict, *, method: ContractMethod = None) -> dict:
def _build_transaction(self, type_: str, obj: dict, *, method: ContractMethod = None) -> TransactionBuilder:
inner = {
"parameter": {"value": obj, "type_url": "type.googleapis.com/protocol.{}".format(type_)},
"type": type_,
Expand Down Expand Up @@ -311,6 +311,7 @@ def asset_issue(
def account_permission_update(self, owner: TAddress, perm: dict) -> "TransactionBuilder":
"""Update account permission.
:param owner:
:param perm: Permission dict from :meth:`~tronpy.Tron.get_account_permission`
"""

Expand Down Expand Up @@ -340,7 +341,10 @@ def freeze_balance(
) -> "TransactionBuilder":
"""Freeze balance to get energy or bandwidth, for 3 days.
:param owner:
:param amount:
:param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
:param receiver:
"""
payload = {
"owner_address": keys.to_hex_address(owner),
Expand All @@ -357,7 +361,9 @@ def unfreeze_balance(
) -> "TransactionBuilder":
"""Unfreeze balance to get TRX back.
:param owner:
:param resource: Resource type, can be ``"ENERGY"`` or ``"BANDWIDTH"``
:param receiver:
"""
payload = {
"owner_address": keys.to_hex_address(owner),
Expand Down Expand Up @@ -693,14 +699,13 @@ def get_solid_transaction_info(self, txn_id: str) -> dict:

# Chain parameters

def list_witnesses(self) -> list:
def list_witnesses(self) -> dict:
"""List all witnesses, including SR, SRP, and SRC."""
# NOTE: visible parameter is ignored
ret = self.provider.make_request("wallet/listwitnesses", {"visible": True})
witnesses = ret.get("witnesses", [])
for witness in witnesses:
witness["address"] = keys.to_base58check_address(witness["address"])

return ret

def list_nodes(self) -> list:
Expand Down Expand Up @@ -821,5 +826,5 @@ def broadcast(self, txn: Transaction) -> dict:
self._handle_api_error(payload)
return payload

def get_sign_weight(self, txn: TransactionBuilder) -> str:
def get_sign_weight(self, txn: Transaction) -> dict:
return self.provider.make_request("wallet/getsignweight", txn.to_json())

0 comments on commit a3db288

Please sign in to comment.