THORChainRemoteRPCClient: add annotations and docstrings
This commit is contained in:
parent
63b6bf5f07
commit
209a51f3aa
1 changed files with 10 additions and 4 deletions
|
|
@ -47,6 +47,8 @@ class ThornodeRemoteRESTClient(HTTPClient):
|
|||
super().__init__(cfg, network_proto=network_proto, host=host)
|
||||
|
||||
class THORChainRemoteRPCClient(RemoteRPCClient):
|
||||
"communicate with remote THORChain JSON-RPC endpoint"
|
||||
|
||||
server_proto = 'THORChain'
|
||||
|
||||
def __init__(self, cfg, proto):
|
||||
|
|
@ -57,7 +59,8 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
|
|||
self.rest_api = ThornodeRemoteRESTClient(cfg, proto)
|
||||
self.rpc_api = ThornodeRemoteRPCClient(cfg, proto)
|
||||
|
||||
def get_balance(self, addr, *, block=None):
|
||||
def get_balance(self, addr: str, *, block=None):
|
||||
"get balance for a given address, optionally at a given block height"
|
||||
res = process_response(
|
||||
self.rest_api.get(path=f'/bank/balances/{addr}'),
|
||||
errmsg = f'address ‘{addr}’ not found in blockchain')
|
||||
|
|
@ -65,19 +68,22 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
|
|||
assert len(rune_res) == 1, f'{rune_res}: result length is not one!'
|
||||
return self.proto.coin_amt(int(rune_res[0]['amount']), from_unit='satoshi')
|
||||
|
||||
def get_account_info(self, addr, *, block=None):
|
||||
def get_account_info(self, addr: str, *, block=None):
|
||||
"get account information for a given address, optionally at a given block height"
|
||||
return process_response(
|
||||
self.rest_api.get(path=f'/auth/accounts/{addr}'),
|
||||
errmsg = f'address ‘{addr}’ not found in blockchain')['value']
|
||||
|
||||
def get_tx_info(self, txid):
|
||||
def get_tx_info(self, txid: str):
|
||||
"get transaction information for a given TxID"
|
||||
return process_response(
|
||||
self.rpc_api.post(
|
||||
path = '/tx',
|
||||
data = {'hash': '0x' + txid}),
|
||||
errmsg = f'get info for transaction {txid} failed')
|
||||
|
||||
def tx_op(self, txhex, op=None):
|
||||
def tx_op(self, txhex: str, op=None):
|
||||
"perform a transaction operation"
|
||||
assert isinstance(txhex, str)
|
||||
assert op in ('check_tx', 'broadcast_tx_sync', 'broadcast_tx_async')
|
||||
return process_response(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue