From 7c18833435f11c2085c739390656164fa6f142c7 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 15 Jun 2025 09:17:02 +0000 Subject: [PATCH] CoinProtocol.Base: new `is_vm` attribute --- mmgen/proto/eth/params.py | 1 + mmgen/proto/rune/params.py | 1 + mmgen/protocol.py | 1 + mmgen/swap/proto/thorchain/thornode.py | 2 +- mmgen/tx/info.py | 2 +- mmgen/tx/new_swap.py | 6 +++--- test/cmdtest_d/swap.py | 4 ++-- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mmgen/proto/eth/params.py b/mmgen/proto/eth/params.py index 1219b2a6..bbd120b5 100755 --- a/mmgen/proto/eth/params.py +++ b/mmgen/proto/eth/params.py @@ -38,6 +38,7 @@ class mainnet(CoinProtocol.DummyWIF, CoinProtocol.Secp256k1): avg_bdi = 15 decimal_prec = 36 address_reuse_ok = True + is_vm = True is_evm = True # https://www.chainid.dev diff --git a/mmgen/proto/rune/params.py b/mmgen/proto/rune/params.py index b368ab7c..0532bc55 100755 --- a/mmgen/proto/rune/params.py +++ b/mmgen/proto/rune/params.py @@ -38,6 +38,7 @@ class mainnet(CoinProtocol.Secp256k1): rpc_type = 'remote' avg_bdi = 6 # TODO has_usr_fee = False + is_vm = True address_reuse_ok = False wif_ver_num = btc_mainnet.wif_ver_num diff --git a/mmgen/protocol.py b/mmgen/protocol.py index fb81660f..4b327279 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -56,6 +56,7 @@ class CoinProtocol(MMGenObject): base_coin = None is_fork_of = None chain_names = None + is_vm = False is_evm = False has_usr_fee = True rpc_type = 'local' diff --git a/mmgen/swap/proto/thorchain/thornode.py b/mmgen/swap/proto/thorchain/thornode.py index f5887f3c..1dcf4241 100755 --- a/mmgen/swap/proto/thorchain/thornode.py +++ b/mmgen/swap/proto/thorchain/thornode.py @@ -114,7 +114,7 @@ class Thornode: def get_estimated_fee(): return tx.feespec2abs( fee_arg = d['recommended_gas_rate'] + gas_unit_data[gas_unit].code, - tx_size = None if tx.proto.is_evm else tx.estimate_size() + tx_size_adj) + tx_size = None if tx.proto.is_vm else tx.estimate_size() + tx_size_adj) _amount_in_label = 'Amount in:' if deduct_est_fee: diff --git a/mmgen/tx/info.py b/mmgen/tx/info.py index b7991436..d92ba94c 100755 --- a/mmgen/tx/info.py +++ b/mmgen/tx/info.py @@ -74,7 +74,7 @@ class TxInfo: if tx.is_swap: from ..swap.proto.thorchain import Memo, name - data = tx.swap_memo.encode() if tx.proto.is_evm else tx.data_output.data + data = tx.swap_memo.encode() if tx.proto.is_vm else tx.data_output.data if Memo.is_partial_memo(data): recv_mmid = getattr(tx, 'swap_recv_addr_mmid', None) p = Memo.parse(data.decode('ascii')) diff --git a/mmgen/tx/new_swap.py b/mmgen/tx/new_swap.py index ba948dd3..a2fbd9a1 100755 --- a/mmgen/tx/new_swap.py +++ b/mmgen/tx/new_swap.py @@ -108,7 +108,7 @@ class NewSwap(New): arg = get_arg() # arg 3: chg_spec (change address spec) - if args.send_amt and not (self.proto.is_evm or arg in sa.recv): # is change arg + if args.send_amt and not (self.proto.is_vm or arg in sa.recv): # is change arg nonlocal chg_output chg_output = await self.get_chg_output(arg, addrfiles) arg = get_arg() @@ -140,7 +140,7 @@ class NewSwap(New): get_char('Press any key to continue: ') msg('') - if args.send_amt and not (chg_output or self.proto.is_evm): + if args.send_amt and not (chg_output or self.proto.is_vm): chg_output = await self.get_chg_output(None, addrfiles) recv_output = await self.get_swap_output( @@ -170,7 +170,7 @@ class NewSwap(New): self.swap_recv_addr_mmid = recv_output.mmid return ( - [f'vault,{args.send_amt}', f'data:{memo}'] if args.send_amt and self.proto.is_evm else + [f'vault,{args.send_amt}', f'data:{memo}'] if args.send_amt and self.proto.is_vm else [f'vault,{args.send_amt}', chg_output.mmid, f'data:{memo}'] if args.send_amt else ['vault', f'data:{memo}']) diff --git a/test/cmdtest_d/swap.py b/test/cmdtest_d/swap.py index fa9d907b..06d0b10a 100755 --- a/test/cmdtest_d/swap.py +++ b/test/cmdtest_d/swap.py @@ -225,12 +225,12 @@ class CmdTestSwapMethods: file_desc = None, new_outputs = False): if new_outputs: - if not self.proto.is_evm: + if not self.proto.is_vm: t.expect(f'{self.fee_desc}: ', interactive_fee + '\n') t.expect('(Y/n): ', 'y') # fee ok? t.expect('(Y/n): ', 'y') # change ok? else: - if not self.proto.is_evm: + if not self.proto.is_vm: t.expect('ENTER for the change output): ', '\n') t.expect('(Y/n): ', 'y') # confirm deduct from chg output t.expect('to continue: ', '\n') # exit swap quote