diff --git a/crates/rpc/rpc-eth-api/src/helpers/receipt.rs b/crates/rpc/rpc-eth-api/src/helpers/receipt.rs index c5b5492952..fbd81e6fd7 100644 --- a/crates/rpc/rpc-eth-api/src/helpers/receipt.rs +++ b/crates/rpc/rpc-eth-api/src/helpers/receipt.rs @@ -3,10 +3,10 @@ use futures::Future; use reth_primitives::{Receipt, TransactionMeta, TransactionSigned}; -use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder}; +use reth_rpc_eth_types::EthStateCache; use reth_rpc_types::AnyTransactionReceipt; -use crate::{EthApiTypes, FromEthApiError}; +use crate::EthApiTypes; /// Assembles transaction receipt data w.r.t to network. /// @@ -23,18 +23,5 @@ pub trait LoadReceipt: EthApiTypes + Send + Sync { tx: TransactionSigned, meta: TransactionMeta, receipt: Receipt, - ) -> impl Future> + Send { - async move { - let hash = meta.block_hash; - // get all receipts for the block - let all_receipts = self - .cache() - .get_receipts(hash) - .await - .map_err(Self::Error::from_eth_err)? - .ok_or(EthApiError::HeaderNotFound(hash.into()))?; - - Ok(ReceiptBuilder::new(&tx, meta, &receipt, &all_receipts)?.build()) - } - } + ) -> impl Future> + Send; } diff --git a/crates/rpc/rpc/src/eth/helpers/receipt.rs b/crates/rpc/rpc/src/eth/helpers/receipt.rs index db1fee781f..77a4058240 100644 --- a/crates/rpc/rpc/src/eth/helpers/receipt.rs +++ b/crates/rpc/rpc/src/eth/helpers/receipt.rs @@ -1,7 +1,9 @@ //! Builds an RPC receipt response w.r.t. data layout of network. -use reth_rpc_eth_api::helpers::LoadReceipt; -use reth_rpc_eth_types::EthStateCache; +use reth_primitives::{Receipt, TransactionMeta, TransactionSigned}; +use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError}; +use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder}; +use reth_rpc_types::AnyTransactionReceipt; use crate::EthApi; @@ -13,4 +15,22 @@ where fn cache(&self) -> &EthStateCache { self.inner.cache() } + + async fn build_transaction_receipt( + &self, + tx: TransactionSigned, + meta: TransactionMeta, + receipt: Receipt, + ) -> Result { + let hash = meta.block_hash; + // get all receipts for the block + let all_receipts = self + .cache() + .get_receipts(hash) + .await + .map_err(Self::Error::from_eth_err)? + .ok_or(EthApiError::HeaderNotFound(hash.into()))?; + + Ok(ReceiptBuilder::new(&tx, meta, &receipt, &all_receipts)?.build()) + } }