Skip to content

Commit e30e7e5

Browse files
committed
Add searcher API client SDK
1 parent 1942afa commit e30e7e5

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ members = [
1010
"relay-client",
1111
"relay-server",
1212
"searcher-api-types",
13+
"searcher-client",
1314
"common"
1415
]
1516

searcher-client/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "searcher-client"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
serde = { workspace = true }
8+
serde_json = { workspace = true }
9+
10+
alloy-primitives = "0.8"
11+
alloy-rpc-types-mev = "0.8"
12+
eyre = "0.6.12"
13+
url = "2.5.4"
14+
reqwest = { version = "0.12", features = ["json"] }
15+
16+
searcher-api-types = { path = "../searcher-api-types" }

searcher-client/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use alloy_rpc_types_mev::EthBundleHash;
2+
use reqwest::Client;
3+
use url::Url;
4+
5+
use searcher_api_types::SendBundleRequest;
6+
7+
pub async fn send_bundle(url: Url, bundle: &SendBundleRequest) -> eyre::Result<EthBundleHash> {
8+
Ok(serde_json::from_str(
9+
&Client::new()
10+
.post(url)
11+
.json(bundle)
12+
.send()
13+
.await?
14+
.text()
15+
.await?,
16+
)?)
17+
}

0 commit comments

Comments
 (0)