fedimint_mint_client/
event.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use std::time::Duration;

use fedimint_core::core::ModuleKind;
use fedimint_core::Amount;
use fedimint_eventlog::{Event, EventKind};
use fedimint_mint_common::{Nonce, KIND};
use serde::{Deserialize, Serialize};

/// Event that is emitted when a note is created.
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct NoteCreated {
    /// The nonce of the note
    pub nonce: Nonce,
}

impl Event for NoteCreated {
    const MODULE: Option<ModuleKind> = Some(KIND);

    const KIND: EventKind = EventKind::from_static("note-created");
}

/// Event that is emitted when a note is spent.
#[derive(Clone, Copy, Serialize, Deserialize)]
pub struct NoteSpent {
    /// The nonce of the note
    pub nonce: Nonce,
}

impl Event for NoteSpent {
    const MODULE: Option<ModuleKind> = Some(KIND);

    const KIND: EventKind = EventKind::from_static("note-spent");
}

/// Event that is emitted when ecash is spent out of band
#[derive(Serialize, Deserialize)]
pub struct OOBNotesSpent {
    /// The requested amount to spend out of band
    pub requested_amount: Amount,

    /// The actual amount of ecash spent
    pub spent_amount: Amount,

    /// The timeout before attempting to refund
    pub timeout: Duration,

    /// Boolean that indicates if the invite code was included in the note
    /// serialization
    pub include_invite: bool,
}

impl Event for OOBNotesSpent {
    const MODULE: Option<ModuleKind> = Some(KIND);

    const KIND: EventKind = EventKind::from_static("oob-notes-spent");
}

/// Event that is emitted when out of band ecash is reissued
#[derive(Serialize, Deserialize)]
pub struct OOBNotesReissued {
    /// The amount of out of band ecash being reissued
    pub amount: Amount,
}

impl Event for OOBNotesReissued {
    const MODULE: Option<ModuleKind> = Some(KIND);

    const KIND: EventKind = EventKind::from_static("oob-notes-reissued");
}