Skip to main content

blockfrost_openapi/models/
proposal.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5pub struct Proposal {
6    /// Governance Action Identifier (CIP-0129)
7    #[serde(rename = "id")]
8    pub id: String,
9    /// Hash of the proposal transaction.
10    #[serde(rename = "tx_hash")]
11    pub tx_hash: String,
12    /// Index of the certificate within the proposal transaction.
13    #[serde(rename = "cert_index")]
14    pub cert_index: i32,
15    /// Type of proposal.
16    #[serde(rename = "governance_type")]
17    pub governance_type: GovernanceType,
18    /// An object describing the content of this GovActionProposal in a readable way.
19    #[serde(rename = "governance_description", deserialize_with = "Option::deserialize")]
20    pub governance_description: Option<std::collections::HashMap<String, serde_json::Value>>,
21    /// The deposit amount paid for this proposal.
22    #[serde(rename = "deposit")]
23    pub deposit: String,
24    /// Bech32 stake address of the reward address to receive the deposit when it is repaid.
25    #[serde(rename = "return_address")]
26    pub return_address: String,
27    /// The epoch at which the proposal was ratified. Null if the proposal has not been ratified.
28    #[serde(rename = "ratified_epoch", deserialize_with = "Option::deserialize")]
29    pub ratified_epoch: Option<i32>,
30    /// The epoch at which the proposal was enacted. Null if the proposal has not been enacted.
31    #[serde(rename = "enacted_epoch", deserialize_with = "Option::deserialize")]
32    pub enacted_epoch: Option<i32>,
33    /// The epoch at which the proposal was dropped. A proposal is dropped if it expires or if any of its dependencies expire.
34    #[serde(rename = "dropped_epoch", deserialize_with = "Option::deserialize")]
35    pub dropped_epoch: Option<i32>,
36    /// The epoch at which the proposal expired. Null if the proposal has not expired.
37    #[serde(rename = "expired_epoch", deserialize_with = "Option::deserialize")]
38    pub expired_epoch: Option<i32>,
39    /// The epoch at which this governance action will expire.
40    #[serde(rename = "expiration")]
41    pub expiration: i32,
42}
43
44impl Proposal {
45    pub fn new(id: String, tx_hash: String, cert_index: i32, governance_type: GovernanceType, governance_description: Option<std::collections::HashMap<String, serde_json::Value>>, deposit: String, return_address: String, ratified_epoch: Option<i32>, enacted_epoch: Option<i32>, dropped_epoch: Option<i32>, expired_epoch: Option<i32>, expiration: i32) -> Proposal {
46        Proposal {
47            id,
48            tx_hash,
49            cert_index,
50            governance_type,
51            governance_description,
52            deposit,
53            return_address,
54            ratified_epoch,
55            enacted_epoch,
56            dropped_epoch,
57            expired_epoch,
58            expiration,
59        }
60    }
61}
62/// Type of proposal.
63#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
64pub enum GovernanceType {
65    #[serde(rename = "hard_fork_initiation")]
66    HardForkInitiation,
67    #[serde(rename = "new_committee")]
68    NewCommittee,
69    #[serde(rename = "new_constitution")]
70    NewConstitution,
71    #[serde(rename = "info_action")]
72    InfoAction,
73    #[serde(rename = "no_confidence")]
74    NoConfidence,
75    #[serde(rename = "parameter_change")]
76    ParameterChange,
77    #[serde(rename = "treasury_withdrawals")]
78    TreasuryWithdrawals,
79}
80
81impl Default for GovernanceType {
82    fn default() -> GovernanceType {
83        Self::HardForkInitiation
84    }
85}
86