#![deny(clippy::pedantic)]
#![allow(clippy::missing_panics_doc)]
#![allow(clippy::module_name_repetitions)]
#![allow(clippy::must_use_candidate)]
use std::fmt;
use config::DummyClientConfig;
use fedimint_core::core::{Decoder, ModuleInstanceId, ModuleKind};
use fedimint_core::encoding::{Decodable, Encodable};
use fedimint_core::module::{CommonModuleInit, ModuleCommon, ModuleConsensusVersion};
use fedimint_core::secp256k1::{Keypair, PublicKey, Secp256k1};
use fedimint_core::{plugin_types_trait_impl_common, Amount};
use serde::{Deserialize, Serialize};
use thiserror::Error;
pub mod config;
pub const KIND: ModuleKind = ModuleKind::from_static_str("dummy");
pub const MODULE_CONSENSUS_VERSION: ModuleConsensusVersion = ModuleConsensusVersion::new(2, 0);
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Encodable, Decodable)]
pub struct DummyConsensusItem;
#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
pub struct DummyInput {
pub amount: Amount,
pub account: PublicKey,
}
#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
pub struct DummyOutput {
pub amount: Amount,
pub account: PublicKey,
}
#[derive(Debug, Clone, Eq, PartialEq, Hash, Deserialize, Serialize, Encodable, Decodable)]
pub struct DummyOutputOutcome(pub Amount, pub PublicKey);
#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
pub enum DummyInputError {
#[error("Not enough funds")]
NotEnoughFunds,
}
#[derive(Debug, Clone, Eq, PartialEq, Hash, Error, Encodable, Decodable)]
pub enum DummyOutputError {}
pub struct DummyModuleTypes;
plugin_types_trait_impl_common!(
KIND,
DummyModuleTypes,
DummyClientConfig,
DummyInput,
DummyOutput,
DummyOutputOutcome,
DummyConsensusItem,
DummyInputError,
DummyOutputError
);
#[derive(Debug)]
pub struct DummyCommonInit;
impl CommonModuleInit for DummyCommonInit {
const CONSENSUS_VERSION: ModuleConsensusVersion = MODULE_CONSENSUS_VERSION;
const KIND: ModuleKind = KIND;
type ClientConfig = DummyClientConfig;
fn decoder() -> Decoder {
DummyModuleTypes::decoder_builder().build()
}
}
impl fmt::Display for DummyClientConfig {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DummyClientConfig")
}
}
impl fmt::Display for DummyInput {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DummyInput {}", self.amount)
}
}
impl fmt::Display for DummyOutput {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DummyOutput {}", self.amount)
}
}
impl fmt::Display for DummyOutputOutcome {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DummyOutputOutcome")
}
}
impl fmt::Display for DummyConsensusItem {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "DummyConsensusItem")
}
}
const FED_SECRET_PHRASE: &str = "Money printer go brrr...........";
const BROKEN_FED_SECRET_PHRASE: &str = "Money printer go <boom>........!";
pub fn fed_public_key() -> PublicKey {
fed_key_pair().public_key()
}
pub fn fed_key_pair() -> Keypair {
Keypair::from_seckey_slice(&Secp256k1::new(), FED_SECRET_PHRASE.as_bytes()).expect("32 bytes")
}
pub fn broken_fed_public_key() -> PublicKey {
broken_fed_key_pair().public_key()
}
pub fn broken_fed_key_pair() -> Keypair {
Keypair::from_seckey_slice(&Secp256k1::new(), BROKEN_FED_SECRET_PHRASE.as_bytes())
.expect("32 bytes")
}