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
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "init4-bin-base"

description = "Internal utilities for binaries produced by the init4 team"
keywords = ["init4", "bin", "base"]
version = "0.18.0-rc.9"
version = "0.18.0-rc.10"
edition = "2021"
rust-version = "1.85"
authors = ["init4", "James Prestwich", "evalir"]
Expand All @@ -15,8 +15,8 @@ repository = "https://github.com/init4tech/bin-base"
init4-from-env-derive = { version = "0.2.0", path = "from-env-derive" }

# Signet
signet-constants = { version = "0.16.0-rc.7" }
signet-tx-cache = { version = "0.16.0-rc.7", optional = true }
signet-constants = { version = "0.16.0-rc.11" }
signet-tx-cache = { version = "0.16.0-rc.11", optional = true }

# alloy
alloy = { version = "1.0.35", optional = true, default-features = false, features = ["std", "signer-local", "consensus", "network"] }
Expand Down
24 changes: 17 additions & 7 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::TxCacheError,
types::{BundleKey, CacheObject, TxCacheBundle, TxCacheBundleResponse, TxCacheBundlesResponse},
types::{BundleKey, BundleList, CacheObject, CacheResponse, CachedBundle},
TxCache,
};
use thiserror::Error;
Expand Down Expand Up @@ -139,8 +139,8 @@ impl BuilderTxCache {
/// 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, query: Option<BundleKey>) -> Result<TxCacheBundlesResponse> {
self.get_inner_with_token::<TxCacheBundlesResponse>(BUNDLES, query)
pub async fn get_bundles(&self, query: Option<BundleKey>) -> Result<CacheResponse<BundleList>> {
self.get_inner_with_token::<CacheResponse<BundleList>>(BUNDLES, query)
.await
}

Expand All @@ -151,10 +151,20 @@ impl BuilderTxCache {
/// Get a bundle from the cache by its UUID. For convenience, this method
/// takes a string reference, which is expected to be a valid UUID.
#[instrument(skip_all)]
pub async fn get_bundle(&self, bundle_id: &str) -> Result<TxCacheBundle> {
let url = self.get_bundle_url_path(bundle_id);
self.get_inner_with_token::<TxCacheBundleResponse>(&url, None)
pub async fn get_bundle(&self, bundle_id: &str) -> Result<CachedBundle> {
let url_path = self.get_bundle_url_path(bundle_id);
let url = self.tx_cache.url().join(&url_path)?;
let secret = self.token.secret().await?;

self.tx_cache
.client()
.get(url)
.bearer_auth(secret)
.send()
.await?
.error_for_status()?
.json::<CachedBundle>()
.await
.map(|response| response.bundle)
.map_err(Into::into)
}
}