diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 44d252790..ab7337427 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -15,7 +15,7 @@ - + \ No newline at end of file diff --git a/src/RpcClient/Models/RpcContractState.cs b/src/RpcClient/Models/RpcContractState.cs index 041cd97f8..802710d0d 100644 --- a/src/RpcClient/Models/RpcContractState.cs +++ b/src/RpcClient/Models/RpcContractState.cs @@ -1,3 +1,4 @@ +using Neo; using Neo.IO.Json; using Neo.Ledger; using Neo.SmartContract.Manifest; @@ -19,6 +20,7 @@ public static RpcContractState FromJson(JObject json) ContractState = new ContractState { Id = (int)json["id"].AsNumber(), + Hash = UInt160.Parse(json["hash"].AsString()), Script = Convert.FromBase64String(json["script"].AsString()), Manifest = ContractManifest.FromJson(json["manifest"]) } diff --git a/src/RpcClient/RpcClient.cs b/src/RpcClient/RpcClient.cs index 431e08988..b9c184137 100644 --- a/src/RpcClient/RpcClient.cs +++ b/src/RpcClient/RpcClient.cs @@ -201,6 +201,7 @@ public static ContractState ContractStateFromJson(JObject json) return new ContractState { Id = (int)json["id"].AsNumber(), + Hash = UInt160.Parse(json["hash"].AsString()), Script = Convert.FromBase64String(json["script"].AsString()), Manifest = ContractManifest.FromJson(json["manifest"]) }; diff --git a/tests/Neo.Network.RPC.Tests/RpcTestCases.json b/tests/Neo.Network.RPC.Tests/RpcTestCases.json index 7b4c1c33d..eae9639f9 100644 --- a/tests/Neo.Network.RPC.Tests/RpcTestCases.json +++ b/tests/Neo.Network.RPC.Tests/RpcTestCases.json @@ -318,109 +318,87 @@ "Request": { "jsonrpc": "2.0", "method": "getcontractstate", - "params": [ "0x806b7fa0db3b46d6c42e1e1b0a7fd50db9d4a9b0" ], + "params": [ "0x36a019d836d964c438c573f78badf79b9e7eebdd" ], "id": 1 }, "Response": { "jsonrpc": "2.0", "id": 1, "result": { - "id": 0, - "hash": "0x806b7fa0db3b46d6c42e1e1b0a7fd50db9d4a9b0", - "script": "VgIMFGklqlVHEkOan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VQLTEw0EAhQZv2Z84MC3RvdGFsU3VwcGx5IVBBkl3oMdshQFcCA3oQticHAAAAEEB4IUH4J+yMJQcAAAAQQHnKDAEU2yGzJQcAAAAQQCFBm/ZnznghUEGSXegx2yFwaHq1JwcAAAAQQHh5mlCaULQlBwAAABFAaHqzJxgAAAAhQZv2Z854IVBBL1jF7SMWAAAAIUGb9mfOeGh6nyFTQeY/GIQhQZv2Z855IVBBkl3oMXFpJ0QAAAAMB2lmIHBhc3MhQc/nR5YhQZv2Z855adshep4hU0HmPxiEDBBTdG9yYWdlLnB1dCBwYXNzIUHP50eWIzsAAAAMCWVsc2UgcGFzcyFBz+dHliFBm/Znznl6IVNB5j8YhAwOYW1vdW50IC0+IHBhc3MhQc/nR5YheHl6IVMMCFRyYW5zZmVyFMBBlQFvYRFA", + "id": -2, + "updatecounter": 0, + "hash": "0x36a019d836d964c438c573f78badf79b9e7eebdd", + "script": "DANHQVNBa2d4Cw==", "manifest": { + "name": "GAS", "groups": [], - "features": { - "storage": true, - "payable": true - }, "supportedstandards": [ - "NEP-5" + "NEP-17" ], "abi": { - "hash": "0x806b7fa0db3b46d6c42e1e1b0a7fd50db9d4a9b0", "methods": [ { - "name": "main", - "parameters": [ - { - "name": "method", - "type": "String" - }, - { - "name": "args", - "type": "Array" - } - ], + "name": "onPersist", + "parameters": [], "offset": 0, - "returntype": "ByteArray" + "returntype": "Void" }, { - "name": "Destroy", + "name": "totalSupply", "parameters": [], - "offset": 400, - "returntype": "Boolean" + "offset": 0, + "returntype": "Integer" }, { - "name": "Migrate", + "name": "balanceOf", "parameters": [ { - "name": "script", + "name": "account", "type": "ByteArray" - }, - { - "name": "manifest", - "type": "String" } ], - "offset": 408, - "returntype": "Boolean" + "offset": 0, + "returntype": "Integer" }, { - "name": "BalanceOf", + "name": "transfer", "parameters": [ { - "name": "account", + "name": "from", "type": "ByteArray" + }, + { + "name": "to", + "type": "ByteArray" + }, + { + "name": "amount", + "type": "Integer" + }, + { + "name": "data", + "type": "Any" } ], - "offset": 474, - "returntype": "Integer" - }, - { - "name": "Decimals", - "parameters": [], - "offset": 585, - "returntype": "Integer" - }, - { - "name": "Deploy", - "parameters": [], - "offset": 610, + "offset": 0, "returntype": "Boolean" }, { - "name": "Name", + "name": "postPersist", "parameters": [], - "offset": 763, - "returntype": "String" + "offset": 0, + "returntype": "Void" }, { - "name": "Symbol", + "name": "symbol", "parameters": [], - "offset": 787, + "offset": 0, "returntype": "String" }, { - "name": "SupportedStandards", + "name": "decimals", "parameters": [], - "offset": 793, - "returntype": "Array" - }, - { - "name": "TotalSupply", - "parameters": [], - "offset": 827, + "offset": 0, "returntype": "Integer" } ], @@ -429,15 +407,15 @@ "name": "Transfer", "parameters": [ { - "name": "arg1", - "type": "ByteArray" + "name": "from", + "type": "Hash160" }, { - "name": "arg2", - "type": "ByteArray" + "name": "to", + "type": "Hash160" }, { - "name": "arg3", + "name": "amount", "type": "Integer" } ] @@ -451,7 +429,12 @@ } ], "trusts": [], - "safemethods": [], + "safemethods": [ + "totalSupply", + "balanceOf", + "symbol", + "decimals" + ], "extra": null } } diff --git a/tests/Neo.Network.RPC.Tests/UT_ContractClient.cs b/tests/Neo.Network.RPC.Tests/UT_ContractClient.cs index 2a120fad4..a442fdd74 100644 --- a/tests/Neo.Network.RPC.Tests/UT_ContractClient.cs +++ b/tests/Neo.Network.RPC.Tests/UT_ContractClient.cs @@ -45,7 +45,6 @@ public async Task TestDeployContract() Permissions = new[] { ContractPermission.DefaultPermission }, Abi = new ContractAbi() { - Hash = new byte[1].ToScriptHash(), Events = new ContractEventDescriptor[0], Methods = new ContractMethodDescriptor[0] }, @@ -55,7 +54,6 @@ public async Task TestDeployContract() SupportedStandards = new string[] { "NEP-10" }, Extra = null, }; - manifest.Features = ContractFeatures.HasStorage | ContractFeatures.Payable; using (ScriptBuilder sb = new ScriptBuilder()) { sb.EmitSysCall(ApplicationEngine.System_Contract_Create, new byte[1], manifest.ToString());