forked from ghostchain/ghost-node
preparation script get data from ghosties file and create rust template code
Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
parent
7a4a50d588
commit
50ed40b9be
@ -1,48 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Please provide the number of initial validators!"
|
||||
exit 1
|
||||
fi
|
||||
current_path=$(pwd)
|
||||
current_script=$(realpath "$0")
|
||||
script_folder=$(dirname "$current_script")
|
||||
project_folder=("$script_folder/..")
|
||||
|
||||
generate_account_id() {
|
||||
./target/release/ghostkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "Account ID" | awk '{ print $3 }'
|
||||
}
|
||||
|
||||
generate_address() {
|
||||
./target/release/ghostkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "SS58 Address" | awk '{ print $3 }'
|
||||
}
|
||||
|
||||
generate_public_key() {
|
||||
./target/release/ghostkey inspect ${3:-} ${4:-} "$SECRET//$1//$2" | grep "Public key (hex)" | awk '{ print $4 }'
|
||||
}
|
||||
|
||||
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 '--scheme sr25519' true)\n"
|
||||
AUTHORITIES+="$(generate_address_and_account_id $i grandpa '--scheme ed25519' true)\n"
|
||||
AUTHORITIES+="$(generate_address_and_account_id $i authority_discovery '--scheme sr25519' true)\n"
|
||||
AUTHORITIES+="$(generate_address_and_account_id $i slow_clap '--scheme sr25519' true)\n"
|
||||
AUTHORITIES+="),\n"
|
||||
num_ghosties=$(grep "Local identity" $project_folder/service/ghosties | wc -l)
|
||||
echo "let endowed_accounts = vec!["
|
||||
for num in $(seq 2 $num_ghosties); do
|
||||
account_id=$(grep -m $num "wallet" $project_folder/service/ghosties | tail -n 1 | awk '{ print $6 }')
|
||||
public_key=$(ghost key inspect $account_id --public | grep "SS58 Address" | awk '{ print $3 }')
|
||||
echo -e "\t// $public_key"
|
||||
echo -e "\thex![\"${account_id:2}\"].into();"
|
||||
done
|
||||
echo "];"
|
||||
echo -e "\n"
|
||||
|
||||
printf "$AUTHORITIES"
|
||||
print_session_key() {
|
||||
echo -e "\t\t// $1"
|
||||
echo -e "\t\thex![\"$2\"].$3(),"
|
||||
}
|
||||
|
||||
echo "let initial_authorities: Vec<("
|
||||
echo -e "\tAccountId,"
|
||||
echo -e "\tAccountId,"
|
||||
echo -e "\tBabeId,"
|
||||
echo -e "\tGrandpaId,"
|
||||
echo -e "\tAuthorityDiscoveryId,"
|
||||
echo -e "\tSlowClapId,"
|
||||
echo ")> = vec!["
|
||||
for num in $(seq 2 $num_ghosties); do
|
||||
echo -e "\t("
|
||||
for key_word in $(echo stash stash babe gran audi slow); do
|
||||
account_id=$(grep -m $num $key_word $project_folder/service/ghosties | tail -n 1 | awk '{ print $7 }')
|
||||
public_key=$(ghost key inspect $account_id --public | grep "SS58 Address" | awk '{ print $3 }')
|
||||
postfix="unchecked_into"
|
||||
if [ $key_word = "stash" ]; then
|
||||
postfix="into"
|
||||
fi
|
||||
print_session_key $public_key $account_id $postfix
|
||||
done
|
||||
echo -e "\t),"
|
||||
done
|
||||
echo "];"
|
||||
|
Loading…
Reference in New Issue
Block a user