proto.base_proto_subclass(): simplify call signature

This commit is contained in:
The MMGen Project 2022-11-12 13:34:42 +00:00
commit 20b250ef98
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
9 changed files with 10 additions and 11 deletions

View file

@ -69,7 +69,7 @@ class AddrData(MMGenObject):
class TwAddrData(AddrData,metaclass=AsyncInit):
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(cls,None,'addrdata'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'addrdata'))
async def __init__(self,proto,wallet=None):
from .rpc import rpc_init

View file

@ -165,13 +165,12 @@ class CoinProtocol(MMGenObject):
def viewkey(self,viewkey_str):
raise NotImplementedError(f'{self.name} protocol does not support view keys')
def base_proto_subclass(self,cls,subdir,modname,sub_clsname=None):
def base_proto_subclass(self,cls,modname,sub_clsname=None):
"""
magic module loading and class selection
"""
modpath = 'mmgen.proto.{}.{}{}'.format(
modpath = 'mmgen.proto.{}.{}'.format(
self.base_proto_coin.lower(),
subdir + '.' if subdir else '',
modname )
clsname = (

View file

@ -72,7 +72,7 @@ class TwAddresses(TwView):
return [d.addr for d in self.data]
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','addresses'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.addresses'))
async def __init__(self,proto,minconf=1,mmgen_addrs='',get_data=False):

View file

@ -28,7 +28,7 @@ from ..rpc import rpc_init
class TwGetBalance(MMGenObject,metaclass=AsyncInit):
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','bal'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.bal'))
async def __init__(self,proto,minconf,quiet):

View file

@ -54,7 +54,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
importing = False
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','ctl'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.ctl'))
async def __init__(self,proto,mode='r',token_addr=None,rpc_ignore_wallet=False):

View file

@ -28,7 +28,7 @@ class TwJSON:
fn_pfx = 'mmgen-tracking-wallet-dump'
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(TwJSON,'tw','json',cls.__name__))
return MMGenObject.__new__(proto.base_proto_subclass(TwJSON,'tw.json',cls.__name__))
def __init__(self,proto):
self.proto = proto

View file

@ -17,7 +17,7 @@ from ..objmethods import MMGenObject
class TwRPC:
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','rpc'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.rpc'))
def __init__(self,proto,rpc,wallet):
self.proto = proto

View file

@ -29,7 +29,7 @@ class TwTxHistory(TwView):
item_separator = '\n\n'
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw','txhistory'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.txhistory'))
has_wallet = False
show_txid = False

View file

@ -46,7 +46,7 @@ class TwUnspentOutputs(TwView):
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'))
return MMGenObject.__new__(proto.base_proto_subclass(cls,'tw.unspent'))
show_mmid = True
no_rpcdata_errmsg = """