Skip to content

Commit 6c964d3

Browse files
committed
chore: response type for orders
1 parent 09b086d commit 6c964d3

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

crates/tx-cache/src/types.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,36 @@ impl TxCacheOrdersResponse {
402402
}
403403
}
404404

405+
/// Response from the transaction cache to successfully adding an order.
406+
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
407+
pub struct TxCacheSendOrderResponse {
408+
/// The order id
409+
pub id: B256,
410+
}
411+
412+
impl From<B256> for TxCacheSendOrderResponse {
413+
fn from(id: B256) -> Self {
414+
Self { id }
415+
}
416+
}
417+
418+
impl From<TxCacheSendOrderResponse> for B256 {
419+
fn from(response: TxCacheSendOrderResponse) -> Self {
420+
response.id
421+
}
422+
}
423+
424+
impl CacheObject for TxCacheSendOrderResponse {
425+
type Key = OrderKey;
426+
}
427+
428+
impl TxCacheSendOrderResponse {
429+
/// Create a new order response from an order id.
430+
pub const fn new(id: B256) -> Self {
431+
Self { id }
432+
}
433+
}
434+
405435
/// Represents the pagination information from a transaction cache response.
406436
/// This applies to all GET endpoints that return a list of items.
407437
#[derive(Debug, Clone, Serialize, Deserialize)]

0 commit comments

Comments
 (0)