diff --git a/src/ApplicationLogs/LogReader.cs b/src/ApplicationLogs/LogReader.cs index 71a9253f0..4d5c7bbc8 100644 --- a/src/ApplicationLogs/LogReader.cs +++ b/src/ApplicationLogs/LogReader.cs @@ -90,14 +90,19 @@ public static JObject TxLogToJson(Blockchain.ApplicationExecuted appExec) trigger["vmstate"] = appExec.VMState; trigger["exception"] = GetExceptionMessage(appExec.Exception); trigger["gasconsumed"] = appExec.GasConsumed.ToString(); - try + var stack = new JArray(); + foreach (var item in appExec.Stack) { - trigger["stack"] = appExec.Stack.Select(q => q.ToJson(Settings.Default.MaxStackSize)).ToArray(); - } - catch (Exception ex) - { - trigger["exception"] = ex.Message; + try + { + stack.Add(item.ToJson(Settings.Default.MaxStackSize)); + } + catch (Exception ex) + { + stack.Add("error: " + ex.Message); + } } + trigger["stack"] = stack; trigger["notifications"] = appExec.Notifications.Select(q => { JObject notification = new JObject(); @@ -133,14 +138,19 @@ public static JObject BlockLogToJson(Block block, IReadOnlyList q.ToJson(Settings.Default.MaxStackSize)).ToArray(); - } - catch (Exception ex) - { - trigger["exception"] = ex.Message; + try + { + stack.Add(item.ToJson(Settings.Default.MaxStackSize)); + } + catch (Exception ex) + { + stack.Add("error: " + ex.Message); + } } + trigger["stack"] = stack; trigger["notifications"] = appExec.Notifications.Select(q => { JObject notification = new JObject(); diff --git a/src/RpcServer/RpcServer.SmartContract.cs b/src/RpcServer/RpcServer.SmartContract.cs index 1a7c24c17..eb5af98f4 100644 --- a/src/RpcServer/RpcServer.SmartContract.cs +++ b/src/RpcServer/RpcServer.SmartContract.cs @@ -93,14 +93,19 @@ private JObject GetInvokeResult(byte[] script, Signer[] signers = null, Witness[ ["storagechanges"] = ToJson(session.Engine.Snapshot.GetChangeSet()) }; } - try + var stack = new JArray(); + foreach (var item in session.Engine.ResultStack) { - json["stack"] = new JArray(session.Engine.ResultStack.Select(p => ToJson(p, session))); - } - catch (InvalidOperationException) - { - json["stack"] = "error: invalid operation"; + try + { + stack.Add(ToJson(item, session)); + } + catch (Exception ex) + { + stack.Add("error: " + ex.Message); + } } + json["stack"] = stack; if (session.Engine.State != VMState.FAULT) { ProcessInvokeWithWallet(json, signers); diff --git a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj index 38851f4a9..0887cd319 100644 --- a/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj +++ b/tests/Neo.Network.RPC.Tests/Neo.Network.RPC.Tests.csproj @@ -1,21 +1,21 @@ - - - Neo.Network.RPC.Tests - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - PreserveNewest - - - \ No newline at end of file + + + Neo.Network.RPC.Tests + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + PreserveNewest + + +