proto.eth.tw.addresses: remove get_column_widths()

This commit is contained in:
The MMGen Project 2025-05-23 15:35:23 +00:00
commit c40f4f9aa5
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 8 additions and 29 deletions

View file

@ -20,6 +20,8 @@ from .rpc import BitcoinTwRPC
class BitcoinTwAddresses(TwAddresses, BitcoinTwRPC):
has_age = True
has_used = True
prompt_fs_in = [
'Sort options: [a]mt, [A]ge, [M]mgen addr, [r]everse',
'Column options: toggle [D]ays/date/confs/block',

View file

@ -19,39 +19,12 @@ from .rpc import EthereumTwRPC
class EthereumTwAddresses(TwAddresses, EthereumTwView, EthereumTwRPC):
has_age = False
prompt_fs_in = [
'Sort options: [a]mt, [M]mgen addr, [r]everse',
'Filters: show [E]mpty addrs, show all [L]abels',
'View/Print: pager [v]iew, [w]ide pager view, [p]rint{s}',
'Actions: [q]uit menu, r[e]draw, [D]elete addr, add [l]abel:']
def get_column_widths(self, data, *, wide, interactive):
return self.compute_column_widths(
widths = { # fixed cols
'num': max(2, len(str(len(data)))+1),
'mmid': max(len(d.twmmid.disp) for d in data),
'used': 0,
'amt': self.amt_widths['amt'],
'date': 0,
'block': 0,
'date_time': 0,
'spc': 5, # 4 spaces between cols + 1 leading space in fs
},
maxws = { # expandable cols
'addr': max(len(d.addr) for d in data) if self.showcoinaddrs else 0,
'comment': max(d.comment.screen_width for d in data),
},
minws = {
'addr': 12 if self.showcoinaddrs else 0,
'comment': len('Comment'),
},
maxws_nice = {'addr': 18},
wide = wide,
interactive = interactive,
)
async def get_rpc_data(self):
self.total = self.proto.coin_amt('0')

View file

@ -35,6 +35,8 @@ class TwAddresses(TwView):
all_labels = False
no_data_errmsg = 'No addresses in tracking wallet!'
mod_subpath = 'tw.addresses'
has_age = False
has_used = False
key_mappings = {
'a':'s_amt',
@ -97,6 +99,8 @@ class TwAddresses(TwView):
await super().__init__(cfg, proto)
self.minconf = NonNegativeInt(minconf)
self.spc_w = 5 + self.has_age + self.has_used # 1 space between cols + 1 leading space in fs
self.used_w = 4 if self.has_used else 0
if mmgen_addrs:
a = mmgen_addrs.rsplit(':', 1)
@ -151,12 +155,12 @@ class TwAddresses(TwView):
widths = { # fixed cols
'num': max(2, len(str(len(data)))+1),
'mmid': max(len(d.twmmid.disp) for d in data),
'used': 4,
'used': self.used_w,
'amt': self.amt_widths['amt'],
'date': self.age_w if self.has_age else 0,
'block': self.age_col_params['block'][0] if wide and self.has_age else 0,
'date_time': self.age_col_params['date_time'][0] if wide and self.has_age else 0,
'spc': 7, # 6 spaces between cols + 1 leading space in fs
'spc': self.spc_w,
},
maxws = { # expandable cols
'addr': max(len(d.addr) for d in data) if self.showcoinaddrs else 0,