reth_rpc_eth_api/
filter.rs

1//! `eth_` RPC API for filtering.
2
3use alloy_json_rpc::RpcObject;
4use alloy_rpc_types_eth::{Filter, FilterChanges, FilterId, Log, PendingTransactionFilterKind};
5use jsonrpsee::{core::RpcResult, proc_macros::rpc};
6
7/// Rpc Interface for poll-based ethereum filter API.
8#[cfg_attr(not(feature = "client"), rpc(server, namespace = "eth"))]
9#[cfg_attr(feature = "client", rpc(server, client, namespace = "eth"))]
10pub trait EthFilterApi<T: RpcObject> {
11    /// Creates anew filter and returns its id.
12    #[method(name = "newFilter")]
13    async fn new_filter(&self, filter: Filter) -> RpcResult<FilterId>;
14
15    /// Creates a new block filter and returns its id.
16    #[method(name = "newBlockFilter")]
17    async fn new_block_filter(&self) -> RpcResult<FilterId>;
18
19    /// Creates a pending transaction filter and returns its id.
20    #[method(name = "newPendingTransactionFilter")]
21    async fn new_pending_transaction_filter(
22        &self,
23        kind: Option<PendingTransactionFilterKind>,
24    ) -> RpcResult<FilterId>;
25
26    /// Returns all filter changes since last poll.
27    #[method(name = "getFilterChanges")]
28    async fn filter_changes(&self, id: FilterId) -> RpcResult<FilterChanges<T>>;
29
30    /// Returns all logs matching given filter (in a range 'from' - 'to').
31    #[method(name = "getFilterLogs")]
32    async fn filter_logs(&self, id: FilterId) -> RpcResult<Vec<Log>>;
33
34    /// Uninstalls filter.
35    #[method(name = "uninstallFilter")]
36    async fn uninstall_filter(&self, id: FilterId) -> RpcResult<bool>;
37
38    /// Returns logs matching given filter object.
39    #[method(name = "getLogs")]
40    async fn logs(&self, filter: Filter) -> RpcResult<Vec<Log>>;
41}