Browse Source

new `proto.vm.tx.info` module

The MMGen Project 5 months ago
parent
commit
cd0538246a
4 changed files with 39 additions and 18 deletions
  1. 4 2
      mmgen/proto/eth/tx/info.py
  2. 4 2
      mmgen/proto/rune/tx/info.py
  3. 30 0
      mmgen/proto/vm/tx/info.py
  4. 1 14
      mmgen/tx/info.py

+ 4 - 2
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'
 

+ 4 - 2
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

+ 30 - 0
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 <mmgen@tuta.io>
+# 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}
+	""")

+ 1 - 14
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