mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
refactor(rpc): accept Recovered<Tx> in build_transaction_receipt (#22795)
Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
use crate::{EthApiTypes, RpcNodeCoreExt, RpcReceipt};
|
||||
use alloy_consensus::{transaction::TransactionMeta, TxReceipt};
|
||||
use futures::Future;
|
||||
use reth_primitives_traits::SignerRecoverable;
|
||||
use reth_primitives_traits::Recovered;
|
||||
use reth_rpc_convert::{transaction::ConvertReceiptInput, RpcConvert};
|
||||
use reth_rpc_eth_types::{
|
||||
error::FromEthApiError, utils::calculate_gas_used_and_next_log_index, EthApiError,
|
||||
@@ -20,7 +20,7 @@ pub trait LoadReceipt:
|
||||
/// Helper method for `eth_getBlockReceipts` and `eth_getTransactionReceipt`.
|
||||
fn build_transaction_receipt(
|
||||
&self,
|
||||
tx: ProviderTx<Self::Provider>,
|
||||
tx: Recovered<ProviderTx<Self::Provider>>,
|
||||
meta: TransactionMeta,
|
||||
receipt: ProviderReceipt<Self::Provider>,
|
||||
) -> impl Future<Output = Result<RpcReceipt<Self::NetworkTypes>, Self::Error>> + Send {
|
||||
@@ -40,10 +40,7 @@ pub trait LoadReceipt:
|
||||
Ok(self
|
||||
.converter()
|
||||
.convert_receipts(vec![ConvertReceiptInput {
|
||||
tx: tx
|
||||
.try_into_recovered_unchecked()
|
||||
.map_err(Self::Error::from_eth_err)?
|
||||
.as_recovered_ref(),
|
||||
tx: tx.as_recovered_ref(),
|
||||
gas_used: receipt.cumulative_gas_used() - gas_used,
|
||||
receipt,
|
||||
next_log_index,
|
||||
|
||||
@@ -243,13 +243,19 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
|
||||
}
|
||||
|
||||
/// Helper method that loads a transaction and its receipt.
|
||||
///
|
||||
/// The returned transaction has its sender already recovered.
|
||||
#[expect(clippy::complexity)]
|
||||
fn load_transaction_and_receipt(
|
||||
&self,
|
||||
hash: TxHash,
|
||||
) -> impl Future<
|
||||
Output = Result<
|
||||
Option<(ProviderTx<Self::Provider>, TransactionMeta, ProviderReceipt<Self::Provider>)>,
|
||||
Option<(
|
||||
Recovered<ProviderTx<Self::Provider>>,
|
||||
TransactionMeta,
|
||||
ProviderReceipt<Self::Provider>,
|
||||
)>,
|
||||
Self::Error,
|
||||
>,
|
||||
> + Send
|
||||
@@ -258,7 +264,7 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
|
||||
{
|
||||
async move {
|
||||
if let Some(cached) = self.cache().get_transaction_by_hash(hash).await &&
|
||||
let Some(tx) = cached.block.body().transactions().get(cached.tx_index).cloned()
|
||||
let Some(tx) = cached.recovered_transaction().map(|tx| tx.cloned())
|
||||
{
|
||||
let meta = cached.transaction_meta(hash);
|
||||
|
||||
@@ -291,6 +297,8 @@ pub trait EthTransactions: LoadTransaction<Provider: BlockReaderIdExt> {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
let tx = tx.try_into_recovered_unchecked().map_err(Self::Error::from_eth_err)?;
|
||||
|
||||
let receipt = provider.receipt_by_hash(hash).map_err(Self::Error::from_eth_err)?;
|
||||
|
||||
Ok(receipt.map(|receipt| (tx, meta, receipt)))
|
||||
|
||||
Reference in New Issue
Block a user