State CLI: fix printMsg to not panic when message isn't found

This commit is contained in:
Aayush Rajasekaran 2021-04-03 22:54:57 -04:00
parent eede19fb0b
commit d9dcc7845f

View File

@ -1464,7 +1464,12 @@ func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message,
}
func printMsg(ctx context.Context, api api.FullNode, msg cid.Cid, mw *lapi.MsgLookup, m *types.Message) error {
if mw != nil {
if mw == nil {
fmt.Println("message was not found on chain")
return nil
}
if mw.Message != msg {
fmt.Printf("Message was replaced: %s\n", mw.Message)
}
@ -1473,10 +1478,6 @@ func printMsg(ctx context.Context, api api.FullNode, msg cid.Cid, mw *lapi.MsgLo
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)
} else {
fmt.Println("message was not found on chain")
}
if err := printReceiptReturn(ctx, api, m, mw.Receipt); err != nil {
return err
}