1use alloy_primitives::{Address, Bytes, B256, U256};
13use jsonrpsee::{
14 core::RpcResult,
15 proc_macros::rpc,
16 types::{error::INTERNAL_ERROR_CODE, ErrorObject},
17};
18use serde::{Deserialize, Serialize};
19
20fn not_enabled(feature: &str) -> ErrorObject<'static> {
21 ErrorObject::owned(
22 INTERNAL_ERROR_CODE,
23 format!("{feature} is not enabled on this node"),
24 None::<()>,
25 )
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(rename_all = "camelCase")]
35pub struct ExpressLaneSubmission {
36 pub chain_id: U256,
37 pub round: u64,
38 pub auction_contract_address: Address,
39 pub sequence: u64,
40 pub transaction: Bytes,
41 pub signature: Bytes,
42}
43
44#[rpc(server, namespace = "arbtimeboost")]
46pub trait ArbTimeboostApi {
47 #[method(name = "sendExpressLaneTransaction")]
50 async fn send_express_lane_transaction(&self, msg: ExpressLaneSubmission) -> RpcResult<()>;
51}
52
53#[rpc(server, namespace = "arbtimeboostauctioneer")]
56pub trait ArbTimeboostAuctioneerApi {
57 #[method(name = "submitAuctionResolutionTransaction")]
61 async fn submit_auction_resolution_transaction(&self, raw_tx: Bytes) -> RpcResult<B256>;
62}
63
64#[derive(Debug, Clone, Default)]
66pub struct ArbTimeboostConfig {
67 pub express_lane_enabled: bool,
69 pub auctioneer_enabled: bool,
71}
72
73#[derive(Debug, Clone)]
75pub struct ArbTimeboostHandler {
76 config: ArbTimeboostConfig,
77}
78
79impl ArbTimeboostHandler {
80 pub fn new(config: ArbTimeboostConfig) -> Self {
81 Self { config }
82 }
83}
84
85#[async_trait::async_trait]
86impl ArbTimeboostApiServer for ArbTimeboostHandler {
87 async fn send_express_lane_transaction(&self, _msg: ExpressLaneSubmission) -> RpcResult<()> {
88 if !self.config.express_lane_enabled {
89 return Err(not_enabled("timeboost express lane"));
90 }
91 Err(not_enabled("timeboost express lane publisher"))
93 }
94}
95
96#[async_trait::async_trait]
97impl ArbTimeboostAuctioneerApiServer for ArbTimeboostHandler {
98 async fn submit_auction_resolution_transaction(&self, _raw_tx: Bytes) -> RpcResult<B256> {
99 if !self.config.auctioneer_enabled {
100 return Err(not_enabled("timeboost auctioneer"));
101 }
102 Err(not_enabled("timeboost auctioneer publisher"))
105 }
106}