Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 19 additions & 4 deletions src/perms/tx_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::perms::oauth::SharedToken;
use serde::de::DeserializeOwned;
use signet_tx_cache::{
error::Result,
types::{CacheObject, TxCacheBundle, TxCacheBundleResponse, TxCacheBundlesResponse},
types::{BundleKey, CacheObject, TxCacheBundle, TxCacheBundleResponse, TxCacheBundlesResponse},
TxCache,
};
use tracing::{instrument, warn};
Expand Down Expand Up @@ -96,11 +96,26 @@ impl BuilderTxCache {
}

/// Get bundles from the cache.
///
/// # Arguments
///
/// * `query` - Optional pagination parameters. Pass `None` to retrieve the
/// first page of bundles. Pass `Some(BundleKey)` with pagination tokens
/// from the previous response to retrieve subsequent pages of results.
///
/// # Returns
///
/// A response containing bundles for the current page and an
/// optional pagination key. If the pagination key is present, there are
/// more pages available. Pass this key to subsequent calls to retrieve
/// the next page.
///
/// Returns an error if the request fails or the builder is not permissioned
/// for the current slot.
#[instrument(skip_all)]
pub async fn get_bundles(&self) -> Result<Vec<TxCacheBundle>> {
self.get_inner_with_token::<TxCacheBundlesResponse>(BUNDLES, None)
pub async fn get_bundles(&self, query: Option<BundleKey>) -> Result<TxCacheBundlesResponse> {
self.get_inner_with_token::<TxCacheBundlesResponse>(BUNDLES, query)
.await
.map(|response| response.bundles)
}

fn get_bundle_url_path(&self, bundle_id: &str) -> String {
Expand Down
2 changes: 1 addition & 1 deletion tests/tx-cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const URL: &str = "https://transactions.parmigiana.signet.sh";
async fn test_tx_cache_get_bundles() {
let client = BuilderTxCache::new_from_string(URL, SharedToken::empty()).unwrap();

let bundles = client.get_bundles().await.unwrap_err();
let bundles = client.get_bundles(None).await.unwrap_err();

assert!(matches!(bundles, TxCacheError::NotOurSlot));
}