Skip to content

Commit 96b97ca

Browse files
Evalirprestwich
authored andcommitted
chore: add new methods
1 parent 9f336c7 commit 96b97ca

File tree

1 file changed

+53
-6
lines changed

1 file changed

+53
-6
lines changed

crates/rpc/src/signet/mod.rs

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,62 @@
11
//! Signet RPC methods and related code.
2+
use crate::util::await_jh_option;
3+
use crate::{ctx::RpcCtx, Pnt};
4+
use ajj::HandlerCtx;
25
use reth_node_api::FullNodeComponents;
3-
4-
use crate::{ctx::RpcCtx, util::not_supported, Pnt};
6+
use signet_bundle::SignetEthBundle;
7+
use signet_zenith::SignedOrder;
58

69
/// Instantiate a `signet` API router.
710
pub fn signet<Host, Signet>() -> ajj::Router<RpcCtx<Host, Signet>>
811
where
912
Host: FullNodeComponents,
1013
Signet: Pnt,
1114
{
12-
ajj::Router::new()
13-
.route("sendBundle", not_supported)
14-
.route("sendOrder", not_supported)
15-
}
15+
ajj::Router::new().route("sendBundle", send_bundle).route("sendOrder", send_order)
16+
}
17+
18+
pub(super) async fn send_bundle<Host, Signet>(
19+
hctx: HandlerCtx,
20+
bundle: SignetEthBundle,
21+
ctx: RpcCtx<Host, Signet>,
22+
) -> Result<(), String>
23+
where
24+
Host: FullNodeComponents,
25+
Signet: Pnt,
26+
{
27+
let task = |hctx: HandlerCtx| async move {
28+
let Some(forwarder) = ctx.signet().forwarder() else {
29+
return Err("tx-cache URL not provided".to_string());
30+
};
31+
32+
hctx.spawn(
33+
async move { forwarder.forward_bundle(bundle).await.map_err(|e| e.to_string()) },
34+
);
35+
36+
Ok(())
37+
};
38+
39+
await_jh_option!(hctx.spawn_blocking_with_ctx(task))
40+
}
41+
42+
pub(super) async fn send_order<Host, Signet>(
43+
hctx: HandlerCtx,
44+
order: SignedOrder,
45+
ctx: RpcCtx<Host, Signet>,
46+
) -> Result<(), String>
47+
where
48+
Host: FullNodeComponents,
49+
Signet: Pnt,
50+
{
51+
let task = |hctx: HandlerCtx| async move {
52+
let Some(forwarder) = ctx.signet().forwarder() else {
53+
return Err("tx-cache URL not provided".to_string());
54+
};
55+
56+
hctx.spawn(async move { forwarder.forward_order(order).await.map_err(|e| e.to_string()) });
57+
58+
Ok(())
59+
};
60+
61+
await_jh_option!(hctx.spawn_blocking_with_ctx(task))
62+
}

0 commit comments

Comments
 (0)