From 209a51f3aac1b2c2bef313775632f4477aa680ef Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Tue, 29 Sep 2026 09:23:30 +0000 Subject: [PATCH] THORChainRemoteRPCClient: add annotations and docstrings --- mmgen/proto/rune/rpc/remote.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/mmgen/proto/rune/rpc/remote.py b/mmgen/proto/rune/rpc/remote.py index 36a81a06..2b59f8d9 100755 --- a/mmgen/proto/rune/rpc/remote.py +++ b/mmgen/proto/rune/rpc/remote.py @@ -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(