Skip to main content

blockfrost_openapi/models/
committee_votes_inner.rs

1use crate::models;
2use serde::{Deserialize, Serialize};
3
4#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
5pub struct CommitteeVotesInner {
6    /// Hash of the vote transaction.
7    #[serde(rename = "tx_hash")]
8    pub tx_hash: String,
9    /// CIP-129 bech32 encoded hot credential of the committee member that cast this vote (`cc_hot1...`).
10    #[serde(rename = "voter_hot_id")]
11    pub voter_hot_id: String,
12    /// CIP-129 Governance Action Identifier of the proposal being voted on.
13    #[serde(rename = "proposal_id")]
14    pub proposal_id: String,
15    /// Hash of the proposal transaction.
16    #[serde(rename = "proposal_tx_hash")]
17    pub proposal_tx_hash: String,
18    /// Index of the proposal within its transaction.
19    #[serde(rename = "proposal_index")]
20    pub proposal_index: i32,
21    /// Type of the governance action being voted on.
22    #[serde(rename = "governance_type")]
23    pub governance_type: GovernanceType,
24    /// The Vote. Can be one of yes, no, abstain.
25    #[serde(rename = "vote")]
26    pub vote: Vote,
27    /// Voting anchor URL — pointer to the off-chain rationale published by the voter.
28    #[serde(rename = "metadata_url", deserialize_with = "Option::deserialize")]
29    pub metadata_url: Option<String>,
30    /// Hex hash of the off-chain anchor document.
31    #[serde(rename = "metadata_hash", deserialize_with = "Option::deserialize")]
32    pub metadata_hash: Option<String>,
33    /// Block height of the vote transaction.
34    #[serde(rename = "block_height")]
35    pub block_height: i32,
36    /// Block creation time in UNIX time of the vote transaction.
37    #[serde(rename = "block_time")]
38    pub block_time: i32,
39}
40
41impl CommitteeVotesInner {
42    pub fn new(tx_hash: String, voter_hot_id: String, proposal_id: String, proposal_tx_hash: String, proposal_index: i32, governance_type: GovernanceType, vote: Vote, metadata_url: Option<String>, metadata_hash: Option<String>, block_height: i32, block_time: i32) -> CommitteeVotesInner {
43        CommitteeVotesInner {
44            tx_hash,
45            voter_hot_id,
46            proposal_id,
47            proposal_tx_hash,
48            proposal_index,
49            governance_type,
50            vote,
51            metadata_url,
52            metadata_hash,
53            block_height,
54            block_time,
55        }
56    }
57}
58/// Type of the governance action being voted on.
59#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
60pub enum GovernanceType {
61    #[serde(rename = "hard_fork_initiation")]
62    HardForkInitiation,
63    #[serde(rename = "new_committee")]
64    NewCommittee,
65    #[serde(rename = "new_constitution")]
66    NewConstitution,
67    #[serde(rename = "info_action")]
68    InfoAction,
69    #[serde(rename = "no_confidence")]
70    NoConfidence,
71    #[serde(rename = "parameter_change")]
72    ParameterChange,
73    #[serde(rename = "treasury_withdrawals")]
74    TreasuryWithdrawals,
75}
76
77impl Default for GovernanceType {
78    fn default() -> GovernanceType {
79        Self::HardForkInitiation
80    }
81}
82/// The Vote. Can be one of yes, no, abstain.
83#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
84pub enum Vote {
85    #[serde(rename = "yes")]
86    Yes,
87    #[serde(rename = "no")]
88    No,
89    #[serde(rename = "abstain")]
90    Abstain,
91}
92
93impl Default for Vote {
94    fn default() -> Vote {
95        Self::Yes
96    }
97}
98