Trait RpcConvert
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<<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,
cfg_env: &CfgEnv<Self::Spec>,
block_env: &BlockEnv,
) -> Result<Self::TxEnv, Self::Error>;
fn convert_receipts(
&self,
receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
) -> 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§
type Primitives: NodePrimitives
type Primitives: NodePrimitives
Associated lower layer consensus types to convert from and into types of Self::Network
.
type Network: RpcTypes + Send + Sync + Unpin + Clone + Debug
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
.
type TxEnv
type TxEnv
A set of variables for executing a transaction.
type Spec
type Spec
The EVM specification identifier.
Required Methods§
fn 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.
fn 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
.
fn tx_env(
&self,
request: <Self::Network as RpcTypes>::TransactionRequest,
cfg_env: &CfgEnv<Self::Spec>,
block_env: &BlockEnv,
) -> Result<Self::TxEnv, Self::Error>
fn tx_env( &self, request: <Self::Network as RpcTypes>::TransactionRequest, 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
.
fn 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.
fn 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§
fn 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
.
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.