Skip to content

Commit 02c00c7

Browse files
committed
Modify relay.sh to work with refactored architecture
1 parent c4dcbb8 commit 02c00c7

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

e2edemo/relay.sh

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,54 @@ else
4040
fi
4141
DST_OPTIONS=$(cat ${CHAIN_CONFIG} | jq -r '.chains.'${DST}'.options // empty')
4242

43+
SRC_NETWORK_NAME=$(echo ${SRC_NETWORK} | cut -d. -f2)
44+
DST_NETWORK_NAME=$(echo ${DST_NETWORK} | cut -d. -f2)
45+
# Assume src is always an ICON chain
46+
if [ $SRC_NETWORK_NAME != icon ]; then
47+
echo "Source network is not an ICON-compatible chain: $SRC_NETWORK_NAME"
48+
exit 1
49+
fi
50+
# Determine src type
4351
if [ "x$BMV_BRIDGE" = xtrue ]; then
4452
echo "Using Bridge mode"
53+
SRC_TYPE="icon-bridge"
4554
else
4655
echo "Using BTPBlock mode"
47-
BMV_BRIDGE=false
56+
SRC_TYPE="icon-btpblock"
57+
fi
58+
# Determine dst type
59+
if [ $DST_NETWORK_NAME == icon ]; then
60+
DST_TYPE="icon-btpblock"
61+
else
62+
DST_TYPE="eth2-v2.0"
4863
fi
4964

65+
get_config() {
66+
if [ $# -gt 5 -a ${#6} -gt 0 ]; then
67+
echo '{
68+
"address": "'$1'",
69+
"endpoint": "'$2'",
70+
"key_store": "'$3'",
71+
"key_password": "'$4'",
72+
"type": "'$5'",
73+
"options": '$6'
74+
}' | tr -d [:space:]
75+
else
76+
echo '{
77+
"address": "'$1'",
78+
"endpoint": "'$2'",
79+
"key_store": "'$3'",
80+
"key_password": "'$4'",
81+
"type": "'$5'"
82+
}' | tr -d [:space:]
83+
fi
84+
}
85+
SRC_CONFIG=$(get_config "$SRC_ADDRESS" "$SRC_ENDPOINT" "$SRC_KEY_STORE" "$SRC_KEY_PASSWORD" "$SRC_TYPE" "$SRC_OPTIONS")
86+
DST_CONFIG=$(get_config "$DST_ADDRESS" "$DST_ENDPOINT" "$DST_KEY_STORE" "$DST_KEY_PASSWORD" "$DST_TYPE" "$DST_OPTIONS")
87+
5088
${RELAY_BIN} \
89+
--base_dir .relay \
5190
--direction both \
52-
--src.address ${SRC_ADDRESS} \
53-
--src.endpoint ${SRC_ENDPOINT} \
54-
--src.key_store ${SRC_KEY_STORE} \
55-
--src.key_password ${SRC_KEY_PASSWORD} \
56-
--src.bridge_mode=${BMV_BRIDGE} \
57-
${SRC_OPTIONS:+--dst.options $SRC_OPTIONS} \
58-
--dst.address ${DST_ADDRESS} \
59-
--dst.endpoint ${DST_ENDPOINT} \
60-
--dst.key_store ${DST_KEY_STORE} \
61-
--dst.key_password ${DST_KEY_PASSWORD} \
62-
${DST_OPTIONS:+--dst.options $DST_OPTIONS} \
91+
--src_config ${SRC_CONFIG} \
92+
--dst_config ${DST_CONFIG} \
6393
start

0 commit comments

Comments
 (0)