diff --git a/src/RpcClient/Models/RpcNativeContract.cs b/src/RpcClient/Models/RpcNativeContract.cs
deleted file mode 100644
index c28251f9c..000000000
--- a/src/RpcClient/Models/RpcNativeContract.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (C) 2015-2024 The Neo Project.
-//
-// RpcNativeContract.cs file belongs to the neo project and is free
-// software distributed under the MIT software license, see the
-// accompanying file LICENSE in the main directory of the
-// repository or http://www.opensource.org/licenses/mit-license.php
-// for more details.
-//
-// Redistribution and use in source and binary forms with or without
-// modifications are permitted.
-
-using Neo.Json;
-using Neo.SmartContract;
-using Neo.SmartContract.Manifest;
-
-namespace Neo.Network.RPC.Models
-{
- public class RpcNativeContract
- {
- public int Id { get; set; }
- public UInt160 Hash { get; set; }
- public NefFile Nef { get; set; }
- public ContractManifest Manifest { get; set; }
-
- public static RpcNativeContract FromJson(JObject json)
- {
- return new RpcNativeContract
- {
- Id = (int)json["id"].AsNumber(),
- Hash = UInt160.Parse(json["hash"].AsString()),
- Nef = RpcNefFile.FromJson((JObject)json["nef"]),
- Manifest = ContractManifest.FromJson((JObject)json["manifest"])
- };
- }
-
- public JObject ToJson()
- {
- return new JObject
- {
- ["id"] = Id,
- ["hash"] = Hash.ToString(),
- ["nef"] = Nef.ToJson(),
- ["manifest"] = Manifest.ToJson()
- };
- }
- }
-}
diff --git a/src/RpcClient/RpcClient.cs b/src/RpcClient/RpcClient.cs
index 8cd8a717a..27b0023ec 100644
--- a/src/RpcClient/RpcClient.cs
+++ b/src/RpcClient/RpcClient.cs
@@ -260,7 +260,7 @@ public static ContractState ContractStateFromJson(JObject json)
return new ContractState
{
Id = (int)json["id"].AsNumber(),
- UpdateCounter = (ushort)json["updatecounter"].AsNumber(),
+ UpdateCounter = (ushort)(json["updatecounter"]?.AsNumber() ?? 0),
Hash = UInt160.Parse(json["hash"].AsString()),
Nef = RpcNefFile.FromJson((JObject)json["nef"]),
Manifest = ContractManifest.FromJson((JObject)json["manifest"])
@@ -270,10 +270,10 @@ public static ContractState ContractStateFromJson(JObject json)
///
/// Get all native contracts.
///
- public async Task GetNativeContractsAsync()
+ public async Task GetNativeContractsAsync()
{
var result = await RpcSendAsync(GetRpcName()).ConfigureAwait(false);
- return ((JArray)result).Select(p => RpcNativeContract.FromJson((JObject)p)).ToArray();
+ return ((JArray)result).Select(p => ContractStateFromJson((JObject)p)).ToArray();
}
///
diff --git a/src/RpcServer/RpcServer.Blockchain.cs b/src/RpcServer/RpcServer.Blockchain.cs
index e381a19ef..a4fda6e73 100644
--- a/src/RpcServer/RpcServer.Blockchain.cs
+++ b/src/RpcServer/RpcServer.Blockchain.cs
@@ -333,7 +333,7 @@ protected virtual JToken GetCommittee(JArray _params)
[RpcMethod]
protected virtual JToken GetNativeContracts(JArray _params)
{
- return new JArray(NativeContract.Contracts.Select(p => p.NativeContractToJson(system)));
+ return new JArray(NativeContract.Contracts.Select(p => NativeContract.ContractManagement.GetContract(system.StoreView, p.Hash).ToJson()));
}
}
}
diff --git a/src/RpcServer/Utility.cs b/src/RpcServer/Utility.cs
index 5f4f2d5b3..24ccc9248 100644
--- a/src/RpcServer/Utility.cs
+++ b/src/RpcServer/Utility.cs
@@ -32,19 +32,5 @@ public static JObject TransactionToJson(Transaction tx, ProtocolSettings setting
json["netfee"] = tx.NetworkFee.ToString();
return json;
}
-
- public static JObject NativeContractToJson(this NativeContract contract, NeoSystem system)
- {
- var state = contract.GetContractState(system.Settings,
- NativeContract.Ledger.CurrentIndex(system.StoreView));
-
- return new JObject
- {
- ["id"] = contract.Id,
- ["hash"] = contract.Hash.ToString(),
- ["nef"] = state.Nef.ToJson(),
- ["manifest"] = state.Manifest.ToJson()
- };
- }
}
}
diff --git a/tests/Neo.Network.RPC.Tests/RpcTestCases.json b/tests/Neo.Network.RPC.Tests/RpcTestCases.json
index 4e36c98f8..cfbffb3ed 100644
--- a/tests/Neo.Network.RPC.Tests/RpcTestCases.json
+++ b/tests/Neo.Network.RPC.Tests/RpcTestCases.json
@@ -1037,6 +1037,7 @@
"result": [
{
"id": -1,
+ "updatecounter": 0,
"hash": "0xa501d7d7d10983673b61b7a2d3a813b36f9f0e43",
"nef": {
"magic": 860243278,
@@ -1206,6 +1207,7 @@
},
{
"id": -2,
+ "updatecounter": 1,
"hash": "0x971d69c6dd10ce88e7dfffec1dc603c6125a8764",
"nef": {
"magic": 860243278,
@@ -1303,6 +1305,7 @@
},
{
"id": -3,
+ "updatecounter": 0,
"hash": "0xef4073a0f2b305a38ec4050e4d3d28bc40ea63f5",
"nef": {
"magic": 860243278,
@@ -1507,6 +1510,7 @@
},
{
"id": -4,
+ "updatecounter": 0,
"hash": "0xd2a4cff31913016155e38e474a2c06d08be276cf",
"nef": {
"magic": 860243278,
@@ -1615,6 +1619,7 @@
},
{
"id": -5,
+ "updatecounter": 0,
"hash": "0x79bcd398505eb779df6e67e4be6c14cded08e2f2",
"nef": {
"magic": 860243278,
@@ -1796,6 +1801,7 @@
},
{
"id": -6,
+ "updatecounter": 0,
"hash": "0x597b1471bbce497b7809e2c8f10db67050008b02",
"nef": {
"magic": 860243278,
@@ -1859,6 +1865,7 @@
},
{
"id": -7,
+ "updatecounter": 0,
"hash": "0x8dc0e742cbdfdeda51ff8a8b78d46829144c80ee",
"nef": {
"magic": 860243278,
@@ -1967,6 +1974,7 @@
},
{
"id": -8,
+ "updatecounter": 0,
"hash": "0xa2b524b68dfe43a9d56af84f443c6b9843b8028c",
"nef": {
"magic": 860243278,