altcoin_subclass() -> base_proto_subclass()

This commit is contained in:
The MMGen Project 2022-02-03 20:40:42 +00:00
commit 301e2516ab
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
8 changed files with 18 additions and 18 deletions

View file

@ -20,7 +20,7 @@
addrdata.py: MMGen AddrData and related classes
"""
from .util import vmsg,altcoin_subclass
from .util import vmsg,base_proto_subclass
from .base_obj import AsyncInit
from .obj import MMGenObject,MMGenDict,get_obj
from .addr import MMGenID,AddrListID
@ -37,7 +37,7 @@ re-import your addresses.
}
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(altcoin_subclass(cls,proto,'tw'))
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw'))
def __init__(self,proto,*args,**kwargs):
self.al_ids = {}
@ -80,7 +80,7 @@ re-import your addresses.
class TwAddrData(AddrData,metaclass=AsyncInit):
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(altcoin_subclass(cls,proto,'tw'))
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw'))
async def __init__(self,proto,wallet=None):
from .rpc import rpc_init

View file

@ -160,7 +160,7 @@ def make_args_list(tw,al,batch,rescan):
async def main():
from .twctl import TrackingWallet
if opt.token_addr:
proto.tokensym = 'foo' # hack to trigger 'Token' in altcoin_subclass()
proto.tokensym = 'foo' # hack to trigger 'Token' in base_proto_subclass()
tw = await TrackingWallet(
proto = proto,

View file

@ -21,7 +21,7 @@ twaddrs: Tracking wallet listaddresses class for the MMGen suite
"""
from .color import green
from .util import msg,die,altcoin_subclass
from .util import msg,die,base_proto_subclass
from .base_obj import AsyncInit
from .obj import MMGenList,MMGenDict,TwComment
from .addr import CoinAddr,MMGenID
@ -32,7 +32,7 @@ class TwAddrList(MMGenDict,TwCommon,metaclass=AsyncInit):
has_age = True
def __new__(cls,proto,*args,**kwargs):
return MMGenDict.__new__(altcoin_subclass(cls,proto,'twaddrs'),*args,**kwargs)
return MMGenDict.__new__(base_proto_subclass(cls,proto,'twaddrs'),*args,**kwargs)
async def __init__(self,proto,usr_addr_list,minconf,showempty,showbtcaddrs,all_labels,wallet=None):

View file

@ -21,7 +21,7 @@ twbal: Tracking wallet getbalance class for the MMGen suite
"""
from .color import red,green
from .util import altcoin_subclass
from .util import base_proto_subclass
from .base_obj import AsyncInit
from .objmethods import MMGenObject
from .rpc import rpc_init
@ -32,7 +32,7 @@ class TwGetBalance(MMGenObject,metaclass=AsyncInit):
fs = '{w:13} {u:<16} {p:<16} {c}'
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(altcoin_subclass(cls,proto,'twbal'))
return MMGenObject.__new__(base_proto_subclass(cls,proto,'twbal'))
async def __init__(self,proto,minconf,quiet):

View file

@ -21,7 +21,7 @@ twctl: Tracking wallet control class for the MMGen suite
"""
from .globalvars import g
from .util import msg,dmsg,write_mode,altcoin_subclass
from .util import msg,dmsg,write_mode,base_proto_subclass
from .base_obj import AsyncInit
from .objmethods import MMGenObject
from .obj import TwComment,get_obj
@ -38,7 +38,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
importing = False
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(altcoin_subclass(cls,proto,'twctl'))
return MMGenObject.__new__(base_proto_subclass(cls,proto,'twctl'))
async def __init__(self,proto,mode='r',token_addr=None):

View file

@ -36,7 +36,7 @@ from .util import (
keypress_confirm,
line_input,
do_pager,
altcoin_subclass
base_proto_subclass
)
from .base_obj import AsyncInit
from .objmethods import MMGenObject
@ -48,7 +48,7 @@ from .tw import TwCommon,TwMMGenID,get_tw_label
class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
def __new__(cls,proto,*args,**kwargs):
return MMGenObject.__new__(altcoin_subclass(cls,proto,'twuo'))
return MMGenObject.__new__(base_proto_subclass(cls,proto,'twuo'))
txid_w = 64
disp_type = 'btc'

View file

@ -35,7 +35,7 @@ from .util import (
is_int,
fmt,
suf,
altcoin_subclass,
base_proto_subclass,
confirm_or_raise,
remove_dups,
get_extension,
@ -353,14 +353,14 @@ class MMGenTX:
def __new__(cls,*args,**kwargs):
"""
determine correct protocol and pass the proto to altcoin_subclass(), which returns the
determine correct protocol and pass the proto to base_proto_subclass(), which returns the
transaction object
"""
assert args == (), f'MMGenTX.Base_chk1: only keyword args allowed in {cls.__name__} initializer'
if 'proto' in kwargs:
return MMGenObject.__new__(altcoin_subclass(cls,kwargs['proto'],'tx'))
return MMGenObject.__new__(base_proto_subclass(cls,kwargs['proto'],'tx'))
elif 'data' in kwargs:
return MMGenObject.__new__(altcoin_subclass(cls,kwargs['data']['proto'],'tx'))
return MMGenObject.__new__(base_proto_subclass(cls,kwargs['data']['proto'],'tx'))
elif 'filename' in kwargs:
from .txfile import MMGenTxFile
tmp_tx = MMGenObject.__new__(cls)
@ -368,7 +368,7 @@ class MMGenTX:
infile = kwargs['filename'],
quiet_open = kwargs.get('quiet_open'),
metadata_only = True )
me = MMGenObject.__new__(altcoin_subclass(cls,tmp_tx.proto,'tx'))
me = MMGenObject.__new__(base_proto_subclass(cls,tmp_tx.proto,'tx'))
me.proto = tmp_tx.proto
return me
elif cls.__name__ == 'Base' and args == () and kwargs == {}: # allow instantiation of empty Base()

View file

@ -672,7 +672,7 @@ def get_subclasses(cls,names=False):
yield j
return tuple((c.__name__ for c in gen(cls)) if names else gen(cls))
def altcoin_subclass(cls,proto,mod_dir):
def base_proto_subclass(cls,proto,mod_dir):
"""
magic module loading and class retrieval
"""