Skip to content

Commit 36a213e

Browse files
authored
Merge pull request #98 from MostroP2P/feature-order-previous-state
Feature order previous state
2 parents 6d7c675 + e4e28a6 commit 36a213e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/dispute.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,21 +61,34 @@ impl FromStr for Status {
6161
#[cfg_attr(feature = "sqlx", derive(FromRow, SqlxCrud), external_id)]
6262
#[derive(Debug, Default, Deserialize, Serialize, Clone, PartialEq, Eq)]
6363
pub struct Dispute {
64+
/// Unique identifier for the dispute
6465
pub id: Uuid,
66+
/// Order ID that the dispute is related to
6567
pub order_id: Uuid,
68+
/// Status of the dispute
6669
pub status: String,
70+
/// Previous status of the order before the dispute was created
71+
pub order_previous_status: String,
72+
/// Public key of the solver
6773
pub solver_pubkey: Option<String>,
74+
/// Timestamp when the dispute was created
6875
pub created_at: i64,
76+
/// Timestamp when the dispute was taken by a solver
6977
pub taken_at: i64,
78+
/// Security token for the buyer
7079
pub buyer_token: Option<u16>,
80+
/// Security token for the seller
7181
pub seller_token: Option<u16>,
7282
}
7383

7484
#[derive(Debug, Default, Deserialize, Serialize, Clone)]
7585

7686
pub struct UserDisputeInfo {
87+
/// User's rating
7788
pub rating: f64,
89+
/// User's total reviews
7890
pub reviews: i64,
91+
/// User's operating days
7992
pub operating_days: u64,
8093
}
8194

@@ -86,6 +99,7 @@ pub struct SolverDisputeInfo {
8699
pub status: String,
87100
pub hash: Option<String>,
88101
pub preimage: Option<String>,
102+
pub order_previous_status: String,
89103
pub initiator_pubkey: String,
90104
pub buyer_pubkey: Option<String>,
91105
pub buyer_token: Option<u16>,
@@ -148,6 +162,7 @@ impl SolverDisputeInfo {
148162
status: order.status.clone(),
149163
hash: order.hash.clone(),
150164
preimage: order.preimage.clone(),
165+
order_previous_status: dispute.order_previous_status.clone(),
151166
initiator_pubkey: initiator_tradekey,
152167
buyer_pubkey: order.buyer_pubkey.clone(),
153168
buyer_token: dispute.buyer_token,
@@ -172,11 +187,12 @@ impl SolverDisputeInfo {
172187
}
173188

174189
impl Dispute {
175-
pub fn new(order_id: Uuid) -> Self {
190+
pub fn new(order_id: Uuid, order_status: String) -> Self {
176191
Self {
177192
id: Uuid::new_v4(),
178193
order_id,
179194
status: Status::Initiated.to_string(),
195+
order_previous_status: order_status,
180196
solver_pubkey: None,
181197
created_at: Utc::now().timestamp(),
182198
taken_at: 0,

0 commit comments

Comments
 (0)