#!/usr/bin/env bash # Validate config/allmainnet-non-dodo-protocol-surface.json shape and internal consistency. # Usage: from repo root: bash scripts/verify/check-allmainnet-protocol-surface.sh set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" F="$PROJECT_ROOT/config/allmainnet-non-dodo-protocol-surface.json" if [[ ! -f "$F" ]]; then echo "[ERROR] Missing $F" exit 1 fi if ! command -v jq &>/dev/null; then echo "[ERROR] jq is required for ALL Mainnet surface validation" exit 1 fi jq -e ' (.chainId == 651940) and (.status | type == "string") and (.summary | type == "object") and (.summary.bridgeOnlyLive | type == "boolean") and (.summary.sameChainSwapInventoryPublished | type == "boolean") and (.classificationFramework.metadataDomains | type == "array") and ((.classificationFramework.metadataDomains - [ "backingMetadata", "bridgeMetadata", "cashMetadata", "commodityMetadata", "reserveMetadata", "securityMetadata", "settlementMetadata" ]) | length == 0) and (.documentedTokens | type == "array") and ((.documentedTokens | length) > 0) and all(.documentedTokens[]; . as $token | ( (.symbol | type == "string") and (.address | test("^0x[0-9a-fA-F]{40}$")) and (.category | type == "string") and (.instrumentType | type == "string") and (.backingAssets | type == "array") and (.tags | type == "array") and (.backingMetadata | type == "object") and (.bridgeMetadata | type == "object") and (.cashMetadata | type == "object") and (.commodityMetadata | type == "object") and (.reserveMetadata | type == "object") and (.securityMetadata | type == "object") and (.settlementMetadata | type == "object") and (($token.gruVersion == null) or (($token.tags | index("gru:" + $token.gruVersion)) != null)) )) and (.bridgeSurface.adapter.address | test("^0x[0-9a-fA-F]{40}$")) and (.bridgeSurface.adapter.status == "live") ' "$F" >/dev/null || { echo "[ERROR] allmainnet-non-dodo-protocol-surface.json: expected chainId 651940, summary flags, metadata domains, documented token metadata, GRU version tags, and live bridge adapter" exit 1 } PUBLISHED="$(jq -r '.summary.sameChainSwapInventoryPublished' "$F")" STATUS="$(jq -r '.status' "$F")" if [[ "$PUBLISHED" == "true" ]] && [[ "$STATUS" == "bridge_live_swap_inventory_pending" ]]; then echo "[ERROR] Inconsistent: summary.sameChainSwapInventoryPublished is true but status is still bridge_live_swap_inventory_pending (update status when promoting inventory)" exit 1 fi echo "[OK] allmainnet-non-dodo-protocol-surface.json OK (chainId, summary flags, publication vs status)" exit 0