mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-27 16:18:08 -05:00
feat(rpc/otterscan): change BlockId to u64 in has_code (#9469)
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
@@ -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<BlockId>) -> RpcResult<bool>;
|
||||
async fn has_code(&self, address: Address, block_number: Option<u64>) -> RpcResult<bool>;
|
||||
|
||||
/// 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
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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<BlockId>) -> RpcResult<bool> {
|
||||
self.eth.get_code(address, block_number).await.map(|code| !code.is_empty())
|
||||
async fn has_code(&self, address: Address, block_number: Option<u64>) -> RpcResult<bool> {
|
||||
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<OtsBlockTransactions> {
|
||||
// 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"))?;
|
||||
|
||||
Reference in New Issue
Block a user