115 lines
3.5 KiB
Bash
Executable File
115 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Setup script for Chain 138 configuration
|
|
# This script helps configure the DApp for Chain 138 deployment
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
echo "=========================================="
|
|
echo "Chain 138 Configuration Setup"
|
|
echo "=========================================="
|
|
echo ""
|
|
|
|
# Chain 138 RPC endpoints
|
|
RPC_URL="${CHAIN138_RPC_URL:-http://192.168.11.250:8545}"
|
|
WS_URL="${CHAIN138_WS_URL:-ws://192.168.11.250:8546}"
|
|
|
|
echo "Chain 138 RPC URL: $RPC_URL"
|
|
echo "Chain 138 WS URL: $WS_URL"
|
|
echo ""
|
|
|
|
# Check if contracts are deployed
|
|
DEPLOYMENT_FILE="$PROJECT_ROOT/contracts/deployments/chain138.json"
|
|
if [[ -f "$DEPLOYMENT_FILE" ]]; then
|
|
echo "Found deployment file: $DEPLOYMENT_FILE"
|
|
TREASURY_ADDRESS=$(jq -r '.contracts.TreasuryWallet' "$DEPLOYMENT_FILE" 2>/dev/null || echo "")
|
|
FACTORY_ADDRESS=$(jq -r '.contracts.SubAccountFactory' "$DEPLOYMENT_FILE" 2>/dev/null || echo "")
|
|
|
|
if [[ -n "$TREASURY_ADDRESS" && "$TREASURY_ADDRESS" != "null" ]]; then
|
|
echo "Treasury Wallet Address: $TREASURY_ADDRESS"
|
|
fi
|
|
if [[ -n "$FACTORY_ADDRESS" && "$FACTORY_ADDRESS" != "null" ]]; then
|
|
echo "SubAccount Factory Address: $FACTORY_ADDRESS"
|
|
fi
|
|
echo ""
|
|
fi
|
|
|
|
# Create frontend .env.production template
|
|
echo "Creating frontend/.env.production template..."
|
|
cat > "$PROJECT_ROOT/frontend/.env.production.template" <<EOF
|
|
# Chain 138 Configuration
|
|
NEXT_PUBLIC_CHAIN138_RPC_URL=$RPC_URL
|
|
NEXT_PUBLIC_CHAIN138_WS_URL=$WS_URL
|
|
NEXT_PUBLIC_CHAIN_ID=138
|
|
|
|
# Contract Addresses (update after deployment)
|
|
NEXT_PUBLIC_TREASURY_WALLET_ADDRESS=${TREASURY_ADDRESS:-}
|
|
NEXT_PUBLIC_SUB_ACCOUNT_FACTORY_ADDRESS=${FACTORY_ADDRESS:-}
|
|
|
|
# WalletConnect
|
|
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id
|
|
|
|
# Backend API
|
|
NEXT_PUBLIC_API_URL=http://192.168.11.61:3001
|
|
EOF
|
|
|
|
# Create backend .env template
|
|
echo "Creating backend/.env template..."
|
|
cat > "$PROJECT_ROOT/backend/.env.template" <<EOF
|
|
# Database Configuration
|
|
DATABASE_URL=postgresql://solace_user:your_password@192.168.11.62:5432/solace_treasury
|
|
|
|
# Chain 138 Configuration
|
|
RPC_URL=$RPC_URL
|
|
CHAIN_ID=138
|
|
CONTRACT_ADDRESS=${TREASURY_ADDRESS:-}
|
|
|
|
# Server Configuration
|
|
PORT=3001
|
|
NODE_ENV=production
|
|
EOF
|
|
|
|
# Create backend .env.indexer template
|
|
echo "Creating backend/.env.indexer template..."
|
|
cat > "$PROJECT_ROOT/backend/.env.indexer.template" <<EOF
|
|
# Database Configuration
|
|
DATABASE_URL=postgresql://solace_user:your_password@192.168.11.62:5432/solace_treasury
|
|
|
|
# Chain 138 Configuration
|
|
RPC_URL=$RPC_URL
|
|
CHAIN_ID=138
|
|
CONTRACT_ADDRESS=${TREASURY_ADDRESS:-}
|
|
|
|
# Indexer Configuration
|
|
START_BLOCK=0
|
|
EOF
|
|
|
|
echo ""
|
|
echo "=========================================="
|
|
echo "Configuration Templates Created"
|
|
echo "=========================================="
|
|
echo ""
|
|
echo "Templates created:"
|
|
echo " - frontend/.env.production.template"
|
|
echo " - backend/.env.template"
|
|
echo " - backend/.env.indexer.template"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo "1. Copy templates to actual .env files:"
|
|
echo " cp frontend/.env.production.template frontend/.env.production"
|
|
echo " cp backend/.env.template backend/.env"
|
|
echo " cp backend/.env.indexer.template backend/.env.indexer"
|
|
echo ""
|
|
echo "2. Update the .env files with:"
|
|
echo " - WalletConnect project ID"
|
|
echo " - Database password"
|
|
echo " - Contract addresses (if deployed)"
|
|
echo ""
|
|
echo "3. Deploy contracts (if not already deployed):"
|
|
echo " cd contracts && pnpm run deploy:chain138"
|
|
echo ""
|
|
echo "4. Update .env files with deployed contract addresses"
|
|
|