Rehabilitate import scripts after leak fixes

This commit is contained in:
Louis Holbrook 2021-02-22 20:00:18 +00:00
parent 42ae8e5ed3
commit c68d9d8404
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)
session = SessionBase.create_session()
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:
raise RoleMissingError(account_address)

View File

@ -3,11 +3,8 @@ FROM node:15.3.0-alpine3.10
WORKDIR /tmp/src/cic-meta
COPY cic-meta/package.json \
cic-meta/package-lock.json \
./
RUN npm install
COPY cic-meta/src/ src/
COPY cic-meta/tests/ tests/
COPY cic-meta/scripts/ scripts/
@ -15,6 +12,8 @@ COPY cic-meta/scripts/ scripts/
RUN alias tsc=node_modules/typescript/bin/tsc
RUN npm install
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

View File

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

View File

@ -6,7 +6,7 @@
"types": "dist/index.d.ts",
"scripts": {
"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",
"pack": "node_modules/typescript/bin/tsc -d --outDir dist && webpack",
"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:
`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_.

View File

@ -191,7 +191,7 @@ class BlockGetter:
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 cic_types.models.person import Person
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
logging.basicConfig(level=logging.WARNING)
@ -142,7 +142,8 @@ if __name__ == '__main__':
new_address = register_eth(i, u)
if u.identities.get('evm') == None:
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)

View File

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

View File

@ -11,7 +11,7 @@ import csv
import json
import urllib
# external impotts
# external imports
import celery
import eth_abi
import confini
@ -19,9 +19,9 @@ from hexathon import (
strip_0x,
add_0x,
)
from cic_registry.chain import ChainSpec
from chainsyncer.backend import MemBackend
from chainsyncer.driver import HeadSyncer
from chainlib.chain import ChainSpec
from chainlib.eth.connection import HTTPConnection
from chainlib.eth.constant import ZERO_ADDRESS
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.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('--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('--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')
@ -254,7 +254,6 @@ def main():
balances = {}
f = open('{}/balances.csv'.format(user_dir, 'r'))
remove_zeros = 10**12
i = 0
while True:
l = f.readline()
@ -266,7 +265,7 @@ def main():
sys.stdout.write('loading balance {} {}'.format(i, address).ljust(200) + "\r")
except ValueError:
break
balance = int(int(r[1].rstrip()) / remove_zeros)
balance = int(r[1].rstrip())
balances[address] = balance
i += 1
@ -294,8 +293,10 @@ def main():
u = Person.deserialize(o)
logg.debug('data {}'.format(u.identities['evm']))
new_address = u.identities['evm'][chain_str][0]
old_address = u.identities['evm'][old_chain_str][0]
subchain_str = '{}:{}'.format(chain_spec.common_name(), chain_spec.network_id())
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]
logg.debug('checking {} -> {} = {}'.format(old_address, new_address, balance))