From 0da7e9ede9553d0ce37c516a1d4a60057d0490bd Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Tue, 24 Dec 2024 11:36:12 +0100 Subject: [PATCH] feat: add L2EthApiExt trait --- crates/rpc/rpc-api/src/lib.rs | 4 ++-- crates/rpc/rpc-eth-api/src/ext.rs | 16 ++++++++++++++++ crates/rpc/rpc-eth-api/src/lib.rs | 4 ++++ 3 files changed, 22 insertions(+), 2 deletions(-) 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..b7f04545d31c 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 }; } @@ -83,6 +83,6 @@ pub mod clients { web3::Web3ApiClient, }; pub use reth_rpc_eth_api::{ - EthApiClient, EthBundleApiClient, EthCallBundleApiClient, EthFilterApiClient, + 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..e70b5f975919 --- /dev/null +++ b/crates/rpc/rpc-eth-api/src/ext.rs @@ -0,0 +1,16 @@ +//! `eth_` Extension traits. + +use alloy_json_rpc::RpcObject; +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(&self, bytes: Bytes, condtion: ConditionalOptions) -> RpcResult; +} diff --git a/crates/rpc/rpc-eth-api/src/lib.rs b/crates/rpc/rpc-eth-api/src/lib.rs index d9c7f39a4404..fd113ec9cc2d 100644 --- a/crates/rpc/rpc-eth-api/src/lib.rs +++ b/crates/rpc/rpc-eth-api/src/lib.rs @@ -19,10 +19,12 @@ pub mod helpers; pub mod node; pub mod pubsub; pub mod types; +pub mod ext; pub use bundle::{EthBundleApiServer, EthCallBundleApiServer}; pub use core::{EthApiServer, FullEthApiServer}; pub use filter::EthFilterApiServer; +pub use ext::L2EthApiExtServer; pub use node::{RpcNodeCore, RpcNodeCoreExt}; pub use pubsub::EthPubSubApiServer; pub use reth_rpc_eth_types::error::{ @@ -37,5 +39,7 @@ pub use bundle::{EthBundleApiClient, EthCallBundleApiClient}; pub use core::EthApiClient; #[cfg(feature = "client")] pub use filter::EthFilterApiClient; +#[cfg(feature = "client")] +pub use ext::L2EthApiExtClient; use reth_trie_common as _;