Use immutable meta
This commit is contained in:
parent
d5b7215b6b
commit
1269377c1f
@ -12,6 +12,7 @@ from cic import (
|
|||||||
Proof,
|
Proof,
|
||||||
Processor,
|
Processor,
|
||||||
)
|
)
|
||||||
|
from cic.proof import ProofWriter
|
||||||
from cic.meta import (
|
from cic.meta import (
|
||||||
Meta,
|
Meta,
|
||||||
MetadataWriter,
|
MetadataWriter,
|
||||||
@ -26,6 +27,7 @@ logg = logging.getLogger(__name__)
|
|||||||
def process_args(argparser):
|
def process_args(argparser):
|
||||||
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
argparser.add_argument('-d', '--directory', type=str, dest='directory', default='.', help='directory')
|
||||||
argparser.add_argument('-o', '--output-directory', type=str, dest='output_directory', help='output directory')
|
argparser.add_argument('-o', '--output-directory', type=str, dest='output_directory', help='output directory')
|
||||||
|
argparser.add_argument('--metadata-endpoint', dest='metadata_endpoint', type=str, help='metadata endpoint to interact with')
|
||||||
argparser.add_argument('-y', '--signer', type=str, dest='y', help='target-specific signer to use for export')
|
argparser.add_argument('-y', '--signer', type=str, dest='y', help='target-specific signer to use for export')
|
||||||
argparser.add_argument('-p', type=str, help='RPC endpoint')
|
argparser.add_argument('-p', type=str, help='RPC endpoint')
|
||||||
argparser.add_argument('target', type=str, help='target network type')
|
argparser.add_argument('target', type=str, help='target network type')
|
||||||
@ -58,16 +60,20 @@ def execute(config, eargs):
|
|||||||
|
|
||||||
writers = init_writers_from_config(config)
|
writers = init_writers_from_config(config)
|
||||||
|
|
||||||
MetadataRequestsHandler.base_url = 'http://localhost:63380'
|
output_writer_path_meta = eargs.output_directory
|
||||||
MetadataSigner.gpg_path = os.path.join('/tmp')
|
if eargs.metadata_endpoint != None:
|
||||||
MetadataSigner.key_file_path = '/home/lash/src/client/cic/grassrootseconomics/cic-internal-integration/apps/cic-ussd/tests/data/pgp/privatekeys_meta.asc'
|
MetadataRequestsHandler.base_url = eargs.metadata_endpoint
|
||||||
MetadataSigner.gpg_passphrase = 'merman'
|
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'
|
||||||
|
writers['proof'] = ProofWriter
|
||||||
|
writers['meta'] = MetadataWriter
|
||||||
|
output_writer_path_meta = eargs.metadata_endpoint
|
||||||
|
|
||||||
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=output_writer_path_meta))
|
||||||
cm = Meta(path=eargs.directory, writer=MetadataWriter())
|
ca = Attachment(path=eargs.directory, writer=writers['attachment'](path=output_writer_path_meta))
|
||||||
ca = Attachment(path=eargs.directory, writer=writers['attachment'](path=eargs.output_directory))
|
cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'](path=output_writer_path_meta))
|
||||||
cp = Proof(path=eargs.directory, attachments=ca, writer=writers['proof'](path=eargs.output_directory))
|
|
||||||
cn = Network(path=eargs.directory)
|
cn = Network(path=eargs.directory)
|
||||||
|
|
||||||
ct.load()
|
ct.load()
|
||||||
|
@ -204,6 +204,7 @@ class CICEth(Extension):
|
|||||||
else:
|
else:
|
||||||
r = o
|
r = o
|
||||||
|
|
||||||
|
logg.debug('>>>>>>>>>>>>>>>>>>>>>>>>>> token index result {} {}'.format(r, o))
|
||||||
writer.write('token_index', r.encode('utf-8'))
|
writer.write('token_index', r.encode('utf-8'))
|
||||||
self.add_outputs('token_index', r)
|
self.add_outputs('token_index', r)
|
||||||
return r
|
return r
|
||||||
|
@ -93,4 +93,3 @@ class MetadataWriter(OutputWriter):
|
|||||||
def write(self, k, v):
|
def write(self, k, v):
|
||||||
rq = MetadataRequestsHandler(MetadataPointer.TOKEN_META, bytes.fromhex(k))
|
rq = MetadataRequestsHandler(MetadataPointer.TOKEN_META, bytes.fromhex(k))
|
||||||
return rq.create(json.loads(v.decode('utf-8')))
|
return rq.create(json.loads(v.decode('utf-8')))
|
||||||
|
|
||||||
|
@ -24,7 +24,10 @@ class StdoutWriter(OutputWriter):
|
|||||||
class KVWriter(OutputWriter):
|
class KVWriter(OutputWriter):
|
||||||
|
|
||||||
def __init__(self, path=None, *args, **kwargs):
|
def __init__(self, path=None, *args, **kwargs):
|
||||||
os.stat(path)
|
try:
|
||||||
|
os.stat(path)
|
||||||
|
except FileNotFoundError:
|
||||||
|
os.makedirs(path)
|
||||||
self.path = path
|
self.path = path
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,4 +49,3 @@ class Processor:
|
|||||||
continue
|
continue
|
||||||
v = a.process(token_address=token_address, writer=self.__outputs_writer)
|
v = a.process(token_address=token_address, writer=self.__outputs_writer)
|
||||||
self.outputs.append(v)
|
self.outputs.append(v)
|
||||||
|
|
||||||
|
20
cic/proof.py
20
cic/proof.py
@ -4,12 +4,18 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import tempfile
|
import tempfile
|
||||||
import cbor2
|
import cbor2
|
||||||
|
import base64
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
# external imports
|
# external imports
|
||||||
from hexathon import strip_0x
|
from hexathon import strip_0x
|
||||||
|
from cic_types import MetadataPointer
|
||||||
|
from cic_types.processor import generate_metadata_pointer
|
||||||
|
from cic_types.ext.metadata import MetadataRequestsHandler
|
||||||
|
|
||||||
# local imports
|
# local imports
|
||||||
from .base import *
|
from .base import *
|
||||||
|
from cic.output import OutputWriter
|
||||||
|
|
||||||
logg = logging.getLogger(__name__)
|
logg = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -121,3 +127,17 @@ class Proof(Data):
|
|||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "description = {}\n".format(self.description)
|
return "description = {}\n".format(self.description)
|
||||||
|
|
||||||
|
|
||||||
|
class ProofWriter(OutputWriter):
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, path=None, *args, **kwargs):
|
||||||
|
super(ProofWriter, self).__init__(*args, **kwargs)
|
||||||
|
self.path = path
|
||||||
|
|
||||||
|
|
||||||
|
def write(self, k, v):
|
||||||
|
rq = urllib.request.Request(self.path, method='POST', data=v)
|
||||||
|
r = urllib.request.urlopen(rq)
|
||||||
|
logg.info('proof submited at {}'.format(r.read(dd)))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
chainlib-eth>=0.0.10a1,<0.1.0
|
chainlib-eth>=0.0.10a5,<0.1.0
|
||||||
funga-eth>=0.5.1a1,<0.6.0
|
funga-eth>=0.5.1a1,<0.6.0
|
||||||
eth-token-index>=0.2.4a1,<0.3.0
|
eth-token-index>=0.2.4a1,<0.3.0
|
||||||
eth-address-index>=0.2.4a1,<0.3.0
|
eth-address-index>=0.2.4a1,<0.3.0
|
||||||
|
@ -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.0a4,<=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.10a3,<0.1.0
|
||||||
cbor2==5.4.1
|
cbor2==5.4.1
|
||||||
|
Loading…
Reference in New Issue
Block a user