Files
proxmox/scripts/configure-bridge-destinations.sh
defiQUG cb47cce074 Complete markdown files cleanup and organization
- Organized 252 files across project
- Root directory: 187 → 2 files (98.9% reduction)
- Moved configuration guides to docs/04-configuration/
- Moved troubleshooting guides to docs/09-troubleshooting/
- Moved quick start guides to docs/01-getting-started/
- Moved reports to reports/ directory
- Archived temporary files
- Generated comprehensive reports and documentation
- Created maintenance scripts and guides

All files organized according to established standards.
2026-01-06 01:46:25 -08:00

176 lines
6.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Configure all bridge destinations for CCIPWETH9Bridge and CCIPWETH10Bridge
# Usage: ./configure-bridge-destinations.sh
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SOURCE_PROJECT="/home/intlc/projects/smom-dbis-138"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
# Load environment variables
if [ -f "$SOURCE_PROJECT/.env" ]; then
source "$SOURCE_PROJECT/.env"
else
log_error ".env file not found in $SOURCE_PROJECT"
exit 1
fi
# Required variables
RPC_URL="${RPC_URL_138:-http://192.168.11.250:8545}"
WETH9_BRIDGE="${CCIPWETH9_BRIDGE_CHAIN138:-}"
WETH10_BRIDGE="${CCIPWETH10_BRIDGE_CHAIN138:-}"
if [ -z "${PRIVATE_KEY:-}" ]; then
log_error "PRIVATE_KEY not set in .env file"
exit 1
fi
if [ -z "$WETH9_BRIDGE" ] || [ -z "$WETH10_BRIDGE" ]; then
log_error "Bridge addresses not set in .env file"
log_error "Please deploy bridges first: bash scripts/deploy-bridge-contracts.sh"
exit 1
fi
# Destination chain configurations
declare -A WETH9_DESTINATIONS=(
["11344663589394136015"]="0x8078a09637e47fa5ed34f626046ea2094a5cde5e" # BSC
["4051577828743386545"]="0xa780ef19a041745d353c9432f2a7f5a241335ffe" # Polygon
["6433500567565415381"]="0x8078a09637e47fa5ed34f626046ea2094a5cde5e" # Avalanche
["15971525489660198786"]="0x8078a09637e47fa5ed34f626046ea2094a5cde5e" # Base
["4949039107694359620"]="0x8078a09637e47fa5ed34f626046ea2094a5cde5e" # Arbitrum
["3734403246176062136"]="0x8078a09637e47fa5ed34f626046ea2094a5cde5e" # Optimism
["5009297550715157269"]="0x8078a09637e47fa5ed34f626046ea2094a5cde5e" # Ethereum Mainnet
)
declare -A WETH10_DESTINATIONS=(
["11344663589394136015"]="0x105f8a15b819948a89153505762444ee9f324684" # BSC
["4051577828743386545"]="0xdab0591e5e89295ffad75a71dcfc30c5625c4fa2" # Polygon
["6433500567565415381"]="0x105f8a15b819948a89153505762444ee9f324684" # Avalanche
["15971525489660198786"]="0x105f8a15b819948a89153505762444ee9f324684" # Base
["4949039107694359620"]="0x105f8a15b819948a89153505762444ee9f324684" # Arbitrum
["3734403246176062136"]="0x105f8a15b819948a89153505762444ee9f324684" # Optimism
["5009297550715157269"]="0x105f8a15b819948a89153505762444ee9f324684" # Ethereum Mainnet
)
declare -A CHAIN_NAMES=(
["11344663589394136015"]="BSC"
["4051577828743386545"]="Polygon"
["6433500567565415381"]="Avalanche"
["15971525489660198786"]="Base"
["4949039107694359620"]="Arbitrum"
["3734403246176062136"]="Optimism"
["5009297550715157269"]="Ethereum"
)
log_info "========================================="
log_info "Configure Bridge Destinations"
log_info "========================================="
log_info ""
log_info "WETH9 Bridge: $WETH9_BRIDGE"
log_info "WETH10 Bridge: $WETH10_BRIDGE"
log_info "RPC URL: $RPC_URL"
log_info ""
# Function to check if destination is already configured
check_destination() {
local bridge="$1"
local selector="$2"
local name="$3"
log_info "Checking $name destination..."
local result=$(cast call "$bridge" "destinations(uint64)" "$selector" --rpc-url "$RPC_URL" 2>/dev/null || echo "")
if echo "$result" | grep -qE "(true|enabled|0x0000000000000000000000000000000000000000)" && ! echo "$result" | grep -q "0x0000000000000000000000000000000000000000$"; then
return 0 # Already configured
else
return 1 # Not configured
fi
}
# Configure WETH9 Bridge destinations
log_info "Configuring WETH9 Bridge destinations..."
WETH9_COUNT=0
for selector in "${!WETH9_DESTINATIONS[@]}"; do
chain_name="${CHAIN_NAMES[$selector]}"
dest_address="${WETH9_DESTINATIONS[$selector]}"
if check_destination "$WETH9_BRIDGE" "$selector" "$chain_name (WETH9)"; then
log_success "$chain_name already configured for WETH9"
else
log_info "Configuring $chain_name for WETH9..."
local output=$(cast send "$WETH9_BRIDGE" \
"addDestination(uint64,address)" \
"$selector" \
"$dest_address" \
--rpc-url "$RPC_URL" \
--private-key "$PRIVATE_KEY" 2>&1 | tee /tmp/weth9-config-$chain_name.log)
if echo "$output" | grep -qE "(blockHash|transactionHash|Success)"; then
log_success "$chain_name configured for WETH9"
((WETH9_COUNT++))
elif echo "$output" | grep -q "destination already exists"; then
log_success "$chain_name already configured for WETH9"
else
log_error "✗ Failed to configure $chain_name for WETH9"
log_info "Check /tmp/weth9-config-$chain_name.log for details"
fi
fi
done
log_info ""
# Configure WETH10 Bridge destinations
log_info "Configuring WETH10 Bridge destinations..."
WETH10_COUNT=0
for selector in "${!WETH10_DESTINATIONS[@]}"; do
chain_name="${CHAIN_NAMES[$selector]}"
dest_address="${WETH10_DESTINATIONS[$selector]}"
if check_destination "$WETH10_BRIDGE" "$selector" "$chain_name (WETH10)"; then
log_success "$chain_name already configured for WETH10"
else
log_info "Configuring $chain_name for WETH10..."
local output=$(cast send "$WETH10_BRIDGE" \
"addDestination(uint64,address)" \
"$selector" \
"$dest_address" \
--rpc-url "$RPC_URL" \
--private-key "$PRIVATE_KEY" 2>&1 | tee /tmp/weth10-config-$chain_name.log)
if echo "$output" | grep -qE "(blockHash|transactionHash|Success)"; then
log_success "$chain_name configured for WETH10"
((WETH10_COUNT++))
elif echo "$output" | grep -q "destination already exists"; then
log_success "$chain_name already configured for WETH10"
else
log_error "✗ Failed to configure $chain_name for WETH10"
log_info "Check /tmp/weth10-config-$chain_name.log for details"
fi
fi
done
log_info ""
log_success "========================================="
log_success "Bridge Configuration Complete!"
log_success "========================================="
log_info ""
log_info "Summary:"
log_info " WETH9 destinations configured: $WETH9_COUNT new"
log_info " WETH10 destinations configured: $WETH10_COUNT new"
log_info ""
log_info "All 7 destination chains configured for both bridges"
log_info ""