1use crate::schema_helpers::*;
4use crate::serde_utils::{EntityHex, Hash256, Pubkey, U128Hex, U64Hex};
5use ckb_jsonrpc_types::{DepType, JsonBytes, OutPoint as OutPointWrapper, Script, ScriptHashType};
6use ckb_types::packed::OutPoint;
7use ckb_types::H256;
8use schemars::JsonSchema;
9use serde::{Deserialize, Serialize};
10use serde_with::serde_as;
11
12#[serde_as]
14#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
15pub struct GraphNodesParams {
16 #[serde_as(as = "Option<U64Hex>")]
17 #[schemars(schema_with = "schema_as_uint_hex_optional")]
18 pub limit: Option<u64>,
20 pub after: Option<JsonBytes>,
22}
23
24#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
26pub struct UdtScript {
27 #[schemars(schema_with = "schema_as_hex_bytes")]
29 pub code_hash: H256,
30 pub hash_type: ScriptHashType,
32 pub args: String,
34}
35
36#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
38pub struct UdtDep {
39 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub cell_dep: Option<UdtCellDep>,
42 #[serde(default, skip_serializing_if = "Option::is_none")]
44 pub type_id: Option<Script>,
45}
46
47#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
49pub struct UdtCellDep {
50 pub out_point: OutPointWrapper,
52 pub dep_type: DepType,
54}
55
56#[serde_as]
58#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
59pub struct UdtArgInfo {
60 pub name: String,
62 pub script: UdtScript,
64 #[serde_as(as = "Option<U128Hex>")]
65 #[schemars(schema_with = "schema_as_uint_hex_optional")]
66 pub auto_accept_amount: Option<u128>,
68 pub cell_deps: Vec<UdtDep>,
70}
71
72#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
74pub struct UdtCfgInfos(
75 pub Vec<UdtArgInfo>,
77);
78
79#[serde_as]
81#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
82pub struct NodeInfo {
83 pub node_name: String,
85 pub version: String,
87 #[schemars(schema_with = "schema_as_string_array")]
89 pub addresses: Vec<String>,
90 pub features: Vec<String>,
92 pub pubkey: Pubkey,
94 #[serde_as(as = "U64Hex")]
95 #[schemars(schema_with = "schema_as_uint_hex")]
96 pub timestamp: u64,
99 pub chain_hash: Hash256,
101 #[serde_as(as = "U64Hex")]
102 #[schemars(schema_with = "schema_as_uint_hex")]
103 pub auto_accept_min_ckb_funding_amount: u64,
105 pub udt_cfg_infos: UdtCfgInfos,
107}
108
109#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
111pub struct GraphNodesResult {
112 pub nodes: Vec<NodeInfo>,
114 pub last_cursor: JsonBytes,
116}
117
118#[serde_as]
120#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
121pub struct GraphChannelsParams {
122 #[serde_as(as = "Option<U64Hex>")]
124 #[schemars(schema_with = "schema_as_uint_hex_optional")]
125 pub limit: Option<u64>,
126 pub after: Option<JsonBytes>,
128}
129
130#[serde_as]
132#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize, JsonSchema)]
133pub struct ChannelUpdateInfo {
134 #[serde_as(as = "U64Hex")]
136 #[schemars(schema_with = "schema_as_uint_hex")]
137 pub timestamp: u64,
138 pub enabled: bool,
140 #[serde_as(as = "Option<U128Hex>")]
142 #[schemars(schema_with = "schema_as_uint_hex_optional")]
143 pub outbound_liquidity: Option<u128>,
144 #[serde_as(as = "U64Hex")]
146 #[schemars(schema_with = "schema_as_uint_hex")]
147 pub tlc_expiry_delta: u64,
148 #[serde_as(as = "U128Hex")]
150 #[schemars(schema_with = "schema_as_uint_hex")]
151 pub tlc_minimum_value: u128,
152 #[serde_as(as = "U64Hex")]
154 #[schemars(schema_with = "schema_as_uint_hex")]
155 pub fee_rate: u64,
156}
157
158#[serde_as]
160#[derive(Debug, Serialize, Deserialize, Clone, JsonSchema)]
161pub struct ChannelInfo {
162 #[serde_as(as = "EntityHex")]
164 #[schemars(schema_with = "schema_as_hex_bytes")]
165 pub channel_outpoint: OutPoint,
166 pub node1: Pubkey,
168 pub node2: Pubkey,
170 #[serde_as(as = "U64Hex")]
173 #[schemars(schema_with = "schema_as_uint_hex")]
174 pub created_timestamp: u64,
175
176 pub update_info_of_node1: Option<ChannelUpdateInfo>,
178
179 pub update_info_of_node2: Option<ChannelUpdateInfo>,
181
182 #[serde_as(as = "U128Hex")]
184 #[schemars(schema_with = "schema_as_uint_hex")]
185 pub capacity: u128,
186 pub chain_hash: Hash256,
188 pub udt_type_script: Option<Script>,
190}
191
192#[derive(Serialize, Deserialize, Clone, JsonSchema)]
194pub struct GraphChannelsResult {
195 pub channels: Vec<ChannelInfo>,
197 pub last_cursor: JsonBytes,
199}