Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- Marked submodules ai-mcp-pmm-controller, explorer-monorepo, and smom-dbis-138 as dirty to reflect recent changes. - Updated documentation to clarify operator script usage, including dotenv loading and task execution instructions. - Enhanced the README and various index files to provide clearer navigation and task completion guidance. Made-with: Cursor
77 lines
2.5 KiB
Bash
Executable File
77 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Merge single-chain allowlists into one multi-chain allowlist for the MCP server.
|
|
# Output format: { "description": "...", "chains": [ { "chainId": "138", "pools": [...] }, ... ] }
|
|
#
|
|
# Usage:
|
|
# ./scripts/merge-mcp-allowlist-multichain.sh -o ai-mcp-pmm-controller/config/allowlist-multichain.json
|
|
# ALLOWLIST_138=path/to/allowlist-138.json CHAIN_IDS="138 137 1" ./scripts/merge-mcp-allowlist-multichain.sh -o out.json
|
|
#
|
|
# If ALLOWLIST_138 is not set, runs generate-mcp-allowlist-from-chain138.sh to get Chain 138 pools.
|
|
# For other chain IDs, runs generate-mcp-allowlist-from-deployment-status.sh and merges.
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
OUT_PATH=""
|
|
ALLOWLIST_138="${ALLOWLIST_138:-}"
|
|
CHAIN_IDS="${CHAIN_IDS:-138}"
|
|
DEPLOYMENT_STATUS="${DEPLOYMENT_STATUS:-$REPO_ROOT/cross-chain-pmm-lps/config/deployment-status.json}"
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
-o) OUT_PATH="$2"; shift 2 ;;
|
|
*) shift ;;
|
|
esac
|
|
done
|
|
|
|
command -v jq &>/dev/null || { echo "jq required"; exit 1; }
|
|
|
|
TMP_DIR=$(mktemp -d)
|
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
|
|
|
# Build chains array
|
|
CHAIN_OBJS=()
|
|
|
|
# Chain 138
|
|
if [[ -n "$ALLOWLIST_138" && -f "$ALLOWLIST_138" ]]; then
|
|
jq -c '{ chainId: "138", pools: .pools }' "$ALLOWLIST_138" > "$TMP_DIR/138.json"
|
|
CHAIN_OBJS+=("$TMP_DIR/138.json")
|
|
else
|
|
GEN_138="$REPO_ROOT/scripts/generate-mcp-allowlist-from-chain138.sh"
|
|
if [[ -x "$GEN_138" ]]; then
|
|
"$GEN_138" 2>/dev/null | jq -c '{ chainId: "138", pools: .pools }' > "$TMP_DIR/138.json" || true
|
|
[[ -s "$TMP_DIR/138.json" ]] && CHAIN_OBJS+=("$TMP_DIR/138.json")
|
|
fi
|
|
fi
|
|
|
|
# Other chains from deployment-status
|
|
for cid in $CHAIN_IDS; do
|
|
[[ "$cid" == "138" ]] && continue
|
|
FRAG="$TMP_DIR/$cid.json"
|
|
if "$REPO_ROOT/scripts/generate-mcp-allowlist-from-deployment-status.sh" "$cid" 2>/dev/null | jq -c --arg c "$cid" '{ chainId: $c, pools: .pools }' > "$FRAG" 2>/dev/null && [[ -s "$FRAG" ]]; then
|
|
CHAIN_OBJS+=("$FRAG")
|
|
fi
|
|
done
|
|
|
|
# Merge: read all chain objects into a jq array
|
|
if [[ ${#CHAIN_OBJS[@]} -eq 0 ]]; then
|
|
CHAINS_JSON="[]"
|
|
else
|
|
CHAINS_JSON=$(jq -s '.' "${CHAIN_OBJS[@]}")
|
|
fi
|
|
|
|
RESULT=$(jq -n --argjson chains "$CHAINS_JSON" '{
|
|
description: "Multi-chain MCP allowlist. Set ALLOWLIST_PATH to this file; set RPC_138, RPC_137, etc. or RPC_BY_CHAIN_PATH.",
|
|
chains: $chains
|
|
}')
|
|
|
|
if [[ -n "$OUT_PATH" ]]; then
|
|
mkdir -p "$(dirname "$OUT_PATH")"
|
|
echo "$RESULT" | jq . > "$OUT_PATH"
|
|
echo "Wrote $OUT_PATH (chains: $(echo "$CHAINS_JSON" | jq 'length'))" >&2
|
|
else
|
|
echo "$RESULT" | jq .
|
|
fi
|