use alloy_eips::BlockId;
use alloy_primitives::{map::HashSet, Bytes, B256};
use alloy_rpc_types_eth::{
state::StateOverride, transaction::TransactionRequest, BlockOverrides, Index,
};
use alloy_rpc_types_trace::{
filter::TraceFilter,
opcode::{BlockOpcodeGas, TransactionOpcodeGas},
parity::*,
};
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
#[cfg_attr(not(feature = "client"), rpc(server, namespace = "trace"))]
#[cfg_attr(feature = "client", rpc(server, client, namespace = "trace"))]
pub trait TraceApi {
#[method(name = "call")]
async fn trace_call(
&self,
call: TransactionRequest,
trace_types: HashSet<TraceType>,
block_id: Option<BlockId>,
state_overrides: Option<StateOverride>,
block_overrides: Option<Box<BlockOverrides>>,
) -> RpcResult<TraceResults>;
#[method(name = "callMany")]
async fn trace_call_many(
&self,
calls: Vec<(TransactionRequest, HashSet<TraceType>)>,
block_id: Option<BlockId>,
) -> RpcResult<Vec<TraceResults>>;
#[method(name = "rawTransaction")]
async fn trace_raw_transaction(
&self,
data: Bytes,
trace_types: HashSet<TraceType>,
block_id: Option<BlockId>,
) -> RpcResult<TraceResults>;
#[method(name = "replayBlockTransactions")]
async fn replay_block_transactions(
&self,
block_id: BlockId,
trace_types: HashSet<TraceType>,
) -> RpcResult<Option<Vec<TraceResultsWithTransactionHash>>>;
#[method(name = "replayTransaction")]
async fn replay_transaction(
&self,
transaction: B256,
trace_types: HashSet<TraceType>,
) -> RpcResult<TraceResults>;
#[method(name = "block")]
async fn trace_block(
&self,
block_id: BlockId,
) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
#[method(name = "filter")]
async fn trace_filter(&self, filter: TraceFilter) -> RpcResult<Vec<LocalizedTransactionTrace>>;
#[method(name = "get")]
async fn trace_get(
&self,
hash: B256,
indices: Vec<Index>,
) -> RpcResult<Option<LocalizedTransactionTrace>>;
#[method(name = "transaction")]
async fn trace_transaction(
&self,
hash: B256,
) -> RpcResult<Option<Vec<LocalizedTransactionTrace>>>;
#[method(name = "transactionOpcodeGas")]
async fn trace_transaction_opcode_gas(
&self,
tx_hash: B256,
) -> RpcResult<Option<TransactionOpcodeGas>>;
#[method(name = "blockOpcodeGas")]
async fn trace_block_opcode_gas(&self, block_id: BlockId) -> RpcResult<Option<BlockOpcodeGas>>;
}