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

3.0.0-preview2 #224

Closed
wants to merge 4 commits into from
Closed
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 src/ApplicationLogs/ApplicationLogs.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00847</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand Down
60 changes: 60 additions & 0 deletions src/ApplicationLogs/Helper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Neo.IO.Json;
using Neo.VM.Types;
using System;
using System.Collections.Generic;
using System.Linq;
using Array = Neo.VM.Types.Array;
using Boolean = Neo.VM.Types.Boolean;
using Buffer = Neo.VM.Types.Buffer;

namespace Neo.Plugins
{
internal static class Helper
{
public static JObject ToJson(this StackItem item)
{
return ToJson(item, null);
}

private static JObject ToJson(StackItem item, HashSet<StackItem> context)
{
JObject json = new JObject();
json["type"] = item.Type;
switch (item)
{
case Array array:
context ??= new HashSet<StackItem>(ReferenceEqualityComparer.Default);
if (!context.Add(array)) throw new InvalidOperationException();
json["value"] = new JArray(array.Select(p => ToJson(p, context)));
break;
case Boolean boolean:
json["value"] = boolean.ToBoolean();
break;
case Buffer buffer:
json["value"] = Convert.ToBase64String(buffer.InnerBuffer);
break;
case ByteString byteString:
json["value"] = Convert.ToBase64String(byteString.Span);
break;
case Integer integer:
json["value"] = integer.ToBigInteger().ToString();
break;
case Map map:
context ??= new HashSet<StackItem>(ReferenceEqualityComparer.Default);
if (!context.Add(map)) throw new InvalidOperationException();
json["value"] = new JArray(map.Select(p =>
{
JObject item = new JObject();
item["key"] = ToJson(p.Key, context);
item["value"] = ToJson(p.Value, context);
return item;
}));
break;
case Pointer pointer:
json["value"] = pointer.Position;
break;
}
return json;
}
}
}
4 changes: 2 additions & 2 deletions src/ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void OnPersist(StoreView snapshot, IReadOnlyList<Blockchain.ApplicationEx
json["gas_consumed"] = appExec.GasConsumed.ToString();
try
{
json["stack"] = appExec.Stack.Select(q => q.ToParameter().ToJson()).ToArray();
json["stack"] = appExec.Stack.Select(q => q.ToJson()).ToArray();
}
catch (InvalidOperationException)
{
Expand All @@ -64,7 +64,7 @@ public void OnPersist(StoreView snapshot, IReadOnlyList<Blockchain.ApplicationEx
notification["contract"] = q.ScriptHash.ToString();
try
{
notification["state"] = q.State.ToParameter().ToJson();
notification["state"] = q.State.ToJson();
}
catch (InvalidOperationException)
{
Expand Down
25 changes: 25 additions & 0 deletions src/ApplicationLogs/ReferenceEqualityComparer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

namespace Neo.Plugins
{
internal sealed class ReferenceEqualityComparer : IEqualityComparer, IEqualityComparer<object>
{
public static readonly ReferenceEqualityComparer Default = new ReferenceEqualityComparer();

private ReferenceEqualityComparer()
{
}

public new bool Equals(object x, object y)
{
return x == y;
}

public int GetHashCode(object obj)
{
return RuntimeHelpers.GetHashCode(obj);
}
}
}
4 changes: 2 additions & 2 deletions src/LevelDBStore/LevelDBStore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00863</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo</RootNamespace>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand All @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00863" />
<PackageReference Include="Neo" Version="3.0.0-preview2-00" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/RocksDBStore/RocksDBStore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00863</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Plugins.Storage</RootNamespace>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00863" />
<PackageReference Include="Neo" Version="3.0.0-preview2-00" />
<PackageReference Include="RocksDbNative" Version="6.2.2" />
<PackageReference Include="RocksDbSharp" Version="6.2.2" />
</ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/RpcClient/RpcClient.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00863</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Network.RPC</RootNamespace>
<Authors>The Neo Project</Authors>
Expand All @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00863" />
<PackageReference Include="Neo" Version="3.0.0-preview2-00" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/RpcNep5Tracker/RpcNep5Tracker.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>3.0.0-CI00847</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/RpcServer/RpcServer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00863</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand All @@ -15,7 +15,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.ResponseCompression" Version="2.2.0" />
<PackageReference Include="Neo" Version="3.0.0-CI00883" />
<PackageReference Include="Neo" Version="3.0.0-preview2-00" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/StatesDumper/StatesDumper.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00863</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00863" />
<PackageReference Include="Neo" Version="3.0.0-preview2-00" />
<PackageReference Include="Neo.ConsoleService" Version="1.0.0" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions src/SystemLog/SystemLog.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>3.0.0-CI00863</Version>
<Version>3.0.0-preview2</Version>
<TargetFramework>netstandard2.1</TargetFramework>
<RootNamespace>Neo.Plugins</RootNamespace>
</PropertyGroup>
Expand All @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI00863" />
<PackageReference Include="Neo" Version="3.0.0-preview2-00" />
</ItemGroup>

</Project>
30 changes: 15 additions & 15 deletions tests/Neo.Network.RPC.Tests/RpcTestCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"Request": {
"jsonrpc": "2.0",
"method": "getblock",
"params": [ "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445" ],
"params": [ "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8" ],
"id": 1
},
"Response": {
Expand All @@ -71,7 +71,7 @@
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445",
"hash": "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8",
"size": 171,
"version": 0,
"previousblockhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand All @@ -91,7 +91,7 @@
},
"tx": [
{
"hash": "0xb13fd7940186896233272811e61b69a0c4b7dd576fdf3b89987c8cdee2d71e37",
"hash": "0x019befa728a371a08fb0f78330b3c697ebc9d8bbf252bd173b17cc2bd6e97e9c",
"size": 57,
"version": 0,
"nonce": 0,
Expand Down Expand Up @@ -120,14 +120,14 @@
"Request": {
"jsonrpc": "2.0",
"method": "getblock",
"params": [ "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445", true ],
"params": [ "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8", true ],
"id": 1
},
"Response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445",
"hash": "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8",
"size": 171,
"version": 0,
"previousblockhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand All @@ -147,7 +147,7 @@
},
"tx": [
{
"hash": "0xb13fd7940186896233272811e61b69a0c4b7dd576fdf3b89987c8cdee2d71e37",
"hash": "0x019befa728a371a08fb0f78330b3c697ebc9d8bbf252bd173b17cc2bd6e97e9c",
"size": 57,
"version": 0,
"nonce": 0,
Expand Down Expand Up @@ -196,7 +196,7 @@
"Response": {
"jsonrpc": "2.0",
"id": 1,
"result": "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445"
"result": "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8"
}
},
{
Expand All @@ -218,7 +218,7 @@
"Request": {
"jsonrpc": "2.0",
"method": "getblockheader",
"params": [ "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445" ],
"params": [ "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8" ],
"id": 1
},
"Response": {
Expand All @@ -239,7 +239,7 @@
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445",
"hash": "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8",
"size": 105,
"version": 0,
"previousblockhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand All @@ -263,14 +263,14 @@
"Request": {
"jsonrpc": "2.0",
"method": "getblockheader",
"params": [ "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445", true ],
"params": [ "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8", true ],
"id": 1
},
"Response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0x5bb05a3b857c9eaaf94dc33fa5b4a2278601eefcdb90703698972ef7d029e445",
"hash": "0xe191fe1aea732c3e23f20af8a95e09f95891176f8064a2fce8571d51f80619a8",
"size": 105,
"version": 0,
"previousblockhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
Expand Down Expand Up @@ -489,7 +489,7 @@
"Request": {
"jsonrpc": "2.0",
"method": "getrawtransaction",
"params": [ "0xd159457e12f6b0d4910fc6729f426be5d0c06f0f149d0836db9f634a5cf216fb" ],
"params": [ "0x0cfd49c48306f9027dc71585589b6456bcc53567c359fb7858eabca482186b78" ],
"id": 1
},
"Response": {
Expand All @@ -503,14 +503,14 @@
"Request": {
"jsonrpc": "2.0",
"method": "getrawtransaction",
"params": [ "0xd159457e12f6b0d4910fc6729f426be5d0c06f0f149d0836db9f634a5cf216fb", true ],
"params": [ "0x0cfd49c48306f9027dc71585589b6456bcc53567c359fb7858eabca482186b78", true ],
"id": 1
},
"Response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"hash": "0xd159457e12f6b0d4910fc6729f426be5d0c06f0f149d0836db9f634a5cf216fb",
"hash": "0x0cfd49c48306f9027dc71585589b6456bcc53567c359fb7858eabca482186b78",
"size": 272,
"version": 0,
"nonce": 969006668,
Expand Down Expand Up @@ -572,7 +572,7 @@
"Request": {
"jsonrpc": "2.0",
"method": "gettransactionheight",
"params": [ "0xd159457e12f6b0d4910fc6729f426be5d0c06f0f149d0836db9f634a5cf216fb" ],
"params": [ "0x0cfd49c48306f9027dc71585589b6456bcc53567c359fb7858eabca482186b78" ],
"id": 1
},
"Response": {
Expand Down