Compare commits

...

6 Commits

Author SHA1 Message Date
nolash
e1b330949c
Update cic-registry version, rename noop local script 2021-02-22 15:37:05 +01:00
Spencer Ofwiti
e07ed88c72 Bug fix. 2021-02-22 16:48:50 +03:00
nolash
d55f73af94
Fix chain spec parse in importuseres 2021-02-22 13:41:10 +01:00
nolash
75063246a7
Correct chain spec parsing in verify import script 2021-02-22 13:32:50 +01:00
nolash
51c06f0c9d
Repair cic-meta dockerfile 2021-02-22 12:36:31 +01:00
nolash
70f1d63867
Add session to create role eth task 2021-02-22 12:14:00 +01:00
10 changed files with 21 additions and 18 deletions

View File

@ -178,8 +178,10 @@ def register(self, account_address, chain_str, writer_address=None):
""" """
chain_spec = ChainSpec.from_chain_str(chain_str) chain_spec = ChainSpec.from_chain_str(chain_str)
session = SessionBase.create_session()
if writer_address == None: if writer_address == None:
writer_address = AccountRole.get_address('ACCOUNTS_INDEX_WRITER') writer_address = AccountRole.get_address('ACCOUNTS_INDEX_WRITER', session)
session.close()
if writer_address == zero_address: if writer_address == zero_address:
raise RoleMissingError(account_address) raise RoleMissingError(account_address)

View File

@ -3,11 +3,8 @@ FROM node:15.3.0-alpine3.10
WORKDIR /tmp/src/cic-meta WORKDIR /tmp/src/cic-meta
COPY cic-meta/package.json \ COPY cic-meta/package.json \
cic-meta/package-lock.json \
./ ./
RUN npm install
COPY cic-meta/src/ src/ COPY cic-meta/src/ src/
COPY cic-meta/tests/ tests/ COPY cic-meta/tests/ tests/
COPY cic-meta/scripts/ scripts/ COPY cic-meta/scripts/ scripts/
@ -15,6 +12,8 @@ COPY cic-meta/scripts/ scripts/
RUN alias tsc=node_modules/typescript/bin/tsc RUN alias tsc=node_modules/typescript/bin/tsc
RUN npm install
COPY cic-meta/.config/ /usr/local/etc/cic-meta/ COPY cic-meta/.config/ /usr/local/etc/cic-meta/
# COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql # COPY cic-meta/scripts/server/initdb/server.postgres.sql /usr/local/share/cic-meta/sql/server.sql

View File

@ -1,6 +1,6 @@
{ {
"name": "cic-client-meta", "name": "cic-client-meta",
"version": "0.0.6", "version": "0.0.7-alpha.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -6,7 +6,7 @@
"types": "dist/index.d.ts", "types": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "mocha -r node_modules/node-localstorage/register -r ts-node/register tests/*.ts", "test": "mocha -r node_modules/node-localstorage/register -r ts-node/register tests/*.ts",
"build": "node_modules/typescript/bin/tsc -d --outDir dist && npm run build-server", "build": "node_modules/typescript/bin/tsc -d --outDir dist src/index.ts",
"build-server": "tsc -d --outDir dist-server scripts/server/*.ts", "build-server": "tsc -d --outDir dist-server scripts/server/*.ts",
"pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack", "pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack",
"clean": "rm -rf dist", "clean": "rm -rf dist",

View File

@ -49,7 +49,7 @@ This will monitor new mined blocks and send balances to the newly created accoun
Without any modifications to the cluster and config files: Without any modifications to the cluster and config files:
`python -c config --redis-host-callback redis <datadir>` `python import_users.py -c config --redis-host-callback redis <datadir>`
** A note on the The callback**: The script uses a redis callback to retrieve the newly generated custodial address. This is the redis server _from the perspective of the cic-eth component_. ** A note on the The callback**: The script uses a redis callback to retrieve the newly generated custodial address. This is the redis server _from the perspective of the cic-eth component_.

View File

@ -191,7 +191,7 @@ class BlockGetter:
def progress_callback(block_number, tx_index, s): def progress_callback(block_number, tx_index, s):
sys.stdout.write(s.ljust(200) + "\n") sys.stdout.write(str(s).ljust(200) + "\n")

View File

@ -20,7 +20,7 @@ from hexathon import (
from chainlib.eth.address import to_checksum from chainlib.eth.address import to_checksum
from cic_types.models.person import Person from cic_types.models.person import Person
from cic_eth.api.api_task import Api from cic_eth.api.api_task import Api
from cic_registry.chain import ChainSpec from chainlib.chain import ChainSpec
from cic_types.processor import generate_metadata_pointer from cic_types.processor import generate_metadata_pointer
logging.basicConfig(level=logging.WARNING) logging.basicConfig(level=logging.WARNING)
@ -142,7 +142,8 @@ if __name__ == '__main__':
new_address = register_eth(i, u) new_address = register_eth(i, u)
if u.identities.get('evm') == None: if u.identities.get('evm') == None:
u.identities['evm'] = {} u.identities['evm'] = {}
u.identities['evm'][chain_str] = [new_address] sub_chain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
u.identities['evm'][sub_chain_str] = [new_address]
register_ussd(u) register_ussd(u)

View File

@ -2,7 +2,7 @@ psycopg2==2.8.6
chainlib~=0.0.1a15 chainlib~=0.0.1a15
chainsyncer~=0.0.1a10 chainsyncer~=0.0.1a10
cic-eth==0.10.0a30+build.fdb16130 cic-eth==0.10.0a30+build.fdb16130
cic-registry~=0.5.3a19 cic-registry~=0.5.3a21
confini~=0.3.6rc3 confini~=0.3.6rc3
celery==4.4.7 celery==4.4.7
redis==3.5.3 redis==3.5.3

View File

@ -11,7 +11,7 @@ import csv
import json import json
import urllib import urllib
# external impotts # external imports
import celery import celery
import eth_abi import eth_abi
import confini import confini
@ -19,9 +19,9 @@ from hexathon import (
strip_0x, strip_0x,
add_0x, add_0x,
) )
from cic_registry.chain import ChainSpec
from chainsyncer.backend import MemBackend from chainsyncer.backend import MemBackend
from chainsyncer.driver import HeadSyncer from chainsyncer.driver import HeadSyncer
from chainlib.chain import ChainSpec
from chainlib.eth.connection import HTTPConnection from chainlib.eth.connection import HTTPConnection
from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.constant import ZERO_ADDRESS
from chainlib.eth.block import ( from chainlib.eth.block import (
@ -53,7 +53,7 @@ config_dir = '/usr/local/etc/cic-syncer'
argparser = argparse.ArgumentParser(description='daemon that monitors transactions in new blocks') argparser = argparse.ArgumentParser(description='daemon that monitors transactions in new blocks')
argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address') argparser.add_argument('-p', '--provider', dest='p', type=str, help='chain rpc provider address')
argparser.add_argument('-c', type=str, default=config_dir, help='config root to use') argparser.add_argument('-c', type=str, default=config_dir, help='config root to use')
argparser.add_argument('--old-chain-spec', type=str, dest='old_chain_spec', default='oldchain:1', help='chain spec') argparser.add_argument('--old-chain-spec', type=str, dest='old_chain_spec', default='evm:oldchain:1', help='chain spec')
argparser.add_argument('-i', '--chain-spec', type=str, dest='i', help='chain spec') argparser.add_argument('-i', '--chain-spec', type=str, dest='i', help='chain spec')
argparser.add_argument('--meta-provider', type=str, dest='meta_provider', default='http://localhost:63380', help='cic-meta url') argparser.add_argument('--meta-provider', type=str, dest='meta_provider', default='http://localhost:63380', help='cic-meta url')
argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address') argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address')
@ -254,7 +254,6 @@ def main():
balances = {} balances = {}
f = open('{}/balances.csv'.format(user_dir, 'r')) f = open('{}/balances.csv'.format(user_dir, 'r'))
remove_zeros = 10**12
i = 0 i = 0
while True: while True:
l = f.readline() l = f.readline()
@ -266,7 +265,7 @@ def main():
sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r") sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
except ValueError: except ValueError:
break break
balance = int(int(r[1].rstrip()) / remove_zeros) balance = int(r[1].rstrip())
balances[address] = balance balances[address] = balance
i += 1 i += 1
@ -294,8 +293,10 @@ def main():
u = Person.deserialize(o) u = Person.deserialize(o)
logg.debug('data {}'.format(u.identities['evm'])) logg.debug('data {}'.format(u.identities['evm']))
new_address = u.identities['evm'][chain_str][0] subchain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
old_address = u.identities['evm'][old_chain_str][0] new_address = u.identities['evm'][subchain_str][0]
subchain_str = '{}:{}'.format(old_chain_spec.common_name(), old_chain_spec.network_id())
old_address = u.identities['evm'][subchain_str][0]
balance = balances[old_address] balance = balances[old_address]
logg.debug('checking {} -> {} = {}'.format(old_address, new_address, balance)) logg.debug('checking {} -> {} = {}'.format(old_address, new_address, balance))