Skip to main content

fedimint_mintv2_client/
event.rs

1use fedimint_core::Amount;
2use fedimint_core::core::{ModuleKind, OperationId};
3use fedimint_eventlog::{Event, EventKind, EventPersistence};
4use fedimint_mintv2_common::KIND;
5use serde::{Deserialize, Serialize};
6
7/// Event emitted when e-cash is sent out-of-band.
8/// This is a final event - once e-cash is sent, the operation is complete.
9#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
10pub struct SendPaymentEvent {
11    pub operation_id: OperationId,
12    pub amount: Amount,
13    pub ecash: String,
14}
15
16impl Event for SendPaymentEvent {
17    const MODULE: Option<ModuleKind> = Some(KIND);
18    const KIND: EventKind = EventKind::from_static("payment-send");
19    const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
20}
21
22/// Event emitted when a receive (reissuance) operation is initiated.
23#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
24pub struct ReceivePaymentEvent {
25    pub operation_id: OperationId,
26    pub amount: Amount,
27}
28
29impl Event for ReceivePaymentEvent {
30    const MODULE: Option<ModuleKind> = Some(KIND);
31    const KIND: EventKind = EventKind::from_static("payment-receive");
32    const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
33}
34
35/// Status of a receive (reissuance) operation.
36#[derive(Serialize, Deserialize, Debug, Clone, Eq, PartialEq)]
37pub enum ReceivePaymentStatus {
38    /// The reissuance was successful.
39    Success,
40    /// The reissuance was rejected.
41    Rejected,
42}
43
44/// Event emitted when a receive (reissuance) operation reaches a final state.
45#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
46pub struct ReceivePaymentUpdateEvent {
47    pub operation_id: OperationId,
48    pub status: ReceivePaymentStatus,
49}
50
51impl Event for ReceivePaymentUpdateEvent {
52    const MODULE: Option<ModuleKind> = Some(KIND);
53    const KIND: EventKind = EventKind::from_static("payment-receive-update");
54    const PERSISTENCE: EventPersistence = EventPersistence::Persistent;
55}