Change return type of ReceiptBuilder (#11987)

This commit is contained in:
tedison
2024-10-25 01:02:43 -04:00
committed by GitHub
parent d9889787a7
commit 5a5ec73c37
3 changed files with 8 additions and 15 deletions

View File

@ -2,10 +2,8 @@
use alloy_consensus::Transaction;
use alloy_primitives::{Address, TxKind};
use alloy_rpc_types::{
AnyReceiptEnvelope, AnyTransactionReceipt, Log, ReceiptWithBloom, TransactionReceipt,
};
use alloy_serde::{OtherFields, WithOtherFields};
use alloy_rpc_types::{AnyReceiptEnvelope, Log, ReceiptWithBloom, TransactionReceipt};
use alloy_serde::OtherFields;
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
use revm_primitives::calc_blob_gasprice;
@ -111,15 +109,8 @@ impl ReceiptBuilder {
Ok(Self { base, other: Default::default() })
}
/// Adds fields to response body.
pub fn add_other_fields(mut self, mut fields: OtherFields) -> Self {
self.other.append(&mut fields);
self
}
/// Builds a receipt response from the base response body, and any set additional fields.
pub fn build(self) -> AnyTransactionReceipt {
let Self { base, other } = self;
WithOtherFields { inner: base, other }
pub fn build(self) -> TransactionReceipt<AnyReceiptEnvelope<Log>> {
self.base
}
}

View File

@ -1,6 +1,7 @@
//! Contains RPC handler implementations specific to blocks.
use alloy_rpc_types::{AnyTransactionReceipt, BlockId};
use alloy_serde::WithOtherFields;
use reth_primitives::TransactionMeta;
use reth_provider::{BlockReaderIdExt, HeaderProvider};
use reth_rpc_eth_api::{
@ -55,9 +56,9 @@ where
excess_blob_gas,
timestamp,
};
ReceiptBuilder::new(&tx, meta, receipt, &receipts)
.map(|builder| builder.build())
.map(WithOtherFields::new)
})
.collect::<Result<Vec<_>, Self::Error>>()
.map(Some)

View File

@ -1,5 +1,6 @@
//! Builds an RPC receipt response w.r.t. data layout of network.
use alloy_serde::WithOtherFields;
use reth_primitives::{Receipt, TransactionMeta, TransactionSigned};
use reth_rpc_eth_api::{helpers::LoadReceipt, FromEthApiError, RpcReceipt};
use reth_rpc_eth_types::{EthApiError, EthStateCache, ReceiptBuilder};
@ -30,6 +31,6 @@ where
.map_err(Self::Error::from_eth_err)?
.ok_or(EthApiError::HeaderNotFound(hash.into()))?;
Ok(ReceiptBuilder::new(&tx, meta, &receipt, &all_receipts)?.build())
Ok(WithOtherFields::new(ReceiptBuilder::new(&tx, meta, &receipt, &all_receipts)?.build()))
}
}