2025-12-12 14:57:48 -08:00
#!/usr/bin/env bash
# Show CCIP bridge status/config
set -euo pipefail
SCRIPT_DIR = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) "
source " $SCRIPT_DIR /../lib/init.sh "
load_env --file " $SCRIPT_DIR /../../.env " ${ ENV_PROFILE : +--profile " $ENV_PROFILE " }
SCRIPT_NAME = "ccip-status.sh"
SCRIPT_DESC = "Display CCIP WETH bridge configuration and status"
SCRIPT_USAGE = " ${ SCRIPT_NAME } --token {weth9|weth10} [--user <address>] [--rpc <url>] [--help] "
SCRIPT_OPTIONS = "--token <name> Bridge token type (weth9|weth10)\n--user ADDR Show nonce for user\n--rpc URL RPC URL (default: ETHEREUM_MAINNET_RPC or public)\n--help Show help"
SCRIPT_REQUIREMENTS = "foundry cast"
handle_help " ${ 1 :- } "
TOKEN = "" ; USER = "" ; RPC_URL = " ${ ETHEREUM_MAINNET_RPC :- https : //eth.llamarpc.com } "
while [ [ $# -gt 0 ] ] ; do
case " $1 " in
--token) TOKEN = " $2 " ; shift 2; ;
--user) USER = " $2 " ; shift 2; ;
--rpc) RPC_URL = " $2 " ; shift 2; ;
--help) handle_help "--help" ; ;
*) log_error " Unknown arg: $1 " ; exit 1; ;
esac
done
case " $TOKEN " in
2026-04-28 23:33:58 -07:00
weth9) BRIDGE_ADDR = " ${ CCIPWETH9_BRIDGE_MAINNET :- ${ MAINNET_CCIP_WETH9_BRIDGE :- } } " ; ;
weth10) BRIDGE_ADDR = " ${ CCIPWETH10_BRIDGE_MAINNET :- ${ MAINNET_CCIP_WETH10_BRIDGE :- } } " ; ;
2025-12-12 14:57:48 -08:00
*) log_error "--token required as weth9|weth10" ; exit 1; ;
esac
2026-04-28 23:33:58 -07:00
if [ -z " $BRIDGE_ADDR " ] ; then
log_error " set CCIPWETH ${ TOKEN #weth } _BRIDGE_MAINNET or MAINNET_CCIP_WETH ${ TOKEN #weth } _BRIDGE in .env "
exit 1
fi
2025-12-12 14:57:48 -08:00
log_section " CCIP STATUS ( $TOKEN ) "
echo " Bridge: $BRIDGE_ADDR "
printf "ccipRouter: %s\n" " $( cast call --rpc-url " $RPC_URL " " $BRIDGE_ADDR " "ccipRouter()(address)" ) "
printf "feeToken: %s\n" " $( cast call --rpc-url " $RPC_URL " " $BRIDGE_ADDR " "feeToken()(address)" ) "
echo
echo "Destination chains:"
selectors_json = $( cast call --rpc-url " $RPC_URL " " $BRIDGE_ADDR " "getDestinationChains()(uint64[])" | sed 's/^\[\|\]$//g' )
if [ -z " $selectors_json " ] ; then
echo " (none)"
else
IFS = ',' read -ra arr <<< " $selectors_json "
for s in " ${ arr [@] } " ; do
s_trim = " $( echo " $s " | xargs) "
echo " - $s_trim "
done
fi
if [ -n " $USER " ] ; then
echo
printf "User nonce (%s): %s\n" " $USER " " $( cast call --rpc-url " $RPC_URL " " $BRIDGE_ADDR " "getUserNonce(address)(uint256)" " $USER " ) "
fi
log_success "OK"