2021-09-06 12:06:58 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -a
|
2021-10-28 13:34:39 +02:00
|
|
|
set -e
|
2021-09-06 12:06:58 +02:00
|
|
|
|
|
|
|
if [ -z $DEV_DATA_DIR ]; then
|
|
|
|
export DEV_DATA_DIR=`mktemp -d`
|
|
|
|
else
|
|
|
|
mkdir -p $DEV_DATA_DIR
|
|
|
|
fi
|
|
|
|
|
2021-10-19 22:08:17 +02:00
|
|
|
# Handle wallet
|
|
|
|
export WALLET_KEY_FILE=${WALLET_KEY_FILE:-`realpath ./keystore/UTC--2021-01-08T17-18-44.521011372Z--eb3907ecad74a0013c259d5874ae7f22dcbcc95c`}
|
|
|
|
if [ ! -f $WALLET_KEY_FILE ]; then
|
|
|
|
>&2 echo "wallet path '$WALLET_KEY_FILE' does not point to a file"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-20 20:02:19 +02:00
|
|
|
|
2021-10-19 22:08:17 +02:00
|
|
|
export DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER=`eth-keyfile -z -d $WALLET_KEY_FILE`
|
|
|
|
noncefile=${DEV_DATA_DIR}/nonce_${DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
|
2021-10-14 11:33:50 +02:00
|
|
|
# By default configuration values generated from previous runs will be used in subsequent invocations
|
|
|
|
# Setting the config reset
|
2021-09-06 12:06:58 +02:00
|
|
|
if [ -z $DEV_CONFIG_RESET ]; then
|
2021-10-14 11:33:50 +02:00
|
|
|
if [ -f $DEV_DATA_DIR/env_reset ]; then
|
|
|
|
>&2 echo -e "\033[;96mimporting existing configuration values from ${DEV_DATA_DIR}/env_reset\033[;39m"
|
2021-09-06 12:06:58 +02:00
|
|
|
. ${DEV_DATA_DIR}/env_reset
|
|
|
|
fi
|
2021-10-14 11:33:50 +02:00
|
|
|
else
|
|
|
|
>&2 echo -e "\033[;33mGenerating scratch configuration\033[;39m"
|
2021-10-19 22:08:17 +02:00
|
|
|
bash_debug_flag=""
|
|
|
|
if [ "$DEV_DEBUG_LEVEL" -gt 1 ]; then
|
|
|
|
bash_debug_flag="-v"
|
|
|
|
fi
|
|
|
|
rm $bash_debug_flag -f ${DEV_DATA_DIR}/env_reset
|
|
|
|
rm $bash_debug_flag -f $noncefile
|
2021-10-28 13:34:39 +02:00
|
|
|
export SYNCER_OFFSET=`eth-info --raw block`
|
2021-10-14 11:33:50 +02:00
|
|
|
confini-dump --schema-dir ./config --prefix export > ${DEV_DATA_DIR}/env_reset
|
2021-09-06 12:06:58 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Wallet dependent variable defaults
|
|
|
|
export DEV_ETH_ACCOUNT_RESERVE_MINTER=${DEV_ETH_ACCOUNT_RESERVE_MINTER:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
export DEV_ETH_ACCOUNT_ACCOUNTS_INDEX_WRITER=${DEV_ETH_ACCOUNT_RESERVE_MINTER:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
export CIC_TRUST_ADDRESS=${CIC_TRUST_ADDRESS:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
export CIC_DEFAULT_TOKEN_SYMBOL=$TOKEN_SYMBOL
|
|
|
|
export TOKEN_SINK_ADDRESS=${TOKEN_SINK_ADDRESS:-$DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER}
|
|
|
|
|
2021-10-29 11:36:14 +02:00
|
|
|
if [ ! -f $noncefile ]; then
|
|
|
|
nonce=`eth-count -p $RPC_PROVIDER $DEV_DEBUG_FLAG $DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER`
|
|
|
|
>&2 echo -e "\033[;96mUsing contract deployer address $DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER with nonce $nonce\033[;39m"
|
|
|
|
echo -n $nonce > $noncefile
|
|
|
|
else
|
|
|
|
nonce=`cat $noncefile`
|
|
|
|
>&2 echo -e "\033[;96mResuming usage with contract deployer address $DEV_ETH_ACCOUNT_CONTRACT_DEPLOYER with nonce $nonce\033[;39m"
|
|
|
|
fi
|
2021-10-28 13:34:39 +02:00
|
|
|
|
2021-09-06 12:06:58 +02:00
|
|
|
# Migration variable processing
|
2021-10-15 12:54:16 +02:00
|
|
|
confini-dump --schema-dir ./config > ${DEV_DATA_DIR}/env_reset
|
2021-10-14 21:31:04 +02:00
|
|
|
|
2021-10-28 13:34:39 +02:00
|
|
|
set +e
|
2021-09-06 12:06:58 +02:00
|
|
|
set +a
|