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 local: DummyConfigLocal,
40    pub private: DummyConfigPrivate,
41    pub consensus: DummyConfigConsensus,
42}
43
44/// Contains all the configuration for the client
45#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Encodable, Decodable, Hash)]
46pub struct DummyClientConfig {
47    /// Accessible to clients
48    pub tx_fee: Amount,
49}
50
51/// Locally unencrypted config unique to each member
52#[derive(Clone, Debug, Serialize, Deserialize, Decodable, Encodable)]
53pub struct DummyConfigLocal;
54
55/// Will be the same for every federation member
56#[derive(Clone, Debug, Serialize, Deserialize, Decodable, Encodable)]
57pub struct DummyConfigConsensus {
58    /// Will be the same for all peers
59    pub tx_fee: Amount,
60}
61
62/// Will be encrypted and not shared such as private key material
63#[derive(Clone, Debug, Serialize, Deserialize)]
64pub struct DummyConfigPrivate;
65
66// Wire together the configs for this module
67plugin_types_trait_impl_config!(
68    DummyCommonInit,
69    DummyGenParams,
70    DummyGenParamsLocal,
71    DummyGenParamsConsensus,
72    DummyConfig,
73    DummyConfigLocal,
74    DummyConfigPrivate,
75    DummyConfigConsensus,
76    DummyClientConfig
77);