Skip to content

Commit

Permalink
Move some actions to cantdoreasons
Browse files Browse the repository at this point in the history
  • Loading branch information
grunch committed Dec 28, 2024
1 parent 7ce5f9c commit b86a406
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
6 changes: 6 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ mod test {
CantDoReason::InvalidParameters,
CantDoReason::OrderAlreadyCanceled,
CantDoReason::CantCreateUser,
CantDoReason::IsNotYourOrder,
CantDoReason::NotAllowedByStatus,
CantDoReason::OutOfRangeFiatAmount,
CantDoReason::OutOfRangeSatsAmount,
CantDoReason::IsNotYourDispute,
CantDoReason::NotFound,
];

for reason in reasons {
Expand Down
30 changes: 14 additions & 16 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,10 @@ pub enum Action {
AdminAddSolver,
AdminTakeDispute,
AdminTookDispute,
IsNotYourOrder,
NotAllowedByStatus,
OutOfRangeFiatAmount,
IsNotYourDispute,
NotFound,
IncorrectInvoiceAmount,
InvalidSatsAmount,
OutOfRangeSatsAmount,
PaymentFailed,
InvoiceUpdated,
SendDm,
TradePubkey,
}

impl fmt::Display for Action {
Expand Down Expand Up @@ -241,6 +234,18 @@ pub enum CantDoReason {
OrderAlreadyCanceled,
/// Can't create user
CantCreateUser,
/// For users trying to do actions on orders that are not theirs
IsNotYourOrder,
/// For users trying to do actions on orders not allowed by status
NotAllowedByStatus,
/// Fiat amount is out of range
OutOfRangeFiatAmount,
/// Sats amount is out of range
OutOfRangeSatsAmount,
/// For users trying to do actions on dispute that are not theirs
IsNotYourDispute,
/// Generic not found
NotFound,
}

/// Message payload
Expand Down Expand Up @@ -329,15 +334,8 @@ impl MessageKind {
| Action::CooperativeCancelInitiatedByPeer
| Action::CooperativeCancelAccepted
| Action::Cancel
| Action::IsNotYourOrder
| Action::NotAllowedByStatus
| Action::OutOfRangeFiatAmount
| Action::OutOfRangeSatsAmount
| Action::IsNotYourDispute
| Action::NotFound
| Action::IncorrectInvoiceAmount
| Action::InvalidSatsAmount
| Action::PaymentFailed
| Action::TradePubkey
| Action::InvoiceUpdated
| Action::AdminAddSolver
| Action::SendDm
Expand Down

0 comments on commit b86a406

Please sign in to comment.