use result for TransactionCompact::fill. (#12170)

Co-authored-by: Emilia Hane <elsaemiliaevahane@gmail.com>
Co-authored-by: dkathiriya <lakshya-sky@users.noreply.github.com>
This commit is contained in:
Darshan Kathiriya
2024-11-12 05:31:32 -05:00
committed by GitHub
parent c261532a27
commit bad7a4f0c9
20 changed files with 124 additions and 62 deletions

View File

@ -1,6 +1,6 @@
//! RPC errors specific to OP.
use alloy_rpc_types_eth::error::EthRpcErrorCode;
use alloy_rpc_types_eth::{error::EthRpcErrorCode, BlockError};
use jsonrpsee_types::error::INTERNAL_ERROR_CODE;
use reth_optimism_evm::OpBlockExecutionError;
use reth_primitives::revm_primitives::{InvalidTransaction, OptimismInvalidTransaction};
@ -113,3 +113,9 @@ impl From<SequencerClientError> for jsonrpsee_types::error::ErrorObject<'static>
)
}
}
impl From<BlockError> for OpEthApiError {
fn from(error: BlockError) -> Self {
Self::Eth(error.into())
}
}

View File

@ -15,7 +15,7 @@ use reth_rpc_eth_api::{
use reth_rpc_eth_types::utils::recover_raw_transaction;
use reth_transaction_pool::{PoolTransaction, TransactionOrigin, TransactionPool};
use crate::{OpEthApi, SequencerClient};
use crate::{OpEthApi, OpEthApiError, SequencerClient};
impl<N> EthTransactions for OpEthApi<N>
where
@ -76,12 +76,13 @@ where
N: FullNodeComponents,
{
type Transaction = Transaction;
type Error = OpEthApiError;
fn fill(
&self,
tx: TransactionSignedEcRecovered,
tx_info: TransactionInfo,
) -> Self::Transaction {
) -> Result<Self::Transaction, Self::Error> {
let from = tx.signer();
let TransactionSigned { transaction, signature, hash } = tx.into_signed();
@ -106,8 +107,7 @@ where
.inner
.provider()
.receipt_by_hash(hash)
.ok() // todo: change sig to return result
.flatten()
.map_err(Self::Error::from_eth_err)?
.and_then(|receipt| receipt.deposit_receipt_version);
let TransactionInfo {
@ -120,7 +120,7 @@ where
})
.unwrap_or_else(|| inner.max_fee_per_gas());
Transaction {
Ok(Transaction {
inner: alloy_rpc_types_eth::Transaction {
inner,
block_hash,
@ -130,7 +130,7 @@ where
effective_gas_price: Some(effective_gas_price),
},
deposit_receipt_version,
}
})
}
fn otterscan_api_truncate_input(tx: &mut Self::Transaction) {