From f7e6904d6d6f065f2bdd7082dcfeba3127aa2d1b Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 15 Oct 2026 09:35:52 +0000 Subject: [PATCH] help, tool, tx.base_swap: remove swap-proto-dependent code --- mmgen/help/remote.py | 7 ++++--- mmgen/help/txcreate.py | 4 ++-- mmgen/tool/amt.py | 6 +++--- mmgen/tx/base_swap.py | 3 +-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/mmgen/help/remote.py b/mmgen/help/remote.py index 63c39648..efc530a8 100644 --- a/mmgen/help/remote.py +++ b/mmgen/help/remote.py @@ -26,9 +26,10 @@ def help(proto, cfg): For individual command usage, invoke ‘{gc.prog_name} --coin={cfg.coin.lower()} help COMMAND’ """ - match cfg.coin: - case 'RUNE': - from ..proto.rune.rpc.remote import THORChainRemoteRPCClient as rpc + match proto.base_proto: + case 'THORChain': + from ..rpc import get_remote_rpc + rpc = get_remote_rpc(cfg, proto) clist = '\n ' + '\n'.join(gen_main_help( mods_data = rpc.mods, get_mod_cls_func = lambda x: rpc, diff --git a/mmgen/help/txcreate.py b/mmgen/help/txcreate.py index e967684d..de44b4ab 100644 --- a/mmgen/help/txcreate.py +++ b/mmgen/help/txcreate.py @@ -40,13 +40,13 @@ an OP_RETURN data output with a zero spend amount. This is the preferred way to embed data in the blockchain. {ds} """.format(ds=data_spec_info.format(dl=proto.max_op_return_data_len)) case 'THORChain': - from ..swap.proto.thorchain.memo import THORChainMemo + from ..swap.util import get_swap_proto_mod outputs_info = """ The transaction output is specified in the form ADDRESS,AMOUNT. A single DATA_SPEC argument may also be given on the command line to embed data (e.g. a memo) in the transaction. {ds} -""".format(ds=data_spec_info.format(dl=THORChainMemo.max_len)) +""".format(ds=data_spec_info.format(dl=get_swap_proto_mod(cfg.swap_proto).Memo.max_len)) case _: outputs_info = """ The transaction output is specified in the form ADDRESS,AMOUNT. diff --git a/mmgen/tool/amt.py b/mmgen/tool/amt.py index 2059b906..7bfa5c6a 100644 --- a/mmgen/tool/amt.py +++ b/mmgen/tool/amt.py @@ -24,7 +24,7 @@ class tool_cmd(tool_cmd_base): assert self.cfg.coin == 'BTC', '--coin arg not supported for this command' - from ..swap.proto.thorchain.memoless import THORChainMemolessAmount - from ..swap.util import get_coin_amt + from ..swap.util import get_swap_proto_mod, get_coin_amt - return str(THORChainMemolessAmount(get_coin_amt(self.cfg, asset, amt), refnum).amt) + return str(get_swap_proto_mod(self.cfg.swap_proto).memoless_amt( + get_coin_amt(self.cfg, asset, amt), refnum).amt) diff --git a/mmgen/tx/base_swap.py b/mmgen/tx/base_swap.py index 09644258..80b77ff7 100644 --- a/mmgen/tx/base_swap.py +++ b/mmgen/tx/base_swap.py @@ -59,8 +59,7 @@ class BaseSwapMethods: if hasattr(self, 'swap_recv_asset_spec'): return self.swap_proto_mod.SwapAsset(self.swap_recv_asset_spec, 'recv') elif self.is_swap and hasattr(self, 'data_output'): - from ..swap.proto.thorchain.memo import THORChainMemo - return THORChainMemo.parse(str(self.data_output.data)).asset + return self.swap_proto_mod.Memo.parse(str(self.data_output.data)).asset else: # backwards-compatibility workaround from ..swap.asset import SwapAsset x = '[unknown]'