cdk_common/wallet/saga/
receive.rs1use cashu::BlindedMessage;
4use serde::{Deserialize, Serialize};
5
6use crate::{Amount, Error};
7
8#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
10#[serde(rename_all = "snake_case")]
11pub enum ReceiveSagaState {
12 ProofsPending,
14 SwapRequested,
16}
17
18impl std::fmt::Display for ReceiveSagaState {
19 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
20 match self {
21 ReceiveSagaState::ProofsPending => write!(f, "proofs_pending"),
22 ReceiveSagaState::SwapRequested => write!(f, "swap_requested"),
23 }
24 }
25}
26
27impl std::str::FromStr for ReceiveSagaState {
28 type Err = Error;
29 fn from_str(s: &str) -> Result<Self, Self::Err> {
30 match s {
31 "proofs_pending" => Ok(ReceiveSagaState::ProofsPending),
32 "swap_requested" => Ok(ReceiveSagaState::SwapRequested),
33 _ => Err(Error::InvalidOperationState),
34 }
35 }
36}
37
38#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
40pub struct ReceiveOperationData {
41 pub token: Option<String>,
43 pub counter_start: Option<u32>,
45 pub counter_end: Option<u32>,
47 pub amount: Option<Amount>,
49 #[serde(default, skip_serializing_if = "Option::is_none")]
54 pub blinded_messages: Option<Vec<BlindedMessage>>,
55}