Commit 384e2dc7 authored by Adrian Sutton's avatar Adrian Sutton Committed by GitHub

challenger: Allow interrupting subcommands. (#10765)

parent c04ca0c4
......@@ -76,6 +76,6 @@ var CreateGameCommand = &cli.Command{
Name: "create-game",
Usage: "Creates a dispute game via the factory",
Description: "Creates a dispute game via the factory",
Action: CreateGame,
Action: Interruptible(CreateGame),
Flags: createGameFlags(),
}
......@@ -112,6 +112,6 @@ var ListCreditsCommand = &cli.Command{
Name: "list-credits",
Usage: "List the credits in a dispute game",
Description: "Lists the credits in a dispute game",
Action: ListCredits,
Action: Interruptible(ListCredits),
Flags: listCreditsFlags(),
}
......@@ -198,6 +198,6 @@ var ListClaimsCommand = &cli.Command{
Name: "list-claims",
Usage: "List the claims in a dispute game",
Description: "Lists the claims in a dispute game",
Action: ListClaims,
Action: Interruptible(ListClaims),
Flags: listClaimsFlags(),
}
......@@ -183,6 +183,6 @@ var ListGamesCommand = &cli.Command{
Name: "list-games",
Usage: "List the games created by a dispute game factory",
Description: "Lists the games created by a dispute game factory",
Action: ListGames,
Action: Interruptible(ListGames),
Flags: listGamesFlags(),
}
......@@ -97,6 +97,6 @@ var MoveCommand = &cli.Command{
Name: "move",
Usage: "Creates and sends a move transaction to the dispute game",
Description: "Creates and sends a move transaction to the dispute game",
Action: Move,
Action: Interruptible(Move),
Flags: moveFlags(),
}
......@@ -46,6 +46,6 @@ var ResolveCommand = &cli.Command{
Name: "resolve",
Usage: "Resolves the specified dispute game if possible",
Description: "Resolves the specified dispute game if possible",
Action: Resolve,
Action: Interruptible(Resolve),
Flags: resolveFlags(),
}
......@@ -66,6 +66,6 @@ var ResolveClaimCommand = &cli.Command{
Name: "resolve-claim",
Usage: "Resolves the specified claim if possible",
Description: "Resolves the specified claim if possible",
Action: ResolveClaim,
Action: Interruptible(ResolveClaim),
Flags: resolveClaimFlags(),
}
......@@ -8,6 +8,7 @@ import (
contractMetrics "github.com/ethereum-optimism/optimism/op-challenger/game/fault/contracts/metrics"
opservice "github.com/ethereum-optimism/optimism/op-service"
"github.com/ethereum-optimism/optimism/op-service/dial"
"github.com/ethereum-optimism/optimism/op-service/opio"
"github.com/ethereum-optimism/optimism/op-service/sources/batching"
"github.com/ethereum-optimism/optimism/op-service/txmgr"
"github.com/ethereum-optimism/optimism/op-service/txmgr/metrics"
......@@ -17,6 +18,12 @@ import (
type ContractCreator[T any] func(context.Context, contractMetrics.ContractMetricer, common.Address, *batching.MultiCaller) (T, error)
func Interruptible(action cli.ActionFunc) cli.ActionFunc {
return func(ctx *cli.Context) error {
ctx.Context = opio.CancelOnInterrupt(ctx.Context)
return action(ctx)
}
}
func AddrFromFlag(flagName string) func(ctx *cli.Context) (common.Address, error) {
return func(ctx *cli.Context) (common.Address, error) {
gameAddr, err := opservice.ParseAddress(ctx.String(flagName))
......
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