#!/usr/bin/env bash # file: scripts/devnet/load_spl_fixture.sh # version: 2 family="${1:-token-2022}" workspace="${KB_WORKSPACE_ROOT:-$(pwd)}" wallet_dir="${KB_DEVNET_WALLET_DIR:-$workspace/wallets/temporary/local_devnet}" case "$family" in token-2022) fixture="$wallet_dir/spl_token_2022_validation/fixture.env"; prefix='TOKEN_2022' ;; classic) fixture="$wallet_dir/spl_token_classic_validation/fixture.env"; prefix='TOKEN_CLASSIC' ;; *) printf 'Usage: source %s token-2022|classic\n' "${BASH_SOURCE[0]}" >&2; return 64 2>/dev/null || exit 64 ;; esac test -f "$fixture" # shellcheck disable=SC1090 source "$fixture" program_var="${prefix}_PROGRAM"; mint_var="${prefix}_MINT"; source_var="${prefix}_SOURCE"; destination_var="${prefix}_DESTINATION"; delegate_var="${prefix}_DELEGATE"; close_var="${prefix}_CLOSE_ACCOUNT"; ata_var="${prefix}_ATA" program="${!program_var}"; mint="${!mint_var}"; source_account="${!source_var}"; destination="${!destination_var}"; delegate="${!delegate_var}"; close_account="${!close_var}"; ata="${!ata_var}" for value in "$program" "$mint" "$source_account" "$destination" "$delegate" "$close_account" "$ata"; do [[ "$value" =~ ^[1-9A-HJ-NP-Za-km-z]{32,44}$ ]] || { printf 'Adresse Base58 invalide: %s\n' "$value" >&2; return 65 2>/dev/null || exit 65; } done printf 'Fixture: %s\nWallet: %s\nProgram: %s\nMint: %s\nSource: %s\nDestination: %s\nDelegate: %s\nClose account: %s\nATA: %s\n' "$fixture" "$KB_DEVNET_WALLET_ADDRESS" "$program" "$mint" "$source_account" "$destination" "$delegate" "$close_account" "$ata" spl-token --url devnet --program-id "$program" display "$mint" | sed -n '1,8p' spl-token --url devnet --program-id "$program" display "$source_account" | sed -n '1,12p' spl-token --url devnet --program-id "$program" display "$destination" | sed -n '1,12p' spl-token --url devnet --program-id "$program" display "$close_account" | sed -n '1,12p'