2022-12-08 18:35:20 +00:00
#!/bin/bash
set -ex
2024-02-08 23:32:44 +00:00
# by sleeping 1 block in between tx's
# we can emulate the behavior of the
# the deprecated and now removed (as of Kava 16)
# broadcast mode of `block` in order to
# minimize the chance tx's fail due to an
# account sequence number mismatch
AVG_SECONDS_BETWEEN_BLOCKS = 6.5
2022-12-08 18:35:20 +00:00
# configure kava binary to talk to the desired chain endpoint
2022-12-14 20:41:53 +00:00
kava config node " ${ CHAIN_API_URL } "
kava config chain-id " ${ CHAIN_ID } "
2022-12-08 18:35:20 +00:00
# use the test keyring to allow scriptng key generation
kava config keyring-backend test
# wait for transactions to be committed per CLI command
2024-02-08 19:52:36 +00:00
kava config broadcast-mode sync
2022-12-08 18:35:20 +00:00
# setup dev wallet
echo " ${ DEV_WALLET_MNEMONIC } " | kava keys add --recover dev-wallet
2023-03-09 18:31:13 +00:00
DEV_TEST_WALLET_ADDRESS = "0x7E08fa61f22f1A40B4617b887eD24b85CDaf33c2"
2023-03-24 19:02:51 +00:00
WEBAPP_E2E_WHALE_ADDRESS = "0x0252284098b19036F81bd22851f8699042fafac2"
2022-12-08 18:35:20 +00:00
2023-03-14 23:45:19 +00:00
# setup kava ethereum compatible account for deploying
2022-12-08 18:35:20 +00:00
# erc20 contracts to the kava chain
echo "sweet ocean blush coil mobile ten floor sample nuclear power legend where place swamp young marble grit observe enforce lake blossom lesson upon plug" | kava keys add --recover --eth dev-erc20-deployer-wallet
# fund evm-contract-deployer account (using issuance)
2022-12-21 19:51:14 +00:00
kava tx issuance issue 200000000ukava kava1van3znl6597xgwwh46jgquutnqkwvwszjg04fz --from dev-wallet --gas-prices 0.5ukava -y
2022-12-08 18:35:20 +00:00
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS
2022-12-08 18:35:20 +00:00
# deploy and fund USDC ERC20 contract
2023-04-14 01:23:02 +00:00
MULTICHAIN_USDC_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "USD Coin" USDC 6)
MULTICHAIN_USDC_CONTRACT_ADDRESS = ${ MULTICHAIN_USDC_CONTRACT_DEPLOY : -42 }
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_USDC_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2022-12-08 18:35:20 +00:00
# # deploy and fund wKava ERC20 contract
2022-12-14 20:41:53 +00:00
wKAVA_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "Wrapped Kava" wKava 6)
2022-12-08 18:35:20 +00:00
wKAVA_CONTRACT_ADDRESS = ${ wKAVA_CONTRACT_DEPLOY : -42 }
2022-12-14 20:41:53 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $wKAVA_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2022-12-08 18:35:20 +00:00
# deploy and fund BNB contract
2022-12-14 20:41:53 +00:00
BNB_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "Binance" BNB 8)
2022-12-08 18:35:20 +00:00
BNB_CONTRACT_ADDRESS = ${ BNB_CONTRACT_DEPLOY : -42 }
2022-12-14 20:41:53 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $BNB_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2022-12-08 18:35:20 +00:00
# deploy and fund USDT contract
2023-06-21 23:05:48 +00:00
MULTICHAIN_USDT_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "Multichain USDT" USDT 6)
2023-04-14 19:22:48 +00:00
MULTICHAIN_USDT_CONTRACT_ADDRESS = ${ MULTICHAIN_USDT_CONTRACT_DEPLOY : -42 }
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_USDT_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2022-12-08 18:35:20 +00:00
# deploy and fund DAI contract
2022-12-14 20:41:53 +00:00
DAI_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "DAI" DAI 18)
2022-12-08 18:35:20 +00:00
DAI_CONTRACT_ADDRESS = ${ DAI_CONTRACT_DEPLOY : -42 }
2022-12-14 20:41:53 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $DAI_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2022-12-21 19:51:14 +00:00
2023-06-05 23:37:00 +00:00
# deploy and fund axlwBTC ERC20 contract
AXL_WBTC_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "Wrapped BTC" BTC 8)
2023-06-06 18:36:11 +00:00
AXL_WBTC_CONTRACT_ADDRESS = ${ AXL_WBTC_CONTRACT_DEPLOY : -42 }
2023-06-05 23:37:00 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $AXL_WBTC_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 100000000000000
2023-03-08 22:49:22 +00:00
# deploy and fund wETH ERC20 contract
wETH_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "Wrapped wETH" ETH 18)
2023-03-09 18:31:13 +00:00
wETH_CONTRACT_ADDRESS = ${ wETH_CONTRACT_DEPLOY : -42 }
2023-03-08 22:49:22 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $wETH_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000000000000
2023-03-14 23:45:19 +00:00
# deploy and fund axlUSDC ERC20 contract
2023-04-14 01:23:02 +00:00
AXL_USDC_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "USD Coin" USDC 6)
AXL_USDC_CONTRACT_ADDRESS = ${ AXL_USDC_CONTRACT_DEPLOY : -42 }
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $AXL_USDC_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2023-03-14 23:45:19 +00:00
2023-04-12 15:44:54 +00:00
# deploy and fund Multichain wBTC ERC20 contract
MULTICHAIN_wBTC_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "Wrapped BTC" BTC 8)
MULTICHAIN_wBTC_CONTRACT_ADDRESS = ${ MULTICHAIN_wBTC_CONTRACT_DEPLOY : -42 }
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_wBTC_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 100000000000000
2023-06-21 23:05:48 +00:00
# deploy and fund Tether USDT ERC20 contract
TETHER_USDT_CONTRACT_DEPLOY = $( npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " deploy-erc20 "USD₮" USD₮ 6)
TETHER_USDT_CONTRACT_ADDRESS = ${ TETHER_USDT_CONTRACT_DEPLOY : -42 }
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $TETHER_USDT_CONTRACT_ADDRESS " 0x6767114FFAA17C6439D7AEA480738B982CE63A02 1000000000000
2023-04-12 15:44:54 +00:00
2023-03-09 18:31:13 +00:00
# seed some evm wallets
2023-06-05 23:37:00 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $AXL_WBTC_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 10000000000000
2023-04-12 15:44:54 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_wBTC_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 10000000000000
2023-04-14 01:23:02 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_USDC_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 100000000000
2023-03-09 18:31:13 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $wETH_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 1000000000000000000000
2023-04-14 01:23:02 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $AXL_USDC_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 100000000000
2023-04-14 19:22:48 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_USDT_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 100000000000
2023-06-21 23:05:48 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $TETHER_USDT_CONTRACT_ADDRESS " " $DEV_TEST_WALLET_ADDRESS " 1000000000000
2023-03-31 22:41:11 +00:00
# seed webapp E2E whale account
2023-06-05 23:37:00 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $AXL_WBTC_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 100000000000000
2023-04-12 15:44:54 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_wBTC_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 10000000000000
2023-04-14 01:23:02 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_USDC_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 1000000000000
2023-03-24 19:02:51 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $wETH_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 10000000000000000000000
2023-04-14 01:23:02 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $AXL_USDC_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 10000000000000
2023-04-14 19:22:48 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $MULTICHAIN_USDT_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 1000000000000
2023-06-21 23:05:48 +00:00
npx hardhat --network " ${ ERC20_DEPLOYER_NETWORK_NAME } " mint-erc20 " $TETHER_USDT_CONTRACT_ADDRESS " " $WEBAPP_E2E_WHALE_ADDRESS " 1000000000000
2023-03-24 19:02:51 +00:00
2022-12-21 19:51:14 +00:00
# give dev-wallet enough delegation power to pass proposals by itself
2023-04-03 18:30:02 +00:00
# issue kava to dev wallet for delegating to each validator
kava tx issuance issue 6000000000ukava kava1vlpsrmdyuywvaqrv7rx6xga224sqfwz3fyfhwq \
2022-12-21 19:51:14 +00:00
--from dev-wallet --gas-prices 0.5ukava -y
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS
2023-04-03 18:30:02 +00:00
# parse space seperated list of validators
# into bash array
2023-06-23 22:25:21 +00:00
read -r -a GENESIS_VALIDATOR_ADDRESS_ARRAY <<< " $GENESIS_VALIDATOR_ADDRESSES "
2023-04-03 18:30:02 +00:00
2022-12-21 19:51:14 +00:00
# delegate 300KAVA to each validator
2023-06-23 22:25:21 +00:00
for validator in " ${ GENESIS_VALIDATOR_ADDRESS_ARRAY [@] } " ; do
2022-12-21 19:51:14 +00:00
kava tx staking delegate " ${ validator } " 300000000ukava --from dev-wallet --gas-prices 0.5ukava -y
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS
2022-12-21 19:51:14 +00:00
done
2023-01-23 19:56:51 +00:00
# create a text proposal
2023-06-05 22:02:08 +00:00
kava tx gov submit-legacy-proposal --deposit 1000000000ukava --type "Text" --title "Example Proposal" --description "This is an example proposal" --gas auto --gas-adjustment 1.2 --from dev-wallet --gas-prices 0.01ukava -y
2023-04-14 01:29:25 +00:00
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS
2023-04-14 01:29:25 +00:00
# setup god's wallet
echo " ${ KAVA_TESTNET_GOD_MNEMONIC } " | kava keys add --recover god
# create template string for the proposal we want to enact
# https://kava-labs.atlassian.net/wiki/spaces/ENG/pages/1228537857/Submitting+Governance+Proposals+WIP
2023-06-23 22:25:21 +00:00
PARAM_CHANGE_PROP_TEMPLATE = $(
cat <<'END_HE REDOC'
2023-04-14 01:29:25 +00:00
{
"@type" : "/cosmos.params.v1beta1.ParameterChangeProposal" ,
"title" : "Set Initial ERC-20 Contracts" ,
"description" : "Set Initial ERC-20 Contracts" ,
"changes" : [
{
"subspace" : "evmutil" ,
"key" : "EnabledConversionPairs" ,
2023-06-21 23:05:48 +00:00
"value" : "[{\"kava_erc20_address\":\"MULTICHAIN_USDC_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/usdc\"},{\"kava_erc20_address\":\"MULTICHAIN_USDT_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/usdt\"},{\"kava_erc20_address\":\"MULTICHAIN_wBTC_CONTRACT_ADDRESS\",\"denom\":\"erc20/multichain/wbtc\"},{\"kava_erc20_address\":\"AXL_USDC_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/usdc\"},{\"kava_erc20_address\":\"AXL_WBTC_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/wbtc\"},{\"kava_erc20_address\":\"wETH_CONTRACT_ADDRESS\",\"denom\":\"erc20/axelar/eth\"},{\"kava_erc20_address\":\"TETHER_USDT_CONTRACT_ADDRESS\",\"denom\":\"erc20/tether/usdt\"}]"
2023-04-14 01:29:25 +00:00
}
]
}
END_HEREDOC
)
# substitute freshly deployed contract addresses
finalProposal = $PARAM_CHANGE_PROP_TEMPLATE
finalProposal = " ${ finalProposal /MULTICHAIN_USDC_CONTRACT_ADDRESS/ $MULTICHAIN_USDC_CONTRACT_ADDRESS } "
finalProposal = " ${ finalProposal /MULTICHAIN_USDT_CONTRACT_ADDRESS/ $MULTICHAIN_USDT_CONTRACT_ADDRESS } "
finalProposal = " ${ finalProposal /MULTICHAIN_wBTC_CONTRACT_ADDRESS/ $MULTICHAIN_wBTC_CONTRACT_ADDRESS } "
finalProposal = " ${ finalProposal /AXL_USDC_CONTRACT_ADDRESS/ $AXL_USDC_CONTRACT_ADDRESS } "
2023-06-06 18:36:11 +00:00
finalProposal = " ${ finalProposal /AXL_WBTC_CONTRACT_ADDRESS/ $AXL_WBTC_CONTRACT_ADDRESS } "
2023-04-14 01:29:25 +00:00
finalProposal = " ${ finalProposal /wETH_CONTRACT_ADDRESS/ $wETH_CONTRACT_ADDRESS } "
2023-06-21 23:05:48 +00:00
finalProposal = " ${ finalProposal /TETHER_USDT_CONTRACT_ADDRESS/ $TETHER_USDT_CONTRACT_ADDRESS } "
2023-04-14 01:29:25 +00:00
# create unique proposal filename
proposalFileName = " $( date +%s) -proposal.json "
touch $proposalFileName
# save proposal as file to disk
2023-06-23 22:25:21 +00:00
echo " $finalProposal " >$proposalFileName
2023-04-14 01:29:25 +00:00
# snapshot original module params
originalEvmUtilParams = $( curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params)
printf "original evm util module params\n %s" , " $originalEvmUtilParams "
# change the params of the chain like a god - make it so 🖖🏽
# make sure to update god committee member permissions for the module
# and params being updated (see below for example)
2024-05-01 03:17:24 +00:00
# https://github.com/0glabs/0g-chain/pull/1556/files#diff-0bd6043650c708661f37bbe6fa5b29b52149e0ec0069103c3954168fc9f12612R900-R903
2023-06-22 18:03:46 +00:00
# committee 1 is the stability committee. on internal testnet, this has only one member.
2023-04-14 01:29:25 +00:00
kava tx committee submit-proposal 1 " $proposalFileName " --gas 2000000 --gas-prices 0.01ukava --from god -y
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS
2023-06-22 18:03:46 +00:00
# vote on the proposal. this assumes no other committee proposal has ever been submitted (id=1)
kava tx committee vote 1 yes --gas 2000000 --gas-prices 0.01ukava --from god -y
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS
2023-04-14 01:29:25 +00:00
# fetch current module params
updatedEvmUtilParams = $( curl https://api.app.internal.testnet.us-east.production.kava.io/kava/evmutil/v1beta1/params)
printf "updated evm util module params\n %s" , " $updatedEvmUtilParams "
2023-06-23 22:25:21 +00:00
# if adding more cosmos coins -> er20s, ensure that the deployment order below remains the same.
# convert 1 HARD to an erc20. doing this ensures the contract is deployed.
kava tx evmutil convert-cosmos-coin-to-erc20 \
" $DEV_TEST_WALLET_ADDRESS " \
1000000hard \
--from dev-wallet --gas 2000000 --gas-prices 0.001ukava -y
2024-02-08 23:32:44 +00:00
sleep $AVG_SECONDS_BETWEEN_BLOCKS