Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix the error jsonp format in vm_message #1160

Merged
merged 2 commits into from
Mar 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lens/util/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func init() {

var log = logging.Logger("lily/lens")

type CBORByteArray struct {
Params string
}

func ParseVmMessageParams(params []byte, paramsCodec uint64, method abi.MethodNum, actCode cid.Cid) (string, string, error) {
m, found := ActorRegistry.Methods[actCode][method]
if !found {
Expand All @@ -52,7 +56,11 @@ func ParseVmMessageParams(params []byte, paramsCodec uint64, method abi.MethodNu
// If the codec is 0, the parameters/return value are "empty".
// If the codec is 0x55, it's bytes.
if paramsCodec == 0 || paramsCodec == 0x55 {
return string(params), m.Name, nil
paramj, err := json.Marshal(CBORByteArray{Params: string(params)})
if err != nil {
return "", "", err
}
return string(paramj), m.Name, nil
}
return ParseParams(params, method, actCode)
}
Expand All @@ -74,7 +82,11 @@ func ParseVmMessageReturn(ret []byte, retCodec uint64, method abi.MethodNum, act
// If the codec is 0, the parameters/return value are "empty".
// If the codec is 0x55, it's bytes.
if retCodec == 0 || retCodec == 0x55 {
return string(ret), m.Name, nil
retj, err := json.Marshal(CBORByteArray{Params: string(ret)})
if err != nil {
return "", "", err
}
return string(retj), m.Name, nil
}
return ParseReturn(ret, method, actCode)
}
Expand Down