2021-01-24 21:16:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-02-10 08:03:11 +01:00
|
|
|
set -a
|
|
|
|
|
|
|
|
DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER=0xEb3907eCad74a0013c259D5874AE7f22DcBcC95C
|
|
|
|
DEV_ETH_ACCOUNT_RESERVE_MINTER=${DEV_ETH_ACCOUNT_RESERVE_MINTER:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER=${DEV_ETH_ACCOUNT_RESERVE_MINTER:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
DEV_ETH_RESERVE_AMOUNT=${DEV_ETH_RESERVE_AMOUNT:-""10000000000000000000000000000000000}
|
2021-01-24 21:16:22 +01:00
|
|
|
keystore_file=$(realpath ./keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c)
|
|
|
|
|
|
|
|
echo "environment:"
|
|
|
|
printenv
|
|
|
|
echo \n
|
|
|
|
|
|
|
|
# This is a grassroots team convention for building the Bancor contracts using the bancor protocol repository truffle setup
|
|
|
|
# Running this in docker-internal dev container (built from Docker folder in this repo) will write a
|
|
|
|
# source-able env file to CIC_DATA_DIR. Services dependent on these contracts can mount this file OR
|
|
|
|
# define these parameters at runtime
|
|
|
|
# pushd /usr/src
|
|
|
|
|
2021-02-10 08:03:11 +01:00
|
|
|
init_level_file=${CIC_DATA_DIR}/.init
|
2021-02-11 17:20:31 +01:00
|
|
|
echo -n 1 > $init_level_file
|
2021-01-24 21:16:22 +01:00
|
|
|
|
|
|
|
# Abort on any error (including if wait-for-it fails).
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Wait for the backend to be up, if we know where it is.
|
|
|
|
if [[ -n "${ETH_PROVIDER}" ]]; then
|
|
|
|
echo "waiting for ${ETH_PROVIDER}..."
|
|
|
|
./wait-for-it.sh "${ETH_PROVIDER_HOST}:${ETH_PROVIDER_PORT}"
|
|
|
|
|
2021-02-10 08:03:11 +01:00
|
|
|
DEV_ETH_RESERVE_ADDRESS=`giftable-token-deploy -p $ETH_PROVIDER -y $keystore_file -i $CIC_CHAIN_SPEC --account $DEV_ETH_ACCOUNT_RESERVE_MINTER --minter $DEV_ETH_ACCOUNT_RESERVE_MINTER -v -w --name "Sarafu" --symbol "SRF" $DEV_ETH_RESERVE_AMOUNT`
|
2021-01-24 21:16:22 +01:00
|
|
|
|
|
|
|
#BANCOR_REGISTRY_ADDRESS=`cic-bancor-deploy --bancor-dir /usr/local/share/cic/bancor -z $DEV_ETH_RESERVE_ADDRESS -p $ETH_PROVIDER -o $DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER`
|
|
|
|
|
|
|
|
CIC_ACCOUNTS_INDEX_ADDRESS=`eth-accounts-index-deploy -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -y $keystore_file --writer $DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER -vv -w`
|
|
|
|
|
|
|
|
CIC_REGISTRY_ADDRESS=`cic-registry-deploy -i $CIC_CHAIN_SPEC -y $keystore_file -k CICRegistry -k BancorRegistry -k AccountRegistry -k TokenRegistry -k AddressDeclarator -k Faucet -k TransferApproval -p $ETH_PROVIDER -vv -w`
|
|
|
|
cic-registry-set -y $keystore_file -r $CIC_REGISTRY_ADDRESS -i $CIC_CHAIN_SPEC -k CICRegistry -p $ETH_PROVIDER $CIC_REGISTRY_ADDRESS -vv
|
|
|
|
#cic-registry-set -r $CIC_REGISTRY_ADDRESS -i $CIC_CHAIN_SPEC -k BancorRegistry -p $ETH_PROVIDER $BANCOR_REGISTRY_ADDRESS -vv
|
|
|
|
cic-registry-set -y $keystore_file -r $CIC_REGISTRY_ADDRESS -i $CIC_CHAIN_SPEC -k AccountRegistry -p $ETH_PROVIDER $CIC_ACCOUNTS_INDEX_ADDRESS -vv
|
2021-02-10 08:03:11 +01:00
|
|
|
|
|
|
|
# Deploy address declarator registry
|
|
|
|
>&2 echo "deploy address declarator contract"
|
|
|
|
declarator_description=0x546869732069732074686520434943206e6574776f726b000000000000000000
|
|
|
|
CIC_DECLARATOR_ADDRESS=`eth-address-declarator-deploy -y $keystore_file -i $CIC_CHAIN_SPEC -p $ETH_PROVIDER -w -v $declarator_description`
|
|
|
|
|
2021-01-24 21:16:22 +01:00
|
|
|
else
|
|
|
|
echo "\$ETH_PROVIDER not set!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p $CIC_DATA_DIR
|
|
|
|
|
|
|
|
# this is consumed in downstream services to set environment variables
|
|
|
|
cat << EOF > $CIC_DATA_DIR/.env
|
|
|
|
export DEV_ETH_RESERVE_ADDRESS=$DEV_ETH_RESERVE_ADDRESS
|
|
|
|
export DEV_ETH_RESERVE_AMOUNT=$DEV_ETH_RESERVE_AMOUNT
|
2021-02-10 08:03:11 +01:00
|
|
|
export DEV_ETH_ACCOUNTS_INDEX_ADDRESS=$CIC_ACCOUNTS_INDEX_ADDRESS
|
2021-01-24 21:16:22 +01:00
|
|
|
export BANCOR_REGISTRY_ADDRESS=$BANCOR_REGISTRY_ADDRESS
|
|
|
|
export CIC_REGISTRY_ADDRESS=$CIC_REGISTRY_ADDRESS
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
2021-02-10 08:03:11 +01:00
|
|
|
cat $CIC_DATA_DIR/envlist | bash from_env.sh > $CIC_DATA_DIR/.env_all
|
2021-01-24 21:16:22 +01:00
|
|
|
# popd
|
|
|
|
|
2021-02-10 08:03:11 +01:00
|
|
|
set +a
|
|
|
|
set +e
|
|
|
|
|
2021-02-11 17:20:31 +01:00
|
|
|
echo -n 2 > $init_level_file
|
2021-02-10 08:03:11 +01:00
|
|
|
|
2021-01-24 21:16:22 +01:00
|
|
|
exec "$@"
|