From b8e117afb133b53e64d97f15ab5cf23d8f275ea8 Mon Sep 17 00:00:00 2001 From: Mathew Richmond Date: Thu, 10 Oct 2024 14:36:37 -0600 Subject: [PATCH] Fix failing test --- src/rpc_cache_handler/eth_get_logs.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/rpc_cache_handler/eth_get_logs.rs b/src/rpc_cache_handler/eth_get_logs.rs index 785ada8..7f80d56 100644 --- a/src/rpc_cache_handler/eth_get_logs.rs +++ b/src/rpc_cache_handler/eth_get_logs.rs @@ -1,7 +1,5 @@ -use alloy_primitives::B256; use anyhow::{bail, Context}; use serde_json::Value; -use std::str::FromStr; use crate::rpc_cache_handler::common::require_array_params; use crate::rpc_cache_handler::{common, RpcCacheHandler}; @@ -25,13 +23,14 @@ impl RpcCacheHandler for Handler { bail!("params[0] not a filter object"); } - let mut block_tag = None; - - if let Some(block_hash) = filter["blockHash"].as_str() { - if let Ok(block_hash) = B256::from_str(block_hash) { - block_tag = Some(format!("{:#x}", block_hash)); - } - } + let mut block_tag = if !filter["blockHash"].is_null() { + Some( + common::extract_and_format_block_hash(&filter["blockHash"]) + .context("expect a valid block hash")?, + ) + } else { + None + }; if block_tag.is_none() { let from_block = if !filter["fromBlock"].is_null() {