-
Notifications
You must be signed in to change notification settings - Fork 5
/
gov.sh
executable file
·73 lines (58 loc) · 2.71 KB
/
gov.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
BIN=neutrond
CONTRACT=./artifacts/neutron_interchain_queries.wasm
CHAIN_ID_1=test-1
CHAIN_ID_2=test-2
NEUTRON_DIR=${NEUTRON_DIR:-../neutron}
HOME_1=${NEUTRON_DIR}/data/test-1/
HOME_2=${NEUTRON_DIR}/data/test-2/
USERNAME_1=demowallet1
USERNAME_2=demowallet2
KEY_2=$(neutrond keys show demowallet2 -a --keyring-backend test --home ${HOME_2})
ADMIN=$(neutrond keys show demowallet1 -a --keyring-backend test --home ${HOME_1})
TARGET_ADDRESS=neutron1mjk79fjjgpplak5wq838w0yd982gzkyf8fxu8u
VAL2=neutronvaloper1qnk2n4nlkpw9xfqntladh74w6ujtulwnqshepx
# Upload the queries contract
RES=$(${BIN} tx wasm store ${CONTRACT} --from ${USERNAME_1} --gas 50000000 --chain-id ${CHAIN_ID_1} --broadcast-mode=block --gas-prices 0.0025stake -y --output json --keyring-backend test --home ${HOME_1} --node tcp://127.0.0.1:16657)
QUERIES_CONTRACT_CODE_ID=$(echo $RES | jq -r '.logs[0].events[1].attributes[0].value')
echo $RES
echo $QUERIES_CONTRACT_CODE_ID
# Instantiate the queries contract
INIT_QUERIES_CONTRACT='{}'
RES=$(${BIN} tx wasm instantiate $QUERIES_CONTRACT_CODE_ID "$INIT_QUERIES_CONTRACT" --from ${USERNAME_1} --admin ${ADMIN} -y --chain-id ${CHAIN_ID_1} --output json --broadcast-mode=block --label "init" --keyring-backend test --gas-prices 0.0025stake --home ${HOME_1} --node tcp://127.0.0.1:16657)
echo $RES
QUERIES_CONTRACT_ADDRESS=$(echo $RES | jq -r '.logs[0].events[0].attributes[0].value')
echo $QUERIES_CONTRACT_ADDRESS
# PRINT contract old info (should have admin set)
# Register new proposal
# json formatted proposal is a nightmare, so we use keys for now
RES=$(${BIN} tx gov submit-proposal clear-contract-admin ${QUERIES_CONTRACT_ADDRESS} --title="clear contract admin" \
--description="ssss" \
--type="Text" \
--deposit="100000000stake" \
--from ${USERNAME_1} \
--gas 500000 \
--fees 5000stake \
-y \
--chain-id ${CHAIN_ID_1} \
--broadcast-mode=block \
--home ${HOME_1} \
--keyring-backend test \
--node tcp://127.0.0.1:16657)
echo $RES
echo
# print proposal in console, voting period should be active
RES=$(${BIN} q gov proposals --chain-id ${CHAIN_ID_1} --home ${HOME_1} --node tcp://127.0.0.1:16657)
echo $RES
echo
# vote yes (w dominance of votes)
RES=$(${BIN} tx gov vote 1 yes --from val1 --fees 5000stake --chain-id ${CHAIN_ID_1} -y --broadcast-mode=block --home ${HOME_1} --keyring-backend test --node tcp://127.0.0.1:16657)
echo $RES
echo
# wait voting period to end
sleep 20
# Is proposal passed?
RES=$(${BIN} query gov proposal 1 --chain-id ${CHAIN_ID_1} --home ${HOME_1} --node tcp://127.0.0.1:16657)
echo $RES
# Print new contract info (should have admin empty)
RES=$(${BIN} query wasm contract ${QUERIES_CONTRACT_ADDRESS} --chain-id ${CHAIN_ID_1} --home ${HOME_1} --node tcp://127.0.0.1:16657)
echo $RES