use cml_crypto::{Ed25519KeyHash, ScriptHash};
use super::{GovAction, Voter};
impl GovAction {
pub fn script_hash(&self) -> Option<&ScriptHash> {
match self {
Self::ParameterChangeAction(action) => action.policy_hash.as_ref(),
Self::HardForkInitiationAction(_action) => None,
Self::TreasuryWithdrawalsAction(action) => action.policy_hash.as_ref(),
Self::NoConfidence(_action) => None,
Self::UpdateCommittee(_action) => None,
Self::NewConstitution(_action) => None,
Self::InfoAction { .. } => None,
}
}
}
impl Voter {
pub fn key_hash(&self) -> Option<&Ed25519KeyHash> {
match self {
Self::ConstitutionalCommitteeHotKeyHash {
ed25519_key_hash, ..
} => Some(ed25519_key_hash),
Self::ConstitutionalCommitteeHotScriptHash { .. } => None,
Self::DRepKeyHash {
ed25519_key_hash, ..
} => Some(ed25519_key_hash),
Self::DRepScriptHash { .. } => None,
Self::StakingPoolKeyHash {
ed25519_key_hash, ..
} => Some(ed25519_key_hash),
}
}
pub fn script_hash(&self) -> Option<&ScriptHash> {
match self {
Self::ConstitutionalCommitteeHotKeyHash { .. } => None,
Self::ConstitutionalCommitteeHotScriptHash { script_hash, .. } => Some(script_hash),
Self::DRepKeyHash { .. } => None,
Self::DRepScriptHash { script_hash, .. } => Some(script_hash),
Self::StakingPoolKeyHash { .. } => None,
}
}
}