forked from informalsystems/hermes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
init-hermes
executable file
·76 lines (58 loc) · 2.29 KB
/
init-hermes
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
#!/bin/bash -e
# Initialize the light clients in the relayer configuration.
usage() {
echo "Usage: $0 CONFIG_FILE CHAIN_0_ID CHAIN_1_ID [CHAIN_2_ID]"
echo "Example: $0 ./config.toml ibc-0 ibc-1 ibc-2"
exit 1
}
missing() {
echo "Missing $1 parameter. Please check if all parameters were specified."
usage
}
if [ -z "$1" ]; then
missing "CONFIG_FILE"
fi
if [ -z "$2" ]; then
missing "CHAIN_0_ID"
fi
if [ -z "$3" ]; then
missing "CHAIN_1_ID"
fi
if [ "$#" -gt 4 ]; then
echo "Incorrect number of parameters."
usage
fi
CONFIG_FILE="$1"
CHAIN_0_ID="$2"
CHAIN_1_ID="$3"
CHAIN_2_ID="$4"
if ! [ -f "$CONFIG_FILE" ]; then
echo "[CONFIG_FILE] ($1) does not exist or is not a file."
usage
fi
if ! grep -q -s "$CHAIN_0_ID" "$CONFIG_FILE"; then
echo "error: configuration for chain [$CHAIN_0_ID] does not exist in file $CONFIG_FILE."
usage
fi
if ! grep -q -s "$CHAIN_1_ID" "$CONFIG_FILE"; then
echo "error: configuration for chain [$CHAIN_1_ID] does not exist in file $CONFIG_FILE."
usage
fi
if [ -n "$CHAIN_2_ID" ] && ! grep -q -s "$CHAIN_2_ID" "$CONFIG_FILE"; then
echo "error: configuration for chain [$CHAIN_2_ID] does not exist in file $CONFIG_FILE."
usage
fi
GAIA_DATA="$(pwd)/data"
echo "Building the Rust relayer..."
cargo build -q --locked
# add the key seeds to the keyring of each chain
echo "Importing keys..."
cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_0_ID" --key-file "$GAIA_DATA/$CHAIN_0_ID/user_seed.json" --overwrite
cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_0_ID" --key-file "$GAIA_DATA/$CHAIN_0_ID/user2_seed.json" --key-name user2 --overwrite
cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_1_ID" --key-file "$GAIA_DATA/$CHAIN_1_ID/user2_seed.json" --key-name user2 --overwrite
cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_1_ID" --key-file "$GAIA_DATA/$CHAIN_1_ID/user_seed.json" --overwrite
if [ -n "$CHAIN_2_ID" ]; then
cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_2_ID" --key-file "$GAIA_DATA/$CHAIN_2_ID/user_seed.json" --overwrite
cargo run -q --bin hermes -- --config "$CONFIG_FILE" keys add --chain "$CHAIN_2_ID" --key-file "$GAIA_DATA/$CHAIN_2_ID/user2_seed.json" --key-name user2 --overwrite
fi
echo "Done!"