mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
chore: relax bounds on RPC types (#14529)
This commit is contained in:
@@ -2,10 +2,9 @@
|
||||
//! RPC methods.
|
||||
|
||||
use super::SpawnBlocking;
|
||||
use crate::{EthApiTypes, FromEthApiError, FromEvmError, RpcNodeCore};
|
||||
use crate::{types::RpcTypes, EthApiTypes, FromEthApiError, FromEvmError, RpcNodeCore};
|
||||
use alloy_consensus::{BlockHeader, Transaction};
|
||||
use alloy_eips::eip4844::MAX_DATA_GAS_PER_BLOCK;
|
||||
use alloy_network::Network;
|
||||
use alloy_primitives::B256;
|
||||
use alloy_rpc_types_eth::BlockNumberOrTag;
|
||||
use futures::Future;
|
||||
@@ -41,8 +40,8 @@ use tracing::debug;
|
||||
/// Behaviour shared by several `eth_` RPC methods, not exclusive to `eth_` blocks RPC methods.
|
||||
pub trait LoadPendingBlock:
|
||||
EthApiTypes<
|
||||
NetworkTypes: Network<
|
||||
HeaderResponse = alloy_rpc_types_eth::Header<ProviderHeader<Self::Provider>>,
|
||||
NetworkTypes: RpcTypes<
|
||||
Header = alloy_rpc_types_eth::Header<ProviderHeader<Self::Provider>>,
|
||||
>,
|
||||
Error: FromEvmError<Self::Evm>,
|
||||
> + RpcNodeCore<
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
//! Trait for specifying `eth` network dependent API types.
|
||||
|
||||
use crate::{AsEthApiError, FromEthApiError, RpcNodeCore};
|
||||
use alloy_network::Network;
|
||||
use alloy_json_rpc::RpcObject;
|
||||
use alloy_network::{Network, ReceiptResponse, TransactionResponse};
|
||||
use alloy_rpc_types_eth::Block;
|
||||
use reth_provider::{ProviderTx, ReceiptProvider, TransactionsProvider};
|
||||
use reth_rpc_types_compat::TransactionCompat;
|
||||
@@ -11,6 +12,27 @@ use std::{
|
||||
fmt::{self},
|
||||
};
|
||||
|
||||
/// RPC types used by the `eth_` RPC API.
|
||||
///
|
||||
/// This is a subset of [`alloy_network::Network`] trait with only RPC response types kept.
|
||||
pub trait RpcTypes {
|
||||
/// Header response type.
|
||||
type Header: RpcObject;
|
||||
/// Receipt response type.
|
||||
type Receipt: RpcObject + ReceiptResponse;
|
||||
/// Transaction response type.
|
||||
type Transaction: RpcObject + TransactionResponse;
|
||||
}
|
||||
|
||||
impl<T> RpcTypes for T
|
||||
where
|
||||
T: Network,
|
||||
{
|
||||
type Header = T::HeaderResponse;
|
||||
type Receipt = T::ReceiptResponse;
|
||||
type Transaction = T::TransactionResponse;
|
||||
}
|
||||
|
||||
/// Network specific `eth` API types.
|
||||
///
|
||||
/// This trait defines the network specific rpc types and helpers required for the `eth_` and
|
||||
@@ -28,7 +50,7 @@ pub trait EthApiTypes: Send + Sync + Clone {
|
||||
+ Send
|
||||
+ Sync;
|
||||
/// Blockchain primitive types, specific to network, e.g. block and transaction.
|
||||
type NetworkTypes: Network;
|
||||
type NetworkTypes: RpcTypes;
|
||||
/// Conversion methods for transaction RPC type.
|
||||
type TransactionCompat: Send + Sync + Clone + fmt::Debug;
|
||||
|
||||
@@ -37,16 +59,16 @@ pub trait EthApiTypes: Send + Sync + Clone {
|
||||
}
|
||||
|
||||
/// Adapter for network specific transaction type.
|
||||
pub type RpcTransaction<T> = <T as Network>::TransactionResponse;
|
||||
pub type RpcTransaction<T> = <T as RpcTypes>::Transaction;
|
||||
|
||||
/// Adapter for network specific block type.
|
||||
pub type RpcBlock<T> = Block<RpcTransaction<T>, <T as Network>::HeaderResponse>;
|
||||
pub type RpcBlock<T> = Block<RpcTransaction<T>, RpcHeader<T>>;
|
||||
|
||||
/// Adapter for network specific receipt type.
|
||||
pub type RpcReceipt<T> = <T as Network>::ReceiptResponse;
|
||||
pub type RpcReceipt<T> = <T as RpcTypes>::Receipt;
|
||||
|
||||
/// Adapter for network specific header type.
|
||||
pub type RpcHeader<T> = <T as Network>::HeaderResponse;
|
||||
pub type RpcHeader<T> = <T as RpcTypes>::Header;
|
||||
|
||||
/// Adapter for network specific error type.
|
||||
pub type RpcError<T> = <T as EthApiTypes>::Error;
|
||||
|
||||
Reference in New Issue
Block a user