hopr_chain_types/
actions.rs1use hopr_internal_types::prelude::*;
9use hopr_primitive_types::prelude::*;
10use std::fmt::{Display, Formatter};
11
12#[allow(clippy::large_enum_variant)] #[derive(Clone, PartialEq, Debug, strum::VariantNames, strum::IntoStaticStr)]
20#[strum(serialize_all = "snake_case")]
21pub enum Action {
22 RedeemTicket(RedeemableTicket),
24
25 OpenChannel(Address, Balance),
27
28 FundChannel(ChannelEntry, Balance),
30
31 CloseChannel(ChannelEntry, ChannelDirection),
33
34 Withdraw(Address, Balance),
36
37 Announce(AnnouncementData),
39
40 RegisterSafe(Address),
42}
43
44impl Display for Action {
45 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
46 match self {
47 Action::RedeemTicket(ack) => write!(f, "redeem action of {ack}"),
48 Action::OpenChannel(dst, amount) => write!(f, "open channel action to {dst} with {amount}"),
49 Action::FundChannel(channel, amount) => write!(
50 f,
51 "fund channel action for channel from {} to {} with {amount}",
52 channel.source, channel.destination
53 ),
54 Action::CloseChannel(channel, direction) => write!(
55 f,
56 "closure action of {} channel from {} to {}",
57 direction, channel.source, channel.destination
58 ),
59 Action::Withdraw(destination, amount) => write!(f, "withdraw action of {amount} to {destination}"),
60 Action::Announce(data) => write!(f, "announce action of {}", data.multiaddress()),
61 Action::RegisterSafe(safe_address) => write!(f, "register safe action {safe_address}"),
62 }
63 }
64}