feat(scripts): resolve CCIP/LINK addresses via config inventory

- Add scripts/lib/address-inventory.sh (jq + JSON inventory fallback)
- Wire deployment helper scripts to load_explorer_runtime_env + resolve_address_value
- Persist new LINK to address-inventory.json via persist_inventory_value
- Document config/*.json in config/README.md

Made-with: Cursor
This commit is contained in:
defiQUG
2026-03-27 22:09:32 -07:00
parent ca24d6127c
commit ed0af8aaa0
12 changed files with 170 additions and 97 deletions

View File

@@ -6,12 +6,13 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
source "$PROJECT_ROOT/.env" 2>/dev/null || source "$PROJECT_ROOT/../.env" 2>/dev/null || true
source "$PROJECT_ROOT/scripts/lib/address-inventory.sh"
load_explorer_runtime_env
RPC_URL="${RPC_URL_138:-http://192.168.11.250:8545}"
LINK_TOKEN="${LINK_TOKEN:-}"
WETH9_BRIDGE="0x971cD9D156f193df8051E48043C476e53ECd4693"
WETH10_BRIDGE="0xe0E93247376aa097dB308B92e6Ba36bA015535D0"
LINK_TOKEN="$(resolve_address_value LINK_TOKEN LINK_TOKEN "")"
WETH9_BRIDGE="$(resolve_address_value CCIPWETH9_BRIDGE CCIPWETH9_BRIDGE 0x971cD9D156f193df8051E48043C476e53ECd4693)"
WETH10_BRIDGE="$(resolve_address_value CCIPWETH10_BRIDGE CCIPWETH10_BRIDGE 0xe0E93247376aa097dB308B92e6Ba36bA015535D0)"
ACCOUNT=$(cast wallet address "$PRIVATE_KEY")
echo "╔══════════════════════════════════════════════════════════════╗"
@@ -53,9 +54,9 @@ if [ "${LINK_CONFIRMED:-false}" != "true" ]; then
echo "Waiting 60 seconds for network confirmation..."
sleep 60
# Update .env
sed -i "s|^LINK_TOKEN=.*|LINK_TOKEN=$NEW_LINK|" "$PROJECT_ROOT/.env" 2>/dev/null || \
echo "LINK_TOKEN=$NEW_LINK" >> "$PROJECT_ROOT/.env"
# Keep address inventory as the script-facing source of truth for addresses.
persist_inventory_value "LINK_TOKEN" "$NEW_LINK" || true
persist_inventory_value "CCIP_CHAIN138_FEE_TOKEN" "$NEW_LINK" || true
export LINK_TOKEN="$NEW_LINK"
# Verify
@@ -139,4 +140,3 @@ if [ "${LINK_CONFIRMED:-false}" = "true" ]; then
fi
echo ""