koios_sdk/models/
address.rs1use serde::{Deserialize, Serialize};
2
3use super::AssetItem;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct AddressInfo {
7 pub address: String,
8 pub balance: String,
9 #[serde(skip_serializing_if = "Option::is_none")]
10 pub stake_address: Option<String>,
11 pub script_address: bool,
12 pub utxo_set: Vec<AddressUtxo>,
13}
14
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct AddressUtxo {
17 pub tx_hash: String,
18 pub tx_index: u64,
19 pub block_height: u64,
20 pub block_time: u64,
21 pub value: String,
22 #[serde(skip_serializing_if = "Option::is_none")]
23 pub datum_hash: Option<String>,
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub inline_datum: Option<serde_json::Value>,
26 #[serde(skip_serializing_if = "Option::is_none")]
27 pub reference_script: Option<serde_json::Value>,
28 pub asset_list: Vec<AssetItem>,
29}
30
31#[derive(Debug, Clone, Serialize, Deserialize)]
32pub struct AddressTransaction {
33 pub tx_hash: String,
34 pub epoch_no: u64,
35 pub block_height: u64,
36 pub block_time: u64,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize)]
40pub struct AddressAsset {
41 pub address: String,
42 pub policy_id: String,
43 pub asset_name: String,
44 pub fingerprint: String,
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub decimals: Option<u64>,
47 pub quantity: String,
48}
49
50impl AddressInfo {
52 pub fn new(
53 address: String,
54 balance: String,
55 stake_address: Option<String>,
56 script_address: bool,
57 ) -> Self {
58 Self {
59 address,
60 balance,
61 stake_address,
62 script_address,
63 utxo_set: Vec::new(),
64 }
65 }
66}
67
68impl AddressUtxo {
69 pub fn new(
70 tx_hash: String,
71 tx_index: u64,
72 block_height: u64,
73 block_time: u64,
74 value: String,
75 ) -> Self {
76 Self {
77 tx_hash,
78 tx_index,
79 block_height,
80 block_time,
81 value,
82 datum_hash: None,
83 inline_datum: None,
84 reference_script: None,
85 asset_list: Vec::new(),
86 }
87 }
88}
89
90impl AssetItem {
91 pub fn new(
92 policy_id: String,
93 asset_name: String,
94 fingerprint: String,
95 quantity: String,
96 ) -> Self {
97 Self {
98 policy_id,
99 asset_name,
100 fingerprint,
101 decimals: None,
102 quantity,
103 }
104 }
105}
106
107impl AddressTransaction {
108 pub fn new(tx_hash: String, epoch_no: u64, block_height: u64, block_time: u64) -> Self {
109 Self {
110 tx_hash,
111 epoch_no,
112 block_height,
113 block_time,
114 }
115 }
116}