Skip to content

Commit

Permalink
Merge pull request #5 from ignite/feat/import-ignite-account-script
Browse files Browse the repository at this point in the history
feat:  add a script to import network keys to Ignite accounts
  • Loading branch information
Pantani authored Nov 30, 2024
2 parents 0a82c3e + 144e5ea commit abdbe5d
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions localnet/keys.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

# This script imports all account keys from the specified YAML configuration file
# into Ignite accounts using the provided names and mnemonics.

# Path to the YAML configuration file
YAML_FILE="config.yml"

# Check if 'yq' is installed, which is required for parsing the YAML file
if ! command -v yq &> /dev/null
then
echo "The 'yq' command-line tool is required to run this script."
echo "You can install it with 'brew install yq' (on macOS) or see https://github.com/mikefarah/yq for other options."
exit 1
fi

# Loop through each account entry in the YAML file
for index in $(yq eval '.accounts | keys' "$YAML_FILE" -o=json | jq '.[]'); do
# Extract the account's name and mnemonic based on the current index
NAME=$(yq eval ".accounts[$index].name" "$YAML_FILE")
MNEMONIC=$(yq eval ".accounts[$index].mnemonic" "$YAML_FILE")

# Run the import command for each account
echo "Importing account: $NAME"
ignite a import "$NAME" --secret "$MNEMONIC"
done

0 comments on commit abdbe5d

Please sign in to comment.