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 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)

View File

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

View File

@ -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')))

View File

@ -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)

View File

@ -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,
}

View File

@ -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

View File

@ -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