generated from dgabriele/cw-contract-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.sh
executable file
·78 lines (67 loc) · 1.47 KB
/
client.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
74
75
76
77
78
#!/bin/bash
CMD=$1
NETWORK=$2
NODE=
CHAIN_ID=
FLAGS=
TAG=$3
if [ -z "$TAG" ]; then
TAG=$(cat ./builds/latest)
fi
CONTRACT_ADDR=$(cat ./builds/build-$TAG/latest-contract)
shift 3
case $NETWORK in
testnet)
NODE="https://rpc.uni.juno.deuslabs.fi:443"
CHAIN_ID=uni-3
DENOM=ujunox
;;
mainnet)
NODE="https://juno.kingnodes.com:443"
CHAIN_ID=juno-1
DENOM=ujuno
;;
devnet)
NODE="http://localhost:26657"
CHAIN_ID=testing
DENOM=ujunox
;;
esac
transfer-ownership() {
sender=$1
msg='{"transfer_ownership":{}}'
flags="\
--node $NODE \
--gas-prices 0.025$DENOM \
--chain-id $CHAIN_ID \
--from $sender \
--gas auto \
--gas-adjustment 1.5 \
--broadcast-mode block \
--output json \
-y \
"
echo junod tx wasm execute $CONTRACT_ADDR "$msg" "$flags"
response=$(junod tx wasm execute "$CONTRACT_ADDR" "$msg" $flags)
echo $response | ./bin/utils/base64-decode-attributes | jq
}
query-select() {
query='{"select":{"fields":null}}'
flags="--chain-id $CHAIN_ID --output json --node $NODE"
echo junod query wasm contract-state smart $CONTRACT_ADDR "$query" $flags
response=$(junod query wasm contract-state smart $CONTRACT_ADDR "$query" $flags)
echo $response | ./bin/utils/base64-decode-attributes | jq
}
set -e
echo "executing $CMD for $CONTRACT_ADDR"
case $CMD in
transfer-ownership)
transfer-ownership $1
;;
query-select)
query-select
;;
*)
echo "unrecognized option: $CMD" >&2
exit -1
esac