Browse Source

tw.view: refactor `sort_funcs`

The MMGen Project 6 months ago
parent
commit
279e901d0d
3 changed files with 12 additions and 12 deletions
  1. 8 0
      mmgen/proto/btc/tw/unspent.py
  2. 0 8
      mmgen/proto/eth/tw/view.py
  3. 4 4
      mmgen/tw/view.py

+ 8 - 0
mmgen/proto/btc/tw/unspent.py

@@ -63,6 +63,14 @@ class BitcoinTwUnspentOutputs(TwUnspentOutputs):
 		'w':'a_view_detail',
 		'l':'i_comment_add'}
 
+	sort_funcs = {
+		'addr':   lambda i: '{} {:010} {:024.12f}'.format(i.addr, 0xffffffff - abs(i.confs), i.amt),
+		'age':    lambda i: '{:010} {:024.12f}'.format(0xffffffff - abs(i.confs), i.amt),
+		'amt':    lambda i: '{:024.12f} {:010} {}'.format(i.amt, 0xffffffff - abs(i.confs), i.addr),
+		'txid':   lambda i: f'{i.txid} {i.vout:04}',
+		'twmmid': lambda i: '{} {:010} {:024.12f}'.format(
+			i.twmmid.sort_key, 0xffffffff - abs(i.confs), i.amt)}
+
 	async def get_rpc_data(self):
 		# bitcoin-cli help listunspent:
 		# Arguments:

+ 0 - 8
mmgen/proto/eth/tw/view.py

@@ -16,14 +16,6 @@ from ....tw.view import TwView
 
 class EthereumTwView(TwView):
 
-	sort_funcs = {
-		'addr':   lambda i: i.addr,
-		'age':    lambda i: 0 - i.confs,
-		'amt':    lambda i: i.amt,
-		'txid':   lambda i: f'{i.txid} {i.vout:04}',
-		'twmmid': lambda i: i.twmmid.sort_key
-	}
-
 	def age_disp(self, o, age_fmt): # TODO
 		pass
 

+ 4 - 4
mmgen/tw/view.py

@@ -243,11 +243,11 @@ class TwView(MMGenObject, metaclass=AsyncInit):
 	}
 
 	sort_funcs = {
-		'addr':   lambda i: '{} {:010} {:024.12f}'.format(i.addr, 0xffffffff - abs(i.confs), i.amt),
-		'age':    lambda i: '{:010} {:024.12f}'.format(0xffffffff - abs(i.confs), i.amt),
-		'amt':    lambda i: '{:024.12f} {:010} {}'.format(i.amt, 0xffffffff - abs(i.confs), i.addr),
+		'addr':   lambda i: i.addr,
+		'age':    lambda i: 0 - i.confs,
+		'amt':    lambda i: i.amt,
 		'txid':   lambda i: f'{i.txid} {i.vout:04}',
-		'twmmid': lambda i: '{} {:010} {:024.12f}'.format(i.twmmid.sort_key, 0xffffffff - abs(i.confs), i.amt)
+		'twmmid': lambda i: i.twmmid.sort_key
 	}
 
 	def sort_info(self, *, include_group=True):