Commit c91cdef7 authored by Adrian Sutton's avatar Adrian Sutton

op-challenger: Add script to resolve a game.

parent 3a6653d8
...@@ -78,6 +78,21 @@ Performs a move to either attack or defend the latest claim in the specified gam ...@@ -78,6 +78,21 @@ Performs a move to either attack or defend the latest claim in the specified gam
These arguments must specify a way for `cast` to sign the transactions. These arguments must specify a way for `cast` to sign the transactions.
See `cast send --help` for supported options. See `cast send --help` for supported options.
### [resolve.sh](scripts/resolve.sh)
```shell
./scripts/resolve.sh <RPC_URL> <GAME_ADDRESS> <SIGNER_ARGS>...
```
Resolves a dispute game. Note that this will fail if the dispute game has already been resolved
or if the clocks have not yet expired and further moves are possible.
If the game is resolved successfully, the result is printed.
* `RPC_URL` - the RPC endpoint of the L1 endpoint to use (e.g. `http://localhost:8545`).
* `GAME_ADDRESS` - the address of the dispute game to resolve.
* `SIGNER_ARGS` the remaining args are past as arguments to `cast` when sending transactions.
These arguments must specify a way for `cast` to sign the transactions.
See `cast send --help` for supported options.
### [list_claims.sh](scripts/list_claims.sh) ### [list_claims.sh](scripts/list_claims.sh)
......
#!/bin/bash
set -euo pipefail
RPC=${1:?Must specify RPC URL}
GAME_ADDR=${2:?Must specify game address}
SIGNER_ARGS="${@:3}"
# Perform the move.
RESULT_DATA=$(cast send --rpc-url "${RPC}" ${SIGNER_ARGS} "${GAME_ADDR}" "resolve()" --json)
RESULT=$(echo "${RESULT_DATA}" | jq -r '.logs[0].topics[1]' | cast to-dec)
if [[ "${RESULT}" == "0" ]]
then
RESULT="In Progress"
elif [[ "${RESULT}" == "1" ]]
then
RESULT="Challenger Wins"
elif [[ "${RESULT}" == "2" ]]
then
RESULT="Defender Wins"
fi
echo "Result: $RESULT"
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