use crate::{
crypto_helper::{KESPeriod, OpCert},
entities::*,
StdError,
};
use async_trait::async_trait;
use thiserror::Error;
#[cfg(test)]
use mockall::automock;
use super::{ChainAddress, TxDatum};
#[derive(Debug, Error)]
pub enum ChainObserverError {
#[error("general error")]
General(#[source] StdError),
#[error("could not parse content")]
InvalidContent(#[source] StdError),
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait ChainObserver: Sync + Send {
async fn get_current_datums(
&self,
address: &ChainAddress,
) -> Result<Vec<TxDatum>, ChainObserverError>;
async fn get_current_era(&self) -> Result<Option<String>, ChainObserverError>;
async fn get_current_epoch(&self) -> Result<Option<Epoch>, ChainObserverError>;
async fn get_current_chain_point(&self) -> Result<Option<ChainPoint>, ChainObserverError>;
async fn get_current_stake_distribution(
&self,
) -> Result<Option<StakeDistribution>, ChainObserverError>;
async fn get_current_kes_period(
&self,
_opcert: &OpCert,
) -> Result<Option<KESPeriod>, ChainObserverError> {
Ok(None)
}
}