mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat(rpc/ots): implement ots_traceTransaction RPC (#9246)
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
@ -43,7 +43,7 @@ pub trait Otterscan {
|
||||
/// Extract all variations of calls, contract creation and self-destructs and returns a call
|
||||
/// tree.
|
||||
#[method(name = "traceTransaction")]
|
||||
async fn trace_transaction(&self, tx_hash: TxHash) -> RpcResult<TraceEntry>;
|
||||
async fn trace_transaction(&self, tx_hash: TxHash) -> RpcResult<Option<Vec<TraceEntry>>>;
|
||||
|
||||
/// Tailor-made and expanded version of eth_getBlockByNumber for block details page in
|
||||
/// Otterscan.
|
||||
|
||||
@ -311,9 +311,7 @@ where
|
||||
|
||||
OtterscanClient::get_transaction_error(client, tx_hash).await.unwrap();
|
||||
|
||||
assert!(is_unimplemented(
|
||||
OtterscanClient::trace_transaction(client, tx_hash).await.err().unwrap()
|
||||
));
|
||||
OtterscanClient::trace_transaction(client, tx_hash).await.unwrap();
|
||||
|
||||
OtterscanClient::get_block_details(client, block_number).await.unwrap();
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ use reth_rpc_types::{
|
||||
BlockTransactions, Header, Transaction,
|
||||
};
|
||||
use revm_inspectors::{
|
||||
tracing::TracingInspectorConfig,
|
||||
tracing::{types::CallTraceNode, TracingInspectorConfig},
|
||||
transfer::{TransferInspector, TransferKind},
|
||||
};
|
||||
use revm_primitives::ExecutionResult;
|
||||
@ -101,8 +101,34 @@ where
|
||||
}
|
||||
|
||||
/// Handler for `ots_traceTransaction`
|
||||
async fn trace_transaction(&self, _tx_hash: TxHash) -> RpcResult<TraceEntry> {
|
||||
Err(internal_rpc_err("unimplemented"))
|
||||
async fn trace_transaction(&self, tx_hash: TxHash) -> RpcResult<Option<Vec<TraceEntry>>> {
|
||||
let traces = self
|
||||
.eth
|
||||
.spawn_trace_transaction_in_block(
|
||||
tx_hash,
|
||||
TracingInspectorConfig::default_parity(),
|
||||
move |_tx_info, inspector, _, _| Ok(inspector.into_traces().into_nodes()),
|
||||
)
|
||||
.await?
|
||||
.map(|traces| {
|
||||
traces
|
||||
.into_iter()
|
||||
.map(|CallTraceNode { trace, .. }| TraceEntry {
|
||||
r#type: if trace.is_selfdestruct() {
|
||||
"SELFDESTRUCT".to_string()
|
||||
} else {
|
||||
trace.kind.to_string()
|
||||
},
|
||||
depth: trace.depth as u32,
|
||||
from: trace.caller,
|
||||
to: trace.address,
|
||||
value: trace.value,
|
||||
input: trace.data,
|
||||
output: trace.output,
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
});
|
||||
Ok(traces)
|
||||
}
|
||||
|
||||
/// Handler for `ots_getBlockDetails`
|
||||
|
||||
Reference in New Issue
Block a user