fedimint_dummy_common/
config.rs

1use fedimint_core::core::ModuleKind;
2use fedimint_core::encoding::{Decodable, Encodable};
3use fedimint_core::{Amount, plugin_types_trait_impl_config};
4use serde::{Deserialize, Serialize};
5
6use crate::DummyCommonInit;
7
8/// Parameters necessary to generate this module's configuration
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct DummyGenParams {
11    pub local: DummyGenParamsLocal,
12    pub consensus: DummyGenParamsConsensus,
13}
14
15/// Local parameters for config generation
16#[derive(Debug, Clone, Serialize, Deserialize)]
17pub struct DummyGenParamsLocal;
18
19/// Consensus parameters for config generation
20#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct DummyGenParamsConsensus {
22    pub tx_fee: Amount,
23}
24
25impl Default for DummyGenParams {
26    fn default() -> Self {
27        Self {
28            local: DummyGenParamsLocal,
29            consensus: DummyGenParamsConsensus {
30                tx_fee: Amount::ZERO,
31            },
32        }
33    }
34}
35
36/// Contains all the configuration for the server
37#[derive(Clone, Debug, Serialize, Deserialize)]
38pub struct DummyConfig {
39    pub private: DummyConfigPrivate,
40    pub consensus: DummyConfigConsensus,
41}
42
43/// Contains all the configuration for the client
44#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Encodable, Decodable, Hash)]
45pub struct DummyClientConfig {
46    /// Accessible to clients
47    pub tx_fee: Amount,
48}
49
50/// Locally unencrypted config unique to each member
51#[derive(Clone, Debug, Serialize, Deserialize, Decodable, Encodable)]
52pub struct DummyConfigLocal;
53
54/// Will be the same for every federation member
55#[derive(Clone, Debug, Serialize, Deserialize, Decodable, Encodable)]
56pub struct DummyConfigConsensus {
57    /// Will be the same for all peers
58    pub tx_fee: Amount,
59}
60
61/// Will be encrypted and not shared such as private key material
62#[derive(Clone, Debug, Serialize, Deserialize)]
63pub struct DummyConfigPrivate;
64
65// Wire together the configs for this module
66plugin_types_trait_impl_config!(
67    DummyCommonInit,
68    DummyGenParams,
69    DummyGenParamsLocal,
70    DummyGenParamsConsensus,
71    DummyConfig,
72    DummyConfigPrivate,
73    DummyConfigConsensus,
74    DummyClientConfig
75);