#!/usr/bin/env bash
set -euo pipefail
#
# RU: Подбирает vanity mint keypair через `solana-keygen grind`.
#     Параметры: [PREFIX] [COUNT] [ignore-case]
# EN: Finds vanity mint keypair using `solana-keygen grind`.
#     Args: [PREFIX] [COUNT] [ignore-case]

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_PATH="$SCRIPT_DIR/governance_token.config.env"
PREFIX="${1:-}"
COUNT="${2:-1}"
IGNORE_CASE="${3:-}"

if [[ -n "$PREFIX" ]]; then
  node "$SCRIPT_DIR/js/grind_vanity_mint_exec.js" "$CONFIG_PATH" "$PREFIX" "$COUNT" "$IGNORE_CASE"
else
  node "$SCRIPT_DIR/js/grind_vanity_mint_exec.js" "$CONFIG_PATH"
fi
