use std::time::Duration;
use fedimint_core::Amount;
use fedimint_core::core::{ModuleKind, OperationId};
use fedimint_eventlog::{Event, EventKind, EventPersistence};
use fedimint_mint_common::{KIND, Nonce};
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct NoteCreated {
pub nonce: Nonce,
}
impl Event for NoteCreated {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("note-created");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct NoteSpent {
pub nonce: Nonce,
}
impl Event for NoteSpent {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("note-spent");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}
#[derive(Serialize, Deserialize)]
pub struct OOBNotesSpent {
pub requested_amount: Amount,
pub spent_amount: Amount,
pub timeout: Duration,
pub include_invite: bool,
}
impl Event for OOBNotesSpent {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("oob-notes-spent");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}
#[derive(Serialize, Deserialize)]
pub struct OOBNotesReissued {
pub amount: Amount,
}
impl Event for OOBNotesReissued {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("oob-notes-reissued");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct SendPaymentEvent {
pub operation_id: OperationId,
pub amount: Amount,
pub oob_notes: String,
}
impl Event for SendPaymentEvent {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("payment-send");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct ReceivePaymentEvent {
pub operation_id: OperationId,
pub amount: Amount,
}
impl Event for ReceivePaymentEvent {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("payment-receive");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}
#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
pub enum ReceivePaymentStatus {
Success,
Rejected,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct ReceivePaymentUpdateEvent {
pub operation_id: OperationId,
pub status: ReceivePaymentStatus,
}
impl Event for ReceivePaymentUpdateEvent {
const MODULE: Option<ModuleKind> = Some(KIND);
const KIND: EventKind = EventKind::from_static("payment-receive-update");
const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
}