Skip to content

Commit 144e5ea

Browse files
committed
import. ignite keys script
1 parent 0a82c3e commit 144e5ea

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

localnet/keys.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# This script imports all account keys from the specified YAML configuration file
4+
# into Ignite accounts using the provided names and mnemonics.
5+
6+
# Path to the YAML configuration file
7+
YAML_FILE="config.yml"
8+
9+
# Check if 'yq' is installed, which is required for parsing the YAML file
10+
if ! command -v yq &> /dev/null
11+
then
12+
echo "The 'yq' command-line tool is required to run this script."
13+
echo "You can install it with 'brew install yq' (on macOS) or see https://github.com/mikefarah/yq for other options."
14+
exit 1
15+
fi
16+
17+
# Loop through each account entry in the YAML file
18+
for index in $(yq eval '.accounts | keys' "$YAML_FILE" -o=json | jq '.[]'); do
19+
# Extract the account's name and mnemonic based on the current index
20+
NAME=$(yq eval ".accounts[$index].name" "$YAML_FILE")
21+
MNEMONIC=$(yq eval ".accounts[$index].mnemonic" "$YAML_FILE")
22+
23+
# Run the import command for each account
24+
echo "Importing account: $NAME"
25+
ignite a import "$NAME" --secret "$MNEMONIC"
26+
done

0 commit comments

Comments
 (0)