-
Notifications
You must be signed in to change notification settings - Fork 13
fix(zhltc): zhltc activation fixes #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
75b139f
chore(release): v1.0.0-pre.1 #27 Merge pull request #27 from KomodoPl…
CharlVS e86e8bc
Enhance ZHTLC activation with improved config parsing and RPC methods
cursoragent d34b6eb
feat(zhtlc): integrate ZHTLC types and task RPCs per KDF API
CharlVS 152b189
dragon_logs: remove tracked ignored files and add .gitignore files
CharlVS e61dc52
Integrate and verify ZHTLC in komodo_defi_sdk (#196)
CharlVS e2b7280
Merge branch 'dev' of https://github.com/KomodoPlatform/komodo-defi-s…
CharlVS cfa70b2
chore: run code generators
CharlVS 0589076
chore(git): delete previously tracked igored files
CharlVS defcc99
Fix ERC20 and ZHTLC activation params serialization and method calls …
CharlVS e03a963
fix: misc fixes
CharlVS 6b357e7
docs(activation): add activation params refactoring plan
CharlVS 0055d7a
docs(sdk): activation refactoring v2
CharlVS 56be9b9
feat(activation,zhtlc,sdk,rpc)!: extract ZHTLC fields to ZhtlcActivat…
CharlVS dc0ab9e
Merge branch 'dev' into cursor/integrate-zhtlc-types-and-rpcs-4654
takenagain 1c277dd
Checkpoint before follow-up message
cursoragent 66c84aa
Fix: Remove unused import statement
cursoragent 5df30e7
feat: Add support for electrum_servers in Zhtlc activation
cursoragent d94e383
feat: initialize Firebase hosting for SDK example and playground
CharlVS b0594fa
fix: update z-coin activation strategy and example UI
CharlVS a026b1c
docs(firebase): reorganize Firebase deployment scripts and documentation
CharlVS f230132
fix: remove global singleton registration of ActivationConfigService
CharlVS 99667b2
Merge branch 'dev' of https://github.com/KomodoPlatform/komodo-defi-s…
CharlVS 9d08169
fix(activation): register ActivationConfigService during bootstrap
CharlVS ebc0aab
docs(tech-debt): add Activation & ZHTLC tech-debt report and refine s…
CharlVS d3dd099
feat(komodo_defi_sdk): add HiveActivationConfigRepository and integra…
CharlVS 840df13
merge: integrate cursor/integrate-zhtlc-types-and-rpcs-4654 [[memory:…
CharlVS 4152626
fix: resolve external logging callback flaws and memory leak
CharlVS 509bced
refactor(withdrawals): inject LegacyWithdrawalManager and use for Ten…
CharlVS 094b1c7
fix(kdf-ops): use conditional imports for platform-specific imports
takenagain 9e1f5f3
fix(activation-params): include other RPC server keys
takenagain 31310c6
fix(activation-config-repository): register adapter type
takenagain 0d6b12c
feat(zhtlc): add desktop zcash params downloader (#228)
takenagain 8626160
feat(zhtlc): web lightwallet server URLs workaround
takenagain ec445d3
fix(zhtlc): align orderbook RPC with KDF schema, and add id paginatio…
takenagain e6e924c
fix(address-select-input): use consistent text theme to fix visibility
takenagain 1af4278
feat(zhtlc): estimate activation percentage based on block height (#230)
takenagain aff12a8
Fix ZHTLC activation issues and improve resilience
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # Firebase GitHub Secrets Scripts | ||
|
|
||
| This directory contains scripts for managing Firebase service account secrets used by GitHub Actions workflows. | ||
|
|
||
| ## Scripts | ||
|
|
||
| ### setup-github-secrets.sh | ||
|
|
||
| Automates the creation and configuration of Firebase service accounts and GitHub repository secrets. | ||
|
|
||
| **What it does:** | ||
| - Creates service accounts in Google Cloud projects (if they don't exist) | ||
| - Grants required IAM permissions for Firebase deployments | ||
| - Generates service account keys | ||
| - Creates/updates GitHub repository secrets | ||
| - Cleans up sensitive key files | ||
|
|
||
| **Usage:** | ||
| ```bash | ||
| ./.github/scripts/firebase/setup-github-secrets.sh | ||
| ``` | ||
|
|
||
| ### verify-github-secrets.sh | ||
|
|
||
| Verifies that Firebase service accounts and GitHub secrets are properly configured. | ||
|
|
||
| **What it checks:** | ||
| - Prerequisites (gcloud, gh, jq installations) | ||
| - Authentication status (Google Cloud and GitHub) | ||
| - Firebase project accessibility | ||
| - Service account existence and permissions | ||
| - GitHub secret configuration | ||
|
|
||
| **Usage:** | ||
| ```bash | ||
| ./.github/scripts/firebase/verify-github-secrets.sh | ||
| ``` | ||
|
|
||
| ## Required Permissions | ||
|
|
||
| To run these scripts, you need: | ||
| - Admin access to Firebase projects (`komodo-defi-sdk` and `komodo-playground`) | ||
| - Write access to GitHub repository secrets | ||
| - Google Cloud CLI (`gcloud`) authenticated | ||
| - GitHub CLI (`gh`) authenticated | ||
|
|
||
| ## Related Documentation | ||
|
|
||
| For detailed setup instructions and troubleshooting, see: | ||
| [Firebase Deployment Setup Guide](../../../docs/firebase/firebase-deployment-setup.md) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,260 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Setup Firebase GitHub Secrets Script | ||
| # This script automates the creation and configuration of Firebase service accounts | ||
| # and GitHub secrets for the Komodo DeFi SDK Flutter project | ||
|
|
||
| set -e # Exit on error | ||
|
|
||
| # Color codes for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| # Configuration | ||
| GITHUB_REPO="KomodoPlatform/komodo-defi-sdk-flutter" | ||
| SDK_PROJECT_ID="komodo-defi-sdk" | ||
| PLAYGROUND_PROJECT_ID="komodo-playground" | ||
| SDK_SERVICE_ACCOUNT_NAME="github-actions-deploy" | ||
| PLAYGROUND_SERVICE_ACCOUNT_NAME="github-actions-deploy" | ||
|
|
||
| # Function to print colored output | ||
| print_status() { | ||
| echo -e "${BLUE}[INFO]${NC} $1" | ||
| } | ||
|
|
||
| print_success() { | ||
| echo -e "${GREEN}[SUCCESS]${NC} $1" | ||
| } | ||
|
|
||
| print_error() { | ||
| echo -e "${RED}[ERROR]${NC} $1" | ||
| } | ||
|
|
||
| print_warning() { | ||
| echo -e "${YELLOW}[WARNING]${NC} $1" | ||
| } | ||
|
|
||
| # Function to check if a command exists | ||
| check_command() { | ||
| if ! command -v $1 &> /dev/null; then | ||
| print_error "$1 is not installed. Please install it first." | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| } | ||
|
|
||
| # Function to check if user is authenticated with gcloud | ||
| check_gcloud_auth() { | ||
| if ! gcloud auth list --filter=status:ACTIVE --format="value(account)" | grep -q .; then | ||
| print_error "Not authenticated with gcloud. Please run: gcloud auth login" | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| } | ||
|
|
||
| # Function to check if user is authenticated with gh | ||
| check_gh_auth() { | ||
| if ! gh auth status &> /dev/null; then | ||
| print_error "Not authenticated with GitHub CLI. Please run: gh auth login" | ||
| return 1 | ||
| fi | ||
| return 0 | ||
| } | ||
|
|
||
| # Function to create service account if it doesn't exist | ||
| create_service_account_if_needed() { | ||
| local project_id=$1 | ||
| local service_account_name=$2 | ||
| local service_account_email="${service_account_name}@${project_id}.iam.gserviceaccount.com" | ||
|
|
||
| print_status "Checking if service account ${service_account_email} exists..." | ||
|
|
||
| if gcloud iam service-accounts describe "${service_account_email}" --project="${project_id}" &> /dev/null; then | ||
| print_status "Service account already exists" | ||
| else | ||
| print_status "Creating service account..." | ||
| gcloud iam service-accounts create "${service_account_name}" \ | ||
| --display-name="GitHub Actions Deploy" \ | ||
| --description="Service account for GitHub Actions Firebase deployments" \ | ||
| --project="${project_id}" | ||
| print_success "Service account created" | ||
| fi | ||
| } | ||
|
|
||
| # Function to grant necessary permissions to service account | ||
| grant_permissions() { | ||
| local project_id=$1 | ||
| local service_account_email=$2 | ||
|
|
||
| print_status "Granting permissions to ${service_account_email}..." | ||
|
|
||
| # Array of roles to grant | ||
| local roles=( | ||
| "roles/firebase.hosting.admin" | ||
| "roles/firebase.rules.admin" | ||
| "roles/iam.serviceAccountTokenCreator" | ||
| ) | ||
|
|
||
| for role in "${roles[@]}"; do | ||
| print_status "Granting ${role}..." | ||
| gcloud projects add-iam-policy-binding "${project_id}" \ | ||
| --member="serviceAccount:${service_account_email}" \ | ||
| --role="${role}" \ | ||
| --quiet &> /dev/null || true | ||
| done | ||
|
|
||
| print_success "Permissions granted" | ||
| } | ||
|
|
||
| # Function to generate service account key | ||
| generate_service_account_key() { | ||
| local project_id=$1 | ||
| local service_account_name=$2 | ||
| local key_file=$3 | ||
| local service_account_email="${service_account_name}@${project_id}.iam.gserviceaccount.com" | ||
|
|
||
| print_status "Generating service account key for ${service_account_email}..." | ||
|
|
||
| gcloud iam service-accounts keys create "${key_file}" \ | ||
| --iam-account="${service_account_email}" \ | ||
| --project="${project_id}" | ||
|
|
||
| print_success "Service account key generated: ${key_file}" | ||
| } | ||
|
|
||
| # Function to create or update GitHub secret | ||
| create_github_secret() { | ||
| local secret_name=$1 | ||
| local key_file=$2 | ||
|
|
||
| print_status "Creating/updating GitHub secret: ${secret_name}..." | ||
|
|
||
| # Check if running in GitHub Actions or local | ||
| if [ -n "$GITHUB_REPOSITORY" ]; then | ||
| # Running in GitHub Actions | ||
| gh secret set "${secret_name}" < "${key_file}" --repo "${GITHUB_REPOSITORY}" | ||
| else | ||
| # Running locally | ||
| gh secret set "${secret_name}" < "${key_file}" --repo "${GITHUB_REPO}" | ||
| fi | ||
|
|
||
| print_success "GitHub secret ${secret_name} created/updated" | ||
| } | ||
|
|
||
| # Main execution | ||
| main() { | ||
| print_status "Starting Firebase GitHub secrets setup..." | ||
|
|
||
| # Step 1: Check prerequisites | ||
| print_status "Checking prerequisites..." | ||
|
|
||
| if ! check_command "gcloud"; then | ||
| print_error "Please install Google Cloud SDK: https://cloud.google.com/sdk/docs/install" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! check_command "gh"; then | ||
| print_error "Please install GitHub CLI: https://cli.github.com/manual/installation" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! check_gcloud_auth; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! check_gh_auth; then | ||
| exit 1 | ||
| fi | ||
|
|
||
| print_success "All prerequisites met" | ||
|
|
||
| # Step 2: Set up komodo-defi-sdk project | ||
| print_status "Setting up komodo-defi-sdk project..." | ||
|
|
||
| # Set the project | ||
| gcloud config set project "${SDK_PROJECT_ID}" --quiet | ||
|
|
||
| # Create service account if needed | ||
| create_service_account_if_needed "${SDK_PROJECT_ID}" "${SDK_SERVICE_ACCOUNT_NAME}" | ||
|
|
||
| # Grant permissions | ||
| grant_permissions "${SDK_PROJECT_ID}" "${SDK_SERVICE_ACCOUNT_NAME}@${SDK_PROJECT_ID}.iam.gserviceaccount.com" | ||
|
|
||
| # Generate key | ||
| SDK_KEY_FILE="komodo-defi-sdk-key.json" | ||
| generate_service_account_key "${SDK_PROJECT_ID}" "${SDK_SERVICE_ACCOUNT_NAME}" "${SDK_KEY_FILE}" | ||
|
|
||
| # Create GitHub secret | ||
| create_github_secret "FIREBASE_SERVICE_ACCOUNT_KOMODO_DEFI_SDK" "${SDK_KEY_FILE}" | ||
|
|
||
| # Step 3: Set up komodo-playground project | ||
| print_status "Setting up komodo-playground project..." | ||
|
|
||
| # Set the project | ||
| gcloud config set project "${PLAYGROUND_PROJECT_ID}" --quiet | ||
|
|
||
| # Create service account if needed | ||
| create_service_account_if_needed "${PLAYGROUND_PROJECT_ID}" "${PLAYGROUND_SERVICE_ACCOUNT_NAME}" | ||
|
|
||
| # Grant permissions | ||
| grant_permissions "${PLAYGROUND_PROJECT_ID}" "${PLAYGROUND_SERVICE_ACCOUNT_NAME}@${PLAYGROUND_PROJECT_ID}.iam.gserviceaccount.com" | ||
|
|
||
| # Generate key | ||
| PLAYGROUND_KEY_FILE="komodo-playground-key.json" | ||
| generate_service_account_key "${PLAYGROUND_PROJECT_ID}" "${PLAYGROUND_SERVICE_ACCOUNT_NAME}" "${PLAYGROUND_KEY_FILE}" | ||
|
|
||
| # Create GitHub secret | ||
| create_github_secret "FIREBASE_SERVICE_ACCOUNT_KOMODO_PLAYGROUND" "${PLAYGROUND_KEY_FILE}" | ||
|
|
||
| # Step 4: Clean up sensitive files | ||
| print_status "Cleaning up sensitive files..." | ||
|
|
||
| if [ -f "${SDK_KEY_FILE}" ]; then | ||
| rm -f "${SDK_KEY_FILE}" | ||
| print_success "Removed ${SDK_KEY_FILE}" | ||
| fi | ||
|
|
||
| if [ -f "${PLAYGROUND_KEY_FILE}" ]; then | ||
| rm -f "${PLAYGROUND_KEY_FILE}" | ||
| print_success "Removed ${PLAYGROUND_KEY_FILE}" | ||
| fi | ||
|
|
||
| # Step 5: Verify setup | ||
| print_status "Verifying setup..." | ||
|
|
||
| # Check if secrets exist | ||
| if gh secret list --repo "${GITHUB_REPO}" | grep -q "FIREBASE_SERVICE_ACCOUNT_KOMODO_DEFI_SDK"; then | ||
| print_success "FIREBASE_SERVICE_ACCOUNT_KOMODO_DEFI_SDK secret exists" | ||
| else | ||
| print_error "FIREBASE_SERVICE_ACCOUNT_KOMODO_DEFI_SDK secret not found" | ||
| fi | ||
|
|
||
| if gh secret list --repo "${GITHUB_REPO}" | grep -q "FIREBASE_SERVICE_ACCOUNT_KOMODO_PLAYGROUND"; then | ||
| print_success "FIREBASE_SERVICE_ACCOUNT_KOMODO_PLAYGROUND secret exists" | ||
| else | ||
| print_error "FIREBASE_SERVICE_ACCOUNT_KOMODO_PLAYGROUND secret not found" | ||
| fi | ||
|
|
||
| print_success "Firebase GitHub secrets setup completed!" | ||
| print_status "You can now test the deployment by creating a pull request or pushing to the dev branch." | ||
| } | ||
|
|
||
| # Display banner | ||
| echo "================================================" | ||
| echo "Firebase GitHub Secrets Setup Script" | ||
| echo "================================================" | ||
| echo | ||
|
|
||
| # Confirm before proceeding | ||
| read -p "This script will set up Firebase service accounts and GitHub secrets. Continue? (y/N) " -n 1 -r | ||
| echo | ||
| if [[ ! $REPLY =~ ^[Yy]$ ]]; then | ||
| print_warning "Setup cancelled" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Run main function | ||
| main | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't swallow IAM role assignment failures
By appending
|| truewe ignore anygcloud projects add-iam-policy-bindingfailure (missing permissions, typos, quota issues, etc.), yet the script still prints “Permissions granted”. That can leave the service account without hosting/rules/token roles and the subsequent deployments will fail in CI with hard‑to‑trace errors. Letset -esurface the failure (or handle it explicitly) so operators know something went wrong.📝 Committable suggestion
🤖 Prompt for AI Agents