- Institutional / JVMTM / reserve-provenance / GRU transport + standards JSON - Validation and verify scripts (Blockscout labels, x402, GRU preflight, P1 local path) - Wormhole wiring in AGENTS, MCP_SETUP, MASTER_INDEX, 04-configuration README - Meta docs, integration gaps, live verification log, architecture updates - CI validate-config workflow updates Operator/LAN items, submodule working trees, and public token-aggregation edge routes remain follow-up (see TODOS_CONSOLIDATED P1). Made-with: Cursor
110 lines
3.4 KiB
Bash
Executable File
110 lines
3.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Check whether Chain 138 deployed tokens (cUSDT, cUSDC) support ERC-2612 permit or ERC-3009.
|
|
# Used to determine x402 compatibility: thirdweb x402 requires permit or ERC-3009.
|
|
#
|
|
# Usage: ./scripts/verify/check-chain138-token-permit-support.sh [RPC_URL] [--token SYMBOL=ADDRESS]...
|
|
# RPC_URL: optional; default from RPC_URL_138 or CHAIN_138_RPC_URL or https://rpc-core.d-bis.org
|
|
# --token SYMBOL=ADDRESS: optional; inspect custom token inventory (repeatable)
|
|
# --dry-run: print RPC and token addresses only (no RPC calls).
|
|
#
|
|
# Exit: 0 if script runs; output is human-readable. Use output to fill CHAIN138_X402_TOKEN_SUPPORT.md.
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
cd "$PROJECT_ROOT"
|
|
|
|
DRY_RUN=""
|
|
RPC_ARG=""
|
|
declare -A TOKENS=()
|
|
TOKEN_ORDER=()
|
|
|
|
add_token() {
|
|
local spec="$1"
|
|
local symbol="${spec%%=*}"
|
|
local address="${spec#*=}"
|
|
if [[ -z "$symbol" || -z "$address" || "$symbol" == "$address" ]]; then
|
|
echo "ERROR: invalid token spec '$spec' (expected SYMBOL=ADDRESS)" >&2
|
|
exit 1
|
|
fi
|
|
TOKENS["$symbol"]="$address"
|
|
TOKEN_ORDER+=("$symbol")
|
|
}
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--dry-run)
|
|
DRY_RUN=1
|
|
shift
|
|
;;
|
|
--token)
|
|
[[ $# -ge 2 ]] || { echo "ERROR: --token requires SYMBOL=ADDRESS" >&2; exit 1; }
|
|
add_token "$2"
|
|
shift 2
|
|
;;
|
|
--token=*)
|
|
add_token "${1#--token=}"
|
|
shift
|
|
;;
|
|
*)
|
|
if [[ -z "$RPC_ARG" ]]; then
|
|
RPC_ARG="$1"
|
|
else
|
|
add_token "$1"
|
|
fi
|
|
shift
|
|
;;
|
|
esac
|
|
done
|
|
|
|
RPC="${RPC_ARG:-${RPC_URL_138:-${CHAIN_138_RPC_URL:-https://rpc-core.d-bis.org}}}"
|
|
|
|
if [[ ${#TOKEN_ORDER[@]} -eq 0 ]]; then
|
|
add_token "cUSDT=0x93E66202A11B1772E55407B32B44e5Cd8eda7f22"
|
|
add_token "cUSDC=0xf22258f57794CC8E06237084b353Ab30fFfa640b"
|
|
fi
|
|
|
|
# Test holder for nonces(address) call (any address is fine)
|
|
HOLDER="0x0000000000000000000000000000000000000001"
|
|
|
|
if [[ -n "$DRY_RUN" ]]; then
|
|
echo "=== Chain 138 token permit support check (--dry-run) ==="
|
|
echo "RPC: $RPC"
|
|
for sym in "${TOKEN_ORDER[@]}"; do echo " $sym: ${TOKENS[$sym]}"; done
|
|
exit 0
|
|
fi
|
|
|
|
echo "=== Chain 138 — ERC-2612 / ERC-3009 token support ==="
|
|
echo "RPC: $RPC"
|
|
echo ""
|
|
|
|
if ! command -v cast &>/dev/null; then
|
|
echo "WARN: 'cast' (foundry) not found. Install foundry or run from a env that has cast."
|
|
echo "Checking via cast is required for on-chain verification."
|
|
exit 1
|
|
fi
|
|
|
|
for sym in "${TOKEN_ORDER[@]}"; do
|
|
addr="${TOKENS[$sym]}"
|
|
echo "--- $sym ($addr) ---"
|
|
|
|
# ERC-2612: nonces(address) selector 0x7ecebe00
|
|
if cast call "$addr" "nonces(address)(uint256)" "$HOLDER" --rpc-url "$RPC" 2>/dev/null; then
|
|
echo " ERC-2612 (permit): supported"
|
|
else
|
|
echo " ERC-2612 (permit): not supported"
|
|
fi
|
|
|
|
# ERC-3009: authorizationState(address,bytes32) — try zero args; if call fails, likely not present
|
|
# bytes32(0) as second arg: 0x0000000000000000000000000000000000000000000000000000000000000000
|
|
if cast call "$addr" "authorizationState(address,bytes32)(bool)" "$HOLDER" 0x0000000000000000000000000000000000000000000000000000000000000000 --rpc-url "$RPC" 2>/dev/null; then
|
|
echo " ERC-3009 (transferWithAuthorization): supported"
|
|
else
|
|
echo " ERC-3009 (transferWithAuthorization): not supported"
|
|
fi
|
|
echo ""
|
|
done
|
|
|
|
echo "x402 compatibility: thirdweb x402 requires ERC-2612 or ERC-3009. Document results in docs/04-configuration/CHAIN138_X402_TOKEN_SUPPORT.md"
|