diff --git a/ethers-core/src/utils/mod.rs b/ethers-core/src/utils/mod.rs index 0099e2e481..63f2e4bf36 100644 --- a/ethers-core/src/utils/mod.rs +++ b/ethers-core/src/utils/mod.rs @@ -241,7 +241,7 @@ pub fn to_checksum(addr: &Address, chain_id: Option) -> String { pub fn format_bytes32_string(text: &str) -> Result<[u8; 32], FormatBytes32StringError> { let str_bytes: &[u8] = text.as_bytes(); if str_bytes.len() > 32 { - return Err(FormatBytes32StringError::TextTooLong) + return Err(FormatBytes32StringError::TextTooLong); } let mut bytes32: [u8; 32] = [0u8; 32]; @@ -284,10 +284,10 @@ fn estimate_priority_fee(rewards: Vec>) -> U256 { let mut rewards: Vec = rewards.iter().map(|r| r[0]).filter(|r| *r > U256::zero()).collect(); if rewards.is_empty() { - return U256::zero() + return U256::zero(); } if rewards.len() == 1 { - return rewards[0] + return rewards[0]; } // Sort the rewards as we will eventually take the median. rewards.sort(); @@ -316,8 +316,8 @@ fn estimate_priority_fee(rewards: Vec>) -> U256 { // If we encountered a big change in fees at a certain position, then consider only // the values >= it. - let values = if *max_change >= EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE && - (max_change_index >= (rewards.len() / 2)) + let values = if *max_change >= EIP1559_FEE_ESTIMATION_THRESHOLD_MAX_CHANGE + && (max_change_index >= (rewards.len() / 2)) { rewards[max_change_index..].to_vec() } else { @@ -378,11 +378,11 @@ mod tests { let gwei = parse_units(1.5, 9).unwrap(); assert_eq!(gwei.as_u64(), 15e8 as u64); - let eth_dec_float = parse_units(1.39563324, "ether").unwrap(); - assert_eq!(eth_dec_float, U256::from_dec_str("1395633240000000000").unwrap()); + let eth_dec_float = parse_units(1.395633240123456789, "ether").unwrap(); + assert_eq!(eth_dec_float, U256::from_dec_str("1395633240123456789").unwrap()); - let eth_dec_string = parse_units("1.39563324", "ether").unwrap(); - assert_eq!(eth_dec_string, U256::from_dec_str("1395633240000000000").unwrap()); + let eth_dec_string = parse_units("1.395633240123456789", "ether").unwrap(); + assert_eq!(eth_dec_string, U256::from_dec_str("1395633240123456789").unwrap()); let eth = parse_units(1, "ether").unwrap(); assert_eq!(eth, WEI_IN_ETHER);