cml_chain/governance/
utils.rs1use cml_crypto::{Ed25519KeyHash, ScriptHash};
2
3use super::{GovAction, Voter};
4
5impl GovAction {
6 pub fn script_hash(&self) -> Option<&ScriptHash> {
7 match self {
8 Self::ParameterChangeAction(action) => action.policy_hash.as_ref(),
9 Self::HardForkInitiationAction(_action) => None,
10 Self::TreasuryWithdrawalsAction(action) => action.policy_hash.as_ref(),
11 Self::NoConfidence(_action) => None,
12 Self::UpdateCommittee(_action) => None,
14 Self::NewConstitution(_action) => None,
17 Self::InfoAction { .. } => None,
18 }
19 }
20}
21
22impl Voter {
23 pub fn key_hash(&self) -> Option<&Ed25519KeyHash> {
24 match self {
25 Self::ConstitutionalCommitteeHotKeyHash {
26 ed25519_key_hash, ..
27 } => Some(ed25519_key_hash),
28 Self::ConstitutionalCommitteeHotScriptHash { .. } => None,
29 Self::DRepKeyHash {
30 ed25519_key_hash, ..
31 } => Some(ed25519_key_hash),
32 Self::DRepScriptHash { .. } => None,
33 Self::StakingPoolKeyHash {
34 ed25519_key_hash, ..
35 } => Some(ed25519_key_hash),
36 }
37 }
38
39 pub fn script_hash(&self) -> Option<&ScriptHash> {
40 match self {
41 Self::ConstitutionalCommitteeHotKeyHash { .. } => None,
42 Self::ConstitutionalCommitteeHotScriptHash { script_hash, .. } => Some(script_hash),
43 Self::DRepKeyHash { .. } => None,
44 Self::DRepScriptHash { script_hash, .. } => Some(script_hash),
45 Self::StakingPoolKeyHash { .. } => None,
46 }
47 }
48}