fedimint_server_core/
setup_ui.rs

1use std::collections::BTreeSet;
2use std::sync::Arc;
3
4use anyhow::Result;
5use async_trait::async_trait;
6use fedimint_core::core::ModuleKind;
7use fedimint_core::module::ApiAuth;
8
9pub type DynSetupApi = Arc<dyn ISetupApi + Send + Sync + 'static>;
10
11/// Interface for the web UI to interact with the config generation process
12#[async_trait]
13pub trait ISetupApi {
14    /// Get our connection info encoded as base32 string
15    async fn setup_code(&self) -> Option<String>;
16
17    /// Get the auth token for API calls
18    async fn auth(&self) -> Option<ApiAuth>;
19
20    /// Get list of names of connected peers
21    async fn connected_peers(&self) -> Vec<String>;
22
23    /// Get the available modules that can be enabled during setup
24    fn available_modules(&self) -> BTreeSet<ModuleKind>;
25
26    /// Reset the set of other guardians
27    async fn reset_setup_codes(&self);
28
29    /// Set local guardian parameters
30    async fn set_local_parameters(
31        &self,
32        auth: ApiAuth,
33        name: String,
34        federation_name: Option<String>,
35        disable_base_fees: Option<bool>,
36        enabled_modules: Option<BTreeSet<ModuleKind>>,
37    ) -> Result<String>;
38
39    /// Add peer connection info
40    async fn add_peer_setup_code(&self, info: String) -> Result<String>;
41
42    /// Start the distributed key generation process
43    async fn start_dkg(&self) -> Result<()>;
44
45    /// Create a trait object
46    fn into_dyn(self) -> DynSetupApi
47    where
48        Self: Sized + Send + Sync + 'static,
49    {
50        Arc::new(self)
51    }
52}