cfx_rpc_eth_api/
filter.rs

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