when use lotus state call method, in lotus/cli/state.go 1620 line, the paramObj needs struct type not a ptr type,

if use a ptr type, the program will panic in line 1621(paramObj.NumField())
This commit is contained in:
eben.xie 2020-12-31 11:41:51 +08:00
parent bb5a92e2f4
commit 72c1fa81db

View File

@ -1617,7 +1617,7 @@ func parseParamsForMethod(act cid.Cid, method uint64, args []string) ([]byte, er
return nil, fmt.Errorf("unknown method %d for actor %s", method, act) return nil, fmt.Errorf("unknown method %d for actor %s", method, act)
} }
paramObj := methodMeta.Params paramObj := methodMeta.Params.Elem()
if paramObj.NumField() != len(args) { if paramObj.NumField() != len(args) {
return nil, fmt.Errorf("not enough arguments given to call that method (expecting %d)", paramObj.NumField()) return nil, fmt.Errorf("not enough arguments given to call that method (expecting %d)", paramObj.NumField())
} }