From ec9c5cfab07346d77a98a5f670af663034dec6f0 Mon Sep 17 00:00:00 2001 From: "nobu.maeda" Date: Fri, 19 Apr 2024 17:31:40 +0800 Subject: [PATCH] Provide unique reasons when cancelling an order --- src/comms/comms.rs | 22 +++++++++++++++------- src/maker/maker.rs | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/comms/comms.rs b/src/comms/comms.rs index 45f7543..ff57f22 100644 --- a/src/comms/comms.rs +++ b/src/comms/comms.rs @@ -226,9 +226,14 @@ impl CommsAccess { pub(crate) async fn delete_maker_order_note( &self, event_id: EventIdString, + reason: impl Into, ) -> Result<(), N3xbError> { let (rsp_tx, rsp_rx) = oneshot::channel::>(); - let request = CommsRequest::DeletMakerOrderNote { event_id, rsp_tx }; + let request = CommsRequest::DeletMakerOrderNote { + event_id, + reason: reason.into(), + rsp_tx, + }; self.tx.send(request).await.unwrap(); rsp_rx.await.unwrap() } @@ -371,6 +376,7 @@ pub(super) enum CommsRequest { }, DeletMakerOrderNote { event_id: EventIdString, + reason: String, rsp_tx: oneshot::Sender>, }, Shutdown { @@ -582,8 +588,12 @@ impl CommsActor { .await; } // Delete an Maker Order Note - CommsRequest::DeletMakerOrderNote { event_id, rsp_tx } => { - self.delete_maker_order_note(event_id, rsp_tx).await; + CommsRequest::DeletMakerOrderNote { + event_id, + reason, + rsp_tx, + } => { + self.delete_maker_order_note(event_id, reason, rsp_tx).await; } // Shutdown @@ -1367,14 +1377,12 @@ impl CommsActor { async fn delete_maker_order_note( &self, event_id: EventIdString, + reason: String, rsp_tx: oneshot::Sender>, ) { let result = self .client - .delete_event( - EventId::from_str(&event_id).unwrap(), - Some("n3xB: Order cancelled by Maker before Trade commenced"), - ) + .delete_event(EventId::from_str(&event_id).unwrap(), Some(reason)) .await; match result { Ok(_) => rsp_tx.send(Ok(())).unwrap(), diff --git a/src/maker/maker.rs b/src/maker/maker.rs index ec958fe..44c84a6 100644 --- a/src/maker/maker.rs +++ b/src/maker/maker.rs @@ -461,7 +461,7 @@ impl MakerActor { // Delete Order Note let result = self .comms_accessor - .delete_maker_order_note(maker_order_note_id.clone()) + .delete_maker_order_note(maker_order_note_id.clone(), "Trade Started on Offer Accept") .await; // Send response back to user @@ -576,7 +576,7 @@ impl MakerActor { // Delete Order Note let result = self .comms_accessor - .delete_maker_order_note(maker_order_note_id.clone()) + .delete_maker_order_note(maker_order_note_id.clone(), "Trade Cancelled") .await; // Send response back to user