RpcConvert

Trait RpcConvert 

Source
pub trait RpcConvert:
    Send
    + Sync
    + Unpin
    + Clone
    + Debug
    + 'static {
    type Primitives: NodePrimitives;
    type Network: RpcTypes + Send + Sync + Unpin + Clone + Debug;
    type TxEnv;
    type Error: Error + Into<ErrorObject<'static>>;
    type Spec;

    // Required methods
    fn fill(
        &self,
        tx: Recovered<TxTy<Self::Primitives>>,
        tx_info: TransactionInfo,
    ) -> Result<RpcTransaction<Self::Network>, Self::Error>;
    fn build_simulate_v1_transaction(
        &self,
        request: RpcTxReq<Self::Network>,
    ) -> Result<TxTy<Self::Primitives>, Self::Error>;
    fn tx_env(
        &self,
        request: RpcTxReq<Self::Network>,
        cfg_env: &CfgEnv<Self::Spec>,
        block_env: &BlockEnv,
    ) -> Result<Self::TxEnv, Self::Error>;
    fn convert_receipts(
        &self,
        receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
    ) -> Result<Vec<RpcReceipt<Self::Network>>, Self::Error>;
    fn convert_header(
        &self,
        header: SealedHeaderFor<Self::Primitives>,
        block_size: usize,
    ) -> Result<RpcHeader<Self::Network>, Self::Error>;

    // Provided method
    fn fill_pending(
        &self,
        tx: Recovered<TxTy<Self::Primitives>>,
    ) -> Result<RpcTransaction<Self::Network>, 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§

Source

type Primitives: NodePrimitives

Associated lower layer consensus types to convert from and into types of Self::Network.

Source

type Network: RpcTypes + Send + Sync + Unpin + Clone + Debug

Associated upper layer JSON-RPC API network requests and responses to convert from and into types of Self::Primitives.

Source

type TxEnv

A set of variables for executing a transaction.

Source

type Error: Error + Into<ErrorObject<'static>>

An associated RPC conversion error.

Source

type Spec

The EVM specification identifier.

Required Methods§

Source

fn fill( &self, tx: Recovered<TxTy<Self::Primitives>>, tx_info: TransactionInfo, ) -> Result<RpcTransaction<Self::Network>, 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.

Source

fn build_simulate_v1_transaction( &self, request: RpcTxReq<Self::Network>, ) -> Result<TxTy<Self::Primitives>, Self::Error>

Builds a fake transaction from a transaction request for inclusion into block built in eth_simulateV1.

Source

fn tx_env( &self, request: RpcTxReq<Self::Network>, cfg_env: &CfgEnv<Self::Spec>, block_env: &BlockEnv, ) -> Result<Self::TxEnv, Self::Error>

Creates a transaction environment for execution based on request with corresponding cfg_env and block_env.

Source

fn convert_receipts( &self, receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>, ) -> Result<Vec<RpcReceipt<Self::Network>>, Self::Error>

Converts a set of primitive receipts to RPC representations. It is guaranteed that all receipts are from the same block.

Source

fn convert_header( &self, header: SealedHeaderFor<Self::Primitives>, block_size: usize, ) -> Result<RpcHeader<Self::Network>, Self::Error>

Converts a primitive header to an RPC header.

Provided Methods§

Source

fn fill_pending( &self, tx: Recovered<TxTy<Self::Primitives>>, ) -> Result<RpcTransaction<Self::Network>, 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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<N, Network, Evm, Receipt, Header, Map, SimTx, RpcTx, TxEnv> RpcConvert for RpcConverter<Network, Evm, Receipt, Header, Map, SimTx, RpcTx, TxEnv>
where N: NodePrimitives, Network: RpcTypes + Send + Sync + Unpin + Clone + Debug, Evm: ConfigureEvm<Primitives = N> + 'static, Receipt: ReceiptConverter<N, RpcReceipt = RpcReceipt<Network>, Error: From<TransactionConversionError> + From<TxEnv::Error> + From<<Map as TxInfoMapper<TxTy<N>>>::Err> + From<RpcTx::Err> + Error + Unpin + Sync + Send + Into<ErrorObject<'static>>> + Send + Sync + Unpin + Clone + Debug, Header: HeaderConverter<HeaderTy<N>, RpcHeader<Network>>, Map: TxInfoMapper<TxTy<N>> + Clone + Debug + Unpin + Send + Sync + 'static, SimTx: SimTxConverter<RpcTxReq<Network>, TxTy<N>>, RpcTx: RpcTxConverter<TxTy<N>, Network::TransactionResponse, <Map as TxInfoMapper<TxTy<N>>>::Out>, TxEnv: TxEnvConverter<RpcTxReq<Network>, TxEnvFor<Evm>, SpecFor<Evm>>,

Source§

type Primitives = N

Source§

type Network = Network

Source§

type TxEnv = <<<Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Tx

Source§

type Error = <Receipt as ReceiptConverter<N>>::Error

Source§

type Spec = <<<Evm as ConfigureEvm>::BlockExecutorFactory as BlockExecutorFactory>::EvmFactory as EvmFactory>::Spec