34 lines
988 B
Rust
Raw Normal View History

2026-01-08 09:10:00 +02:00
use anyhow::Result;
pub use logos_blockchain_common_http_client::{BasicAuthCredentials, CommonHttpClient, Error};
use logos_blockchain_core::mantle::SignedMantleTx;
2026-01-21 11:47:28 -03:00
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
#[derive(Clone)]
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()
2026-01-20 10:26:22 +02:00
//Add more fields if needed
2026-01-08 09:10:00 +02:00
.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
}
}