Skip to main content

signet_bundle/call/
alloy.rs

1//! This module extends the Alloy provider with the Signet namespace's bundle-related RPC methods.
2use crate::{SignetCallBundle, SignetCallBundleResponse};
3use alloy::{network::Network, providers::Provider, transports::TransportResult};
4use core::future::Future;
5
6/// Signet namespace RPC interface.
7pub trait SignetBundleApi<N: Network = alloy::network::Ethereum>: Send + Sync {
8    /// Simulates a bundle of transactions against a specific block and returns
9    /// the execution results.
10    ///
11    /// This is similar to the Flashbots [`eth_callBundle`] endpoint, but includes
12    /// Signet-specific fields like aggregate orders and fills in the response.
13    ///
14    /// [`eth_callBundle`]: https://docs.flashbots.net/flashbots-auction/advanced/rpc-endpoint#eth_callbundle
15    fn call_bundle(
16        &self,
17        bundle: SignetCallBundle,
18    ) -> impl Future<Output = TransportResult<SignetCallBundleResponse>> + Send;
19}
20
21impl<N, P> SignetBundleApi<N> for P
22where
23    N: Network,
24    P: Provider<N>,
25{
26    async fn call_bundle(
27        &self,
28        bundle: SignetCallBundle,
29    ) -> TransportResult<SignetCallBundleResponse> {
30        self.client().request("signet_callBundle", (bundle,)).await
31    }
32}
33
34#[cfg(test)]
35mod tests {
36    use super::*;
37    use alloy::network::Ethereum;
38    use alloy::providers::RootProvider;
39
40    #[allow(dead_code)]
41    const fn assert_impl<T: SignetBundleApi>() {}
42    const _: () = assert_impl::<RootProvider<Ethereum>>();
43}