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

@@ -24,16 +24,6 @@ elif [[ -n "${REPO_ROOT:-}" && -f "$REPO_ROOT/.env" ]]; then
set +a
fi
# Colors
# Load environment variables
if [ -f "$PROJECT_ROOT/.env" ]; then
source "$PROJECT_ROOT/.env"
else
log_error "Error: .env file not found"
exit 1
fi
log_info "=== Wallet Address from .env Private Key ==="
# Check if cast is available
@@ -43,17 +33,15 @@ if ! command -v cast &> /dev/null; then
fi
# Get private key from .env
if [ -z "$PRIVATE_KEY" ]; then
log_error "Error: PRIVATE_KEY not set in .env"
if ! require_private_key_env; then
exit 1
fi
# Derive address
WALLET_ADDRESS=$(cast wallet address --private-key "$PRIVATE_KEY" 2>/dev/null || echo "")
WALLET_ADDRESS="$(derive_deployer_address || true)"
if [ -z "$WALLET_ADDRESS" ]; then
log_error "Error: Could not derive address from private key"
echo "Please check that PRIVATE_KEY is valid (should start with 0x and be 66 characters)"
log_error "ERROR: Could not derive DEPLOYER_ADDRESS from PRIVATE_KEY."
exit 1
fi
@@ -71,15 +59,13 @@ echo " Recommended: 2 ETH (with buffer)"
echo " Purpose: Gas fees for bridge deployment"
# Show balances if RPC is available
RPC_URL="${RPC_URL:-${RPC_URL_138:-${CHAIN138_RPC_URL:-}}}"
MAINNET_RPC_URL="${MAINNET_RPC_URL:-${ETHEREUM_MAINNET_RPC:-}}"
if [ -n "$RPC_URL" ]; then
log_info "=== Current Balances ==="
# Check Mainnet balance
if [ -n "$MAINNET_RPC_URL" ]; then
MAINNET_RPC="$MAINNET_RPC_URL"
else
MAINNET_RPC="https://eth.llamarpc.com"
fi
MAINNET_RPC="${MAINNET_RPC_URL:-https://eth.llamarpc.com}"
MAINNET_BALANCE=$(cast balance "$WALLET_ADDRESS" --rpc-url "$MAINNET_RPC" 2>/dev/null || echo "0")
MAINNET_ETH=$(cast --to-unit "$MAINNET_BALANCE" ether 2>/dev/null || echo "0")