use holochain_keystore::{AgentPubKeyExt, LairResult, MetaLairClient};
use holochain_zome_types::prelude::*;
#[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 async fn sign(keystore: &MetaLairClient, warrant: Warrant) -> LairResult<Self> {
let signature = warrant.author.sign(keystore, warrant.clone()).await?;
Ok(Self::from(SignedWarrant::new(warrant, signature)))
}
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()
}
}