provide decoded return values in output of StateWaitMsg

This commit is contained in:
whyrusleeping
2020-07-03 09:57:58 -07:00
parent d3a1261f1e
commit 16e493a67a
4 changed files with 94 additions and 59 deletions
+24 -2
View File
@@ -361,9 +361,31 @@ func (a *StateAPI) StateWaitMsg(ctx context.Context, msg cid.Cid, confidence uin
return nil, err
}
var returndec interface{}
if recpt.ExitCode == 0 && len(recpt.Return) > 0 {
cmsg, err := a.Chain.GetCMessage(msg)
if err != nil {
return nil, xerrors.Errorf("failed to load message after successful receipt search: %w", err)
}
vmsg := cmsg.VMMessage()
t, err := stmgr.GetReturnType(ctx, a.StateManager, vmsg.To, vmsg.Method, ts)
if err != nil {
return nil, xerrors.Errorf("failed to get return type: %w", err)
}
if err := t.UnmarshalCBOR(bytes.NewReader(recpt.Return)); err != nil {
return nil, err
}
returndec = t
}
return &api.MsgLookup{
Receipt: *recpt,
TipSet: ts,
Receipt: *recpt,
ReturnDec: returndec,
TipSet: ts,
}, nil
}