Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rpc/ots): set block_number as u64 instead of NumberOrTag #9302

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions crates/rpc/rpc-api/src/otterscan.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use jsonrpsee::{core::RpcResult, proc_macros::rpc};
use reth_primitives::{Address, BlockId, BlockNumberOrTag, Bytes, TxHash, B256};
use reth_primitives::{Address, BlockId, Bytes, TxHash, B256};
use reth_rpc_types::{
trace::otterscan::{
BlockDetails, ContractCreator, InternalOperation, OtsBlockTransactions, TraceEntry,
Expand Down Expand Up @@ -48,10 +48,7 @@ pub trait Otterscan {
/// Tailor-made and expanded version of eth_getBlockByNumber for block details page in
/// Otterscan.
#[method(name = "getBlockDetails")]
async fn get_block_details(
&self,
block_number: BlockNumberOrTag,
) -> RpcResult<Option<BlockDetails>>;
async fn get_block_details(&self, block_number: u64) -> RpcResult<Option<BlockDetails>>;

/// Tailor-made and expanded version of eth_getBlockByHash for block details page in Otterscan.
#[method(name = "getBlockDetailsByHash")]
Expand All @@ -61,7 +58,7 @@ pub trait Otterscan {
#[method(name = "getBlockTransactions")]
async fn get_block_transactions(
&self,
block_number: BlockNumberOrTag,
block_number: u64,
page_number: usize,
page_size: usize,
) -> RpcResult<OtsBlockTransactions>;
Expand All @@ -71,7 +68,7 @@ pub trait Otterscan {
async fn search_transactions_before(
&self,
address: Address,
block_number: BlockNumberOrTag,
block_number: u64,
page_size: usize,
) -> RpcResult<TransactionsWithReceipts>;

Expand All @@ -80,7 +77,7 @@ pub trait Otterscan {
async fn search_transactions_after(
&self,
address: Address,
block_number: BlockNumberOrTag,
block_number: u64,
page_size: usize,
) -> RpcResult<TransactionsWithReceipts>;

Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/rpc-builder/tests/it/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,13 +295,13 @@ where
let address = Address::default();
let sender = Address::default();
let tx_hash = TxHash::default();
let block_number = BlockNumberOrTag::default();
let block_number = 1;
let page_number = 1;
let page_size = 10;
let nonce = 1;
let block_hash = B256::default();

OtterscanClient::get_header_by_number(client, 1).await.unwrap();
OtterscanClient::get_header_by_number(client, block_number).await.unwrap();

OtterscanClient::has_code(client, address, None).await.unwrap();

Expand Down
14 changes: 6 additions & 8 deletions crates/rpc/rpc/src/otterscan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ where
}

/// Handler for `ots_getBlockDetails`
async fn get_block_details(
&self,
block_number: BlockNumberOrTag,
) -> RpcResult<Option<BlockDetails>> {
let block = self.eth.block_by_number(block_number, true).await?;
async fn get_block_details(&self, block_number: u64) -> RpcResult<Option<BlockDetails>> {
let block = self.eth.block_by_number(BlockNumberOrTag::Number(block_number), true).await?;
Ok(block.map(Into::into))
}

Expand All @@ -116,11 +113,12 @@ where
/// Handler for `getBlockTransactions`
async fn get_block_transactions(
&self,
block_number: BlockNumberOrTag,
block_number: u64,
page_number: usize,
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, receipts) = futures::try_join!(block, receipts)?;
Expand Down Expand Up @@ -184,7 +182,7 @@ where
async fn search_transactions_before(
&self,
_address: Address,
_block_number: BlockNumberOrTag,
_block_number: u64,
_page_size: usize,
) -> RpcResult<TransactionsWithReceipts> {
Err(internal_rpc_err("unimplemented"))
Expand All @@ -194,7 +192,7 @@ where
async fn search_transactions_after(
&self,
_address: Address,
_block_number: BlockNumberOrTag,
_block_number: u64,
_page_size: usize,
) -> RpcResult<TransactionsWithReceipts> {
Err(internal_rpc_err("unimplemented"))
Expand Down
Loading