forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.sh
executable file
·26 lines (21 loc) · 807 Bytes
/
move.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/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}
PARENT_INDEX=${4:?Must specify parent index. Use latest to counter the latest claim added to the game.}
CLAIM=${5:?Must specify claim hash}
SIGNER_ARGS=("${@:6}")
if [[ "${ACTION}" != "attack" && "${ACTION}" != "defend" ]]
then
echo "Action must be either attack or defend"
exit 1
fi
if [[ "${PARENT_INDEX}" == "latest" ]]
then
# Fetch the index of the most recent claim made.
PARENT_INDEX=$(cast call --rpc-url "${RPC}" "${GAME_ADDR}" 'claimDataLen() returns(uint256)')
((PARENT_INDEX=PARENT_INDEX-1))
fi
# Perform the move.
cast send --rpc-url "${RPC}" "${SIGNER_ARGS[@]}" "${GAME_ADDR}" "$ACTION(uint256,bytes32)" "${PARENT_INDEX}" "${CLAIM}"