forked from classic-terra/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scripts for token migration (classic-terra#300)
Co-authored-by: Till Ziegler <[email protected]>
- Loading branch information
1 parent
77547ce
commit 33b8d5e
Showing
8 changed files
with
157 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#! /bin/bash | ||
|
||
BINARY=_build/new/terrad | ||
CONTRACTPATH="scripts/wasm/contracts/new_anc_token.wasm" | ||
RECEIVERPATH="scripts/wasm/contracts/cw20_receiver_template.wasm" | ||
KEYRING_BACKEND="test" | ||
HOME=mytestnet | ||
CHAIN_ID=localterra | ||
|
||
if [ -z "$PRE_UPGRADE_CONTRACT_ADDR" ]; then | ||
echo "PRE_UPGRADE_CONTRACT_ADDR is empty" | ||
exit 1 | ||
fi | ||
|
||
### DEBUG ### | ||
#contract_addr="terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5" | ||
### DEBUG ### | ||
addr2=$($BINARY keys show test1 -a --home $HOME --keyring-backend $KEYRING_BACKEND) | ||
|
||
echo "STORE DUMMY RECEIVER" | ||
res=$($BINARY tx wasm store $RECEIVERPATH --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 100000000uluna --chain-id $CHAIN_ID --home $HOME --broadcast-mode block --keyring-backend $KEYRING_BACKEND -y) | ||
tx=$(echo $res | jq -r ."txhash") | ||
res=$($BINARY q tx --output json ${tx}) | ||
code=$(echo "$res" | jq -r ."code") | ||
if [ "$code" != "0" ]; then | ||
echo "store contract failed" | ||
exit -1 | ||
fi | ||
code_id=$(echo "$res" | jq -r '.logs[0].events[] | select(.type == "store_code") | .attributes[] | select(.key == "code_id") | .value') | ||
echo "CODE = ${code_id}" | ||
echo "" | ||
|
||
echo "INSTANTIATE DUMMY RECEIVER" | ||
res=$($BINARY tx wasm instantiate $code_id '{}' --label "contract_${code_id}" --no-admin --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 100000000uluna --chain-id $CHAIN_ID --home $HOME --broadcast-mode block --keyring-backend $KEYRING_BACKEND -y) | ||
code=$(echo $res | jq -r ."code") | ||
tx=$(echo $res | jq -r ."txhash") | ||
if [ "$code" != 0 ]; then | ||
echo "instantiate contract failed" | ||
exit -1 | ||
fi | ||
receiver=$($BINARY q tx --output json ${tx} | jq -r '.logs[0].events[] | select(.type == "instantiate") | .attributes[] | select(.key == "_contract_address") | .value') | ||
echo "ADDRESS = ${receiver}" | ||
echo "" | ||
|
||
echo "TRANSFER P2P - BEFORE MIGRATION" | ||
msg=$(jq -n ' | ||
{ | ||
"transfer": { | ||
"amount": "100000", | ||
"recipient": "'$addr2'" | ||
} | ||
}') | ||
echo $msg | ||
res=$($BINARY tx wasm execute "$PRE_UPGRADE_CONTRACT_ADDR" "$msg" --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 100000000uluna --chain-id $CHAIN_ID --home $HOME --keyring-backend $KEYRING_BACKEND -y) | ||
tx=$(echo $res | jq -r ."txhash") | ||
code=$(echo $res | jq -r ."code") | ||
if [ "$code" != "0" ]; then | ||
echo "transfer message failed" | ||
exit -1 | ||
fi | ||
|
||
echo $res | ||
|
||
sleep 5 | ||
|
||
echo "SEND - BEFORE MIGRATION" | ||
msg=$(jq -n ' | ||
{ | ||
"send": { | ||
"amount": "1", | ||
"contract": "'$receiver'", | ||
"msg": "eyJ0ZXJtIjp7ImFtb3VudCI6IjEwMDAwMCJ9fQ==" | ||
} | ||
}') | ||
echo $msg | ||
res=$($BINARY tx wasm execute "$PRE_UPGRADE_CONTRACT_ADDR" "$msg" --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 100000000uluna --chain-id $CHAIN_ID --home $HOME --keyring-backend $KEYRING_BACKEND -y) | ||
tx=$(echo $res | jq -r ."txhash") | ||
code=$(echo $res | jq -r ."code") | ||
if [ "$code" != "0" ]; then | ||
echo "transfer message failed" | ||
exit -1 | ||
fi | ||
echo $res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/sh | ||
|
||
BINARY=_build/old/terrad | ||
CONTRACTPATH="scripts/wasm/contracts/old_anc_token.wasm" | ||
KEYRING_BACKEND="test" | ||
HOME=mytestnet | ||
CHAIN_ID=localterra | ||
|
||
# upload old contracts | ||
echo "... stores a wasm" | ||
addr=$($BINARY keys show test0 -a --home $HOME --keyring-backend $KEYRING_BACKEND) | ||
addr2=$($BINARY keys show test1 -a --home $HOME --keyring-backend $KEYRING_BACKEND) | ||
out=$($BINARY tx wasm store ${CONTRACTPATH} --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 100000000uluna --chain-id $CHAIN_ID --home $HOME --keyring-backend $KEYRING_BACKEND -y) | ||
code=$(echo $out | jq -r '.code') | ||
if [ "$code" != "0" ]; then | ||
echo "... Could not store binary" >&2 | ||
echo $out >&2 | ||
exit $code | ||
fi | ||
sleep 10 | ||
txhash=$(echo $out | jq -r '.txhash') | ||
id=$($BINARY q tx $txhash -o json | jq -r '.raw_log' | jq -r '.[0].events[1].attributes[1].value') | ||
echo "CODE = $id" | ||
echo "" | ||
|
||
# upload old contracts | ||
echo "... stores a second wasm" | ||
addr=$($BINARY keys show test0 -a --home $HOME --keyring-backend $KEYRING_BACKEND) | ||
addr2=$($BINARY keys show test1 -a --home $HOME --keyring-backend $KEYRING_BACKEND) | ||
out=$($BINARY tx wasm store ${CONTRACTPATH} --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 100000000uluna --chain-id $CHAIN_ID --home $HOME --keyring-backend $KEYRING_BACKEND -y) | ||
code=$(echo $out | jq -r '.code') | ||
if [ "$code" != "0" ]; then | ||
echo "... Could not store binary" >&2 | ||
echo $out >&2 | ||
exit $code | ||
fi | ||
sleep 10 | ||
txhash=$(echo $out | jq -r '.txhash') | ||
# commented out on purpose | ||
# we wanna use the first id to instantiate | ||
# a contract from | ||
# id=$($BINARY q tx $txhash -o json | jq -r '.raw_log' | jq -r '.[0].events[1].attributes[1].value') | ||
echo "CODE = $id" | ||
echo "" | ||
|
||
# instantiates contract | ||
echo "... instantiates contract" | ||
msg=$(jq -n ' | ||
{ | ||
"decimals":8, | ||
"initial_balances":[ | ||
{ | ||
"address":"'$addr'", | ||
"amount":"1000000000" | ||
} | ||
], | ||
"name":"Anchor Token", | ||
"symbol":"ANC" | ||
}') | ||
echo $msg | ||
out=$($BINARY tx wasm instantiate $id "$msg" --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 20000000uluna --chain-id $CHAIN_ID --home $HOME --keyring-backend $KEYRING_BACKEND -y) | ||
code=$(echo $out | jq -r '.code') | ||
if [ "$code" != "0" ]; then | ||
echo "... Could not instantiate contract" >&2 | ||
echo $out >&2 | ||
exit $code | ||
fi | ||
sleep 10 | ||
txhash=$(echo $out | jq -r '.txhash') | ||
|
||
PRE_UPGRADE_CONTRACT_ADDR=$($BINARY q tx $txhash -o json | jq -r '.raw_log' | jq -r '.[0].events[0].attributes[3].value') | ||
export PRE_UPGRADE_CONTRACT_ADDR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
ADDITIONAL_PRE_SCRIPTS=scripts/wasm/wasm-deploy.sh bash scripts/upgrade-test.sh | ||
ADDITIONAL_PRE_SCRIPTS=scripts/wasm/token-migration.sh ADDITIONAL_AFTER_SCRIPTS=scripts/wasm/token-migration-after.sh bash scripts/upgrade-test.sh | ||
ADDITIONAL_PRE_SCRIPTS=scripts/wasm/wasm-deploy.sh ADDITIONAL_AFTER_SCRIPTS=scripts/wasm/wasm-tx-check.sh bash scripts/upgrade-test.sh | ||
./_build/new/terrad tx wasm execute terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 '{"mint":{"token_id":"'4'","owner":"'terra1p20jxrllewr5meecvhtmpddexr0kkz3tdename'"}}' --from test0 --output json --gas auto --gas-adjustment 2.3 --fees 20000000uluna --chain-id test --home mytestnet --keyring-backend test -y | ||
./_build/new/terrad q wasm contract-state smart terra18vd8fpwxzck93qlwghaj6arh4p7c5n896xzem5 '{"all_tokens":{}}' --chain-id test --home mytestnet |