From 6da406354404a3ca1322cafd446449305f2b15e1 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 12 Nov 2022 13:35:50 +0000 Subject: [PATCH] tracking wallet views: move module loading to tw.view --- mmgen/data/version | 2 +- mmgen/proto/eth/tw/rpc.py | 7 +------ mmgen/tw/addresses.py | 4 +--- mmgen/tw/txhistory.py | 4 +--- mmgen/tw/unspent.py | 4 +--- mmgen/tw/view.py | 3 +++ test/objtest.py | 2 +- 7 files changed, 9 insertions(+), 17 deletions(-) diff --git a/mmgen/data/version b/mmgen/data/version index b7239029..321f28f9 100644 --- a/mmgen/data/version +++ b/mmgen/data/version @@ -1 +1 @@ -13.3.dev18 +13.3.dev19 diff --git a/mmgen/proto/eth/tw/rpc.py b/mmgen/proto/eth/tw/rpc.py index cac5522c..736d79f8 100755 --- a/mmgen/proto/eth/tw/rpc.py +++ b/mmgen/proto/eth/tw/rpc.py @@ -21,19 +21,14 @@ class EthereumTwRPC(TwRPC): async def get_addr_label_pairs(self,twmmid=None): - wallet = self.wallet or await TrackingWallet(self.proto,mode='w') - ret = [( TwLabel( self.proto, mmid + ' ' + d['comment'] ), CoinAddr( self.proto, d['addr'] ) - ) for mmid,d in wallet.mmid_ordered_dict.items() ] + ) for mmid,d in self.wallet.mmid_ordered_dict.items() ] if twmmid: ret = [e for e in ret if e[0].mmid == twmmid] - if wallet is not self.wallet: - del wallet - return ret or None class EthereumTokenTwRPC(EthereumTwRPC): diff --git a/mmgen/tw/addresses.py b/mmgen/tw/addresses.py index 8e1310f9..830e042e 100755 --- a/mmgen/tw/addresses.py +++ b/mmgen/tw/addresses.py @@ -34,6 +34,7 @@ class TwAddresses(TwView): showused = 1 # tristate: 0:no, 1:yes, 2:all all_labels = False no_data_errmsg = 'No addresses in tracking wallet!' + mod_subpath = 'tw.addresses' class display_type(TwView.display_type): @@ -71,9 +72,6 @@ class TwAddresses(TwView): def coinaddr_list(self): return [d.addr for d in self.data] - def __new__(cls,proto,*args,**kwargs): - return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.addresses')) - async def __init__(self,proto,minconf=1,mmgen_addrs='',get_data=False): await super().__init__(proto) diff --git a/mmgen/tw/txhistory.py b/mmgen/tw/txhistory.py index c1fdf83a..d739764f 100755 --- a/mmgen/tw/txhistory.py +++ b/mmgen/tw/txhistory.py @@ -28,9 +28,6 @@ class TwTxHistory(TwView): need_column_widths = False item_separator = '\n\n' - def __new__(cls,proto,*args,**kwargs): - return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.txhistory')) - has_wallet = False show_txid = False show_unconfirmed = False @@ -38,6 +35,7 @@ class TwTxHistory(TwView): update_widths_on_age_toggle = True print_output_types = ('squeezed','detail') filters = ('show_unconfirmed',) + mod_subpath = 'tw.txhistory' async def __init__(self,proto,sinceblock=0): await super().__init__(proto) diff --git a/mmgen/tw/unspent.py b/mmgen/tw/unspent.py index b1958898..7f546768 100755 --- a/mmgen/tw/unspent.py +++ b/mmgen/tw/unspent.py @@ -45,9 +45,6 @@ class TwUnspentOutputs(TwView): class detail(TwView.display_type.detail): cols = ('num','txid','vout','addr','mmid','amt','amt2','block','date_time','comment') - def __new__(cls,proto,*args,**kwargs): - return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.unspent')) - show_mmid = True no_rpcdata_errmsg = """ No spendable outputs found! Import addresses with balances into your @@ -55,6 +52,7 @@ class TwUnspentOutputs(TwView): """ update_widths_on_age_toggle = False print_output_types = ('detail',) + mod_subpath = 'tw.unspent' class MMGenTwUnspentOutput(MMGenListItem): txid = ListItemAttr(CoinTxID) diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index 5666b61f..ed6762ef 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -111,6 +111,9 @@ class TwView(MMGenObject,metaclass=AsyncInit): Please resize your screen to at least {} characters and hit any key: """ + def __new__(cls,proto,*args,**kwargs): + return MMGenObject.__new__(proto.base_proto_subclass(cls,cls.mod_subpath)) + async def __init__(self,proto): self.proto = proto self.rpc = await rpc_init(proto) diff --git a/test/objtest.py b/test/objtest.py index de58c990..f10bb332 100755 --- a/test/objtest.py +++ b/test/objtest.py @@ -38,7 +38,7 @@ from mmgen.seedsplit import * from mmgen.addr import * from mmgen.addrlist import * from mmgen.addrdata import * -from mmgen.tw.view import * +from mmgen.tw.shared import * from mmgen.amt import * from mmgen.key import * from mmgen.rpc import IPPort