From 784bac0b38116c1b6354ee96bdcbd094dd29f564 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Fri, 13 Mar 2020 12:32:26 +0300 Subject: [PATCH] rpc: bug with empty stack marshalling in getapplicationlog Problem: cannot marshall empty raw message from appExecResult.Stack Solution: add handler for case when appExecResult.Stack is an empty string --- pkg/rpc/response/result/application_log.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/rpc/response/result/application_log.go b/pkg/rpc/response/result/application_log.go index 83275b9bd..27e2026c0 100644 --- a/pkg/rpc/response/result/application_log.go +++ b/pkg/rpc/response/result/application_log.go @@ -46,12 +46,18 @@ func NewApplicationLog(appExecRes *state.AppExecResult, scriptHash util.Uint160) triggerString := appExecRes.Trigger.String() + var rawStack json.RawMessage + if len(appExecRes.Stack) != 0 { + rawStack = json.RawMessage(appExecRes.Stack) + } else { + rawStack = json.RawMessage("[]") + } executions := []Execution{{ Trigger: triggerString, ScriptHash: scriptHash, VMState: appExecRes.VMState, GasConsumed: appExecRes.GasConsumed, - Stack: json.RawMessage(appExecRes.Stack), + Stack: rawStack, Events: events, }}