Skip to content

Commit

Permalink
update applicationLogs serialization (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
ProDog authored Aug 17, 2020
1 parent 1fbe6f2 commit c465029
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 40 deletions.
9 changes: 5 additions & 4 deletions src/RpcClient/Models/RpcApplicationLog.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Neo.IO.Json;
using Neo.SmartContract;
using Neo.VM;
using Neo.VM.Types;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -16,7 +17,7 @@ public class RpcApplicationLog

public long GasConsumed { get; set; }

public List<ContractParameter> Stack { get; set; }
public List<StackItem> Stack { get; set; }

public List<RpcNotifyEventArgs> Notifications { get; set; }

Expand All @@ -39,7 +40,7 @@ public static RpcApplicationLog FromJson(JObject json)
log.Trigger = json["trigger"].TryGetEnum<TriggerType>();
log.VMState = json["vmstate"].TryGetEnum<VMState>();
log.GasConsumed = long.Parse(json["gasconsumed"].AsString());
log.Stack = ((JArray)json["stack"]).Select(p => ContractParameter.FromJson(p)).ToList();
log.Stack = ((JArray)json["stack"]).Select(p => Utility.StackItemFromJson(p)).ToList();
log.Notifications = ((JArray)json["notifications"]).Select(p => RpcNotifyEventArgs.FromJson(p)).ToList();
return log;
}
Expand All @@ -51,7 +52,7 @@ public class RpcNotifyEventArgs

public string EventName { get; set; }

public ContractParameter State { get; set; }
public StackItem State { get; set; }

public JObject ToJson()
{
Expand All @@ -68,7 +69,7 @@ public static RpcNotifyEventArgs FromJson(JObject json)
{
Contract = UInt160.Parse(json["contract"].AsString()),
EventName = json["eventname"].AsString(),
State = ContractParameter.FromJson(json["state"])
State = Utility.StackItemFromJson(json["state"])
};
}
}
Expand Down
172 changes: 136 additions & 36 deletions tests/Neo.Network.RPC.Tests/RpcTestCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1205,51 +1205,151 @@
},
"Response": {
"jsonrpc": "2.0",
"id": 1,
"id": "1",
"result": {
"txid": "0x183cd84359cd9f8b956afcd02403ec07361c1dba55f0800241b4ef2b28e88bbb",
"txid": "0xe36f62923deb64376e5e982e19b60afc65faca8d9e8eb71ac12f7298ce32ef7b",
"trigger": "Application",
"vmstate": "HALT",
"gasconsumed": "9007810",
"stack": [],
"notifications": [
"gasconsumed": "5814860",
"stack": [
{
"contract": "0x8c23f196d8a1bfd103a9dcb1f9ccf0c611377d3b",
"eventname": "Transfer",
"state": {
"type": "Array",
"value": [
{
"type": "Any"
},
{
"type": "ByteArray",
"value": "eU9We10tADBFvus3caGe5hjcaNE="
},
{
"type": "Integer",
"value": "6321697534537"
}
]
}
},
"type": "Array",
"value": [
{
"type": "Integer",
"value": "1"
},
{
"type": "Integer",
"value": "1223"
},
{
"type": "ByteString",
"value": "dGVzdHFxd2FzZGFz"
},
{
"type": "Buffer",
"value": "CAwiNQw="
},
{
"type": "Array",
"value": [
{
"type": "ByteString",
"value": "YWE="
},
{
"type": "ByteString",
"value": "YmI="
},
{
"type": "ByteString",
"value": "Y2Mw"
}
]
},
{
"type": "Map",
"value": [
{
"key": {
"type": "Integer",
"value": "2"
},
"value": {
"type": "Integer",
"value": "12"
}
},
{
"key": {
"type": "Integer",
"value": "0"
},
"value": {
"type": "Integer",
"value": "24"
}
}
]
}
]
}
],
"notifications": [
{
"contract": "0x9bde8f209c88dd0e7ca3bf0af0f476cdd8207789",
"eventname": "Transfer",
"contract": "0xbfe215933f29b29dacf0e8383722a62974ac8aa6",
"eventname": "event_name",
"state": {
"type": "Array",
"value": [
{
"type": "ByteArray",
"value": "eU9We10tADBFvus3caGe5hjcaNE="
},
{
"type": "ByteArray",
"value": "eU9We10tADBFvus3caGe5hjcaNE="
},
{
"type": "Integer",
"value": "99999961"
"type": "Array",
"value": [
{
"type": "Array",
"value": [
{
"type": "Integer",
"value": "1"
},
{
"type": "Integer",
"value": "1223"
},
{
"type": "ByteString",
"value": "dGVzdHFxd2FzZGFz"
},
{
"type": "Buffer",
"value": "CAwiNQw="
},
{
"type": "Array",
"value": [
{
"type": "ByteString",
"value": "YWE="
},
{
"type": "ByteString",
"value": "YmI="
},
{
"type": "ByteString",
"value": "Y2Mw"
}
]
},
{
"type": "Map",
"value": [
{
"key": {
"type": "Integer",
"value": "2"
},
"value": {
"type": "Integer",
"value": "12"
}
},
{
"key": {
"type": "Integer",
"value": "0"
},
"value": {
"type": "Integer",
"value": "24"
}
}
]
}
]
}
]
}
]
}
Expand Down

0 comments on commit c465029

Please sign in to comment.