Merge pull request #1724 from filecoin-project/feat/wait-msg-cli-nice

make the wait-msg cli print out pretty printed return values
This commit is contained in:
Łukasz Magiera 2020-05-13 19:57:14 +02:00 committed by GitHub
commit 40972762df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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",