celo-bootstrap/boot.sh
Mohamed Sohail 2e4ea1eb87 Add custodial proxy and update defaults (#1)
Add:

- Custodial proxy contract

Fixes:

- Deploying the voucher takes a bit more than 5M

Also changed defaults:

- Voucher name
- Voucher symbol
- Faucet gift amount (worth 30 transfers)
- Faucet gift threshold (worth 5 transfers)
- Facuet period (every 24 hrs)

Co-authored-by: Mohammed Sohail <sohailsameja@gmail.com>
Reviewed-on: #1
Co-authored-by: Mohamed Sohail <kamikazechaser@noreply.localhost>
Co-committed-by: Mohamed Sohail <kamikazechaser@noreply.localhost>
2023-03-28 07:05:38 +00:00

86 lines
4.3 KiB
Bash

RPC_PROVIDER=${RPC_PROVIDER:-http://localhost:8545}
CHAIN_SPEC=${CHAIN_SPEC:-evm:celo:1337:celo}
KEY_FILE=${KEY_FILE:-keyfile.json}
RPC_DIALECT=${RPC_DIALECT:-chainlib_eth_celo}
TOKEN_NAME="TrainingVoucher"
TOKEN_SYMBOL=TRN
TOKEN_DECIMALS=6
TOKEN_DEMURRAGE=20000
TOKEN_PERIOD=43200
TOKEN_SINK_ADDRESS=${TOKEN_SINK_ADDRESS:-Eb3907eCad74a0013c259D5874AE7f22DcBcC95C}
# 30 * 20000000010 * 100000
GAS_FAUCET_AMOUNT=${GAS_FAUCET_AMOUNT:-60000000030000000}
# 5 * 20000000010 * 100000
GAS_FAUCET_THRESHOLD=${GAS_FAUCET_THRESHOLD:-10000000005000000}
# 24 hrs
GAS_FAUCET_PERIOD=${GAS_FAUCET_PERIOD:-86400}
log='-v'
set +e
t=$(mktemp -d)
# get the writer keyfile address
publisher=$(eth-keyfile -d $KEY_FILE)
if [ -z "$publisher" ]; then
exit 1
fi
writer=${WRITER_ADDRESS:-$publisher}
writer=$(eth-checksum $writer)
>&2 echo publisher: $publisher
>&2 echo writer: $writer
>&2 echo datadir: $t
# publish a voucher token
token=$(erc20-demurrage-token-publish --name $TOKEN_NAME --symbol $TOKEN_SYMBOL --decimals $TOKEN_DECIMALS --demurrage-level $TOKEN_DEMURRAGE --redistribution-period $TOKEN_PERIOD --sink-address $TOKEN_SINK_ADDRESS -y $KEY_FILE --fee-limit 6000000 -s -w $log | tee $t/token.txt)
# account registry
accounts=$(eth-accounts-index-publish -y $KEY_FILE --fee-limit 2000000 -s -w $log | tee $t/accounts.txt)
# token index
index=$(eth-token-index-publish -y $KEY_FILE --fee-limit 2000000 -s -w $log | tee $t/index.txt)
# eth faucet
gasfaucet=$(eth-faucet-publish -y $KEY_FILE --fee-limit 2000000 -s -w $log | tee $t/gasfaucet.txt)
# create the faucet period checker
hsh=$(eth-gas -y $KEY_FILE --data <(eth-faucet-gen period) --fee-limit 2000000 -s -w $log 0)
period=$(eth-get $hsh --raw -o contract | tee $t/period.txt)
eth-encode -y $KEY_FILE --mode tx --signature setPoker a:$gasfaucet -e $(eth-checksum $period) --fee-limit 100000 -s -w $log
# set parameters for faucet and period checker backend
eth-encode -y $KEY_FILE --mode tx --signature setAmount u:$GAS_FAUCET_AMOUNT -e $(eth-checksum $gasfaucet) --fee-limit 100000 -s -w $log
eth-encode -y $KEY_FILE --mode tx --signature setRegistry a:$accounts -e $(eth-checksum $gasfaucet) --fee-limit 100000 -s -w $log
eth-encode -y $KEY_FILE --mode tx --signature setPeriodChecker a:$period -e $(eth-checksum $gasfaucet) --fee-limit 100000 -s -w $log
eth-encode -y $KEY_FILE --mode tx --signature setPoker a:$gasfaucet -e $(eth-checksum $period) --fee-limit 100000 -s -w $log
if [ ! -z "$GAS_FAUCET_THRESHOLD" ]; then
eth-encode -y $KEY_FILE --mode tx --signature setBalanceThreshold u:$GAS_FAUCET_THRESHOLD -e $(eth-checksum $period) --fee-limit 100000 -s -w $log
fi
if [ ! -z "$GAS_FAUCET_PERIOD" ]; then
eth-encode -y $KEY_FILE --mode tx --signature setPeriod u:$GAS_FAUCET_PERIOD -e $(eth-checksum $period) --fee-limit 100000 -s -w $log
fi
eth-encode -y $KEY_FILE --mode tx --signature addWriter a:$writer -e $(eth-checksum $accounts) --fee-limit 100000 -s -w $log
eth-encode -y $KEY_FILE --mode tx --signature addWriter a:$writer -e $(eth-checksum $token) --fee-limit 100000 -s -w $log
eth-encode -y $KEY_FILE --mode tx --signature addWriter a:$writer -e $(eth-checksum $index) --fee-limit 100000 -s -w $log
# publish custodial registration proxy
proxy=$(ge-custodial-registration-proxy-publish -y $KEY_FILE --fee-limit 2000000 -s -w $log --eth-faucet-address $gasfaucet --account-index-address $accounts --training-voucher-address $token --system-account-address $publisher | tee $t/proxy.txt)
# publish contract registry
contracts=$(eth-contract-registry-publish -y $KEY_FILE --fee-limit 2000000 -s -w $log --identifier TrainingVoucher --identifier AccountIndex --identifier TokenIndex --identifier GasFaucet --identifier CustodialRegistrationProxy | tee $t/contracts.txt)
contracts=$(eth-checksum $contracts)
eth-contract-registry-set -y $KEY_FILE --fee-limit 100000 -s -w $log -e $contracts -a $(eth-checksum $token) TrainingVoucher
eth-contract-registry-set -y $KEY_FILE --fee-limit 100000 -s -w $log -e $contracts -a $(eth-checksum $accounts) AccountIndex
eth-contract-registry-set -y $KEY_FILE --fee-limit 100000 -s -w $log -e $contracts -a $(eth-checksum $index) TokenIndex
eth-contract-registry-set -y $KEY_FILE --fee-limit 100000 -s -w $log -e $contracts -a $(eth-checksum $gasfaucet) GasFaucet
eth-contract-registry-set -y $KEY_FILE --fee-limit 100000 -s -w $log -e $contracts -a $(eth-checksum $proxy) CustodialRegistrationProxy
set -e
echo $contracts