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