1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
//! Trait for specifying `eth` network dependent API types.
use std::error::Error;
use alloy_network::{AnyNetwork, Network};
use reth_rpc_eth_types::EthApiError;
use reth_rpc_types::{Block, Transaction, WithOtherFields};
use crate::{AsEthApiError, FromEthApiError, FromEvmError};
/// Network specific `eth` API types.
pub trait EthApiTypes: Send + Sync + Clone {
/// Extension of [`EthApiError`], with network specific errors.
type Error: Into<jsonrpsee_types::error::ErrorObject<'static>>
+ FromEthApiError
+ AsEthApiError
+ FromEvmError
+ Error
+ Send
+ Sync;
/// Blockchain primitive types, specific to network, e.g. block and transaction.
// todo: remove restriction [`reth_rpc_types::Transaction`]
type NetworkTypes: Network<
TransactionResponse = WithOtherFields<Transaction>,
HeaderResponse = reth_rpc_types::Header,
>;
}
impl EthApiTypes for () {
type Error = EthApiError;
type NetworkTypes = AnyNetwork;
}
/// Adapter for network specific transaction type.
pub type RpcTransaction<T> = <T as Network>::TransactionResponse;
/// Adapter for network specific block type.
pub type RpcBlock<T> = Block<RpcTransaction<T>, <T as Network>::HeaderResponse>;
/// Adapter for network specific receipt type.
pub type RpcReceipt<T> = <T as Network>::ReceiptResponse;