-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-proxies.sh
executable file
·86 lines (76 loc) · 4.2 KB
/
setup-proxies.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
79
80
81
82
83
84
85
86
#!/bin/bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
# Description: instantiate proxies and migrate ics721 with proxies
for ENV in "osmosis" "stargaze"; do
echo "================================================================"
echo "reading $SCRIPT_DIR/$ENV.env"
source $SCRIPT_DIR/$ENV.env
echo "============ instantiating incoming proxy"
MSG="'{\"origin\": \"$ADDR_ICS721\", \"channels\": [\"$CHANNEL_ID\"]}'"
CMD="$CLI tx wasm instantiate $CODE_ID_INCOMING_PROXY "$MSG" --from $WALLET_ARKITE_PASSPORT --label 'ICS721 Incoming Proxy (powered by Ark)' --admin $WALLET_ARKITE_PASSPORT --gas-prices $CLI_GAS_PRICES --gas $CLI_GAS --gas-adjustment $CLI_GAS_ADJUSTMENT -b $CLI_BROADCAST_MODE --yes --node $CHAIN_NODE --chain-id $CHAIN_ID --output $CLI_OUTPUT"
echo "executing cmd: $CMD" >&2
OUTPUT=$(eval $CMD)
EXIT_CODE=$?
if [ $EXIT_CODE != 0 ]; then
exit "$EXIT_CODE"
fi
TX_HASH=$(echo $OUTPUT | jq -r ".txhash")
echo "TX_HASH: $TX_HASH"
sleep 10
QUERY_OUTPUT=$($CLI q tx $TX_HASH --chain-id $CHAIN_ID --node $CHAIN_NODE --output json)
echo "============ Updating ADDR_INCOMING_PROXY in config"
ADDR_INCOMING_PROXY=$(echo $QUERY_OUTPUT | jq '.events[] | select(.type == "instantiate") | .attributes[] | select(.key =="_contract_address")' | jq -r '.value') &>/dev/null
if [ -z "$ADDR_INCOMING_PROXY" ]; then
echo "Failed to get ADDR_INCOMING_PROXY from tx $TX_HASH"
exit 1
fi
# remove the extra quotes around it ""1234""
ADDR_INCOMING_PROXY=$(echo "$ADDR_INCOMING_PROXY" | sed 's/"//g')
echo "ADDR_INCOMING_PROXY: $ADDR_INCOMING_PROXY"
CMD="sed -i \"s@export ADDR_INCOMING_PROXY.*@export ADDR_INCOMING_PROXY=\\\"$ADDR_INCOMING_PROXY\\\"@\" $SCRIPT_DIR/$ENV.env"
echo $CMD
eval $CMD
echo "============ instantiating outgoing proxy"
MSG="'{\"origin\": \"$ADDR_ICS721\", \"rate_limit\": {\"per_block\": 1}}'"
CMD="$CLI tx wasm instantiate $CODE_ID_OUTGOING_PROXY "$MSG" --from $WALLET_ARKITE_PASSPORT --label 'ICS721 Outgoing Proxy (powered by Ark)' --admin $WALLET_ARKITE_PASSPORT --gas-prices $CLI_GAS_PRICES --gas $CLI_GAS --gas-adjustment $CLI_GAS_ADJUSTMENT -b $CLI_BROADCAST_MODE --yes --node $CHAIN_NODE --chain-id $CHAIN_ID --output $CLI_OUTPUT"
echo "executing cmd: $CMD" >&2
OUTPUT=$(eval $CMD)
EXIT_CODE=$?
if [ $EXIT_CODE != 0 ]; then
exit "$EXIT_CODE"
fi
TX_HASH=$(echo $OUTPUT | jq -r ".txhash")
echo "TX_HASH: $TX_HASH"
sleep 10
QUERY_OUTPUT=$($CLI q tx $TX_HASH --chain-id $CHAIN_ID --node $CHAIN_NODE --output json)
echo "============ Updating ADDR_OUTGOING_PROXY in config"
ADDR_OUTGOING_PROXY=$(echo $QUERY_OUTPUT | jq '.events[] | select(.type == "instantiate") | .attributes[] | select(.key =="_contract_address")' | jq -r '.value') &>/dev/null
if [ -z "$ADDR_OUTGOING_PROXY" ]; then
echo "Failed to get ADDR_OUTGOING_PROXY from tx $TX_HASH"
exit 1
fi
# remove the extra quotes around it ""1234""
ADDR_OUTGOING_PROXY=$(echo "$ADDR_OUTGOING_PROXY" | sed 's/"//g')
echo "ADDR_OUTGOING_PROXY: $ADDR_OUTGOING_PROXY"
CMD="sed -i \"s@export ADDR_OUTGOING_PROXY.*@export ADDR_OUTGOING_PROXY=\\\"$ADDR_OUTGOING_PROXY\\\"@\" $SCRIPT_DIR/$ENV.env"
echo $CMD
eval $CMD
echo "============ migrating ics721 with proxies, wallet ($ADDR_ARKITE_PASSPORT) as pauser and arkite contract ($ADDR_ARKITE_PASSPORT) as cw721_admin"
MSG="'{\"with_update\":{
\"incoming_proxy\": \"$ADDR_INCOMING_PROXY\",
\"outgoing_proxy\": \"$ADDR_OUTGOING_PROXY\",
\"cw721_base_code_id\": $CODE_ID_CW721,
\"pauser\": \"$WALLET_ARKITE_PASSPORT\",
\"cw721_admin\": \"$WALLET_ARKITE_PASSPORT\",
\"cw721_creator\": \"$ADDR_ARKITE_PASSPORT\"
}}'"
CMD="$CLI tx wasm migrate $ADDR_ICS721 $CODE_ID_ICS721 "$MSG" --from $WALLET_ARKITE_PASSPORT --gas-prices $CLI_GAS_PRICES --gas $CLI_GAS --gas-adjustment $CLI_GAS_ADJUSTMENT -b $CLI_BROADCAST_MODE --yes --node $CHAIN_NODE --chain-id $CHAIN_ID --output $CLI_OUTPUT"
echo "executing cmd: $CMD" >&2
OUTPUT=$(eval $CMD)
EXIT_CODE=$?
if [ $EXIT_CODE != 0 ]; then
exit "$EXIT_CODE"
fi
TX_HASH=$(echo $OUTPUT | jq -r ".txhash")
echo "TX_HASH: $TX_HASH"
done