1use alloy::{consensus::TxEnvelope, primitives::B256};
3use serde::{Deserialize, Serialize};
4use signet_bundle::SignetEthBundle;
5use signet_types::SignedOrder;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct TxCacheBundle {
11 pub id: uuid::Uuid,
13 pub bundle: SignetEthBundle,
15}
16
17impl TxCacheBundle {
18 pub const fn new(bundle: SignetEthBundle, id: uuid::Uuid) -> Self {
20 Self { id, bundle }
21 }
22
23 #[deprecated = "Use `Self::new` instead"]
25 pub const fn from_bundle_and_id(bundle: SignetEthBundle, id: uuid::Uuid) -> Self {
26 Self::new(bundle, id)
27 }
28
29 pub fn into_bundle(self) -> SignetEthBundle {
31 self.bundle
32 }
33
34 pub fn into_id(self) -> uuid::Uuid {
36 self.id
37 }
38
39 pub const fn id(&self) -> uuid::Uuid {
41 self.id
42 }
43
44 pub const fn bundle(&self) -> &SignetEthBundle {
46 &self.bundle
47 }
48}
49
50#[derive(Debug, Clone, Serialize, Deserialize)]
52pub struct TxCacheBundleResponse {
53 pub bundle: TxCacheBundle,
55}
56
57impl From<TxCacheBundle> for TxCacheBundleResponse {
58 fn from(bundle: TxCacheBundle) -> Self {
59 Self { bundle }
60 }
61}
62
63impl From<TxCacheBundleResponse> for TxCacheBundle {
64 fn from(response: TxCacheBundleResponse) -> Self {
65 response.bundle
66 }
67}
68
69impl TxCacheBundleResponse {
70 pub const fn new(bundle: TxCacheBundle) -> Self {
72 Self { bundle }
73 }
74
75 #[deprecated = "Use `From::from` instead, `Self::new` in const contexts"]
77 pub const fn from_bundle(bundle: TxCacheBundle) -> Self {
78 Self::new(bundle)
79 }
80
81 #[deprecated = "Use `this.bundle` instead."]
83 pub fn into_bundle(self) -> TxCacheBundle {
84 self.bundle
85 }
86}
87
88#[derive(Debug, Clone, Serialize, Deserialize)]
90pub struct TxCacheBundlesResponse {
91 pub bundles: Vec<TxCacheBundle>,
93}
94
95impl From<Vec<TxCacheBundle>> for TxCacheBundlesResponse {
96 fn from(bundles: Vec<TxCacheBundle>) -> Self {
97 Self { bundles }
98 }
99}
100
101impl From<TxCacheBundlesResponse> for Vec<TxCacheBundle> {
102 fn from(response: TxCacheBundlesResponse) -> Self {
103 response.bundles
104 }
105}
106
107impl TxCacheBundlesResponse {
108 pub const fn new(bundles: Vec<TxCacheBundle>) -> Self {
110 Self { bundles }
111 }
112
113 #[deprecated = "Use `From::from` instead, `Self::new` in const contexts"]
115 pub const fn from_bundles(bundles: Vec<TxCacheBundle>) -> Self {
116 Self::new(bundles)
117 }
118
119 #[deprecated = "Use `this.bundles` instead."]
121 pub fn into_bundles(self) -> Vec<TxCacheBundle> {
122 self.bundles
123 }
124}
125
126#[derive(Debug, Copy, Clone, Serialize, Deserialize)]
128pub struct TxCacheSendBundleResponse {
129 pub id: uuid::Uuid,
131}
132
133impl TxCacheSendBundleResponse {
134 pub const fn new(id: uuid::Uuid) -> Self {
136 Self { id }
137 }
138}
139
140impl From<uuid::Uuid> for TxCacheSendBundleResponse {
141 fn from(id: uuid::Uuid) -> Self {
142 Self { id }
143 }
144}
145
146impl From<TxCacheSendBundleResponse> for uuid::Uuid {
147 fn from(response: TxCacheSendBundleResponse) -> Self {
148 response.id
149 }
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
154pub struct TxCacheTransactionsResponse {
155 pub transactions: Vec<TxEnvelope>,
157}
158
159impl From<Vec<TxEnvelope>> for TxCacheTransactionsResponse {
160 fn from(transactions: Vec<TxEnvelope>) -> Self {
161 Self { transactions }
162 }
163}
164
165impl From<TxCacheTransactionsResponse> for Vec<TxEnvelope> {
166 fn from(response: TxCacheTransactionsResponse) -> Self {
167 response.transactions
168 }
169}
170
171impl TxCacheTransactionsResponse {
172 pub const fn new(transactions: Vec<TxEnvelope>) -> Self {
174 Self { transactions }
175 }
176
177 #[deprecated = "Use `From::from` instead, or `Self::new` in const contexts"]
179 pub const fn from_transactions(transactions: Vec<TxEnvelope>) -> Self {
180 Self::new(transactions)
181 }
182
183 #[deprecated = "Use `this.transactions` instead."]
185 pub fn into_transactions(self) -> Vec<TxEnvelope> {
186 self.transactions
187 }
188}
189
190#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
192pub struct TxCacheSendTransactionResponse {
193 pub tx_hash: B256,
195}
196
197impl From<B256> for TxCacheSendTransactionResponse {
198 fn from(tx_hash: B256) -> Self {
199 Self { tx_hash }
200 }
201}
202
203impl From<TxCacheSendTransactionResponse> for B256 {
204 fn from(response: TxCacheSendTransactionResponse) -> Self {
205 response.tx_hash
206 }
207}
208
209impl TxCacheSendTransactionResponse {
210 pub const fn new(tx_hash: B256) -> Self {
212 Self { tx_hash }
213 }
214
215 #[deprecated = "Use `From::from` instead, or `Self::new` in const contexts"]
217 pub const fn from_tx_hash(tx_hash: B256) -> Self {
218 Self { tx_hash }
219 }
220
221 #[deprecated = "Use `this.tx_hash` instead."]
223 pub const fn into_tx_hash(self) -> B256 {
224 self.tx_hash
225 }
226}
227
228#[derive(Debug, Clone, Serialize, Deserialize)]
230pub struct TxCacheOrdersResponse {
231 pub orders: Vec<SignedOrder>,
233}
234
235impl From<Vec<SignedOrder>> for TxCacheOrdersResponse {
236 fn from(orders: Vec<SignedOrder>) -> Self {
237 Self { orders }
238 }
239}
240
241impl From<TxCacheOrdersResponse> for Vec<SignedOrder> {
242 fn from(response: TxCacheOrdersResponse) -> Self {
243 response.orders
244 }
245}
246
247impl TxCacheOrdersResponse {
248 pub const fn new(orders: Vec<SignedOrder>) -> Self {
250 Self { orders }
251 }
252
253 #[deprecated = "Use `From::from` instead, `Self::new` in const contexts"]
255 pub const fn from_orders(orders: Vec<SignedOrder>) -> Self {
256 Self { orders }
257 }
258
259 #[deprecated = "Use `this.orders` instead."]
261 pub fn into_orders(self) -> Vec<SignedOrder> {
262 self.orders
263 }
264}