From 8e9e76830e51973d0291441405235c823f2812d9 Mon Sep 17 00:00:00 2001 From: Enrique Ortiz Date: Tue, 15 Aug 2023 15:02:11 -0400 Subject: [PATCH] chore: clippy --- .../src/executor/inspector/cheatcodes/fork.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/crates/evm/src/executor/inspector/cheatcodes/fork.rs b/crates/evm/src/executor/inspector/cheatcodes/fork.rs index cf6f0e37788aa..234daeb053322 100644 --- a/crates/evm/src/executor/inspector/cheatcodes/fork.rs +++ b/crates/evm/src/executor/inspector/cheatcodes/fork.rs @@ -258,7 +258,7 @@ fn create_fork_request( /// Retrieve the logs specified for the current fork. /// Equivalent to eth_getLogs but on a cheatcode. -fn eth_getlogs(data: &mut EVMData, inner: &EthGetLogsCall) -> Result { +fn eth_getlogs(data: &EVMData, inner: &EthGetLogsCall) -> Result { let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; if inner.0 > U256::from(u64::MAX) || inner.1 > U256::from(u64::MAX) { return Err(fmt_err!("Blocks in block range must be less than 2^64 - 1")) @@ -287,7 +287,7 @@ fn eth_getlogs(data: &mut EVMData, inner: &EthGetLogsCall) .block_on(provider.get_logs(&filter)) .map_err(|_| fmt_err!("Error in calling eth_getLogs"))?; - if logs.len() == 0 { + if logs.is_empty() { let empty: Bytes = abi::encode(&[Token::Array(vec![])]).into(); return Ok(empty) } @@ -335,7 +335,7 @@ fn eth_getlogs(data: &mut EVMData, inner: &EthGetLogsCall) Ok(result) } -fn rpc(data: &mut EVMData, inner: &RpcCall) -> Result { +fn rpc(data: &EVMData, inner: &RpcCall) -> Result { let url = data.db.active_fork_url().ok_or(fmt_err!("No active fork url found"))?; let provider = ProviderBuilder::new(url).build()?; @@ -350,15 +350,12 @@ fn rpc(data: &mut EVMData, inner: &RpcCall) -> Result { let result_as_tokens = value_to_token(&result).map_err(|err| fmt_err!("Failed to parse result: {err}"))?; - let abi_encoded: Vec; - match result_as_tokens { - Token::Tuple(vec) | Token::Array(vec) | Token::FixedArray(vec) => { - abi_encoded = abi::encode(&vec); - } + let abi_encoded: Vec = match result_as_tokens { + Token::Tuple(vec) | Token::Array(vec) | Token::FixedArray(vec) => abi::encode(&vec), _ => { let vec = vec![result_as_tokens]; - abi_encoded = abi::encode(&vec); + abi::encode(&vec) } - } + }; Ok(abi_encoded.into()) }