proto.base_proto_subclass(): simplify call signature
This commit is contained in:
parent
e237cf0e39
commit
20b250ef98
9 changed files with 10 additions and 11 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = (
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 = """
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue