Browse Source

proto.eth.tw.unspent: use parent `MMGenTwUnspentOutput` class

The MMGen Project 7 months ago
parent
commit
c51cd601b3
3 changed files with 15 additions and 18 deletions
  1. 4 1
      mmgen/proto/btc/tw/unspent.py
  2. 0 5
      mmgen/proto/eth/tw/unspent.py
  3. 11 12
      mmgen/tw/unspent.py

+ 4 - 1
mmgen/proto/btc/tw/unspent.py

@@ -12,7 +12,9 @@
 proto.btc.tw.unspent: Bitcoin base protocol tracking wallet unspent outputs class
 """
 
+from ....obj import ImmutableAttr, ListItemAttr, HexStr
 from ....tw.unspent import TwUnspentOutputs
+
 from .view import BitcoinTwView
 
 class BitcoinTwUnspentOutputs(BitcoinTwView, TwUnspentOutputs):
@@ -39,7 +41,8 @@ class BitcoinTwUnspentOutputs(BitcoinTwView, TwUnspentOutputs):
 			'date',
 			'scriptPubKey',
 			'skip'}
-		invalid_attrs = {'proto'}
+		date         = ListItemAttr(int, typeconv=False, reassign_ok=True)
+		scriptPubKey = ImmutableAttr(HexStr)
 
 	has_age = True
 	can_group = True

+ 0 - 5
mmgen/proto/eth/tw/unspent.py

@@ -24,13 +24,8 @@ from ....tw.shared import TwLabel
 from ....tw.unspent import TwUnspentOutputs
 from .view import EthereumTwView
 
-# No unspent outputs with Ethereum, but naming must be consistent
 class EthereumTwUnspentOutputs(EthereumTwView, TwUnspentOutputs):
 
-	class MMGenTwUnspentOutput(TwUnspentOutputs.MMGenTwUnspentOutput):
-		valid_attrs = {'txid', 'vout', 'amt', 'amt2', 'comment', 'twmmid', 'addr', 'confs', 'skip'}
-		invalid_attrs = {'proto'}
-
 	hdr_lbl = 'tracked accounts'
 	desc    = 'account balances'
 	item_desc = 'account'

+ 11 - 12
mmgen/tw/unspent.py

@@ -26,7 +26,6 @@ from ..obj import (
 	ListItemAttr,
 	MMGenListItem,
 	TwComment,
-	HexStr,
 	CoinTxID,
 	NonNegativeInt)
 from ..addr import CoinAddr
@@ -82,17 +81,17 @@ class TwUnspentOutputs(TwView):
 			cols = ('num', 'addr', 'mmid', 'amt', 'amt2', 'comment')
 
 	class MMGenTwUnspentOutput(MMGenListItem):
-		txid         = ListItemAttr(CoinTxID)
-		vout         = ListItemAttr(NonNegativeInt)
-		amt          = ImmutableAttr(CoinAmtChk, include_proto=True)
-		amt2         = ListItemAttr(CoinAmtChk, include_proto=True) # the ETH balance for token account
-		comment      = ListItemAttr(TwComment, reassign_ok=True)
-		twmmid       = ImmutableAttr(TwMMGenID, include_proto=True)
-		addr         = ImmutableAttr(CoinAddr, include_proto=True)
-		confs        = ImmutableAttr(int, typeconv=False)
-		date         = ListItemAttr(int, typeconv=False, reassign_ok=True)
-		scriptPubKey = ImmutableAttr(HexStr)
-		skip         = ListItemAttr(str, typeconv=False, reassign_ok=True)
+		valid_attrs = {'txid', 'vout', 'amt', 'amt2', 'comment', 'twmmid', 'addr', 'confs', 'skip'}
+		invalid_attrs = {'proto'}
+		txid    = ListItemAttr(CoinTxID)
+		vout    = ListItemAttr(NonNegativeInt)
+		amt     = ImmutableAttr(CoinAmtChk, include_proto=True)
+		amt2    = ListItemAttr(CoinAmtChk, include_proto=True) # the ETH balance for token account
+		comment = ListItemAttr(TwComment, reassign_ok=True)
+		twmmid  = ImmutableAttr(TwMMGenID, include_proto=True)
+		addr    = ImmutableAttr(CoinAddr, include_proto=True)
+		confs   = ImmutableAttr(int, typeconv=False)
+		skip    = ListItemAttr(str, typeconv=False, reassign_ok=True)
 
 		def __init__(self, proto, **kwargs):
 			self.__dict__['proto'] = proto