use cashu::BlindedMessage;
use serde::{Deserialize, Serialize};
use crate::{Amount, Error};
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ReceiveSagaState {
ProofsPending,
SwapRequested,
}
impl std::fmt::Display for ReceiveSagaState {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ReceiveSagaState::ProofsPending => write!(f, "proofs_pending"),
ReceiveSagaState::SwapRequested => write!(f, "swap_requested"),
}
}
}
impl std::str::FromStr for ReceiveSagaState {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"proofs_pending" => Ok(ReceiveSagaState::ProofsPending),
"swap_requested" => Ok(ReceiveSagaState::SwapRequested),
_ => Err(Error::InvalidOperationState),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ReceiveOperationData {
pub token: Option<String>,
pub counter_start: Option<u32>,
pub counter_end: Option<u32>,
pub amount: Option<Amount>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub blinded_messages: Option<Vec<BlindedMessage>>,
}