From 81746808730b768f26b4235a52a060f109992c90 Mon Sep 17 00:00:00 2001
From: Spencer Corwin <29364457+spencercorwin@users.noreply.github.com>
Date: Fri, 11 Jun 2021 14:07:55 -0700
Subject: [PATCH] fix(node): update distpacher stack item return
---
packages/neo-one-node-vm/lib/Dispatcher.csproj | 4 ++--
packages/neo-one-node-vm/lib/ReturnHelpers.cs | 14 +++++++++++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/packages/neo-one-node-vm/lib/Dispatcher.csproj b/packages/neo-one-node-vm/lib/Dispatcher.csproj
index dfd61c9da0..5af090e5d7 100644
--- a/packages/neo-one-node-vm/lib/Dispatcher.csproj
+++ b/packages/neo-one-node-vm/lib/Dispatcher.csproj
@@ -14,8 +14,8 @@
-
+
+
diff --git a/packages/neo-one-node-vm/lib/ReturnHelpers.cs b/packages/neo-one-node-vm/lib/ReturnHelpers.cs
index 056e61ae85..e3261f3e50 100644
--- a/packages/neo-one-node-vm/lib/ReturnHelpers.cs
+++ b/packages/neo-one-node-vm/lib/ReturnHelpers.cs
@@ -106,6 +106,18 @@ public MapReturn(Map item)
}
}
+ public class BufferReturn
+ {
+ public byte[] value;
+ public StackItemType Type => StackItemType.Buffer;
+ public readonly bool IsNull;
+ public BufferReturn(Neo.VM.Types.Buffer item)
+ {
+ this.value = item.InnerBuffer;
+ this.IsNull = item.IsNull;
+ }
+ }
+
public class InteropInterfaceReturn
{
public dynamic value;
@@ -135,7 +147,7 @@ public static dynamic convertStackItem(StackItem item)
return item.Type switch
{
StackItemType.Any => item,
- StackItemType.Buffer => item,
+ StackItemType.Buffer => new BufferReturn((Neo.VM.Types.Buffer)item),
StackItemType.Pointer => new PointerReturn((Neo.VM.Types.Pointer)item),
StackItemType.Array => new ArrayReturn((Neo.VM.Types.Array)item),
StackItemType.Struct => new StructReturn((Struct)item),