forked from paritytech/polkadot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprepare-test-net.sh
executable file
·45 lines (36 loc) · 1.23 KB
/
prepare-test-net.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
#!/usr/bin/env bash
set -e
if [ "$#" -ne 1 ]; then
echo "Please provide the number of initial validators!"
exit 1
fi
generate_account_id() {
subkey ${3:-} inspect "$SECRET//$1//$2" | grep "Account ID" | awk '{ print $3 }'
}
generate_address() {
subkey ${3:-} inspect "$SECRET//$1//$2" | grep "SS58 Address" | awk '{ print $3 }'
}
generate_address_and_account_id() {
ACCOUNT=$(generate_account_id $1 $2 $3)
ADDRESS=$(generate_address $1 $2 $3)
if ${4:-false}; then
INTO="unchecked_into"
else
INTO="into"
fi
printf "//$ADDRESS\nhex![\"${ACCOUNT#'0x'}\"].$INTO(),"
}
V_NUM=$1
AUTHORITIES=""
for i in $(seq 1 $V_NUM); do
AUTHORITIES+="(\n"
AUTHORITIES+="$(generate_address_and_account_id $i stash)\n"
AUTHORITIES+="$(generate_address_and_account_id $i controller)\n"
AUTHORITIES+="$(generate_address_and_account_id $i babe '--sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i grandpa '--ed25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i im_online '--sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i parachains '--sr25519' true)\n"
AUTHORITIES+="$(generate_address_and_account_id $i authority_discovery '--sr25519' true)\n"
AUTHORITIES+="),\n"
done
printf "$AUTHORITIES"