diff --git a/src/perms/tx_cache.rs b/src/perms/tx_cache.rs index 351428c..954bf3c 100644 --- a/src/perms/tx_cache.rs +++ b/src/perms/tx_cache.rs @@ -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}; @@ -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> { - self.get_inner_with_token::(BUNDLES, None) + pub async fn get_bundles(&self, query: Option) -> Result { + self.get_inner_with_token::(BUNDLES, query) .await - .map(|response| response.bundles) } fn get_bundle_url_path(&self, bundle_id: &str) -> String { diff --git a/tests/tx-cache.rs b/tests/tx-cache.rs index 8f75dad..7eca382 100644 --- a/tests/tx-cache.rs +++ b/tests/tx-cache.rs @@ -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)); }