From 1e1668e949c2ad66ec626ccfa4ea0b6d3e01b6ba Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Mon, 10 Feb 2020 16:38:02 -0800 Subject: [PATCH] expose StateWaitMsg through the cli --- cli/state.go | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/cli/state.go b/cli/state.go index 7abc1e3f4..a024c5713 100644 --- a/cli/state.go +++ b/cli/state.go @@ -47,6 +47,7 @@ var stateCmd = &cli.Command{ stateComputeStateCmd, stateCallCmd, stateGetDealSetCmd, + stateWaitMsgCmd, }, } @@ -710,6 +711,46 @@ var stateComputeStateCmd = &cli.Command{ }, } +var stateWaitMsgCmd = &cli.Command{ + Name: "wait-msg", + Usage: "Wait for a message to appear on chain", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "timeout", + Value: "10m", + }, + }, + Action: func(cctx *cli.Context) error { + if !cctx.Args().Present() { + return fmt.Errorf("must specify message cid to wait for") + } + + api, closer, err := GetFullNodeAPI(cctx) + if err != nil { + return err + } + defer closer() + + ctx := ReqContext(cctx) + + msg, err := cid.Decode(cctx.Args().First()) + if err != nil { + return err + } + + mw, err := api.StateWaitMsg(ctx, msg) + if err != nil { + return err + } + + fmt.Printf("message was executed in tipset: %s", mw.TipSet.Cids()) + fmt.Printf("Exit Code: %d", mw.Receipt.ExitCode) + fmt.Printf("Gas Used: %s", mw.Receipt.GasUsed) + fmt.Printf("Return: %x", mw.Receipt.Return) + return nil + }, +} + var stateCallCmd = &cli.Command{ Name: "call", Usage: "Invoke a method on an actor locally",