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

empty scripthash, all notifications #1074

Merged
merged 4 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion neo.UnitTests/SmartContract/UT_InteropService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void Runtime_GetNotifications_Test()

// Receive all notifications

script.EmitPush(UInt160.Zero.ToArray());
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
script.EmitPush(new byte[0]);
script.EmitSysCall(InteropService.System_Runtime_GetNotifications);

// Execute
Expand Down
10 changes: 6 additions & 4 deletions neo/SmartContract/InteropService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ private static bool Runtime_Serialize(ApplicationEngine engine)

private static bool Runtime_GetNotifications(ApplicationEngine engine)
{
var data = engine.CurrentContext.EvaluationStack.Pop().GetByteArray();
if (data.Length != UInt160.Length) return false;
byte[] data = engine.CurrentContext.EvaluationStack.Pop().GetByteArray();
if ((data.Length != 0) && (data.Length != UInt160.Length)) return false;

var hash = new UInt160(data);
IEnumerable<NotifyEventArgs> notifications = engine.Notifications;
if (!hash.Equals(UInt160.Zero))
if (data.Length == UInt160.Length) // must filter by scriptHash
{
var hash = new UInt160(data);
shargon marked this conversation as resolved.
Show resolved Hide resolved
notifications = notifications.Where(p => p.ScriptHash == hash);
}

if (!engine.CheckArraySize(notifications.Count())) return false;
engine.CurrentContext.EvaluationStack.Push(notifications.Select(u => new VM.Types.Array(new StackItem[] { u.ScriptHash.ToArray(), u.State })).ToArray());
Expand Down