forked from neutron-org/neutron-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_kv_query_result.sh
executable file
·36 lines (27 loc) · 1.86 KB
/
test_kv_query_result.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
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
# Register a query for KEY_2 balance
RES=$(${BIN} tx wasm execute $QUERIES_CONTRACT_ADDRESS "{\"register_balance_query\": {\"connection_id\": \"connection-0\", \"denom\": \"stake\", \"addr\": \"${KEY_2}\", \"update_period\": 5, \"zone_id\": \"${CHAIN_ID_2}\"}}" --from ${USERNAME_1} -y --chain-id ${CHAIN_ID_1} --output json --broadcast-mode=block --gas-prices 0.0025stake --gas 1000000 --keyring-backend test --home ${HOME_1} --node tcp://127.0.0.1:16657)
echo $RES