tracking wallet: TwCommon -> TwView

This commit is contained in:
The MMGen Project 2022-11-12 13:34:34 +00:00
commit 14fb60bc67
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 29 additions and 29 deletions

View file

@ -13,11 +13,11 @@ proto.eth.tw.common: Ethereum base protocol tracking wallet dependency classes
"""
from ....globalvars import g
from ....tw.ctl import TrackingWallet
from ....tw.common import TwCommon
from ....tw.common import TwView
from ....addr import CoinAddr
from ....tw.common import TwLabel
class EthereumTwCommon(TwCommon):
class EthereumTwCommon(TwView):
def age_disp(self,o,age_fmt): # TODO
pass

View file

@ -21,7 +21,7 @@ tool/rpc.py: JSON/RPC routines for the 'mmgen-tool' utility
"""
from .common import tool_cmd_base,options_annot_str
from ..tw.common import TwCommon
from ..tw.common import TwView
from ..tw.txhistory import TwTxHistory
class tool_cmd(tool_cmd_base):
@ -68,8 +68,8 @@ class tool_cmd(tool_cmd_base):
reverse: 'reverse order of unspent outputs' = False,
wide: 'display data in wide tabular format' = False,
minconf: 'minimum number of confirmations' = 1,
sort: 'unspent output sort order ' + options_annot_str(TwCommon.sort_funcs) = 'age',
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs',
sort: 'unspent output sort order ' + options_annot_str(TwView.sort_funcs) = 'age',
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwView.age_fmts) = 'confs',
interactive: 'enable interactive operation' = False,
show_mmid: 'show MMGen IDs along with coin addresses' = True ):
"view tracking wallet unspent outputs"
@ -88,7 +88,7 @@ class tool_cmd(tool_cmd_base):
detail: 'produce detailed, non-tabular output' = False,
sinceblock: 'display transactions starting from this block' = 0,
sort: 'transaction sort order ' + options_annot_str(TwTxHistory.sort_funcs) = 'age',
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs',
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwView.age_fmts) = 'confs',
interactive: 'enable interactive operation' = False ):
"view transaction history of tracking wallet"
@ -101,7 +101,7 @@ class tool_cmd(tool_cmd_base):
wide: 'display data in wide tabular format' = False,
minconf: 'minimum number of confirmations' = 1,
showcoinaddr: 'display coin address in addition to MMGen ID' = True,
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs' ):
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwView.age_fmts) = 'confs' ):
"list the specified MMGen address in the tracking wallet and its balance"
return await self.listaddresses(
@ -117,7 +117,7 @@ class tool_cmd(tool_cmd_base):
wide: 'display data in wide tabular format' = False,
minconf: 'minimum number of confirmations' = 1,
sort: 'address sort order ' + options_annot_str(['reverse','mmid','addr','amt']) = '',
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs',
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwView.age_fmts) = 'confs',
interactive: 'enable interactive operation' = False,
mmgen_addrs: 'hyphenated range or comma-separated list of addresses' = '',
showcoinaddrs:'display coin addresses in addition to MMGen IDs' = True,

View file

@ -19,9 +19,9 @@ from ..obj import MMGenListItem,ImmutableAttr,ListItemAttr,TwComment,NonNegative
from ..rpc import rpc_init
from ..addr import CoinAddr,MMGenID
from ..color import red,green
from .common import TwCommon,TwMMGenID
from .common import TwView,TwMMGenID
class TwAddresses(MMGenObject,TwCommon,metaclass=AsyncInit):
class TwAddresses(MMGenObject,TwView,metaclass=AsyncInit):
hdr_lbl = 'tracking wallet addresses'
desc = 'address list'
@ -37,12 +37,12 @@ class TwAddresses(MMGenObject,TwCommon,metaclass=AsyncInit):
all_labels = False
no_data_errmsg = 'No addresses in tracking wallet!'
class display_type(TwCommon.display_type):
class display_type(TwView.display_type):
class squeezed(TwCommon.display_type.squeezed):
class squeezed(TwView.display_type.squeezed):
cols = ('num','mmid','used','addr','comment','amt','date')
class detail(TwCommon.display_type.detail):
class detail(TwView.display_type.detail):
cols = ('num','mmid','used','addr','comment','amt','block','date_time')
class TwAddress(MMGenListItem):
@ -249,7 +249,7 @@ class TwAddresses(MMGenObject,TwCommon,metaclass=AsyncInit):
def dump_fn_pfx(self):
return 'listaddresses' + (f'-minconf-{self.minconf}' if self.minconf else '')
class action(TwCommon.action):
class action(TwView.action):
def s_amt(self,parent):
parent.do_sort('amt')

View file

@ -31,7 +31,7 @@ from ..util import msg,msg_r,fmt,die,capfirst,make_timestr
from ..addr import MMGenID
# mixin class for TwUnspentOutputs,TwAddresses,TwTxHistory:
class TwCommon:
class TwView:
dates_set = False
cols = None

View file

@ -19,16 +19,16 @@ from ..base_obj import AsyncInit
from ..objmethods import MMGenObject
from ..obj import CoinTxID,MMGenList,Int
from ..rpc import rpc_init
from .common import TwCommon
from .common import TwView
class TwTxHistory(MMGenObject,TwCommon,metaclass=AsyncInit):
class TwTxHistory(MMGenObject,TwView,metaclass=AsyncInit):
class display_type(TwCommon.display_type):
class display_type(TwView.display_type):
class squeezed(TwCommon.display_type.squeezed):
class squeezed(TwView.display_type.squeezed):
cols = ('num','txid','date','inputs','amt','outputs','comment')
class detail(TwCommon.display_type.detail):
class detail(TwView.display_type.detail):
need_column_widths = False
item_separator = '\n\n'
@ -177,7 +177,7 @@ class TwTxHistory(MMGenObject,TwCommon,metaclass=AsyncInit):
def dump_fn_pfx(self):
return 'transaction-history' + (f'-since-block-{self.sinceblock}' if self.sinceblock else '')
class action(TwCommon.action):
class action(TwView.action):
def s_amt(self,parent):
parent.do_sort('amt')

View file

@ -35,16 +35,16 @@ from ..obj import (
NonNegativeInt )
from ..addr import CoinAddr,MMGenID
from ..rpc import rpc_init
from .common import TwCommon,TwMMGenID,get_tw_label
from .common import TwView,TwMMGenID,get_tw_label
class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
class TwUnspentOutputs(MMGenObject,TwView,metaclass=AsyncInit):
class display_type(TwCommon.display_type):
class display_type(TwView.display_type):
class squeezed(TwCommon.display_type.squeezed):
class squeezed(TwView.display_type.squeezed):
cols = ('num','txid','vout','addr','mmid','comment','amt','amt2','date')
class detail(TwCommon.display_type.detail):
class detail(TwView.display_type.detail):
cols = ('num','txid','vout','addr','mmid','amt','amt2','block','date_time','comment')
def __new__(cls,proto,*args,**kwargs):
@ -235,7 +235,7 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
o.date = dates[idx]
self.dates_set = True
class action(TwCommon.action):
class action(TwView.action):
def s_twmmid(self,parent):
parent.do_sort('twmmid')

View file

@ -7,7 +7,7 @@ if overlay_fake_os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC'):
# add a minute to each successive time value
time_iter = (1321009871 + (i*60) for i in range(1000000))
TwCommon.date_formatter = {
TwView.date_formatter = {
'days': lambda rpc,secs: (next(overlay_fake_data.time_iter) - secs) // 86400,
'date': lambda rpc,secs: '{}-{:02}-{:02}'.format(*time.gmtime(next(overlay_fake_data.time_iter))[:3])[2:],
'date_time': lambda rpc,secs: '{}-{:02}-{:02} {:02}:{:02}'.format(*time.gmtime(next(overlay_fake_data.time_iter))[:5]),
@ -16,4 +16,4 @@ if overlay_fake_os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC'):
if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'):
# 1831006505 (09 Jan 2028) = projected time of block 1000000
TwCommon.date_formatter['days'] = lambda rpc,secs: (1831006505 - secs) // 86400
TwView.date_formatter['days'] = lambda rpc,secs: (1831006505 - secs) // 86400