Commit c73d7e1f authored by Adrian Sutton's avatar Adrian Sutton

op-challenger: Add script to perform moves.

Update visualize script to use cast to list claims so it works with cannon games.
parent 8bb2ea5a
#!/bin/bash
set -euo pipefail
RPC=${1:?Must specify RPC URL}
GAME_ADDR=${2:?Must specify game address}
ACTION=${3:?Must specify attack or defend}
CLAIM=${4:?Must specify claim hash}
SIGNER_ARGS="${@:5}"
# Respond to the last claim that was made
CLAIM_IDX=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" 'claimDataLen() returns(uint256)')
((CLAIM_IDX=CLAIM_IDX-1))
cast send --rpc-url "${RPC}" ${SIGNER_ARGS} "${GAME_ADDR}" "$ACTION(uint256,bytes32)" "${CLAIM_IDX}" "${CLAIM}"
...@@ -2,30 +2,19 @@ ...@@ -2,30 +2,19 @@
set -euo pipefail set -euo pipefail
if [ $# -eq 0 ] RPC=${1:?Must specify RPC address}
then GAME_ADDR=${2:?Must specify fault dispute game address}
echo "Missing Fault Dispute Game address argument"
fi COUNT=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" 'claimDataLen() returns(uint256)')
echo "Claim count: ${COUNT}"
echo "" ((COUNT=COUNT-1))
echo "Visualize the fault dispute game at https://dispute.clab.by/game?addr=$1" for i in $(seq 0 "${COUNT}")
echo "" do
CLAIM=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" 'claimData(uint256) returns(uint32 parentIndex, bool countered, bytes32 claim, uint128 position, uint128 clock)' "${i}")
DISPUTE_GAME_PROXY=$(jq .DisputeGameFactoryProxy .devnet/addresses.json) SAVEIFS=$IFS # Save current IFS (Internal Field Separator)
DISPUTE_GAME_PROXY=$(echo $DISPUTE_GAME_PROXY | tr -d '"') IFS=$'\n' # Change IFS to newline char
CLAIM=($CLAIM) # split the string into an array by the same name
echo "----------------------------------------------------------------" IFS=$SAVEIFS # Restore original IFS
echo " Dispute Game Factory at $DISPUTE_GAME_PROXY"
echo "----------------------------------------------------------------" echo "${i} Parent: ${CLAIM[0]} Countered: ${CLAIM[1]} Claim: ${CLAIM[2]} Position: ${CLAIM[3]} Clock ${CLAIM[4]}"
done
FAULT_GAME_ADDRESS=$1
DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
DIR=$(echo ${DIR%/*/*})
cd $DIR/packages/contracts-bedrock
forge script scripts/FaultDisputeGameViz.s.sol \
--sig "remote(address)" $FAULT_GAME_ADDRESS \
--fork-url http://localhost:8545
mv dispute_game.svg "$dir"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment