proto.{btc,eth}.tw: module moves, class renames

- proto.btc.tw.common -> proto.btc.tw.rpc
    - proto.eth.tw.common -> proto.eth.tw.rpc, proto.eth.tw.view

    - BitcoinTwCommon -> BitcoinTwRPC
    - EthereumTwCommon -> EthereumTwRPC, EthereumTwView
This commit is contained in:
The MMGen Project 2022-11-12 13:34:40 +00:00
commit 79bcc049a5
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
9 changed files with 53 additions and 35 deletions

View file

@ -17,9 +17,9 @@ from ....tw.shared import TwLabel
from ....util import msg,msg_r
from ....addr import CoinAddr
from ....obj import NonNegativeInt,get_obj
from .common import BitcoinTwCommon
from .rpc import BitcoinTwRPC
class BitcoinTwAddresses(TwAddresses,BitcoinTwCommon):
class BitcoinTwAddresses(TwAddresses,BitcoinTwRPC):
has_age = True
prompt = """

View file

@ -15,9 +15,9 @@ proto.btc.twctl: Bitcoin base protocol tracking wallet control class
from ....globalvars import g
from ....tw.ctl import TrackingWallet,write_mode
from ....util import msg,msg_r,rmsg,vmsg,die,suf,fmt_list
from .common import BitcoinTwCommon
from .rpc import BitcoinTwRPC
class BitcoinTrackingWallet(TrackingWallet,BitcoinTwCommon):
class BitcoinTrackingWallet(TrackingWallet,BitcoinTwRPC):
def init_empty(self):
self.data = { 'coin': self.proto.coin, 'addresses': {} }

View file

@ -9,7 +9,7 @@
# https://gitlab.com/mmgen/mmgen
"""
proto.btc.tw.common: Bitcoin base protocol tracking wallet dependency classes
proto.btc.tw.rpc: Bitcoin base protocol tracking wallet RPC classes
"""
from ....addr import CoinAddr
@ -17,7 +17,7 @@ from ....util import die,msg,rmsg
from ....obj import MMGenList
from ....tw.shared import get_tw_label
class BitcoinTwCommon:
class BitcoinTwRPC:
async def get_addr_label_pairs(self,twmmid=None):
"""

View file

@ -20,9 +20,9 @@ from ....addr import CoinAddr
from ....util import msg,msg_r
from ....color import nocolor,red,pink,gray
from ....obj import TwComment,CoinTxID,Int
from .common import BitcoinTwCommon
from .rpc import BitcoinTwRPC
class BitcoinTwTransaction(BitcoinTwCommon):
class BitcoinTwTransaction(BitcoinTwRPC):
def __init__(self,parent,proto,rpc,
idx, # unique numeric identifier of this transaction in listing
@ -221,7 +221,7 @@ class BitcoinTwTransaction(BitcoinTwCommon):
self.fee.to_unit(atomic_unit) // self.vsize,
atomic_unit )) )
class BitcoinTwTxHistory(TwTxHistory,BitcoinTwCommon):
class BitcoinTwTxHistory(TwTxHistory,BitcoinTwRPC):
has_age = True
hdr_lbl = 'transaction history'

View file

@ -15,9 +15,10 @@ proto.eth.tw.addresses: Ethereum base protocol tracking wallet address list clas
from ....tw.addresses import TwAddresses
from ....tw.ctl import TrackingWallet
from ....addr import CoinAddr
from .common import EthereumTwCommon
from .view import EthereumTwView
from .rpc import EthereumTwRPC
class EthereumTwAddresses(EthereumTwCommon,TwAddresses):
class EthereumTwAddresses(EthereumTwView,EthereumTwRPC,TwAddresses):
has_age = False
prompt = """

View file

@ -25,9 +25,9 @@ from ....tw.ctl import TrackingWallet,write_mode
from ....addr import is_coin_addr,is_mmgen_id
from ....amt import ETHAmt
from ..contract import Token,TokenResolve
from .common import EthereumTwCommon
from .rpc import EthereumTwRPC
class EthereumTrackingWallet(EthereumTwCommon,TrackingWallet):
class EthereumTrackingWallet(EthereumTwRPC,TrackingWallet):
caps = ('batch',)
data_key = 'accounts'

View file

@ -9,31 +9,14 @@
# https://gitlab.com/mmgen/mmgen
"""
proto.eth.tw.common: Ethereum base protocol tracking wallet dependency classes
proto.eth.tw.rpc: Ethereum base protocol tracking wallet RPC class
"""
from ....globalvars import g
from ....tw.ctl import TrackingWallet
from ....tw.view import TwView
from ....addr import CoinAddr
from ....tw.shared import TwLabel
class EthereumTwCommon(TwView):
def age_disp(self,o,age_fmt): # TODO
pass
def get_disp_prec(self,wide):
return self.proto.coin_amt.max_prec if wide else 8
def subheader(self,color):
ret = ''
if self.disp_prec == 8:
ret += 'Balances truncated to 8 decimal points\n'
if g.cached_balances:
from ....color import nocolor,yellow
ret += (nocolor,yellow)[color](
'WARNING: Using cached balances. These may be out of date!') + '\n'
return ret
class EthereumTwRPC:
async def get_addr_label_pairs(self,twmmid=None):
wallet = (

View file

@ -22,10 +22,10 @@ proto.eth.twuo: Ethereum tracking wallet unspent outputs class
from ....tw.shared import TwLabel
from ....tw.unspent import TwUnspentOutputs
from .common import EthereumTwCommon
from .view import EthereumTwView
# No unspent outputs with Ethereum, but naming must be consistent
class EthereumTwUnspentOutputs(EthereumTwCommon,TwUnspentOutputs):
class EthereumTwUnspentOutputs(EthereumTwView,TwUnspentOutputs):
class display_type(TwUnspentOutputs.display_type):

34
mmgen/proto/eth/tw/view.py Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/env python3
#
# mmgen = Multi-Mode GENerator, a command-line cryptocurrency wallet
# Copyright (C)2013-2022 The MMGen Project <mmgen@tuta.io>
# Licensed under the GNU General Public License, Version 3:
# https://www.gnu.org/licenses
# Public project repositories:
# https://github.com/mmgen/mmgen
# https://gitlab.com/mmgen/mmgen
"""
proto.eth.tw.view: Ethereum base protocol base class for tracking wallet view classes
"""
from ....globalvars import g
from ....tw.view import TwView
class EthereumTwView(TwView):
def age_disp(self,o,age_fmt): # TODO
pass
def get_disp_prec(self,wide):
return self.proto.coin_amt.max_prec if wide else 8
def subheader(self,color):
ret = ''
if self.disp_prec == 8:
ret += 'Balances truncated to 8 decimal points\n'
if g.cached_balances:
from ....color import nocolor,yellow
ret += (nocolor,yellow)[color](
'WARNING: Using cached balances. These may be out of date!') + '\n'
return ret