koios_sdk/models/
network.rs

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
use serde::{Deserialize, Serialize};

use super::ProposalType;

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Tip {
    pub hash: String,
    pub epoch_no: u64,
    pub abs_slot: u64,
    pub epoch_slot: u64,
    pub block_no: u64,
    pub block_time: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Genesis {
    pub networkmagic: String,
    pub networkid: String,
    pub epochlength: String,
    pub slotlength: String,
    pub maxlovelacesupply: String,
    pub systemstart: u64,
    pub activeslotcoeff: String,
    pub slotsperkesperiod: String,
    pub maxkesrevolutions: String,
    pub securityparam: String,
    pub updatequorum: String,
    pub alonzogenesis: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Totals {
    pub epoch_no: u64,
    pub circulation: String,
    pub treasury: String,
    pub reward: String,
    pub supply: String,
    pub reserves: String,
    pub fees: String,
    pub deposits_stake: String,
    pub deposits_drep: String,
    pub deposits_proposal: String,
}

#[derive(Debug, Clone, Serialize, Copy, Deserialize)]
pub struct CliProtocolParams {
    pub collateral_percentage: u64,
    pub max_block_body_size: u64,
    pub max_block_header_size: u64,
    pub max_collateral_inputs: u64,
    pub max_tx_size: u64,
    pub max_value_size: u64,
    pub min_pool_cost: u64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min_utxo_value: Option<u64>,
    pub monetary_expansion: f64,
    pub pool_pledge_influence: f64,
    pub pool_retire_max_epoch: u64,
    pub protocol_version: ProtocolVersion,
    pub stake_address_deposit: u64,
    pub stake_pool_deposit: u64,
    pub stake_pool_target_num: u64,
    pub treasury_cut: f64,
    pub tx_fee_fixed: u64,
    pub tx_fee_per_byte: u64,
    pub utxo_cost_per_byte: u64,
}

#[derive(Debug, Clone, Serialize, Copy, Deserialize)]
pub struct ProtocolVersion {
    pub major: u64,
    pub minor: u64,
}

// Implement conversion traits and custom methods
impl Tip {
    pub fn new(
        hash: String,
        epoch_no: u64,
        abs_slot: u64,
        epoch_slot: u64,
        block_no: u64,
        block_time: u64,
    ) -> Self {
        Self {
            hash,
            epoch_no,
            abs_slot,
            epoch_slot,
            block_no,
            block_time,
        }
    }
}

impl Genesis {
    pub fn new(
        networkmagic: String,
        networkid: String,
        epochlength: String,
        slotlength: String,
        maxlovelacesupply: String,
        systemstart: u64,
        activeslotcoeff: String,
        slotsperkesperiod: String,
        maxkesrevolutions: String,
        securityparam: String,
        updatequorum: String,
        alonzogenesis: String,
    ) -> Self {
        Self {
            networkmagic,
            networkid,
            epochlength,
            slotlength,
            maxlovelacesupply,
            systemstart,
            activeslotcoeff,
            slotsperkesperiod,
            maxkesrevolutions,
            securityparam,
            updatequorum,
            alonzogenesis,
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ReserveWithdrawal {
    pub epoch_no: u64,
    pub epoch_slot: u64,
    pub tx_hash: String,
    pub block_hash: String,
    pub block_height: u64,
    pub amount: String,
    pub stake_address: String,
    pub earned_epoch: u64,
    pub spendable_epoch: u64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ParamUpdate {
    pub tx_hash: String,
    pub block_height: u64,
    pub block_time: u64,
    pub epoch_no: u64,
    pub data: String,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct OgmiosTip {
    pub jsonrpc: String,
    pub method: String,
    #[serde(default)] // Handle missing result field
    pub result: OgmiosTipResult,
}

#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct OgmiosTipResult {
    pub slot: u64,
    pub id: String,
}

impl OgmiosTip {
    pub fn new(slot: u64, id: String) -> Self {
        Self {
            jsonrpc: "2.0".to_string(),
            method: "queryNetwork/tip".to_string(),
            result: OgmiosTipResult { slot, id },
        }
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProposalVotingSummary {
    pub proposal_type: ProposalType,
    pub epoch_no: u64,
    pub drep_yes_votes_cast: u64,
    pub drep_active_yes_vote_power: u64,
    pub drep_yes_vote_power: u64,
    pub drep_yes_pct: f64,
    pub drep_no_votes_cast: u64,
    pub drep_active_no_vote_power: u64,
    pub drep_no_vote_power: u64,
    pub drep_no_pct: f64,
    pub drep_abstain_votes_cast: u64,
    pub drep_active_abstain_vote_power: u64,
    pub drep_always_no_confidence_vote_power: u64,
    pub drep_always_abstain_vote_power: u64,
    pub pool_yes_votes_cast: u64,
    pub pool_active_yes_vote_power: u64,
    pub pool_yes_vote_power: u64,
    pub pool_yes_pct: f64,
    pub pool_no_votes_cast: u64,
    pub pool_active_no_vote_power: u64,
    pub pool_no_vote_power: u64,
    pub pool_no_pct: f64,
    pub pool_abstain_votes_cast: u64,
    pub pool_active_abstain_vote_power: u64,
    pub pool_passive_always_abstain_votes_assigned: u64,
    pub pool_passive_always_abstain_vote_power: u64,
    pub pool_passive_always_no_confidence_votes_assigned: u64,
    pub pool_passive_always_no_confidence_vote_power: u64,
    pub committee_yes_votes_cast: u64,
    pub committee_yes_pct: f64,
    pub committee_no_votes_cast: u64,
    pub committee_no_pct: f64,
    pub committee_abstain_votes_cast: u64,
}