From fa8796c1cdcf644e10c1222f11eaa5625f4a70eb Mon Sep 17 00:00:00 2001 From: ilya Date: Mon, 27 Nov 2023 11:29:09 +0000 Subject: [PATCH] Eliminate clippy warnings (#2082) # Description No more `clippy` warnings for now # Changes Also uses the latest `ethcontract` --- Cargo.lock | 16 +++---- Cargo.toml | 2 +- .../onchain_order_events/ethflow_events.rs | 48 +++++++++---------- crates/database/src/orders.rs | 8 ++-- crates/solver/src/settlement_simulation.rs | 2 +- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cc06594b97..72c506e721 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1810,9 +1810,9 @@ dependencies = [ [[package]] name = "ethcontract" -version = "0.25.2" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d08846ff0ee806115900c1936bc8499a9276b4ae27fe75492417765bd539322" +checksum = "c28ee036fde35000df46c82ec67f2e9f5a6ebc53093e0af2a9b045cce9818acf" dependencies = [ "arrayvec", "aws-config 0.55.3", @@ -1837,9 +1837,9 @@ dependencies = [ [[package]] name = "ethcontract-common" -version = "0.25.2" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "742bc83515d431a92e6c5978d95e02076e494cfe05949717bc7f8340812823f4" +checksum = "422d0b0977f0855eaeab796ff5502302f5ac33ae96209c0ea81b0aa164dd370e" dependencies = [ "ethabi", "hex", @@ -1853,9 +1853,9 @@ dependencies = [ [[package]] name = "ethcontract-derive" -version = "0.25.2" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb46cfc07d197ef11a37254eadac65f334d076ac07e468ba16f5866a2e96ce1f" +checksum = "2e68257cfdf589ae3f9d2edd348072e2bf105fa87288fc0a7f5e090e20a2acd4" dependencies = [ "anyhow", "ethcontract-common", @@ -1867,9 +1867,9 @@ dependencies = [ [[package]] name = "ethcontract-generate" -version = "0.25.2" +version = "0.25.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d030b773b4837eec117c11c4aab4f56412d4c342c12300648ba73fb6b1f8ab20" +checksum = "8c013062a68f3e5d6fa2db391134cfc5fb0ee64d8d15d6205d79ec7cf7e8ffa4" dependencies = [ "Inflector", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 0e476a6f28..2d0a7b4e2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ cached = { version = "0.44", default-features = false } chrono = { version = "0.4", default-features = false } clap = { version = "4", features = ["derive", "env"] } derivative = "2" -ethcontract = { version = "0.25.2", default-features = false, features = ["aws-kms"] } +ethcontract = { version = "0.25.4", default-features = false, features = ["aws-kms"] } ethcontract-generate = { version = "0.25", default-features = false } ethcontract-mock = { version = "0.25", default-features = false } ethereum-types = "0.14" diff --git a/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs b/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs index ae8af8c5f4..2d027c8ab1 100644 --- a/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs +++ b/crates/autopilot/src/database/onchain_order_events/ethflow_events.rs @@ -143,6 +143,30 @@ fn convert_to_quote_id_and_user_valid_to( Ok((quote_id, user_valid_to)) } +/// The block from which to start indexing eth-flow events. Note that this +/// function is expected to be used at the start of the services and will panic +/// if it cannot retrieve the information it needs. +pub async fn determine_ethflow_indexing_start( + skip_event_sync_start: &Option, + ethflow_indexing_start: Option, + web3: &Web3, + chain_id: u64, +) -> BlockNumberHash { + if let Some(block_number_hash) = skip_event_sync_start { + return *block_number_hash; + } + if let Some(block_number) = ethflow_indexing_start { + return block_number_to_block_number_hash(web3, block_number.into()) + .await + .expect("Should be able to find block at specified indexing start"); + } + settlement_deployment_block_number_hash(web3, chain_id) + .await + .unwrap_or_else(|err| { + panic!("Should be able to find settlement deployment block. Error: {err}") + }) +} + #[cfg(test)] mod test { use { @@ -229,27 +253,3 @@ mod test { assert_eq!(result.len(), 0); } } - -/// The block from which to start indexing eth-flow events. Note that this -/// function is expected to be used at the start of the services and will panic -/// if it cannot retrieve the information it needs. -pub async fn determine_ethflow_indexing_start( - skip_event_sync_start: &Option, - ethflow_indexing_start: Option, - web3: &Web3, - chain_id: u64, -) -> BlockNumberHash { - if let Some(block_number_hash) = skip_event_sync_start { - return *block_number_hash; - } - if let Some(block_number) = ethflow_indexing_start { - return block_number_to_block_number_hash(web3, block_number.into()) - .await - .expect("Should be able to find block at specified indexing start"); - } - settlement_deployment_block_number_hash(web3, chain_id) - .await - .unwrap_or_else(|err| { - panic!("Should be able to find settlement deployment block. Error: {err}") - }) -} diff --git a/crates/database/src/orders.rs b/crates/database/src/orders.rs index 8b29c381b0..5d4843caef 100644 --- a/crates/database/src/orders.rs +++ b/crates/database/src/orders.rs @@ -971,7 +971,7 @@ mod tests { let post_interactions = read_order_interactions(&mut db, &order.uid, ExecutionTime::Post) .await .unwrap(); - assert_eq!(*post_interactions.get(0).unwrap(), post_interaction_0); + assert_eq!(*post_interactions.first().unwrap(), post_interaction_0); assert_eq!(*post_interactions.get(1).unwrap(), post_interaction_1); let post_interaction_overwrite_0 = Interaction { @@ -992,7 +992,7 @@ mod tests { .await .unwrap(); assert_eq!( - *post_interactions.get(0).unwrap(), + *post_interactions.first().unwrap(), post_interaction_overwrite_0 ); assert_eq!(*post_interactions.get(1).unwrap(), post_interaction_1); @@ -1061,7 +1061,7 @@ mod tests { let pre_interactions = read_order_interactions(&mut db, &order.uid, ExecutionTime::Pre) .await .unwrap(); - assert_eq!(*pre_interactions.get(0).unwrap(), pre_interaction_0); + assert_eq!(*pre_interactions.first().unwrap(), pre_interaction_0); assert_eq!(*pre_interactions.get(1).unwrap(), pre_interaction_1); let pre_interaction_overwrite_0 = Interaction { @@ -1082,7 +1082,7 @@ mod tests { .await .unwrap(); assert_eq!( - *pre_interactions.get(0).unwrap(), + *pre_interactions.first().unwrap(), pre_interaction_overwrite_0 ); assert_eq!(*pre_interactions.get(1).unwrap(), pre_interaction_1); diff --git a/crates/solver/src/settlement_simulation.rs b/crates/solver/src/settlement_simulation.rs index 3a338db16d..f3399977b4 100644 --- a/crates/solver/src/settlement_simulation.rs +++ b/crates/solver/src/settlement_simulation.rs @@ -699,7 +699,7 @@ mod tests { .await .map(|settlement| vec![settlement]) .unwrap(); - let settlement = settlements.get(0).unwrap(); + let settlement = settlements.first().unwrap(); let settlement_encoded = settlement .clone() .encode(InternalizationStrategy::SkipInternalizableInteraction);