fedimint_empty_common/
lib.rs

1#![deny(clippy::pedantic)]
2#![allow(clippy::module_name_repetitions)]
3
4use std::fmt;
5
6use config::EmptyClientConfig;
7use fedimint_core::core::{Decoder, ModuleInstanceId, ModuleKind};
8use fedimint_core::encoding::{Decodable, Encodable};
9use fedimint_core::module::{CommonModuleInit, ModuleCommon, ModuleConsensusVersion};
10use fedimint_core::plugin_types_trait_impl_common;
11use serde::{Deserialize, Serialize};
12use thiserror::Error;
13
14// Common contains types shared by both the client and server
15
16// The client and server configuration
17pub mod config;
18
19/// Unique name for this module
20pub const KIND: ModuleKind = ModuleKind::from_static_str("dummy");
21
22/// Modules are non-compatible with older versions
23pub const MODULE_CONSENSUS_VERSION: ModuleConsensusVersion = ModuleConsensusVersion::new(0, 0);
24
25/// Non-transaction items that will be submitted to consensus
26#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Encodable, Decodable)]
27pub struct EmptyConsensusItem;
28
29/// Input for a fedimint transaction
30#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
31pub struct EmptyInput;
32
33/// Output for a fedimint transaction
34#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
35pub struct EmptyOutput;
36
37/// Information needed by a client to update output funds
38#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
39pub struct EmptyOutputOutcome;
40
41/// Errors that might be returned by the server
42#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
43pub enum EmptyInputError {
44    #[error("This module does not support inputs")]
45    NotSupported,
46}
47
48/// Errors that might be returned by the server
49#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
50pub enum EmptyOutputError {
51    #[error("This module does not support outputs")]
52    NotSupported,
53}
54
55/// Contains the types defined above
56pub struct EmptyModuleTypes;
57
58// Wire together the types for this module
59plugin_types_trait_impl_common!(
60    KIND,
61    EmptyModuleTypes,
62    EmptyClientConfig,
63    EmptyInput,
64    EmptyOutput,
65    EmptyOutputOutcome,
66    EmptyConsensusItem,
67    EmptyInputError,
68    EmptyOutputError
69);
70
71#[derive(Debug)]
72pub struct EmptyCommonInit;
73
74impl CommonModuleInit for EmptyCommonInit {
75    const CONSENSUS_VERSION: ModuleConsensusVersion = MODULE_CONSENSUS_VERSION;
76    const KIND: ModuleKind = KIND;
77
78    type ClientConfig = EmptyClientConfig;
79
80    fn decoder() -> Decoder {
81        EmptyModuleTypes::decoder_builder().build()
82    }
83}
84
85impl fmt::Display for EmptyClientConfig {
86    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87        write!(f, "EmptyClientConfig")
88    }
89}
90impl fmt::Display for EmptyInput {
91    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
92        write!(f, "EmptyInput")
93    }
94}
95
96impl fmt::Display for EmptyOutput {
97    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
98        write!(f, "EmptyOutput")
99    }
100}
101
102impl fmt::Display for EmptyOutputOutcome {
103    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
104        write!(f, "EmptyOutputOutcome")
105    }
106}
107
108impl fmt::Display for EmptyConsensusItem {
109    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110        write!(f, "EmptyConsensusItem")
111    }
112}