use std::{collections::HashSet, sync::Arc};
mod dpki_service;
pub use dpki_service::*;
mod app_store_service;
pub use app_store_service::*;
use holochain_keystore::MetaLairClient;
use holochain_types::prelude::*;
#[async_trait::async_trait]
pub trait CellRunner: Send + Sync + 'static {
async fn call_zome(
&self,
provenance: &AgentPubKey,
cap_secret: Option<CapSecret>,
cell_id: CellId,
zome_name: ZomeName,
fn_name: FunctionName,
payload: ExternIO,
) -> anyhow::Result<ExternIO>;
}
#[derive(Clone)]
pub struct ConductorServices {
pub dpki: Arc<dyn DpkiService>,
pub app_store: Arc<dyn AppStoreService>,
}
impl ConductorServices {
pub fn builtin(
runner: Arc<impl CellRunner>,
keystore: MetaLairClient,
cell_ids: ConductorServiceCells,
) -> Self {
Self {
dpki: Arc::new(DeepkeyBuiltin::new(runner.clone(), keystore, cell_ids.dpki)),
app_store: AppStoreBuiltin::new(runner, cell_ids.app_store),
}
}
pub fn protected_cell_ids(&self) -> HashSet<&CellId> {
self.dpki
.cell_ids()
.union(&self.app_store.cell_ids())
.copied()
.collect()
}
}
pub struct ConductorServiceCells {
pub dpki: CellId,
pub app_store: CellId,
}