minor fixes, cleanups, renames

This commit is contained in:
The MMGen Project 2026-10-07 16:40:39 +00:00
commit f558e4ec21
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 18 additions and 12 deletions

View file

@ -11,7 +11,7 @@ mmgen-remote: Retrieve data from a remote JSON-RPC server
"""
from .cfg import Config
from .util import Msg, die, fmt_list, async_run
from .util import Msg, die, fmt_list
opts_data = {
'filter_codes': ['-'],
@ -49,7 +49,7 @@ def log(text, cmd, args, kwargs):
from .fileutil import write_data_to_file
write_data_to_file(cfg, fn, text)
async def main():
def main():
from .tool import get_cmds, process_args
match cfg.coin:
@ -82,4 +82,4 @@ async def main():
case _:
cfg._usage()
async_run(cfg, main)
main()

View file

@ -15,6 +15,9 @@ import json
from ....http import RemoteJSONClient
from ....rpc.remote import RemoteRPCClient
def make_query_string(kwargs):
return '&'.join(f'{k}={v}' for k, v in kwargs.items() if v)
# throws exception on error:
def process_response(json_response, errmsg):
data = json.loads(json_response)
@ -26,16 +29,16 @@ def process_response(json_response, errmsg):
return data
# HTTP POST, JSON-RPC response:
class ThornodeRemoteRPCClient(RemoteJSONClient):
class RPCClient(RemoteJSONClient):
params = 'rpc_remote_rpc_params'
timeout = 30
# HTTP GET, params in query string, JSON-RPC response:
class ThornodeRemoteRESTClient(RemoteJSONClient):
# HTTP GET, JSON-RPC response:
class RESTClient(RemoteJSONClient): # same endpoint as RPCClient for test suite
params = 'rpc_remote_rest_params'
timeout = 15
class ThornodeRemoteMidgardClient(RemoteJSONClient):
class MidgardClient(RemoteJSONClient):
params = 'rpc_remote_midgard_params'
timeout = 30
@ -61,9 +64,9 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
setattr(self, k, v)
super().__init__(cfg, proto)
self.caps = ('lbl_id',)
self.rest_api = ThornodeRemoteRESTClient(cfg, proto)
self.rpc_api = ThornodeRemoteRPCClient(cfg, proto)
self.midgard_api = ThornodeRemoteMidgardClient(cfg, proto)
self.rest_api = RESTClient(cfg, proto)
self.rpc_api = RPCClient(cfg, proto)
self.midgard_api = MidgardClient(cfg, proto)
@staticmethod
def data_for_coin(ret, coin):
@ -102,7 +105,7 @@ class THORChainRemoteRPCClient(RemoteRPCClient):
def actions(self, *, addr: str=None, txid: str=None): # noqa: RUF013
"get actions for a given address or TxID"
assert addr or txid, 'one of addr or txid must be specified'
qs = '&'.join(f'{k}={v}' for k, v in (('address', addr), ('txid', txid)) if v)
qs = make_query_string({'address': addr, 'txid': txid})
return process_response(
self.midgard_api.get(path=f'/v2/actions?{qs}'),
errmsg = 'get actions info failed')

View file

@ -250,6 +250,8 @@ class Base(MMGenObject):
rpc = await rpc_init(self.cfg, proto)
data = rpc.inbound_addrs()
for asset in (self.send_asset, self.recv_asset):
if asset.name == 'RUNE':
continue
for key, state in (
('global_trading_paused', 'paused'),
('chain_trading_paused', f'paused for asset {asset.name}'),

View file

@ -48,6 +48,7 @@ init_tests() {
a $objtest_py --coin=ltc
a $objtest_py --coin=ltc --testnet=1
a $objtest_py --coin=eth
a $objtest_py --coin=xmr
x $objattrtest_py
"
[ "$SKIP_ALT_DEP" ] && t_obj_skip='a'
@ -266,7 +267,7 @@ init_tests() {
d_ltc="overall operations with emulated RPC data (Litecoin)"
t_ltc="
- $cmdtest_py --coin=ltc --exclude regtest,autosign_automount,help
- $cmdtest_py --coin=ltc --exclude regtest,autosign_automount,help,runeswap
- $cmdtest_py --coin=ltc --segwit
- $cmdtest_py --coin=ltc --segwit-random
- $cmdtest_py --coin=ltc --bech32