Skip to content

Commit 9d64f1f

Browse files
authored
chore(clippy): make clippy happy (#3546)
* chore(clippy): make clippy happy * test: use retry provider in tests
1 parent b1dc9ad commit 9d64f1f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+307
-316
lines changed

anvil/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ fn main() {
55
// Change the SHA output to the short variant
66
*config.git_mut().sha_kind_mut() = ShaKind::Short;
77
vergen::vergen(config)
8-
.unwrap_or_else(|e| panic!("vergen crate failed to generate version information! {}", e));
8+
.unwrap_or_else(|e| panic!("vergen crate failed to generate version information! {e}"));
99
}

anvil/core/src/eth/subscription.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a> Deserialize<'a> for SubscriptionParams {
4848
}
4949

5050
let filter: Filter = serde_json::from_value(val)
51-
.map_err(|e| D::Error::custom(format!("Invalid Subscription parameters: {}", e)))?;
51+
.map_err(|e| D::Error::custom(format!("Invalid Subscription parameters: {e}")))?;
5252
Ok(SubscriptionParams { filter: Some(filter) })
5353
}
5454
}
@@ -119,7 +119,7 @@ impl HexIdProvider {
119119
let id: String =
120120
(&mut thread_rng()).sample_iter(Alphanumeric).map(char::from).take(self.len).collect();
121121
let out = hex::encode(id);
122-
format!("0x{}", out)
122+
format!("0x{out}")
123123
}
124124
}
125125

anvil/core/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ impl<'a> Deserialize<'a> for Index {
129129
{
130130
if let Some(val) = value.strip_prefix("0x") {
131131
usize::from_str_radix(val, 16).map(Index).map_err(|e| {
132-
Error::custom(format!("Failed to parse hex encoded index value: {}", e))
132+
Error::custom(format!("Failed to parse hex encoded index value: {e}"))
133133
})
134134
} else {
135135
value
136136
.parse::<usize>()
137137
.map(Index)
138-
.map_err(|e| Error::custom(format!("Failed to parse numeric index: {}", e)))
138+
.map_err(|e| Error::custom(format!("Failed to parse numeric index: {e}")))
139139
}
140140
}
141141

anvil/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl NodeConfig {
149149
fn as_string(&self, fork: Option<&ClientFork>) -> String {
150150
let mut config_string: String = "".to_owned();
151151
let _ = write!(config_string, "\n{}", Paint::green(BANNER));
152-
let _ = write!(config_string, "\n {}", VERSION_MESSAGE);
152+
let _ = write!(config_string, "\n {VERSION_MESSAGE}");
153153
let _ = write!(
154154
config_string,
155155
"\n {}",
@@ -166,7 +166,7 @@ Available Accounts
166166
);
167167
let balance = format_ether(self.genesis_balance);
168168
for (idx, wallet) in self.genesis_accounts.iter().enumerate() {
169-
let _ = write!(config_string, "\n({}) {:?} ({} ETH)", idx, wallet.address(), balance);
169+
let _ = write!(config_string, "\n({idx}) {:?} ({balance} ETH)", wallet.address());
170170
}
171171

172172
let _ = write!(
@@ -180,7 +180,7 @@ Private Keys
180180

181181
for (idx, wallet) in self.genesis_accounts.iter().enumerate() {
182182
let hex = hex::encode(wallet.signer().to_bytes());
183-
let _ = write!(config_string, "\n({}) 0x{}", idx, hex);
183+
let _ = write!(config_string, "\n({idx}) 0x{hex}");
184184
}
185185

186186
if let Some(ref gen) = self.account_generator {
@@ -773,7 +773,7 @@ impl NodeConfig {
773773
fork_block_number, latest_block
774774
);
775775
}
776-
panic!("Failed to get block for block number: {}", fork_block_number)
776+
panic!("Failed to get block for block number: {fork_block_number}")
777777
};
778778

779779
// we only use the gas limit value of the block if it is non-zero, since there are networks where this is not used and is always `0x0` which would inevitably result in `OutOfGas` errors as soon as the evm is about to record gas, See also <https://github.com/foundry-rs/foundry/issues/3247>
@@ -966,7 +966,7 @@ impl AccountGenerator {
966966

967967
for idx in 0..self.amount {
968968
let builder =
969-
builder.clone().derivation_path(&format!("{}{}", derivation_path, idx)).unwrap();
969+
builder.clone().derivation_path(&format!("{derivation_path}{idx}")).unwrap();
970970
let wallet = builder.build().unwrap().with_chain_id(self.chain_id);
971971
wallets.push(wallet)
972972
}

anvil/src/eth/api.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl EthApi {
683683
node_info!("eth_signTypedData_v4");
684684
let signer = self.get_signer(address).ok_or(BlockchainError::NoSignerAvailable)?;
685685
let signature = signer.sign_typed_data(address, data).await?;
686-
Ok(format!("0x{}", signature))
686+
Ok(format!("0x{signature}"))
687687
}
688688

689689
/// The sign method calculates an Ethereum specific signature
@@ -693,7 +693,7 @@ impl EthApi {
693693
node_info!("eth_sign");
694694
let signer = self.get_signer(address).ok_or(BlockchainError::NoSignerAvailable)?;
695695
let signature = signer.sign(address, content.as_ref()).await?;
696-
Ok(format!("0x{}", signature))
696+
Ok(format!("0x{signature}"))
697697
}
698698

699699
/// Sends a transaction
@@ -1570,7 +1570,7 @@ impl EthApi {
15701570
.initial_backoff(1000)
15711571
.build()
15721572
.map_err(|_| {
1573-
ProviderError::CustomError(format!("Failed to parse invalid url {}", url))
1573+
ProviderError::CustomError(format!("Failed to parse invalid url {url}"))
15741574
})?
15751575
.interval(interval),
15761576
);

anvil/src/eth/backend/mem/cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl DiskStateCache {
3232
}
3333
}
3434
if let Some(ref temp_dir) = self.temp_dir {
35-
let path = temp_dir.path().join(format!("{:?}.json", hash));
35+
let path = temp_dir.path().join(format!("{hash:?}.json"));
3636
Some(f(path))
3737
} else {
3838
None

anvil/src/eth/backend/time.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,5 +148,5 @@ pub fn duration_since_unix_epoch() -> Duration {
148148
use std::time::SystemTime;
149149
let now = SystemTime::now();
150150
now.duration_since(SystemTime::UNIX_EPOCH)
151-
.unwrap_or_else(|err| panic!("Current time {:?} is invalid: {:?}", now, err))
151+
.unwrap_or_else(|err| panic!("Current time {now:?} is invalid: {err:?}"))
152152
}

anvil/src/eth/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ impl<T: Serialize> ToRpcResponseResult for Result<T> {
206206
// this mimics geth revert error
207207
let mut msg = "execution reverted".to_string();
208208
if let Some(reason) = data.as_ref().and_then(decode_revert_reason) {
209-
msg = format!("{}: {}", msg, reason);
209+
msg = format!("{msg}: {reason}");
210210
}
211211
RpcError {
212212
// geth returns this error code on reverts, See <https://github.com/ethereum/wiki/wiki/JSON-RPC-Error-Codes-Improvement-Proposal>
@@ -241,7 +241,7 @@ impl<T: Serialize> ToRpcResponseResult for Result<T> {
241241
),
242242
BlockchainError::ForkProvider(err) => {
243243
error!("fork provider error: {:?}", err);
244-
RpcError::internal_error_with(format!("Fork Error: {:?}", err))
244+
RpcError::internal_error_with(format!("Fork Error: {err:?}"))
245245
}
246246
err @ BlockchainError::EvmError(_) => {
247247
RpcError::internal_error_with(err.to_string())

anvil/src/eth/miner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Miner {
5454

5555
/// Sets the mining mode to operate in
5656
pub fn set_mining_mode(&self, mode: MiningMode) {
57-
let new_mode = format!("{:?}", mode);
57+
let new_mode = format!("{mode:?}");
5858
let mode = std::mem::replace(&mut *self.mode_write(), mode);
5959
trace!(target: "miner", "updated mining mode from {:?} to {}", mode, new_mode);
6060
self.inner.wake();

anvil/src/eth/pool/transactions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl FromStr for TransactionOrder {
5757
let order = match s.as_str() {
5858
"fees" => TransactionOrder::Fees,
5959
"fifo" => TransactionOrder::Fifo,
60-
_ => return Err(format!("Unknown TransactionOrder: `{}`", s)),
60+
_ => return Err(format!("Unknown TransactionOrder: `{s}`")),
6161
};
6262
Ok(order)
6363
}

0 commit comments

Comments
 (0)