1use std::collections::HashMap;
2
3#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct RequestError {
6 #[serde(skip_serializing_if = "Option::is_none")]
7 pub message: Option<String>,
8 #[serde(skip_serializing_if = "Option::is_none")]
9 pub errors: Option<String>,
10}
11
12#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct Meta {
15 pub limit: Option<u32>,
16 pub offset: Option<u32>,
17 pub count: Option<u64>,
18 pub from_timestamp: Option<u64>,
19 pub to_timestamp: Option<u64>,
20 pub last_block: Option<u64>,
21 pub last_block_slot: Option<u64>,
22 pub current_slot: Option<u64>,
23}
24
25#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
26#[serde(rename_all = "camelCase")]
27pub struct Response<T> {
28 pub data: T,
29 pub meta: Meta,
30}
31
32#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct ParamErrorMessage {
35 pub code: String,
36 pub message: String,
37 pub description: String,
38 pub path: Vec<HashMap<String, String>>,
39}
40
41#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
42#[serde(rename_all = "camelCase")]
43pub struct ParamError {
44 pub code: String,
45 pub name: String,
46 pub message: String,
47 pub errors: Vec<HashMap<String, String>>,
48}
49
50#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
51#[serde(rename_all = "camelCase")]
52pub struct ParamErrorResponse {
53 pub message: String,
54 pub errors: Vec<HashMap<String, String>>,
55}
56
57#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
58pub struct TransactionsInPool {
59 pub confirmed: u64,
60 pub unconfirmed: u16,
61 pub unprocessed: u16,
62 pub unsigned: u16,
63 pub total: u64,
64}
65
66#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct Account {
69 pub address: String,
70 pub public_key: String,
71 pub balance: Option<String>,
72 pub unconfirmed_balance: Option<String>,
73 pub second_public_key: Option<String>,
74 pub min: Option<u8>,
75 pub lifetime: Option<u32>,
76 pub delegate: Option<DelegateWithAccount>,
77 pub members: Option<Vec<Member>>,
78}
79
80#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
81#[serde(rename_all = "camelCase")]
82pub struct Member {
83 pub address: String,
84 pub public_key: String,
85 pub second_public_key: String,
86}
87
88#[derive(Clone, Debug, Default, PartialEq, Deserialize, Serialize)]
89#[serde(rename_all = "camelCase")]
90pub struct Block {
91 pub id: String,
92 pub version: u64,
93 pub timestamp: u64,
94 pub height: u64,
95 pub number_of_transactions: u64,
96 pub total_amount: String,
97 pub total_fee: String,
98 pub reward: String,
99 pub payload_length: u64,
100 pub payload_hash: String,
101 pub generator_public_key: String,
102 pub block_signature: String,
103 pub confirmations: u64,
104 pub total_forged: String,
105 pub generator_address: String,
106 pub previous_block_id: String,
107}
108
109#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
110#[serde(default)]
111#[serde(rename_all = "camelCase")]
112pub struct Transaction {
113 pub id: String,
114 pub height: u64,
115 pub block_id: String,
116 pub r#type: u8,
117 pub timestamp: u64,
118 pub sender_public_key: String,
119 pub recipient_public_key: String,
120 pub sender_id: String,
121 pub recipient_id: String,
122 pub amount: String,
123 pub fee: String,
124 pub signature: String,
125 pub signatures: Option<Vec<Signature>>,
126 #[serde(skip_serializing_if = "Asset::is_none")]
127 pub asset: Asset,
128 pub confirmations: u64,
129 pub sender_second_public_key: Option<String>,
130 pub sign_signature: Option<String>,
131 pub relays: Option<u16>,
132 pub ready: Option<bool>,
133}
134
135#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
136#[serde(rename_all = "camelCase")]
137pub struct Signature {
138 pub transaction_id: String,
139 pub public_key: String,
140 pub signature: String,
141}
142
143#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
144#[serde(rename_all = "camelCase")]
145pub struct Dapp {
146 pub transaction_id: String,
147 pub icon: String,
148 pub category: u8,
149 pub r#type: u8,
150 pub link: String,
151 pub tags: String,
152 pub description: String,
153 pub name: String,
154}
155
156#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
157#[serde(rename_all = "camelCase")]
158pub struct Peer {
159 pub ip: String,
160 pub http_port: Option<u64>,
161 pub ws_port: u64,
162 pub os: Option<String>,
163 pub version: String,
164 pub protocol_version: Option<String>,
165 pub state: Option<u64>,
166 pub height: Option<u64>,
167 pub broadhash: Option<String>,
168 pub nonce: Option<String>,
169}
170
171#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
172#[serde(rename_all = "camelCase")]
173pub struct NodeConstants {
174 pub epoch: String,
175 pub milestone: String,
176 pub build: String,
177 pub commit: String,
178 pub version: String,
179 pub protocol_version: String,
180 pub nethash: String,
181 pub supply: String,
182 pub reward: String,
183 pub nonce: String,
184 pub fees: Fees,
185}
186
187#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
188#[serde(rename_all = "camelCase")]
189pub struct Fees {
190 pub send: String,
191 pub vote: String,
192 pub second_signature: String,
193 pub delegate: String,
194 pub multisignature: String,
195 pub dapp_registration: String,
196 pub dapp_withdrawal: String,
197 pub dapp_deposit: String,
198}
199
200#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
201#[serde(rename_all = "camelCase")]
202pub struct NodeStatus {
203 pub broadhash: String,
204 pub consensus: u64,
205 pub current_time: u64,
206 pub seconds_since_epoch: u64,
207 pub height: u64,
208 pub loaded: bool,
209 pub network_height: i64,
210 pub syncing: bool,
211 pub transactions: TransactionsInPool,
212}
213
214#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
215#[serde(rename_all = "camelCase")]
216pub struct ForgingStats {
217 pub fees: String,
218 pub rewards: String,
219 pub forged: String,
220 pub count: String,
221}
222
223#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
224#[serde(rename_all = "camelCase")]
225pub struct ForgingStatus {
226 pub forging: bool,
227 pub public_key: String,
228}
229
230#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
231#[serde(rename_all = "camelCase")]
232pub struct Forger {
233 pub username: String,
234 pub address: String,
235 pub public_key: String,
236 pub next_slot: String,
237}
238
239#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
240#[serde(rename_all = "camelCase")]
241pub struct DelegateWithAccount {
242 pub username: String,
243 pub vote: String,
244 pub rewards: String,
245 pub produced_blocks: u32,
246 pub missed_blocks: u32,
247 pub rank: u16,
248 pub productivity: f32,
249 pub approval: f32,
250 pub account: Option<HashMap<String, String>>,
251}
252
253#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
254#[serde(rename_all = "camelCase")]
255pub struct DelegateWithVoters {
256 pub address: String,
257 pub public_key: String,
258 pub balance: String,
259 pub votes: u32,
260 pub username: String,
261 pub voters: Vec<Voter>,
262}
263
264#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
265#[serde(rename_all = "camelCase")]
266pub struct DelegateWithVotes {
267 pub address: String,
268 pub balance: String,
269 pub username: String,
270 pub public_key: String,
271 pub votes_used: u32,
272 pub votes_available: u32,
273 pub votes: Vec<Vote>,
274}
275
276#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
277#[serde(rename_all = "camelCase")]
278pub struct Voter {
279 pub address: String,
280 pub public_key: String,
281 pub balance: String,
282}
283
284#[derive(Clone, Debug, Default, PartialEq, Deserialize)]
285#[serde(rename_all = "camelCase")]
286pub struct Vote {
287 pub address: String,
288 pub public_key: String,
289 pub balance: String,
290 pub username: String,
291}
292
293#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
294#[serde(rename_all = "camelCase")]
295pub enum Asset {
296 #[serde(skip)]
297 None,
298 Data(String),
299 Signature {
300 #[serde(rename = "publicKey")]
301 public_key: String,
302 },
303 Delegate {
304 #[serde(rename = "publicKey")]
305 public_key: String,
306 username: String,
307 address: String,
308 },
309 Votes(Vec<String>),
310 Multisignature {
311 min: u8,
312 lifetime: u64,
313 keysgroup: Vec<String>,
314 },
315 Dapp {
316 icon: String,
317 link: String,
318 name: String,
319 tags: String,
320 r#type: u8,
321 category: u8,
322 description: String,
323 },
324}
325
326impl Asset {
327 pub fn is_none(&self) -> bool {
328 match *self {
329 Asset::None => true,
330 _ => false,
331 }
332 }
333}
334
335impl Default for Asset {
336 fn default() -> Self {
337 Asset::None
338 }
339}