From bd7366692265b90756833a782ef1e9212df2606c Mon Sep 17 00:00:00 2001 From: nolash Date: Thu, 14 Oct 2021 15:43:23 +0200 Subject: [PATCH] Add missing supply member in token --- cic/cmd/export.py | 19 ++++++++++++++++--- cic/data/proof_template_v0.json | 1 + cic/meta.py | 10 ++++++++++ cic/processor.py | 7 ++++--- cic/proof.py | 2 ++ cic/token.py | 3 ++- requirements.txt | 1 + 7 files changed, 36 insertions(+), 7 deletions(-) diff --git a/cic/cmd/export.py b/cic/cmd/export.py index 50e8830..095b95b 100644 --- a/cic/cmd/export.py +++ b/cic/cmd/export.py @@ -3,12 +3,19 @@ import logging import importlib import os +# external imports +from cic_types.ext.metadata import MetadataRequestsHandler +from cic_types.ext.metadata.signer import Signer as MetadataSigner + # local imports from cic import ( Proof, Processor, ) -from cic.meta import Meta +from cic.meta import ( + Meta, + MetadataWriter, + ) from cic.attachment import Attachment from cic.network import Network from cic.token import Token @@ -50,9 +57,15 @@ def execute(config, eargs): cmd_mod = importlib.import_module(modname) writers = init_writers_from_config(config) - + + MetadataRequestsHandler.base_url = 'http://localhost:63380' + MetadataSigner.gpg_path = os.path.join('/tmp') + MetadataSigner.key_file_path = '/home/lash/src/client/cic/grassrootseconomics/cic-internal-integration/apps/cic-ussd/tests/data/pgp/privatekeys_meta.asc' + MetadataSigner.gpg_passphrase = 'merman' + ct = Token(path=eargs.directory) - cm = Meta(path=eargs.directory, writer=writers['meta'](path=eargs.output_directory)) + #cm = Meta(path=eargs.directory, writer=writers['meta'](path=eargs.output_directory)) + cm = Meta(path=eargs.directory, writer=MetadataWriter()) ca = Attachment(path=eargs.directory, writer=writers['attachment'](path=eargs.output_directory)) cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'](path=eargs.output_directory)) cn = Network(path=eargs.directory) diff --git a/cic/data/proof_template_v0.json b/cic/data/proof_template_v0.json index 9e36901..5800c5a 100644 --- a/cic/data/proof_template_v0.json +++ b/cic/data/proof_template_v0.json @@ -1,5 +1,6 @@ { "version": 0, "namespace": "ge", + "issuer": "", "description": "" } diff --git a/cic/meta.py b/cic/meta.py index 82cb978..f50bf4c 100644 --- a/cic/meta.py +++ b/cic/meta.py @@ -5,6 +5,7 @@ import json # external imports from cic_types import MetadataPointer from cic_types.processor import generate_metadata_pointer +from cic_types.ext.metadata import MetadataRequestsHandler from hexathon import strip_0x # local imports @@ -12,6 +13,7 @@ from .base import ( Data, data_dir, ) +from cic.output import OutputWriter class Meta(Data): @@ -84,3 +86,11 @@ class Meta(Data): s += "contact.{} = {}\n".format(k.lower(), self.contact[k]) return s + + +class MetadataWriter(OutputWriter): + + def write(self, k, v): + rq = MetadataRequestsHandler(MetadataPointer.TOKEN, bytes.fromhex(k)) + return rq.create(json.loads(v.decode('utf-8'))) + diff --git a/cic/processor.py b/cic/processor.py index acd0b34..22be34e 100644 --- a/cic/processor.py +++ b/cic/processor.py @@ -33,13 +33,14 @@ class Processor: def process(self, writer=None): tasks = [ - 'attachment', - 'proof', + #'attachment', + #'proof', 'metadata', ] for ext in self.extensions: - token_address = ext.process() +# token_address = ext.process() + token_address = '0x1222afdeadbeef' for task in tasks: a = self.cores.get(task) diff --git a/cic/proof.py b/cic/proof.py index 72e7e5e..53fde91 100644 --- a/cic/proof.py +++ b/cic/proof.py @@ -38,6 +38,7 @@ class Proof(Data): self.set_version(o['version']) self.description = o['description'] self.namespace = o['namespace'] + self.issuer = o['issuer'] self.inited = True @@ -61,6 +62,7 @@ class Proof(Data): 'version': self.version(), 'namespace': self.namespace, 'description': self.description, + 'issuer': self.issuer, } diff --git a/cic/token.py b/cic/token.py index 9e2f996..d10965b 100644 --- a/cic/token.py +++ b/cic/token.py @@ -11,10 +11,11 @@ from .base import ( class Token(Data): - def __init__(self, path='.', name=None, symbol=None, precision=1, code=None): + def __init__(self, path='.', name=None, symbol=None, precision=1, supply=0, code=None): super(Token, self).__init__() self.name = name self.symbol = symbol + self.supply = supply self.precision = precision self.code = code self.extra_args = None diff --git a/requirements.txt b/requirements.txt index 4da6a4f..a8a49d0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ funga>=0.5.0a1,<0.6.0 cic-types>=0.2.0a1,<=0.2.0 confini>=0.4.2rc3,<0.5.0 chainlib>=0.0.10a1,<0.1.0 +cbor2==4.5.1