Browse Source

tracking wallet views: move module loading to tw.view

The MMGen Project 2 years ago
parent
commit
6da4063544
7 changed files with 9 additions and 17 deletions
  1. 1 1
      mmgen/data/version
  2. 1 6
      mmgen/proto/eth/tw/rpc.py
  3. 1 3
      mmgen/tw/addresses.py
  4. 1 3
      mmgen/tw/txhistory.py
  5. 1 3
      mmgen/tw/unspent.py
  6. 3 0
      mmgen/tw/view.py
  7. 1 1
      test/objtest.py

+ 1 - 1
mmgen/data/version

@@ -1 +1 @@
-13.3.dev18
+13.3.dev19

+ 1 - 6
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):

+ 1 - 3
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)

+ 1 - 3
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)

+ 1 - 3
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)

+ 3 - 0
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)

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