Skip to content

Commit abdbe5d

Browse files
authored
Merge pull request #5 from ignite/feat/import-ignite-account-script
feat: add a script to import network keys to Ignite accounts
2 parents 0a82c3e + 144e5ea commit abdbe5d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

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)