diff --git a/cic/attachment.py b/cic/attachment.py index aa52ba3..7c76fc4 100644 --- a/cic/attachment.py +++ b/cic/attachment.py @@ -44,7 +44,7 @@ class Attachment(Data): 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: writer = self.writer diff --git a/cic/extension.py b/cic/extension.py index 61f4393..5bcc932 100644 --- a/cic/extension.py +++ b/cic/extension.py @@ -94,7 +94,8 @@ class Extension: 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: raise RuntimeError('neither token address nor token code has been set') @@ -114,4 +115,4 @@ class Extension: logg.debug('ciceth adapter process {}'.format(task)) r = getattr(self, 'process_' + task)(writer=writer) - return self.token_address + return (self.token_address, self.token_details['symbol']) diff --git a/cic/meta.py b/cic/meta.py index fa08415..b9c1c67 100644 --- a/cic/meta.py +++ b/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: writer = self.writer - k = self.reference(token_address) 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')) return (k, v) @@ -89,7 +95,8 @@ class Meta(Data): class MetadataWriter(OutputWriter): - + 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'))) + rq = urllib.request.Request(self.path) diff --git a/cic/processor.py b/cic/processor.py index e3f164d..a55ebf2 100644 --- a/cic/processor.py +++ b/cic/processor.py @@ -39,7 +39,7 @@ class Processor: ] for ext in self.extensions: - token_address = ext.process() + (token_address, token_symbol) = ext.process() for task in tasks: a = self.cores.get(task) @@ -47,5 +47,5 @@ class Processor: if a == None: logg.debug('skipping missing task receiver "{}"'.format(task)) 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) diff --git a/cic/proof.py b/cic/proof.py index 9d84231..887dd00 100644 --- a/cic/proof.py +++ b/cic/proof.py @@ -99,7 +99,7 @@ class Proof(Data): 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: writer = self.writer diff --git a/requirements.txt b/requirements.txt index 94b1a28..87eaac1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ 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 chainlib>=0.0.10a3,<0.1.0 cbor2==5.4.1