From cd0538246a4eee7bcef765b88f25dfdcc12f3724 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 13 Jun 2025 10:23:55 +0000 Subject: [PATCH] new `proto.vm.tx.info` module --- mmgen/proto/eth/tx/info.py | 6 ++++-- mmgen/proto/rune/tx/info.py | 6 ++++-- mmgen/proto/vm/tx/info.py | 30 ++++++++++++++++++++++++++++++ mmgen/tx/info.py | 15 +-------------- 4 files changed, 39 insertions(+), 18 deletions(-) create mode 100755 mmgen/proto/vm/tx/info.py diff --git a/mmgen/proto/eth/tx/info.py b/mmgen/proto/eth/tx/info.py index a8b730ea..4600624c 100755 --- a/mmgen/proto/eth/tx/info.py +++ b/mmgen/proto/eth/tx/info.py @@ -12,11 +12,13 @@ proto.eth.tx.info: Ethereum transaction info class """ -from ....tx.info import TxInfo, mmid_disp +from ....tx.info import TxInfo from ....color import red, yellow, blue, cyan, pink from ....obj import NonNegativeInt -class TxInfo(TxInfo): +from ...vm.tx.info import VmTxInfo, mmid_disp + +class TxInfo(VmTxInfo, TxInfo): to_addr_key = 'to' diff --git a/mmgen/proto/rune/tx/info.py b/mmgen/proto/rune/tx/info.py index 3b1b4da3..90e7a7ce 100755 --- a/mmgen/proto/rune/tx/info.py +++ b/mmgen/proto/rune/tx/info.py @@ -12,11 +12,13 @@ proto.rune.tx.info: THORChain transaction info class """ -from ....tx.info import TxInfo, mmid_disp +from ....tx.info import TxInfo from ....color import blue, pink from ....obj import NonNegativeInt -class TxInfo(TxInfo): +from ...vm.tx.info import VmTxInfo, mmid_disp + +class TxInfo(VmTxInfo, TxInfo): def format_body(self, blockcount, nonmm_str, max_mmwid, enl, *, terse, sort): tx = self.tx diff --git a/mmgen/proto/vm/tx/info.py b/mmgen/proto/vm/tx/info.py new file mode 100755 index 00000000..2c1ed8d3 --- /dev/null +++ b/mmgen/proto/vm/tx/info.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# +# MMGen Wallet, a terminal-based cryptocurrency wallet +# Copyright (C)2013-2025 The MMGen Project +# Licensed under the GNU General Public License, Version 3: +# https://www.gnu.org/licenses +# Public project repositories: +# https://github.com/mmgen/mmgen-wallet +# https://gitlab.com/mmgen/mmgen-wallet + +""" +proto.vm.tx.info: transaction info methods for VM chains +""" + +from ....util import fmt +from ....addr import MMGenID + +def mmid_disp(io, nonmm_str): + return ' ' + (io.mmid.hl() if io.mmid else MMGenID.hlc(nonmm_str)) + +class VmTxInfo: + + txinfo_hdr_fs = '{hdr}\n ID={i} ({a} {c}) Sig={s}\n' + txinfo_hdr_fs_short = 'TX {i} ({a} {c}) Sig={s}\n' + txinfo_ftr_fs = fmt(""" + Total in account: {i} {d} + Total to spend: {o} {d} + Remaining balance: {C} {d} + TX fee: {a} {c}{r} + """) diff --git a/mmgen/tx/info.py b/mmgen/tx/info.py index fef2306b..b7991436 100755 --- a/mmgen/tx/info.py +++ b/mmgen/tx/info.py @@ -16,24 +16,11 @@ import importlib from ..cfg import gc from ..color import red, green, cyan, orange, blue, yellow, magenta -from ..util import msg, msg_r, fmt, decode_timestamp, make_timestr +from ..util import msg, msg_r, decode_timestamp, make_timestr from ..util2 import format_elapsed_hr -from ..addr import MMGenID - -def mmid_disp(io, nonmm_str): - return ' ' + (io.mmid.hl() if io.mmid else MMGenID.hlc(nonmm_str)) class TxInfo: - txinfo_hdr_fs = '{hdr}\n ID={i} ({a} {c}) Sig={s}\n' - txinfo_hdr_fs_short = 'TX {i} ({a} {c}) Sig={s}\n' - txinfo_ftr_fs = fmt(""" - Total in account: {i} {d} - Total to spend: {o} {d} - Remaining balance: {C} {d} - TX fee: {a} {c}{r} - """) - def __init__(self, cfg, tx): self.cfg = cfg self.tx = tx