-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathRpcNativeContract.cs
50 lines (46 loc) · 1.65 KB
/
RpcNativeContract.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (C) 2015-2023 The Neo Project.
//
// The Neo.Network.RPC is free software distributed under the MIT software license,
// see the accompanying file LICENSE in the main directory of the
// project 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;
using System.Linq;
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 uint[] UpdateHistory { 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"]),
UpdateHistory = ((JArray)json["updatehistory"]).Select(u => (uint)u.GetInt32()).ToArray()
};
}
public JObject ToJson()
{
return new JObject
{
["id"] = Id,
["hash"] = Hash.ToString(),
["nef"] = Nef.ToJson(),
["manifest"] = Manifest.ToJson(),
["updatehistory"] = new JArray(UpdateHistory.Select(u => new JNumber(u)).ToArray())
};
}
}
}