diff --git a/crates/rpc/rpc-api/src/otterscan.rs b/crates/rpc/rpc-api/src/otterscan.rs index a06fa1a4dd..c29d335a8f 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, Bytes, TxHash, B256}; +use reth_primitives::{Address, Bytes, TxHash, B256}; use reth_rpc_types::{ trace::otterscan::{ BlockDetails, ContractCreator, InternalOperation, OtsBlockTransactions, TraceEntry, @@ -24,7 +24,7 @@ pub trait Otterscan { /// Check if a certain address contains a deployed code. #[method(name = "hasCode")] - async fn has_code(&self, address: Address, block_number: Option) -> RpcResult; + async fn has_code(&self, address: Address, block_number: Option) -> RpcResult; /// Very simple API versioning scheme. Every time we add a new capability, the number is /// incremented. This allows for Otterscan to check if the node contains all API it diff --git a/crates/rpc/rpc-builder/tests/it/http.rs b/crates/rpc/rpc-builder/tests/it/http.rs index 14143d229c..3db8bd88a9 100644 --- a/crates/rpc/rpc-builder/tests/it/http.rs +++ b/crates/rpc/rpc-builder/tests/it/http.rs @@ -304,6 +304,7 @@ where OtterscanClient::get_header_by_number(client, block_number).await.unwrap(); OtterscanClient::has_code(client, address, None).await.unwrap(); + OtterscanClient::has_code(client, address, Some(block_number)).await.unwrap(); OtterscanClient::get_api_level(client).await.unwrap(); diff --git a/crates/rpc/rpc/src/otterscan.rs b/crates/rpc/rpc/src/otterscan.rs index b1255a11d7..34a92992a5 100644 --- a/crates/rpc/rpc/src/otterscan.rs +++ b/crates/rpc/rpc/src/otterscan.rs @@ -1,7 +1,7 @@ use alloy_primitives::Bytes; use async_trait::async_trait; use jsonrpsee::core::RpcResult; -use reth_primitives::{Address, BlockId, BlockNumberOrTag, TxHash, B256}; +use reth_primitives::{Address, BlockNumberOrTag, TxHash, B256}; use reth_rpc_api::{EthApiServer, OtterscanServer}; use reth_rpc_eth_api::helpers::TraceExt; use reth_rpc_eth_types::EthApiError; @@ -49,8 +49,8 @@ where } /// Handler for `ots_hasCode` - async fn has_code(&self, address: Address, block_number: Option) -> RpcResult { - self.eth.get_code(address, block_number).await.map(|code| !code.is_empty()) + async fn has_code(&self, address: Address, block_number: Option) -> RpcResult { + self.eth.get_code(address, block_number.map(Into::into)).await.map(|code| !code.is_empty()) } /// Handler for `ots_getApiLevel` @@ -152,9 +152,8 @@ where page_size: usize, ) -> RpcResult { // retrieve full block and its receipts - let block_number = BlockNumberOrTag::Number(block_number); - let block = self.eth.block_by_number(block_number, true); - let receipts = self.eth.block_receipts(BlockId::Number(block_number)); + let block = self.eth.block_by_number(block_number.into(), true); + let receipts = self.eth.block_receipts(block_number.into()); let (block, receipts) = futures::try_join!(block, receipts)?; let mut block = block.ok_or_else(|| internal_rpc_err("block not found"))?;