pub trait RpcConvert:
Send
+ Sync
+ Unpin
+ Debug
+ DynClone
+ 'static {
type Primitives: NodePrimitives;
type Evm: ConfigureEvm<Primitives = Self::Primitives>;
type Network: RpcTypes
where <Self::Network as RpcTypes>::TransactionRequest: SignableTxRequest<<Self::Primitives as NodePrimitives>::SignedTx>;
type Error: Error + Into<ErrorObject<'static>>;
// Required methods
fn fill(
&self,
tx: Recovered<<Self::Primitives as NodePrimitives>::SignedTx>,
tx_info: TransactionInfo,
) -> Result<<Self::Network as RpcTypes>::TransactionResponse, Self::Error>;
fn build_simulate_v1_transaction(
&self,
request: <Self::Network as RpcTypes>::TransactionRequest,
) -> Result<<Self::Primitives as NodePrimitives>::SignedTx, Self::Error>;
fn tx_env(
&self,
request: <Self::Network as RpcTypes>::TransactionRequest,
evm_env: &EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>,
) -> Result<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx, Self::Error>;
fn convert_receipts(
&self,
receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
) -> Result<Vec<<Self::Network as RpcTypes>::Receipt>, Self::Error>;
fn convert_receipts_with_block(
&self,
receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
block: &SealedBlock<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<Vec<<Self::Network as RpcTypes>::Receipt>, Self::Error>;
fn convert_header(
&self,
header: SealedHeader<<Self::Primitives as NodePrimitives>::BlockHeader>,
block_size: usize,
) -> Result<<Self::Network as RpcTypes>::Header, Self::Error>;
// Provided method
fn fill_pending(
&self,
tx: Recovered<<Self::Primitives as NodePrimitives>::SignedTx>,
) -> Result<<Self::Network as RpcTypes>::TransactionResponse, Self::Error> { ... }
}Expand description
Responsible for the conversions from and into RPC requests and responses.
The JSON-RPC schema and the Node primitives are configurable using the RpcConvert::Network
and RpcConvert::Primitives associated types respectively.
A generic implementation RpcConverter should be preferred over a manual implementation. As
long as its trait bound requirements are met, the implementation is created automatically and
can be used in RPC method handlers for all the conversions.
Required Associated Types§
Sourcetype Primitives: NodePrimitives
type Primitives: NodePrimitives
Associated lower layer consensus types to convert from and into types of Self::Network.
Sourcetype Evm: ConfigureEvm<Primitives = Self::Primitives>
type Evm: ConfigureEvm<Primitives = Self::Primitives>
The EVM configuration.
Sourcetype Network: RpcTypes
where
<Self::Network as RpcTypes>::TransactionRequest: SignableTxRequest<<Self::Primitives as NodePrimitives>::SignedTx>
type Network: RpcTypes where <Self::Network as RpcTypes>::TransactionRequest: SignableTxRequest<<Self::Primitives as NodePrimitives>::SignedTx>
Associated upper layer JSON-RPC API network requests and responses to convert from and into
types of Self::Primitives.
Required Methods§
Sourcefn fill(
&self,
tx: Recovered<<Self::Primitives as NodePrimitives>::SignedTx>,
tx_info: TransactionInfo,
) -> Result<<Self::Network as RpcTypes>::TransactionResponse, Self::Error>
fn fill( &self, tx: Recovered<<Self::Primitives as NodePrimitives>::SignedTx>, tx_info: TransactionInfo, ) -> Result<<Self::Network as RpcTypes>::TransactionResponse, Self::Error>
Create a new rpc transaction result for a mined transaction, using the given block hash, number, and tx index fields to populate the corresponding fields in the rpc result.
The block hash, number, and tx index fields should be from the original block where the transaction was mined.
Sourcefn build_simulate_v1_transaction(
&self,
request: <Self::Network as RpcTypes>::TransactionRequest,
) -> Result<<Self::Primitives as NodePrimitives>::SignedTx, Self::Error>
fn build_simulate_v1_transaction( &self, request: <Self::Network as RpcTypes>::TransactionRequest, ) -> Result<<Self::Primitives as NodePrimitives>::SignedTx, Self::Error>
Builds a fake transaction from a transaction request for inclusion into block built in
eth_simulateV1.
Sourcefn tx_env(
&self,
request: <Self::Network as RpcTypes>::TransactionRequest,
evm_env: &EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>,
) -> Result<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx, Self::Error>
fn tx_env( &self, request: <Self::Network as RpcTypes>::TransactionRequest, evm_env: &EvmEnv<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec, <<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::BlockEnv>, ) -> Result<<<<Self::Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx, Self::Error>
Creates a transaction environment for execution based on request with corresponding
cfg_env and block_env.
Sourcefn convert_receipts(
&self,
receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
) -> Result<Vec<<Self::Network as RpcTypes>::Receipt>, Self::Error>
fn convert_receipts( &self, receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>, ) -> Result<Vec<<Self::Network as RpcTypes>::Receipt>, Self::Error>
Converts a set of primitive receipts to RPC representations. It is guaranteed that all receipts are from the same block.
Sourcefn convert_receipts_with_block(
&self,
receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
block: &SealedBlock<<Self::Primitives as NodePrimitives>::Block>,
) -> Result<Vec<<Self::Network as RpcTypes>::Receipt>, Self::Error>
fn convert_receipts_with_block( &self, receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>, block: &SealedBlock<<Self::Primitives as NodePrimitives>::Block>, ) -> Result<Vec<<Self::Network as RpcTypes>::Receipt>, Self::Error>
Converts a set of primitive receipts to RPC representations. It is guaranteed that all receipts are from the same block.
Also accepts the corresponding block in case the receipt requires additional metadata.
Sourcefn convert_header(
&self,
header: SealedHeader<<Self::Primitives as NodePrimitives>::BlockHeader>,
block_size: usize,
) -> Result<<Self::Network as RpcTypes>::Header, Self::Error>
fn convert_header( &self, header: SealedHeader<<Self::Primitives as NodePrimitives>::BlockHeader>, block_size: usize, ) -> Result<<Self::Network as RpcTypes>::Header, Self::Error>
Converts a primitive header to an RPC header.
Provided Methods§
Sourcefn fill_pending(
&self,
tx: Recovered<<Self::Primitives as NodePrimitives>::SignedTx>,
) -> Result<<Self::Network as RpcTypes>::TransactionResponse, Self::Error>
fn fill_pending( &self, tx: Recovered<<Self::Primitives as NodePrimitives>::SignedTx>, ) -> Result<<Self::Network as RpcTypes>::TransactionResponse, Self::Error>
Wrapper for fill() with default TransactionInfo
Create a new rpc transaction result for a pending signed transaction, setting block
environment related fields to None.
Trait Implementations§
Source§impl<'clone, Primitives, Network, Error, Evm> Clone for Box<dyn RpcConvert<Error = Error, Evm = Evm, Primitives = Primitives, Network = Network> + 'clone>
impl<'clone, Primitives, Network, Error, Evm> Clone for Box<dyn RpcConvert<Error = Error, Evm = Evm, Primitives = Primitives, Network = Network> + 'clone>
Source§fn clone(
&self,
) -> Box<dyn RpcConvert<Error = Error, Evm = Evm, Primitives = Primitives, Network = Network> + 'clone>
fn clone( &self, ) -> Box<dyn RpcConvert<Error = Error, Evm = Evm, Primitives = Primitives, Network = Network> + 'clone>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more