reth_rpc_eth_api/
types.rs1use std::{
4 error::Error,
5 fmt::{self},
6};
7
8use alloy_network::Network;
9use alloy_rpc_types_eth::Block;
10use reth_provider::{ProviderTx, ReceiptProvider, TransactionsProvider};
11use reth_rpc_types_compat::TransactionCompat;
12use reth_transaction_pool::{PoolTransaction, TransactionPool};
13
14use crate::{AsEthApiError, FromEthApiError, FromEvmError, RpcNodeCore};
15
16pub trait EthApiTypes: Send + Sync + Clone {
18 type Error: Into<jsonrpsee_types::error::ErrorObject<'static>>
20 + FromEthApiError
21 + AsEthApiError
22 + FromEvmError
23 + Error
24 + Send
25 + Sync;
26 type NetworkTypes: Network;
28 type TransactionCompat: Send + Sync + Clone + fmt::Debug;
30
31 fn tx_resp_builder(&self) -> &Self::TransactionCompat;
33}
34
35pub type RpcTransaction<T> = <T as Network>::TransactionResponse;
37
38pub type RpcBlock<T> = Block<RpcTransaction<T>, <T as Network>::HeaderResponse>;
40
41pub type RpcReceipt<T> = <T as Network>::ReceiptResponse;
43
44pub type RpcHeader<T> = <T as Network>::HeaderResponse;
46
47pub type RpcError<T> = <T as EthApiTypes>::Error;
49
50pub trait FullEthApiTypes
52where
53 Self: RpcNodeCore<
54 Provider: TransactionsProvider + ReceiptProvider,
55 Pool: TransactionPool<
56 Transaction: PoolTransaction<Consensus = ProviderTx<Self::Provider>>,
57 >,
58 > + EthApiTypes<
59 TransactionCompat: TransactionCompat<
60 <Self::Provider as TransactionsProvider>::Transaction,
61 Transaction = RpcTransaction<Self::NetworkTypes>,
62 Error = RpcError<Self>,
63 >,
64 >,
65{
66}
67
68impl<T> FullEthApiTypes for T where
69 T: RpcNodeCore<
70 Provider: TransactionsProvider + ReceiptProvider,
71 Pool: TransactionPool<
72 Transaction: PoolTransaction<Consensus = ProviderTx<Self::Provider>>,
73 >,
74 > + EthApiTypes<
75 TransactionCompat: TransactionCompat<
76 <Self::Provider as TransactionsProvider>::Transaction,
77 Transaction = RpcTransaction<T::NetworkTypes>,
78 Error = RpcError<T>,
79 >,
80 >
81{
82}