Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
44e49d9
feat(tx-cache): Pagination types and impl
Evalir Oct 23, 2025
c024d76
chore: from impl for paginationinfo/params
Evalir Oct 23, 2025
92c4ded
chore: extra helper fns
Evalir Oct 27, 2025
3303fa2
feat: re-design pagination to contain a CacheResponse<T>
Evalir Oct 31, 2025
af2decb
chore: adapt client
Evalir Nov 6, 2025
e4f385c
feat: traits for cursor/cache objects
Evalir Nov 7, 2025
09dfe87
chore: utility fn
Evalir Nov 7, 2025
3e7d667
chore: make cacheresponse untagged
Evalir Nov 7, 2025
3dd9b78
chore: flatten the actual response type on CacheResponse
Evalir Nov 7, 2025
44e53a1
chore: use C for anything cursorkey related
Evalir Nov 7, 2025
404e062
chore: more type foo
Evalir Nov 7, 2025
ae4bbcc
chore: response type for orders
Evalir Nov 7, 2025
f494d50
chore: dedup
Evalir Nov 10, 2025
cde92dc
chore: inline, remove limit
Evalir Nov 11, 2025
003964a
chore: review comments
Evalir Nov 11, 2025
8c73ffc
chore: make key optional on PaginationParams
Evalir Nov 12, 2025
39bb26e
chore: rework cursor types to manually deser for correct behavior
Evalir Nov 12, 2025
6ca953b
chore: make client fns take key directly
Evalir Nov 12, 2025
17670e8
clippy
Evalir Nov 12, 2025
75126e8
chore: no more need for `CursorKey`
Evalir Nov 12, 2025
a4f491d
chore: simplify bounds further
Evalir Nov 12, 2025
8fa47ec
chore: correct visitor impl
Evalir Nov 12, 2025
2d22d48
chore: test edge cases properly
Evalir Nov 12, 2025
2be9325
chore: rm `PaginationInfo`
Evalir Nov 12, 2025
a93669d
chore: modify tests to serialize without `PaginationParams`
Evalir Nov 12, 2025
3a61bb6
chore: clippy
Evalir Nov 12, 2025
c9ca389
chore: simplify client get
Evalir Nov 12, 2025
ad594e5
chore: rename `PaginationParams to `CursorPayload`
Evalir Nov 12, 2025
252ada0
chore: more tests
Evalir Nov 12, 2025
4e3fbde
feat: turn cacheresponse enum into struct
Evalir Nov 12, 2025
15b655d
chore: remove dbg
Evalir Nov 12, 2025
18ebd0a
?
Evalir Nov 12, 2025
09614d6
??
Evalir Nov 12, 2025
e1e5d63
chore: correct naming
Evalir Nov 13, 2025
c83d489
chore: move CursorPayload
Evalir Nov 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion crates/tx-cache/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ eyre.workspace = true
reqwest.workspace = true
serde = { workspace = true, features = ["derive"] }
tracing.workspace = true
uuid = { workspace = true, features = ["serde"] }
uuid = { workspace = true, features = ["serde"] }

[dev-dependencies]
serde_urlencoded = "0.7.1"
uuid = { workspace = true, features = ["serde", "v4"] }
serde_json.workspace = true
31 changes: 16 additions & 15 deletions crates/tx-cache/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::types::{
TxCacheOrdersResponse, TxCacheSendBundleResponse, TxCacheSendTransactionResponse,
TxCacheTransactionsResponse,
CacheObject, CacheResponse, OrderKey, TxCacheOrdersResponse, TxCacheSendBundleResponse,
TxCacheSendTransactionResponse, TxCacheTransactionsResponse, TxKey,
};
use alloy::consensus::TxEnvelope;
use eyre::Error;
Expand Down Expand Up @@ -93,22 +93,21 @@ impl TxCache {
self.client.post(url).json(&obj).send().await?.error_for_status().map_err(Into::into)
}

async fn get_inner<T>(&self, join: &'static str) -> Result<T, Error>
async fn get_inner<T>(&self, join: &'static str, query: Option<T::Key>) -> Result<T, Error>
where
T: DeserializeOwned,
T: DeserializeOwned + CacheObject,
{
// Append the path to the URL.
let url = self
.url
.join(join)
.inspect_err(|e| warn!(%e, "Failed to join URL. Not querying transaction cache."))?;

// Get the result.
self.client
.get(url)
.query(&query)
.send()
.await
.inspect_err(|e| warn!(%e, "Failed to get object from transaction cache"))?
.inspect_err(|e| warn!(%e, "Failed to get object from transaction cache."))?
.json::<T>()
.await
.map_err(Into::into)
Expand Down Expand Up @@ -140,17 +139,19 @@ impl TxCache {

/// Get transactions from the URL.
#[instrument(skip_all)]
pub async fn get_transactions(&self) -> Result<Vec<TxEnvelope>, Error> {
let response: TxCacheTransactionsResponse =
self.get_inner::<TxCacheTransactionsResponse>(TRANSACTIONS).await?;
Ok(response.transactions)
pub async fn get_transactions(
&self,
query: Option<TxKey>,
) -> Result<CacheResponse<TxCacheTransactionsResponse>, Error> {
self.get_inner(TRANSACTIONS, query).await
}

/// Get signed orders from the URL.
#[instrument(skip_all)]
pub async fn get_orders(&self) -> Result<Vec<SignedOrder>, Error> {
let response: TxCacheOrdersResponse =
self.get_inner::<TxCacheOrdersResponse>(ORDERS).await?;
Ok(response.orders)
pub async fn get_orders(
&self,
query: Option<OrderKey>,
) -> Result<CacheResponse<TxCacheOrdersResponse>, Error> {
self.get_inner(ORDERS, query).await
}
}
Loading