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§
Sourcetype Primitives: NodePrimitives
type Primitives: NodePrimitives
Associated lower layer consensus types to convert from and into types of Self::Network
.
Required Methods§
Sourcefn fill(
&self,
tx: Recovered<TxTy<Self::Primitives>>,
tx_info: TransactionInfo,
) -> Result<RpcTransaction<Self::Network>, Self::Error>
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.
Sourcefn build_simulate_v1_transaction(
&self,
request: RpcTxReq<Self::Network>,
) -> Result<TxTy<Self::Primitives>, Self::Error>
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
.
Sourcefn tx_env(
&self,
request: RpcTxReq<Self::Network>,
cfg_env: &CfgEnv<Self::Spec>,
block_env: &BlockEnv,
) -> Result<Self::TxEnv, Self::Error>
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
.
Sourcefn convert_receipts(
&self,
receipts: Vec<ConvertReceiptInput<'_, Self::Primitives>>,
) -> Result<Vec<RpcReceipt<Self::Network>>, Self::Error>
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.
Sourcefn convert_header(
&self,
header: SealedHeaderFor<Self::Primitives>,
block_size: usize,
) -> Result<RpcHeader<Self::Network>, Self::Error>
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§
Sourcefn fill_pending(
&self,
tx: Recovered<TxTy<Self::Primitives>>,
) -> Result<RpcTransaction<Self::Network>, Self::Error>
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.