Skip to main content

blockfrost_openapi/models/
drep.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5pub struct Drep {
6    /// Bech32 encoded DRep address
7    #[serde(rename = "drep_id")]
8    pub drep_id: String,
9    /// The raw bytes of the DRep
10    #[serde(rename = "hex")]
11    pub hex: String,
12    /// The total amount of voting power this DRep is delegated.
13    #[serde(rename = "amount")]
14    pub amount: String,
15    /// Registration state of the DRep
16    #[serde(rename = "active")]
17    pub active: bool,
18    /// Epoch of the most recent registration
19    #[serde(rename = "active_epoch", deserialize_with = "Option::deserialize")]
20    pub active_epoch: Option<i32>,
21    /// Flag which shows if this DRep credentials are a script hash
22    #[serde(rename = "has_script")]
23    pub has_script: bool,
24    /// Registration state of the DRep. Set to `true` if the DRep has been deregistered; otherwise, `false`.
25    #[serde(rename = "retired")]
26    pub retired: bool,
27    /// Whether the DRep has been inactive for a consecutive number of epochs (determined by a epoch parameter `drep_activity`)
28    #[serde(rename = "expired")]
29    pub expired: bool,
30    /// Epoch of the most recent action - registration, update, deregistration or voting
31    #[serde(rename = "last_active_epoch", deserialize_with = "Option::deserialize")]
32    pub last_active_epoch: Option<i32>,
33}
34
35impl Drep {
36    pub fn new(drep_id: String, hex: String, amount: String, active: bool, active_epoch: Option<i32>, has_script: bool, retired: bool, expired: bool, last_active_epoch: Option<i32>) -> Drep {
37        Drep {
38            drep_id,
39            hex,
40            amount,
41            active,
42            active_epoch,
43            has_script,
44            retired,
45            expired,
46            last_active_epoch,
47        }
48    }
49}
50