use holo_hash::{hash_type, HashableContent, HashableContentBytes};
use holochain_serialized_bytes::prelude::*;
use holochain_timestamp::Timestamp;
use holochain_zome_types::prelude::{SignedWarrant, Warrant, WarrantProof};
#[derive(
Clone,
Debug,
Serialize,
Deserialize,
SerializedBytes,
Eq,
PartialEq,
Hash,
derive_more::From,
derive_more::Deref,
)]
pub struct WarrantOp(SignedWarrant);
impl WarrantOp {
pub fn get_type(&self) -> WarrantOpType {
match self.proof {
WarrantProof::ChainIntegrity(_) => WarrantOpType::ChainIntegrityWarrant,
}
}
pub fn timestamp(&self) -> Timestamp {
self.timestamp
}
pub fn warrant(&self) -> &Warrant {
self
}
}
#[derive(
Clone,
Copy,
Debug,
Serialize,
Deserialize,
Eq,
PartialEq,
Hash,
derive_more::Display,
strum_macros::EnumString,
)]
pub enum WarrantOpType {
ChainIntegrityWarrant,
}
impl HashableContent for WarrantOp {
type HashType = hash_type::DhtOp;
fn hash_type(&self) -> Self::HashType {
hash_type::DhtOp
}
fn hashable_content(&self) -> HashableContentBytes {
self.warrant().hashable_content()
}
}