Compare commits
2 Commits
master
...
1498edbb07
Author | SHA1 | Date | |
---|---|---|---|
1498edbb07 | |||
10cbb1344d |
@ -4,5 +4,10 @@
|
||||
"precision": 0,
|
||||
"code": null,
|
||||
"supply": 0,
|
||||
"extra": {}
|
||||
"extra": [
|
||||
{
|
||||
"arg": "",
|
||||
"arg_type": ""
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class Extension:
|
||||
:returns: Token data state of extension after load
|
||||
"""
|
||||
return self.prepare_token(token.name, token.symbol, token.precision, token.code, token.supply)
|
||||
|
||||
|
||||
|
||||
def prepare_token(self, name, symbol, precision, code, supply, extra=[], extra_types=[], positions=None):
|
||||
"""Initialize extension token data.
|
||||
@ -105,10 +105,10 @@ class Extension:
|
||||
r = f.read()
|
||||
f.close()
|
||||
self.parse_code_as_hex(r)
|
||||
except FileNotFoundError:
|
||||
except FileNotFoundError as e:
|
||||
logg.debug('could not parse code as file: {}'.format(e))
|
||||
pass
|
||||
except IsADirectoryError:
|
||||
except IsADirectoryError as e:
|
||||
logg.debug('could not parse code as file: {}'.format(e))
|
||||
pass
|
||||
|
||||
@ -121,7 +121,7 @@ class Extension:
|
||||
:param v: Bytecode as hex
|
||||
:type v: str
|
||||
"""
|
||||
try:
|
||||
try:
|
||||
self.token_code = valid_hex(v)
|
||||
except ValueError as e:
|
||||
logg.debug('could not parse code as hex: {}'.format(e))
|
||||
@ -139,7 +139,7 @@ class Extension:
|
||||
code = self.token_details['code']
|
||||
if hint == 'hex':
|
||||
self.token_code = valid_hex(code)
|
||||
|
||||
|
||||
for m in [
|
||||
self.parse_code_as_hex,
|
||||
self.parse_code_as_file,
|
||||
@ -147,7 +147,7 @@ class Extension:
|
||||
m(code)
|
||||
if self.token_code != None:
|
||||
break
|
||||
|
||||
|
||||
if self.token_code == None:
|
||||
raise RuntimeError('could not successfully parse token code')
|
||||
|
||||
@ -167,9 +167,9 @@ class Extension:
|
||||
if writer == None:
|
||||
writer = self.outputs_writer
|
||||
|
||||
tasks = []
|
||||
tasks = []
|
||||
self.token_address = self.resources['token']['reference']
|
||||
|
||||
|
||||
# TODO: get token details when token address is not none
|
||||
if self.token_address == None:
|
||||
if self.token_details['code'] == None:
|
||||
@ -182,7 +182,7 @@ class Extension:
|
||||
continue
|
||||
if self.resources[k]['reference'] != None:
|
||||
tasks.append(k)
|
||||
|
||||
|
||||
self.prepare_extension()
|
||||
|
||||
for task in tasks:
|
||||
|
18
cic/token.py
18
cic/token.py
@ -34,7 +34,8 @@ class Token(Data):
|
||||
self.supply = supply
|
||||
self.precision = precision
|
||||
self.code = code
|
||||
self.extra_args = None
|
||||
self.extra_args: list = []
|
||||
self.extra_args_types: list = []
|
||||
self.path = path
|
||||
self.token_path = os.path.join(self.path, 'token.json')
|
||||
|
||||
@ -53,8 +54,19 @@ class Token(Data):
|
||||
self.precision = o['precision']
|
||||
self.code = o['code']
|
||||
self.supply = o['supply']
|
||||
self.extra_args = o['extra']
|
||||
|
||||
extras = []
|
||||
extra_types = []
|
||||
token_extras: list = o['extra']
|
||||
if token_extras:
|
||||
for token_extra in token_extras:
|
||||
arg = token_extra.get('arg')
|
||||
arg_type = token_extra.get('arg_type')
|
||||
if arg:
|
||||
extras.append(arg)
|
||||
if arg_type:
|
||||
extra_types.append(arg_type)
|
||||
self.extra_args = extras
|
||||
self.extra_args_types = extra_types
|
||||
self.inited = True
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user