From a4410c83e8f155a2e1bac06cae62e0722eefa652 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 24 Dec 2024 14:58:52 +0100 Subject: [PATCH] feat: add L2EthApiExt trait (#13539) --- crates/rpc/rpc-api/src/lib.rs | 3 ++- crates/rpc/rpc-eth-api/src/ext.rs | 18 ++++++++++++++++++ crates/rpc/rpc-eth-api/src/lib.rs | 4 ++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 crates/rpc/rpc-eth-api/src/ext.rs diff --git a/crates/rpc/rpc-api/src/lib.rs b/crates/rpc/rpc-api/src/lib.rs index 098214f103f8..196a4f4ec1ad 100644 --- a/crates/rpc/rpc-api/src/lib.rs +++ b/crates/rpc/rpc-api/src/lib.rs @@ -53,7 +53,7 @@ pub mod servers { }; pub use reth_rpc_eth_api::{ self as eth, EthApiServer, EthBundleApiServer, EthCallBundleApiServer, EthFilterApiServer, - EthPubSubApiServer, + EthPubSubApiServer, L2EthApiExtServer, }; } @@ -84,5 +84,6 @@ pub mod clients { }; pub use reth_rpc_eth_api::{ EthApiClient, EthBundleApiClient, EthCallBundleApiClient, EthFilterApiClient, + L2EthApiExtServer, }; } diff --git a/crates/rpc/rpc-eth-api/src/ext.rs b/crates/rpc/rpc-eth-api/src/ext.rs new file mode 100644 index 000000000000..4589982912fa --- /dev/null +++ b/crates/rpc/rpc-eth-api/src/ext.rs @@ -0,0 +1,18 @@ +//! `eth_` Extension traits. + +use alloy_primitives::{Bytes, B256}; +use alloy_rpc_types_eth::erc4337::ConditionalOptions; +use jsonrpsee::{core::RpcResult, proc_macros::rpc}; + +/// Extension trait for `eth_` namespace for L2s. +#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))] +#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))] +pub trait L2EthApiExt { + /// Sends signed transaction with the given condition. + #[method(name = "sendRawTransactionConditional")] + async fn send_raw_transaction_conditional( + &self, + bytes: Bytes, + condition: ConditionalOptions, + ) -> RpcResult; +} diff --git a/crates/rpc/rpc-eth-api/src/lib.rs b/crates/rpc/rpc-eth-api/src/lib.rs index d9c7f39a4404..d96a937cc5dc 100644 --- a/crates/rpc/rpc-eth-api/src/lib.rs +++ b/crates/rpc/rpc-eth-api/src/lib.rs @@ -14,6 +14,7 @@ pub mod bundle; pub mod core; +pub mod ext; pub mod filter; pub mod helpers; pub mod node; @@ -22,6 +23,7 @@ pub mod types; pub use bundle::{EthBundleApiServer, EthCallBundleApiServer}; pub use core::{EthApiServer, FullEthApiServer}; +pub use ext::L2EthApiExtServer; pub use filter::EthFilterApiServer; pub use node::{RpcNodeCore, RpcNodeCoreExt}; pub use pubsub::EthPubSubApiServer; @@ -36,6 +38,8 @@ pub use bundle::{EthBundleApiClient, EthCallBundleApiClient}; #[cfg(feature = "client")] pub use core::EthApiClient; #[cfg(feature = "client")] +pub use ext::L2EthApiExtClient; +#[cfg(feature = "client")] pub use filter::EthFilterApiClient; use reth_trie_common as _;