Merge pull request #4105 from filecoin-project/asr/decode-params

Add a StateDecodeParams method
This commit is contained in:
Łukasz Magiera
2020-10-31 01:05:50 +01:00
committed by GitHub
6 changed files with 63 additions and 5 deletions
+4 -5
View File
@@ -1324,12 +1324,11 @@ func sumGas(changes []*types.GasTrace) types.GasTrace {
}
func JsonParams(code cid.Cid, method abi.MethodNum, params []byte) (string, error) {
methodMeta, found := stmgr.MethodsMap[code][method]
if !found {
return "", fmt.Errorf("method %d not found on actor %s", method, code)
p, err := stmgr.GetParamType(code, method)
if err != nil {
return "", err
}
re := reflect.New(methodMeta.Params.Elem())
p := re.Interface().(cbg.CBORUnmarshaler)
if err := p.UnmarshalCBOR(bytes.NewReader(params)); err != nil {
return "", err
}