From 20b250ef980a5eba1f190ecd0013c7377ea28dce Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 12 Nov 2022 13:34:42 +0000 Subject: [PATCH] proto.base_proto_subclass(): simplify call signature --- mmgen/addrdata.py | 2 +- mmgen/protocol.py | 5 ++--- mmgen/tw/addresses.py | 2 +- mmgen/tw/bal.py | 2 +- mmgen/tw/ctl.py | 2 +- mmgen/tw/json.py | 2 +- mmgen/tw/rpc.py | 2 +- mmgen/tw/txhistory.py | 2 +- mmgen/tw/unspent.py | 2 +- 9 files changed, 10 insertions(+), 11 deletions(-) diff --git a/mmgen/addrdata.py b/mmgen/addrdata.py index 6210e5fe..30dc1edd 100755 --- a/mmgen/addrdata.py +++ b/mmgen/addrdata.py @@ -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 diff --git a/mmgen/protocol.py b/mmgen/protocol.py index 30c65d75..000d6bb6 100755 --- a/mmgen/protocol.py +++ b/mmgen/protocol.py @@ -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 = ( diff --git a/mmgen/tw/addresses.py b/mmgen/tw/addresses.py index 502a8bfe..8e1310f9 100755 --- a/mmgen/tw/addresses.py +++ b/mmgen/tw/addresses.py @@ -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): diff --git a/mmgen/tw/bal.py b/mmgen/tw/bal.py index 9e831c50..0df72c11 100755 --- a/mmgen/tw/bal.py +++ b/mmgen/tw/bal.py @@ -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): diff --git a/mmgen/tw/ctl.py b/mmgen/tw/ctl.py index f9c25b78..6e37ef2d 100755 --- a/mmgen/tw/ctl.py +++ b/mmgen/tw/ctl.py @@ -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): diff --git a/mmgen/tw/json.py b/mmgen/tw/json.py index b740085d..02b9f1fb 100755 --- a/mmgen/tw/json.py +++ b/mmgen/tw/json.py @@ -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 diff --git a/mmgen/tw/rpc.py b/mmgen/tw/rpc.py index d25f7c6b..09ab7c5b 100755 --- a/mmgen/tw/rpc.py +++ b/mmgen/tw/rpc.py @@ -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 diff --git a/mmgen/tw/txhistory.py b/mmgen/tw/txhistory.py index d53acb57..c1fdf83a 100755 --- a/mmgen/tw/txhistory.py +++ b/mmgen/tw/txhistory.py @@ -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 diff --git a/mmgen/tw/unspent.py b/mmgen/tw/unspent.py index ecbb533b..b1958898 100755 --- a/mmgen/tw/unspent.py +++ b/mmgen/tw/unspent.py @@ -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 = """