Add missing supply member in token

This commit is contained in:
nolash 2021-10-14 15:43:23 +02:00
parent ab4976d809
commit bd73666922
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
7 changed files with 36 additions and 7 deletions

View File

@ -3,12 +3,19 @@ import logging
import importlib import importlib
import os import os
# external imports
from cic_types.ext.metadata import MetadataRequestsHandler
from cic_types.ext.metadata.signer import Signer as MetadataSigner
# local imports # local imports
from cic import ( from cic import (
Proof, Proof,
Processor, Processor,
) )
from cic.meta import Meta from cic.meta import (
Meta,
MetadataWriter,
)
from cic.attachment import Attachment from cic.attachment import Attachment
from cic.network import Network from cic.network import Network
from cic.token import Token from cic.token import Token
@ -50,9 +57,15 @@ def execute(config, eargs):
cmd_mod = importlib.import_module(modname) cmd_mod = importlib.import_module(modname)
writers = init_writers_from_config(config) 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) 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)) 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)) cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'](path=eargs.output_directory))
cn = Network(path=eargs.directory) cn = Network(path=eargs.directory)

View File

@ -1,5 +1,6 @@
{ {
"version": 0, "version": 0,
"namespace": "ge", "namespace": "ge",
"issuer": "",
"description": "" "description": ""
} }

View File

@ -5,6 +5,7 @@ import json
# external imports # external imports
from cic_types import MetadataPointer from cic_types import MetadataPointer
from cic_types.processor import generate_metadata_pointer from cic_types.processor import generate_metadata_pointer
from cic_types.ext.metadata import MetadataRequestsHandler
from hexathon import strip_0x from hexathon import strip_0x
# local imports # local imports
@ -12,6 +13,7 @@ from .base import (
Data, Data,
data_dir, data_dir,
) )
from cic.output import OutputWriter
class Meta(Data): class Meta(Data):
@ -84,3 +86,11 @@ class Meta(Data):
s += "contact.{} = {}\n".format(k.lower(), self.contact[k]) s += "contact.{} = {}\n".format(k.lower(), self.contact[k])
return s 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')))

View File

@ -33,13 +33,14 @@ class Processor:
def process(self, writer=None): def process(self, writer=None):
tasks = [ tasks = [
'attachment', #'attachment',
'proof', #'proof',
'metadata', 'metadata',
] ]
for ext in self.extensions: for ext in self.extensions:
token_address = ext.process() # token_address = ext.process()
token_address = '0x1222afdeadbeef'
for task in tasks: for task in tasks:
a = self.cores.get(task) a = self.cores.get(task)

View File

@ -38,6 +38,7 @@ class Proof(Data):
self.set_version(o['version']) self.set_version(o['version'])
self.description = o['description'] self.description = o['description']
self.namespace = o['namespace'] self.namespace = o['namespace']
self.issuer = o['issuer']
self.inited = True self.inited = True
@ -61,6 +62,7 @@ class Proof(Data):
'version': self.version(), 'version': self.version(),
'namespace': self.namespace, 'namespace': self.namespace,
'description': self.description, 'description': self.description,
'issuer': self.issuer,
} }

View File

@ -11,10 +11,11 @@ from .base import (
class Token(Data): 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__() super(Token, self).__init__()
self.name = name self.name = name
self.symbol = symbol self.symbol = symbol
self.supply = supply
self.precision = precision self.precision = precision
self.code = code self.code = code
self.extra_args = None self.extra_args = None

View File

@ -2,3 +2,4 @@ funga>=0.5.0a1,<0.6.0
cic-types>=0.2.0a1,<=0.2.0 cic-types>=0.2.0a1,<=0.2.0
confini>=0.4.2rc3,<0.5.0 confini>=0.4.2rc3,<0.5.0
chainlib>=0.0.10a1,<0.1.0 chainlib>=0.0.10a1,<0.1.0
cbor2==4.5.1