Skip to content
Merged
Show file tree
Hide file tree
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 Jun 5, 2025
e86e8bc
Enhance ZHTLC activation with improved config parsing and RPC methods
cursoragent Aug 18, 2025
d34b6eb
feat(zhtlc): integrate ZHTLC types and task RPCs per KDF API
CharlVS Aug 18, 2025
152b189
dragon_logs: remove tracked ignored files and add .gitignore files
CharlVS Aug 18, 2025
e61dc52
Integrate and verify ZHTLC in komodo_defi_sdk (#196)
CharlVS Aug 21, 2025
e2b7280
Merge branch 'dev' of https://github.com/KomodoPlatform/komodo-defi-s…
CharlVS Aug 26, 2025
cfa70b2
chore: run code generators
CharlVS Aug 26, 2025
0589076
chore(git): delete previously tracked igored files
CharlVS Aug 28, 2025
defcc99
Fix ERC20 and ZHTLC activation params serialization and method calls …
CharlVS Aug 28, 2025
e03a963
fix: misc fixes
CharlVS Aug 28, 2025
6b357e7
docs(activation): add activation params refactoring plan
CharlVS Aug 29, 2025
0055d7a
docs(sdk): activation refactoring v2
CharlVS Sep 1, 2025
56be9b9
feat(activation,zhtlc,sdk,rpc)!: extract ZHTLC fields to ZhtlcActivat…
CharlVS Sep 1, 2025
dc0ab9e
Merge branch 'dev' into cursor/integrate-zhtlc-types-and-rpcs-4654
takenagain Sep 8, 2025
1c277dd
Checkpoint before follow-up message
cursoragent Sep 10, 2025
66c84aa
Fix: Remove unused import statement
cursoragent Sep 10, 2025
5df30e7
feat: Add support for electrum_servers in Zhtlc activation
cursoragent Sep 10, 2025
d94e383
feat: initialize Firebase hosting for SDK example and playground
CharlVS Sep 12, 2025
b0594fa
fix: update z-coin activation strategy and example UI
CharlVS Sep 12, 2025
a026b1c
docs(firebase): reorganize Firebase deployment scripts and documentation
CharlVS Sep 12, 2025
f230132
fix: remove global singleton registration of ActivationConfigService
CharlVS Sep 14, 2025
99667b2
Merge branch 'dev' of https://github.com/KomodoPlatform/komodo-defi-s…
CharlVS Sep 22, 2025
9d08169
fix(activation): register ActivationConfigService during bootstrap
CharlVS Sep 22, 2025
ebc0aab
docs(tech-debt): add Activation & ZHTLC tech-debt report and refine s…
CharlVS Sep 22, 2025
d3dd099
feat(komodo_defi_sdk): add HiveActivationConfigRepository and integra…
CharlVS Sep 22, 2025
840df13
merge: integrate cursor/integrate-zhtlc-types-and-rpcs-4654 [[memory:…
CharlVS Sep 22, 2025
4152626
fix: resolve external logging callback flaws and memory leak
CharlVS Sep 22, 2025
509bced
refactor(withdrawals): inject LegacyWithdrawalManager and use for Ten…
CharlVS Sep 22, 2025
094b1c7
fix(kdf-ops): use conditional imports for platform-specific imports
takenagain Sep 24, 2025
9e1f5f3
fix(activation-params): include other RPC server keys
takenagain Sep 24, 2025
31310c6
fix(activation-config-repository): register adapter type
takenagain Sep 24, 2025
0d6b12c
feat(zhtlc): add desktop zcash params downloader (#228)
takenagain Sep 25, 2025
8626160
feat(zhtlc): web lightwallet server URLs workaround
takenagain Sep 26, 2025
ec445d3
fix(zhtlc): align orderbook RPC with KDF schema, and add id paginatio…
takenagain Sep 28, 2025
e6e924c
fix(address-select-input): use consistent text theme to fix visibility
takenagain Sep 28, 2025
1af4278
feat(zhtlc): estimate activation percentage based on block height (#230)
takenagain Sep 30, 2025
aff12a8
Fix ZHTLC activation issues and improve resilience
cursoragent Oct 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/scripts/firebase/README.md
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)
260 changes: 260 additions & 0 deletions .github/scripts/firebase/setup-github-secrets.sh
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"
Comment on lines +101 to +109

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don't swallow IAM role assignment failures

By appending || true we ignore any gcloud projects add-iam-policy-binding failure (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. Let set -e surface the failure (or handle it explicitly) so operators know something went wrong.

-        gcloud projects add-iam-policy-binding "${project_id}" \
-            --member="serviceAccount:${service_account_email}" \
-            --role="${role}" \
-            --quiet &> /dev/null || true
+        if ! gcloud projects add-iam-policy-binding "${project_id}" \
+            --member="serviceAccount:${service_account_email}" \
+            --role="${role}" \
+            --quiet; then
+            print_error "Failed to grant ${role} on ${project_id}"
+            return 1
+        fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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"
for role in "${roles[@]}"; do
print_status "Granting ${role}..."
if ! gcloud projects add-iam-policy-binding "${project_id}" \
--member="serviceAccount:${service_account_email}" \
--role="${role}" \
--quiet; then
print_error "Failed to grant ${role} on ${project_id}"
return 1
fi
done
print_success "Permissions granted"
🤖 Prompt for AI Agents
.github/scripts/firebase/setup-github-secrets.sh around lines 101 to 109
currently swallows any gcloud IAM binding errors by appending "|| true", then
prints "Permissions granted"; remove the "|| true" so failures propagate (or
explicitly capture the command exit status and fail the script with a clear
error message), and ensure the script runs with set -e (or exits non‑zero) so
any failed gcloud projects add-iam-policy-binding stops execution and prevents
the misleading "Permissions granted" message.

}

# 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
Loading
Loading