diff --git a/.gitignore b/.gitignore index f5f5405d..1f83602a 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,5 @@ dependency-graph.png *.out *.synctex.gz contract_tests/* +.eved +scripts/wasm/*.wasm \ No newline at end of file diff --git a/scripts/wasm/README.md b/scripts/wasm/README.md new file mode 100644 index 00000000..0c2e7342 --- /dev/null +++ b/scripts/wasm/README.md @@ -0,0 +1,27 @@ +# Cosmwasm contracts e2e tests + +## Guideline + +Run local node + +```bash +bash scripts/run-node.sh +``` + +Download the cw20_base wasm file + +```bash +bash scripts/wasm/get_contract.sh +``` + +Then test upload code + +```bash +bash scripts/wasm/upload_code.sh +``` + +After upload, we can test instantiate the cw20_code + +```bash +bash scripts/wasm/instantiate_cw20.sh +``` diff --git a/scripts/wasm/get_contract.sh b/scripts/wasm/get_contract.sh new file mode 100644 index 00000000..796afaab --- /dev/null +++ b/scripts/wasm/get_contract.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +VERSION="v0.16.0" +CONTRACTS="cw20_base" + +for CONTRACT in $CONTRACTS; do + # check if already exists wasm + if [ -f ./scripts/wasm/$CONTRACT.wasm ]; then + echo "Wasm file already exists for $CONTRACT" + continue + fi + curl -s -L -o ./scripts/wasm/$CONTRACT.wasm https://github.com/CosmWasm/cw-plus/releases/download/$VERSION/$CONTRACT.wasm +done \ No newline at end of file diff --git a/scripts/wasm/gov_upload_code.sh b/scripts/wasm/gov_upload_code.sh new file mode 100644 index 00000000..58d738fe --- /dev/null +++ b/scripts/wasm/gov_upload_code.sh @@ -0,0 +1,42 @@ +#!/bin/bash +BINARY=build/eved + +CHAIN_ID=local-eve +VAL_KEY=test0 +VOTER= +VAL=$($BINARY keys show -a $VAL_KEY --keyring-backend test) +CONTRACT=cw20_base +PROPOSAL=1 +DENOM=${2:-"ueve"} +HOME=mytestnet + +echo "submit wasm store proposal..." +$BINARY tx wasm submit-proposal wasm-store scripts/wasm/$CONTRACT.wasm --title "Add $CONTRACT" \ + --summary "Let's upload this contract 3" \ + --from $VAL_KEY --keyring-backend test --chain-id $CHAIN_ID -y \ + --gas auto --gas-adjustment 1.3 > /dev/null + + +echo "deposit ueve to proposal..." +sleep 5 +# $BINARY query gov proposal $PROPOSAL +$BINARY tx gov deposit $PROPOSAL 40000000000000000000$DENOM --from $VAL_KEY --keyring-backend test \ + --chain-id $CHAIN_ID -y -b sync --gas auto --gas-adjustment 1.3 --home $HOME > /dev/null + +echo "process to self vote..." +sleep 5 +$BINARY tx gov vote $PROPOSAL yes --from $VAL_KEY --keyring-backend test \ + --chain-id $CHAIN_ID -y -b sync --gas auto --gas-adjustment 1.3 --home $HOME > /dev/null + +echo "Waiting for voting periods to finish..." +COUNTER=0 +while ((COUNTER < 12)); do + # Capture output of $BINARY command and extract "status" using jq + status=$($BINARY q gov proposal 1 --output=json | jq '.status') + sleep 5 + echo "Current proposal status: $status" + # Increment COUNTER using arithmetic expansion + ((COUNTER++)) +done + +$BINARY query wasm list-code \ No newline at end of file diff --git a/scripts/wasm/instantiate_cw20.sh b/scripts/wasm/instantiate_cw20.sh new file mode 100644 index 00000000..f2b8b837 --- /dev/null +++ b/scripts/wasm/instantiate_cw20.sh @@ -0,0 +1,79 @@ +#!bin/bash + +# this is cw20 code from install_contracts.sh, true if this is the first proposal +CODE=1 +CHAIN_ID=local-eve +BINARY=build/eved +HOME=mytestnet +$BINARY keys add demo --keyring-backend test --home $HOME +VAL_KEY=test0 +VAL=$($BINARY keys show -a $VAL_KEY --keyring-backend test --home $HOME) +DEMO=$($BINARY keys show -a demo --keyring-backend test --home $HOME) + + +# Init params in json +INIT=$(cat <