Update contract migrations and cic-cache to chainlib erc20 split

This commit is contained in:
nolash 2021-05-02 16:22:17 +02:00
parent 2e66e48dd6
commit ef1e1658f7
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
6 changed files with 14 additions and 14 deletions

View File

@ -2,7 +2,6 @@
import logging import logging
# external imports # external imports
from chainlib.eth.erc20 import ERC20
from chainlib.eth.address import ( from chainlib.eth.address import (
to_checksum_address, to_checksum_address,
) )
@ -13,6 +12,7 @@ from cic_eth_registry.error import (
NotAContractError, NotAContractError,
ContractMismatchError, ContractMismatchError,
) )
from eth_erc20 import ERC20
# local imports # local imports
from .base import TagSyncFilter from .base import TagSyncFilter

View File

@ -3,7 +3,7 @@ import logging
# external imports # external imports
import celery import celery
from erc20_single_shot_faucet import SingleShotFaucet as Faucet from erc20_faucet import Faucet
from hexathon import ( from hexathon import (
strip_0x, strip_0x,
) )
@ -20,7 +20,7 @@ from chainlib.eth.tx import (
) )
from chainlib.chain import ChainSpec from chainlib.chain import ChainSpec
from chainlib.error import JSONRPCException from chainlib.error import JSONRPCException
from eth_accounts_index import AccountRegistry from eth_accounts_index import AccountsIndex
from sarafu_faucet import MinterFaucet as Faucet from sarafu_faucet import MinterFaucet as Faucet
from chainqueue.db.models.tx import TxCache from chainqueue.db.models.tx import TxCache
@ -127,13 +127,13 @@ def register(self, account_address, chain_spec_dict, writer_address=None):
if writer_address == ZERO_ADDRESS: if writer_address == ZERO_ADDRESS:
session.close() session.close()
raise RoleMissingError('call address for resgistering {}'.format(account_address)) raise RoleMissingError('call address for resgistering {}'.format(account_address))
account_registry_address = registry.by_name('AccountRegistry', sender_address=call_address) account_registry_address = registry.by_name('AccountsIndex', sender_address=call_address)
# Generate and sign transaction # Generate and sign transaction
rpc_signer = RPCConnection.connect(chain_spec, 'signer') rpc_signer = RPCConnection.connect(chain_spec, 'signer')
nonce_oracle = CustodialTaskNonceOracle(writer_address, self.request.root_id, session=session) #, default_nonce) nonce_oracle = CustodialTaskNonceOracle(writer_address, self.request.root_id, session=session) #, default_nonce)
gas_oracle = self.create_gas_oracle(rpc, AccountRegistry.gas) gas_oracle = self.create_gas_oracle(rpc, AccountsIndex.gas)
account_registry = AccountRegistry(chain_spec, signer=rpc_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle) account_registry = AccountsIndex(chain_spec, signer=rpc_signer, nonce_oracle=nonce_oracle, gas_oracle=gas_oracle)
(tx_hash_hex, tx_signed_raw_hex) = account_registry.add(account_registry_address, writer_address, account_address, tx_format=TxFormat.RLP_SIGNED) (tx_hash_hex, tx_signed_raw_hex) = account_registry.add(account_registry_address, writer_address, account_address, tx_format=TxFormat.RLP_SIGNED)
rpc_signer.disconnect() rpc_signer.disconnect()
@ -338,7 +338,7 @@ def cache_account_data(
chain_spec = ChainSpec.from_dict(chain_spec_dict) chain_spec = ChainSpec.from_dict(chain_spec_dict)
tx_signed_raw_bytes = bytes.fromhex(tx_signed_raw_hex[2:]) tx_signed_raw_bytes = bytes.fromhex(tx_signed_raw_hex[2:])
tx = unpack(tx_signed_raw_bytes, chain_spec) tx = unpack(tx_signed_raw_bytes, chain_spec)
tx_data = AccountRegistry.parse_add_request(tx['data']) tx_data = AccountsIndex.parse_add_request(tx['data'])
session = SessionBase.create_session() session = SessionBase.create_session()
tx_cache = TxCache( tx_cache = TxCache(

View File

@ -7,7 +7,7 @@ from chainlib.chain import ChainSpec
from chainlib.connection import RPCConnection from chainlib.connection import RPCConnection
from chainlib.eth.constant import ZERO_ADDRESS from chainlib.eth.constant import ZERO_ADDRESS
from cic_eth_registry import CICRegistry from cic_eth_registry import CICRegistry
from eth_address_declarator import AddressDeclarator from eth_address_declarator import Declarator
# local imports # local imports
from cic_eth.task import BaseTask from cic_eth.task import BaseTask
@ -22,13 +22,13 @@ def translate_address(address, trusted_addresses, chain_spec, sender_address=ZER
rpc = RPCConnection.connect(chain_spec, 'default') rpc = RPCConnection.connect(chain_spec, 'default')
registry = CICRegistry(chain_spec, rpc) registry = CICRegistry(chain_spec, rpc)
declarator_address = registry.by_name('AddressDeclarator', sender_address=sender_address) declarator_address = registry.by_name('Declarator', sender_address=sender_address)
c = AddressDeclarator(chain_spec) c = Declarator(chain_spec)
for trusted_address in trusted_addresses: for trusted_address in trusted_addresses:
o = c.declaration(declarator_address, trusted_address, address, sender_address=sender_address) o = c.declaration(declarator_address, trusted_address, address, sender_address=sender_address)
r = rpc.do(o) r = rpc.do(o)
declaration_hex = AddressDeclarator.parse_declaration(r) declaration_hex = Declarator.parse_declaration(r)
declaration_hex = declaration_hex[0].rstrip('0') declaration_hex = declaration_hex[0].rstrip('0')
declaration_bytes = bytes.fromhex(declaration_hex) declaration_bytes = bytes.fromhex(declaration_hex)
declaration = None declaration = None

View File

@ -29,7 +29,7 @@ RUN /usr/local/bin/python -m pip install --upgrade pip
# python merge_requirements.py | tee merged_requirements.txt # python merge_requirements.py | tee merged_requirements.txt
#RUN cd cic-base && \ #RUN cd cic-base && \
# pip install $pip_extra_index_url_flag -r ./merged_requirements.txt # pip install $pip_extra_index_url_flag -r ./merged_requirements.txt
RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2a77 RUN pip install $pip_extra_index_url_flag cic-base[full_graph]==0.1.2b8
COPY cic-eth/scripts/ scripts/ COPY cic-eth/scripts/ scripts/
COPY cic-eth/setup.cfg cic-eth/setup.py ./ COPY cic-eth/setup.cfg cic-eth/setup.py ./

View File

@ -54,8 +54,8 @@ USER grassroots
ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433 ARG pip_extra_index_url=https://pip.grassrootseconomics.net:8433
ARG cic_base_version=0.1.2b8 ARG cic_base_version=0.1.2b8
ARG cic_eth_version=0.11.0b12 ARG cic_eth_version=0.11.0b12
ARG sarafu_faucet_version=0.0.3a2
ARG sarafu_token_version=0.0.1a8 ARG sarafu_token_version=0.0.1a8
ARG sarafu_faucet_version=0.0.3a2
#ARG cic_contracts_version=0.0.2a2 #ARG cic_contracts_version=0.0.2a2
RUN pip install --user --index-url https://pypi.org/simple --extra-index-url $pip_extra_index_url \ RUN pip install --user --index-url https://pypi.org/simple --extra-index-url $pip_extra_index_url \
cic-base[full_graph]==$cic_base_version \ cic-base[full_graph]==$cic_base_version \

View File

@ -99,7 +99,7 @@ export DEV_ETH_SARAFU_TOKEN_ADDRESS=$DEV_ETH_RESERVE_ADDRESS
# Transfer tokens to gifter address # Transfer tokens to gifter address
>&2 echo "transfer sarafu tokens to token gifter address" >&2 echo "transfer sarafu tokens to token gifter address"
>&2 eth-transfer -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER --token-address $DEV_RESERVE_ADDRESS -w $debug $DEV_ETH_ACCOUNT_SARAFU_GIFTER ${token_amount:0:-1} >&2 erc20-transfer -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER --token-address $DEV_RESERVE_ADDRESS -w $debug $DEV_ETH_ACCOUNT_SARAFU_GIFTER ${token_amount:0:-1}
#echo -n 0 > $init_level_file #echo -n 0 > $init_level_file