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:
commit
40972762df
33
cli/state.go
33
cli/state.go
@ -1113,14 +1113,39 @@ var stateWaitMsgCmd = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("message was executed in tipset: %s", mw.TipSet.Cids())
|
m, err := api.ChainGetMessage(ctx, msg)
|
||||||
fmt.Printf("Exit Code: %d", mw.Receipt.ExitCode)
|
if err != nil {
|
||||||
fmt.Printf("Gas Used: %d", mw.Receipt.GasUsed)
|
return err
|
||||||
fmt.Printf("Return: %x", mw.Receipt.Return)
|
}
|
||||||
|
|
||||||
|
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
|
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{
|
var stateSearchMsgCmd = &cli.Command{
|
||||||
Name: "search-msg",
|
Name: "search-msg",
|
||||||
Usage: "Search to see whether a message has appeared on chain",
|
Usage: "Search to see whether a message has appeared on chain",
|
||||||
|
Loading…
Reference in New Issue
Block a user