diff --git a/crates/rpc/rpc-api/src/otterscan.rs b/crates/rpc/rpc-api/src/otterscan.rs index 110d922f318..2593a114207 100644 --- a/crates/rpc/rpc-api/src/otterscan.rs +++ b/crates/rpc/rpc-api/src/otterscan.rs @@ -1,5 +1,5 @@ use jsonrpsee::{core::RpcResult, proc_macros::rpc}; -use reth_primitives::{Address, BlockId, BlockNumberOrTag, TxHash, B256}; +use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, TxHash, B256}; use reth_rpc_types::{ BlockDetails, ContractCreator, InternalOperation, OtsBlockTransactions, TraceEntry, Transaction, TransactionsWithReceipts, @@ -25,7 +25,7 @@ pub trait Otterscan { /// Given a transaction hash, returns its raw revert reason. #[method(name = "getTransactionError")] - async fn get_transaction_error(&self, tx_hash: TxHash) -> RpcResult; + async fn get_transaction_error(&self, tx_hash: TxHash) -> RpcResult>; /// Extract all variations of calls, contract creation and self-destructs and returns a call /// tree. diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index c96ce6b8451..fa1e48a380c 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -301,7 +301,7 @@ where OtterscanClient::get_internal_operations(client, tx_hash).await.err().unwrap() )); - OtterscanClient::get_transaction_error(client, tx_hash).await.err().unwrap(); + OtterscanClient::get_transaction_error(client, tx_hash).await.unwrap(); assert!(is_unimplemented( OtterscanClient::trace_transaction(client, tx_hash).await.err().unwrap() diff --git a/crates/rpc/rpc/src/otterscan.rs b/crates/rpc/rpc/src/otterscan.rs index a4ec31bb526..f8672f0f431 100644 --- a/crates/rpc/rpc/src/otterscan.rs +++ b/crates/rpc/rpc/src/otterscan.rs @@ -1,4 +1,5 @@ use crate::{eth::EthTransactions, result::internal_rpc_err}; +use alloy_primitives::Bytes; use async_trait::async_trait; use jsonrpsee::core::RpcResult; use reth_primitives::{Address, BlockId, BlockNumberOrTag, TxHash, B256}; @@ -46,23 +47,18 @@ where } /// Handler for `ots_getTransactionError` - async fn get_transaction_error(&self, _tx_hash: TxHash) -> RpcResult { + async fn get_transaction_error(&self, tx_hash: TxHash) -> RpcResult> { self.eth .spawn_trace_transaction_in_block_with_inspector( - _tx_hash, + tx_hash, NoOpInspector, |_tx_info, _inspector, res, _| match res.result { - // hexadecimal-formatted error blob - ExecutionResult::Revert { output, .. } => Ok(format!("b{output}")), - - // Returns "0x" - // 1. if the transaction was successfully executed. - // 2. if it failed with no revert reason or out of gas - _ => Ok("0x".to_string()), + ExecutionResult::Revert { output, .. } => Ok(output), + _ => Ok(Bytes::new()), }, ) - .await? - .ok_or_else(|| internal_rpc_err("transaction not found")) + .await + .map_err(|e| internal_rpc_err(e.to_string())) } /// Handler for `ots_traceTransaction`