From 4f624465c221ea148493a1b89259dabf4fa18fbc Mon Sep 17 00:00:00 2001 From: Jeromy Date: Wed, 13 May 2020 10:53:02 -0700 Subject: [PATCH] make the wait-msg cli print out pretty printed return values --- cli/state.go | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/cli/state.go b/cli/state.go index 6f271906e..b98478d69 100644 --- a/cli/state.go +++ b/cli/state.go @@ -1113,14 +1113,39 @@ var stateWaitMsgCmd = &cli.Command{ 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: %d", mw.Receipt.GasUsed) - fmt.Printf("Return: %x", mw.Receipt.Return) + m, err := api.ChainGetMessage(ctx, msg) + if err != nil { + return err + } + + fmt.Printf("message was executed in tipset: %s\n", mw.TipSet.Cids()) + fmt.Printf("Exit Code: %d\n", mw.Receipt.ExitCode) + fmt.Printf("Gas Used: %d\n", mw.Receipt.GasUsed) + fmt.Printf("Return: %x\n", mw.Receipt.Return) + if err := printReceiptReturn(ctx, api, m, mw.Receipt); err != nil { + return err + } + return nil }, } +func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message, r types.MessageReceipt) error { + act, err := api.StateGetActor(ctx, m.To, types.EmptyTSK) + if err != nil { + return err + } + + jret, err := jsonReturn(act.Code, m.Method, r.Return) + if err != nil { + return err + } + + fmt.Println(jret) + + return nil +} + var stateSearchMsgCmd = &cli.Command{ Name: "search-msg", Usage: "Search to see whether a message has appeared on chain",