Standardize deployment env and deployer handling

This commit is contained in:
defiQUG
2026-04-22 14:47:28 -07:00
parent 768168de5e
commit c3d4c786fa
51 changed files with 424 additions and 621 deletions

View File

@@ -30,36 +30,17 @@ fi
log_info "=== Deploy All Contracts in Proper Order ==="
# Check if .env exists
if [ ! -f .env ]; then
log_error "Error: .env file not found"
echo "Creating .env from .env.example..."
if [ -f .env.example ]; then
cp .env.example .env
log_success "✅ Created .env from .env.example"
log_warn "Please configure .env with your values before continuing"
exit 1
else
log_error "Error: .env.example not found"
exit 1
fi
fi
# Load environment variables
source .env
# Check PRIVATE_KEY
if [ -z "$PRIVATE_KEY" ]; then
log_error "Error: PRIVATE_KEY not set in .env"
if ! require_private_key_env; then
exit 1
fi
# Check RPC_URL
RPC_URL="${RPC_URL:-${RPC_URL_138:-${CHAIN138_RPC_URL:-}}}"
if [ -z "$RPC_URL" ]; then
log_warn "RPC_URL not set in .env"
log_warn "Chain 138 RPC not configured"
log_warn "Options:"
echo "1. Start local Anvil testnet (for testing)"
echo "2. Set RPC_URL to existing blockchain endpoint"
echo "2. Set RPC_URL/RPC_URL_138 to existing blockchain endpoint"
echo "3. Deploy blockchain infrastructure first (Azure/Kubernetes)"
read -p "Choose option (1/2/3): " choice
@@ -74,30 +55,12 @@ if [ -z "$RPC_URL" ]; then
# Set RPC_URL
RPC_URL="http://localhost:8545"
update_env() {
local key=$1
local value=$2
if grep -q "^${key}=" .env; then
sed -i "s|^${key}=.*|${key}=${value}|" .env
else
echo "${key}=${value}" >> .env
fi
}
update_env "RPC_URL" "$RPC_URL"
log_success "✅ RPC_URL set to: ${RPC_URL}"
log_warn "Note: Anvil is running in background. Kill it with: kill $ANVIL_PID"
;;
2)
read -p "Enter RPC URL: " RPC_URL
update_env() {
local key=$1
local value=$2
if grep -q "^${key}=" .env; then
sed -i "s|^${key}=.*|${key}=${value}|" .env
else
echo "${key}=${value}" >> .env
fi
}
update_env "RPC_URL" "$RPC_URL"
log_success "✅ RPC_URL set to: ${RPC_URL}"
;;
@@ -116,6 +79,17 @@ if [ -z "$RPC_URL" ]; then
esac
fi
update_env() {
local key=$1
local value=$2
if grep -q "^${key}=" .env 2>/dev/null; then
sed -i "s|^${key}=.*|${key}=${value}|" .env
else
echo "${key}=${value}" >> .env
fi
log_success "✅ Updated .env: ${key}=${value}"
}
# Verify RPC endpoint is accessible
log_warn "Verifying RPC endpoint..."
if ! curl -s -X POST "$RPC_URL" -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' > /dev/null 2>&1; then
@@ -200,7 +174,7 @@ if [ -z "$CCIP_FEE_TOKEN" ] || [ "$CCIP_FEE_TOKEN" = "0x000000000000000000000000
# Fund deployer with LINK tokens
log_warn "Funding deployer with LINK tokens..."
DEPLOYER_ADDRESS=$(cast wallet address --private-key "$PRIVATE_KEY" 2>/dev/null || echo "")
DEPLOYER_ADDRESS="$(derive_deployer_address || true)"
if [ -n "$DEPLOYER_ADDRESS" ]; then
cast send "$CCIP_FEE_TOKEN" "mint(address,uint256)" "$DEPLOYER_ADDRESS" "1000000e18" \
--rpc-url "$RPC_URL" \