fedimint_server_core/
setup_ui.rs

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