From da717d73557c7448467a34ff169cdf2ceaac1810 Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 20 Nov 2023 09:40:39 +0000 Subject: [PATCH] Reduce minor compilation warnings (#964) Eliminates minor compilation warnings while using the generated smart contracts: > warning: accessing first element with `log . topics.get(0)` --> /Users/squadgazzz/RustroverProjects/services/target/debug/build/contracts-3ef65e6ec386b1a7/out/IUniswapV3Factory.rs:1:29696 | 1 | ...ntract :: errors :: ExecutionError > { let standard_event = log . topics . get (0) . copied () . map (| topic | match topic { self :: ethcontract :: H256 ([198 , 106 , 63 , 223... | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `log . topics.first()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#get_first --- ethcontract-common/Cargo.toml | 2 +- ethcontract-common/src/bytecode.rs | 5 +---- ethcontract-derive/Cargo.toml | 6 +++--- ethcontract-generate/Cargo.toml | 4 ++-- ethcontract-generate/src/generate/events.rs | 4 ++-- ethcontract-mock/Cargo.toml | 6 +++--- ethcontract/Cargo.toml | 6 +++--- ethcontract/src/errors/nethermind.rs | 1 + ethcontract/src/test/prelude.rs | 1 + ethcontract/src/transaction/build.rs | 2 +- 10 files changed, 18 insertions(+), 19 deletions(-) diff --git a/ethcontract-common/Cargo.toml b/ethcontract-common/Cargo.toml index 79c479f8..dff97bd7 100644 --- a/ethcontract-common/Cargo.toml +++ b/ethcontract-common/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethcontract-common" -version = "0.25.2" +version = "0.25.3" authors = ["Gnosis developers "] edition = "2021" license = "MIT OR Apache-2.0" diff --git a/ethcontract-common/src/bytecode.rs b/ethcontract-common/src/bytecode.rs index d6166799..16c73cd0 100644 --- a/ethcontract-common/src/bytecode.rs +++ b/ethcontract-common/src/bytecode.rs @@ -36,10 +36,7 @@ impl Bytecode { for block in CodeIter(s) { let block = block?; - if let Some(pos) = block - .bytes() - .position(|b| !matches!(b, b'0'..=b'9' | b'a'..=b'f' | b'A'..=b'F')) - { + if let Some(pos) = block.bytes().position(|b| !b.is_ascii_hexdigit()) { return Err(BytecodeError::InvalidHexDigit( block.chars().nth(pos).expect("valid pos"), )); diff --git a/ethcontract-derive/Cargo.toml b/ethcontract-derive/Cargo.toml index 7e327119..bab96b6e 100644 --- a/ethcontract-derive/Cargo.toml +++ b/ethcontract-derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethcontract-derive" -version = "0.25.2" +version = "0.25.3" authors = ["Gnosis developers "] edition = "2021" license = "MIT OR Apache-2.0" @@ -20,8 +20,8 @@ proc-macro = true [dependencies] anyhow = "1.0" -ethcontract-common = { version = "0.25.2", path = "../ethcontract-common" } -ethcontract-generate = { version = "0.25.2", path = "../ethcontract-generate", default-features = false } +ethcontract-common = { version = "0.25.3", path = "../ethcontract-common" } +ethcontract-generate = { version = "0.25.3", path = "../ethcontract-generate", default-features = false } proc-macro2 = "1.0" quote = "1.0" syn = "2.0" diff --git a/ethcontract-generate/Cargo.toml b/ethcontract-generate/Cargo.toml index 91a36200..0d8e63d7 100644 --- a/ethcontract-generate/Cargo.toml +++ b/ethcontract-generate/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethcontract-generate" -version = "0.25.2" +version = "0.25.3" authors = ["Gnosis developers "] edition = "2021" license = "MIT OR Apache-2.0" @@ -18,7 +18,7 @@ http = ["curl"] [dependencies] anyhow = "1.0" curl = { version = "0.4", optional = true } -ethcontract-common = { version = "0.25.2", path = "../ethcontract-common" } +ethcontract-common = { version = "0.25.3", path = "../ethcontract-common" } Inflector = "0.11" proc-macro2 = "1.0" quote = "1.0" diff --git a/ethcontract-generate/src/generate/events.rs b/ethcontract-generate/src/generate/events.rs index 820ba208..4c6e62af 100644 --- a/ethcontract-generate/src/generate/events.rs +++ b/ethcontract-generate/src/generate/events.rs @@ -500,7 +500,7 @@ fn expand_event_parse_log(cx: &Context) -> TokenStream { log: self::ethcontract::RawLog, ) -> Result { let standard_event = log.topics - .get(0) + .first() .copied() .map(|topic| match topic { #( #standard_event_match_arms )* @@ -793,7 +793,7 @@ mod tests { log: self::ethcontract::RawLog, ) -> Result { let standard_event = log.topics - .get(0) + .first() .copied() .map(|topic| match topic { #foo_signature => Ok(Event::Foo( diff --git a/ethcontract-mock/Cargo.toml b/ethcontract-mock/Cargo.toml index 2604faa7..60a1fa06 100644 --- a/ethcontract-mock/Cargo.toml +++ b/ethcontract-mock/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethcontract-mock" -version = "0.25.2" +version = "0.25.3" authors = ["Gnosis developers "] edition = "2021" license = "MIT OR Apache-2.0" @@ -12,7 +12,7 @@ Tools for mocking ethereum contracts. """ [dependencies] -ethcontract = { version = "0.25.2", path = "../ethcontract", default-features = false, features = ["derive"] } +ethcontract = { version = "0.25.3", path = "../ethcontract", default-features = false, features = ["derive"] } hex = "0.4" mockall = "0.11" rlp = "0.5" @@ -20,4 +20,4 @@ predicates = "3.0" [dev-dependencies] tokio = { version = "1.6", features = ["macros", "rt"] } -ethcontract-derive = { version = "0.25.2", path = "../ethcontract-derive", default-features = false } +ethcontract-derive = { version = "0.25.3", path = "../ethcontract-derive", default-features = false } diff --git a/ethcontract/Cargo.toml b/ethcontract/Cargo.toml index 56a73a1a..1b2bb3bc 100644 --- a/ethcontract/Cargo.toml +++ b/ethcontract/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ethcontract" -version = "0.25.2" +version = "0.25.3" authors = ["Gnosis developers "] edition = "2021" license = "MIT OR Apache-2.0" @@ -35,8 +35,8 @@ ws-tokio = ["web3/ws-tokio"] aws-config = { version = "0.55", optional = true } aws-sdk-kms = { version = "0.28", optional = true } arrayvec = "0.7" -ethcontract-common = { version = "0.25.2", path = "../ethcontract-common" } -ethcontract-derive = { version = "0.25.2", path = "../ethcontract-derive", optional = true, default-features = false } +ethcontract-common = { version = "0.25.3", path = "../ethcontract-common" } +ethcontract-derive = { version = "0.25.3", path = "../ethcontract-derive", optional = true, default-features = false } futures = "0.3" futures-timer = "3.0" hex = "0.4" diff --git a/ethcontract/src/errors/nethermind.rs b/ethcontract/src/errors/nethermind.rs index 03a00c11..852f867a 100644 --- a/ethcontract/src/errors/nethermind.rs +++ b/ethcontract/src/errors/nethermind.rs @@ -46,6 +46,7 @@ fn get_error_message(err: &JsonrpcError) -> &str { .unwrap_or(&err.message) } +#[allow(unused)] #[cfg(test)] pub use tests::*; diff --git a/ethcontract/src/test/prelude.rs b/ethcontract/src/test/prelude.rs index d4a17c0b..7d0d957e 100644 --- a/ethcontract/src/test/prelude.rs +++ b/ethcontract/src/test/prelude.rs @@ -4,6 +4,7 @@ pub use crate::test::transport::TestTransport; use futures::future::FutureExt; pub use serde_json::json; use std::future::Future; +#[allow(unused)] pub use web3::api::Web3; /// An extension future to wait for a future. diff --git a/ethcontract/src/transaction/build.rs b/ethcontract/src/transaction/build.rs index d8de0287..e54faf46 100644 --- a/ethcontract/src/transaction/build.rs +++ b/ethcontract/src/transaction/build.rs @@ -187,7 +187,7 @@ async fn build_transaction_request_for_local_signing( .eth() .accounts() .await? - .get(0) + .first() .ok_or(ExecutionError::NoLocalAccounts)?, }; let gas = resolve_gas_limit(&web3, from, &options.0).await?;