34 lines
967 B
Rust
Raw Normal View History

2026-01-08 09:10:00 +02:00
use anyhow::Result;
use common_http_client::CommonHttpClient;
2026-01-08 09:10:45 +02:00
pub use common_http_client::{BasicAuthCredentials, Error};
2026-01-21 11:47:28 -03:00
use nomos_core::mantle::SignedMantleTx;
use reqwest::{Client, Url};
2026-01-07 16:29:37 +02:00
2026-01-08 09:10:00 +02:00
// Simple wrapper
// maybe extend in the future for our purposes
2026-01-21 11:47:28 -03:00
pub struct BedrockClient {
http_client: CommonHttpClient,
node_url: Url,
}
2026-01-07 16:29:37 +02:00
2026-01-08 09:10:00 +02:00
impl BedrockClient {
2026-01-21 11:47:28 -03:00
pub fn new(auth: Option<BasicAuthCredentials>, node_url: Url) -> Result<Self> {
2026-01-08 09:10:00 +02:00
let client = Client::builder()
//Add more fiedls if needed
.timeout(std::time::Duration::from_secs(60))
.build()?;
2026-01-07 16:29:37 +02:00
2026-01-21 11:47:28 -03:00
let http_client = CommonHttpClient::new_with_client(client, auth);
Ok(Self {
http_client,
node_url,
})
}
pub async fn post_transaction(&self, tx: SignedMantleTx) -> Result<(), Error> {
self.http_client
.post_transaction(self.node_url.clone(), tx)
.await
2026-01-07 16:29:37 +02:00
}
}