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
This commit is contained in:
Anna Shaleva 2020-03-13 12:32:26 +03:00
parent d9a83373ed
commit 784bac0b38

View file

@ -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,
}}