Add token symbol metadata pointer
This commit is contained in:
parent
4518c8b700
commit
fd6e9c23a7
@ -44,7 +44,7 @@ class Attachment(Data):
|
|||||||
return self.contents
|
return self.contents
|
||||||
|
|
||||||
|
|
||||||
def process(self, token_address=None, writer=None):
|
def process(self, token_address=None, token_symbol=None, writer=None):
|
||||||
if writer == None:
|
if writer == None:
|
||||||
writer = self.writer
|
writer = self.writer
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ class Extension:
|
|||||||
tasks = []
|
tasks = []
|
||||||
self.token_address = self.resources['token']['reference']
|
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_address == None:
|
||||||
if self.token_details['code'] == None:
|
if self.token_details['code'] == None:
|
||||||
raise RuntimeError('neither token address nor token code has been set')
|
raise RuntimeError('neither token address nor token code has been set')
|
||||||
@ -114,4 +115,4 @@ class Extension:
|
|||||||
logg.debug('ciceth adapter process {}'.format(task))
|
logg.debug('ciceth adapter process {}'.format(task))
|
||||||
r = getattr(self, 'process_' + task)(writer=writer)
|
r = getattr(self, 'process_' + task)(writer=writer)
|
||||||
|
|
||||||
return self.token_address
|
return (self.token_address, self.token_details['symbol'])
|
||||||
|
13
cic/meta.py
13
cic/meta.py
@ -66,12 +66,18 @@ class Meta(Data):
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def process(self, token_address=None, writer=None):
|
def process(self, token_address=None, token_symbol=None, writer=None):
|
||||||
if writer == None:
|
if writer == None:
|
||||||
writer = self.writer
|
writer = self.writer
|
||||||
|
|
||||||
k = self.reference(token_address)
|
|
||||||
v = json.dumps(self.asdict())
|
v = json.dumps(self.asdict())
|
||||||
|
|
||||||
|
token_address_bytes = bytes.fromhex(strip_0x(token_address))
|
||||||
|
k = generate_metadata_pointer(token_address_bytes, MetadataPointer.TOKEN_META)
|
||||||
|
writer.write(k, v.encode('utf-8'))
|
||||||
|
|
||||||
|
token_symbol_bytes = token_symbol.encode('utf-8')
|
||||||
|
k = generate_metadata_pointer(token_symbol_bytes, MetadataPointer.TOKEN_META_SYMBOL)
|
||||||
writer.write(k, v.encode('utf-8'))
|
writer.write(k, v.encode('utf-8'))
|
||||||
|
|
||||||
return (k, v)
|
return (k, v)
|
||||||
@ -91,5 +97,6 @@ class Meta(Data):
|
|||||||
class MetadataWriter(OutputWriter):
|
class MetadataWriter(OutputWriter):
|
||||||
|
|
||||||
def write(self, k, v):
|
def write(self, k, v):
|
||||||
rq = MetadataRequestsHandler(MetadataPointer.TOKEN_META, bytes.fromhex(k))
|
rq = MetadataRequestsHandler(MetadataPointer.NONE, bytes.fromhex(k))
|
||||||
return rq.create(json.loads(v.decode('utf-8')))
|
return rq.create(json.loads(v.decode('utf-8')))
|
||||||
|
rq = urllib.request.Request(self.path)
|
||||||
|
@ -39,7 +39,7 @@ class Processor:
|
|||||||
]
|
]
|
||||||
|
|
||||||
for ext in self.extensions:
|
for ext in self.extensions:
|
||||||
token_address = ext.process()
|
(token_address, token_symbol) = ext.process()
|
||||||
|
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
a = self.cores.get(task)
|
a = self.cores.get(task)
|
||||||
@ -47,5 +47,5 @@ class Processor:
|
|||||||
if a == None:
|
if a == None:
|
||||||
logg.debug('skipping missing task receiver "{}"'.format(task))
|
logg.debug('skipping missing task receiver "{}"'.format(task))
|
||||||
continue
|
continue
|
||||||
v = a.process(token_address=token_address, writer=self.__outputs_writer)
|
v = a.process(token_address=token_address, token_symbol=token_symbol, writer=self.__outputs_writer)
|
||||||
self.outputs.append(v)
|
self.outputs.append(v)
|
||||||
|
@ -99,7 +99,7 @@ class Proof(Data):
|
|||||||
return (hsh, hshs)
|
return (hsh, hshs)
|
||||||
|
|
||||||
|
|
||||||
def process(self, token_address=None, writer=None):
|
def process(self, token_address=None, token_symbol=None, writer=None):
|
||||||
if writer == None:
|
if writer == None:
|
||||||
writer = self.writer
|
writer = self.writer
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
funga-eth>=0.5.0a1,<0.6.0
|
funga-eth>=0.5.0a1,<0.6.0
|
||||||
cic-types>=0.2.0a4,<=0.2.0
|
cic-types>=0.2.1a1,<=0.2.1
|
||||||
confini>=0.4.2rc3,<0.5.0
|
confini>=0.4.2rc3,<0.5.0
|
||||||
chainlib>=0.0.10a3,<0.1.0
|
chainlib>=0.0.10a3,<0.1.0
|
||||||
cbor2==5.4.1
|
cbor2==5.4.1
|
||||||
|
Loading…
Reference in New Issue
Block a user