Skip to content

Commit

Permalink
Merge pull request #78 from MostroP2P/move-actions-to-cantdoreasons
Browse files Browse the repository at this point in the history
Move actions to cantdoreasons
  • Loading branch information
grunch authored Dec 28, 2024
2 parents 7ce5f9c + 189e86e commit 0f55ed5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mostro-core"
version = "0.6.21"
version = "0.6.22"
edition = "2021"
license = "MIT"
authors = ["Francisco Calderón <[email protected]>"]
Expand Down
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 0f55ed5

Please sign in to comment.