Skip to content

Instantly share code, notes, and snippets.

@ChewingGlass
Last active December 18, 2024 18:46
Show Gist options
  • Select an option

  • Save ChewingGlass/c27e9bad70337aa87b7fc16bf4946435 to your computer and use it in GitHub Desktop.

Select an option

Save ChewingGlass/c27e9bad70337aa87b7fc16bf4946435 to your computer and use it in GitHub Desktop.
Verify all anchor programs
#!/bin/bash
# Function to verify a single program
verify_program() {
local program_dir=$1
local max_attempts=5
local attempt=1
# Get the base name and convert hyphens to underscores
library_name=$(basename "$program_dir" | tr '-' '_')
# Get the program ID from Anchor.toml
program_id=$(toml get Anchor.toml programs.localnet.$library_name | tr -d '"')
# Skip if program ID is empty
[ -z "$program_id" ] && return
# Get the last commit SHA that modified this program directory or any of its contents
commit_hash=$(git log -1 --pretty=format:%H "$program_dir")
# Check if commit hash exists
if [ -z "$commit_hash" ]; then
echo "Error: No commits found for $program_dir"
return 1
fi
echo "Verifying $library_name with program ID $program_id"
echo "Using commit: $commit_hash"
while [ $attempt -le $max_attempts ]; do
if solana-verify verify-from-repo \
https://github.com/helium/helium-program-library \
--program-id "$program_id" \
--remote \
--commit-hash "$commit_hash" \
--library-name "$library_name" \
-b solanafoundation/solana-verifiable-build:1.16.13; then
return 0
fi
echo "Attempt $attempt failed. Retrying in 10 seconds..."
sleep 10
attempt=$((attempt + 1))
done
echo "Error: Verification failed after $max_attempts attempts"
return 1
}
# Check if a specific program was provided
if [ $# -eq 1 ]; then
program_dir="programs/$1"
if [ -d "$program_dir" ]; then
verify_program "$program_dir"
else
echo "Error: Program directory '$program_dir' not found"
exit 1
fi
else
# Iterate through each directory in programs/
for program_dir in programs/*/; do
verify_program "$program_dir"
done
fi
@ngundotra
Copy link
Copy Markdown

are all these programs managed by squads instances?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment