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

+1-1
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

+2-2
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

+2-2
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

+5-5
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

+3-3
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

+1-1
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

+1-1
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

+2-2
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

+1-1
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

+1-1
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
}

anvil/src/eth/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ impl<'a> fmt::Display for HexDisplay<'a> {
3131
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
3232
if self.0.len() < 1027 {
3333
for byte in self.0 {
34-
f.write_fmt(format_args!("{:02x}", byte))?;
34+
f.write_fmt(format_args!("{byte:02x}"))?;
3535
}
3636
} else {
3737
for byte in &self.0[0..512] {
38-
f.write_fmt(format_args!("{:02x}", byte))?;
38+
f.write_fmt(format_args!("{byte:02x}"))?;
3939
}
4040
f.write_str("...")?;
4141
for byte in &self.0[self.0.len() - 512..] {
42-
f.write_fmt(format_args!("{:02x}", byte))?;
42+
f.write_fmt(format_args!("{byte:02x}"))?;
4343
}
4444
}
4545
Ok(())
@@ -49,7 +49,7 @@ impl<'a> fmt::Display for HexDisplay<'a> {
4949
impl<'a> fmt::Debug for HexDisplay<'a> {
5050
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5151
for byte in self.0 {
52-
f.write_fmt(format_args!("{:02x}", byte))?;
52+
f.write_fmt(format_args!("{byte:02x}"))?;
5353
}
5454
Ok(())
5555
}

anvil/src/hardfork.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl FromStr for Hardfork {
108108
"arrowglacier" | "13" => Hardfork::ArrowGlacier,
109109
"grayglacier" => Hardfork::GrayGlacier,
110110
"latest" | "14" => Hardfork::Latest,
111-
_ => return Err(format!("Unknown hardfork {}", s)),
111+
_ => return Err(format!("Unknown hardfork {s}")),
112112
};
113113
Ok(hardfork)
114114
}

anvil/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ impl NodeHandle {
275275
let ipc_path = self.config.get_ipc_path()?;
276276
tracing::trace!(target = "ipc", ?ipc_path, "connecting ipc provider");
277277
let provider = Provider::connect_ipc(&ipc_path).await.unwrap_or_else(|err| {
278-
panic!("Failed to connect to node's ipc endpoint {}: {:?}", ipc_path, err)
278+
panic!("Failed to connect to node's ipc endpoint {ipc_path}: {err:?}")
279279
});
280280
Some(provider)
281281
}

anvil/tests/it/fork.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ async fn test_fork_timestamp() {
321321

322322
// ensure the diff between the new mined block and the original block is within the elapsed time
323323
let diff = block.timestamp - BLOCK_TIMESTAMP;
324-
assert!(diff <= elapsed.into(), "diff={}, elapsed={}", diff, elapsed);
324+
assert!(diff <= elapsed.into(), "diff={diff}, elapsed={elapsed}");
325325

326326
let start = std::time::Instant::now();
327327
// reset to check timestamp works after resetting
@@ -562,7 +562,7 @@ async fn test_reset_fork_on_new_blocks() {
562562

563563
let next_block = anvil_provider.get_block_number().await.unwrap();
564564

565-
assert!(next_block > current_block, "nextblock={} currentblock={}", next_block, current_block)
565+
assert!(next_block > current_block, "nextblock={next_block} currentblock={current_block}")
566566
}
567567

568568
#[tokio::test(flavor = "multi_thread")]

anvil/tests/it/ganache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ contract Contract {
108108
.unwrap();
109109

110110
let mut compiled = prj.compile().unwrap();
111-
println!("{}", compiled);
111+
println!("{compiled}");
112112
assert!(!compiled.has_compiler_errors());
113113

114114
let contract = compiled.remove_first("Contract").unwrap();

anvil/tests/it/ipc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use futures::StreamExt;
99
pub fn rand_ipc_endpoint() -> String {
1010
let num: u64 = rand::Rng::gen(&mut rand::thread_rng());
1111
if cfg!(windows) {
12-
format!(r"\\.\pipe\anvil-ipc-{}", num)
12+
format!(r"\\.\pipe\anvil-ipc-{num}")
1313
} else {
14-
format!(r"/tmp/anvil-ipc-{}", num)
14+
format!(r"/tmp/anvil-ipc-{num}")
1515
}
1616
}
1717

anvil/tests/it/proof/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ async fn can_get_random_account_proofs() {
6969
let _ = api
7070
.get_proof(acc, Vec::new(), None)
7171
.await
72-
.unwrap_or_else(|_| panic!("Failed to get proof for {:?}", acc));
72+
.unwrap_or_else(|_| panic!("Failed to get proof for {acc:?}"));
7373
}
7474
}

anvil/tests/it/transaction.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ async fn test_tx_access_list() {
792792
})
793793
.collect::<Vec<_>>();
794794

795-
format!("{:?}", a)
795+
format!("{a:?}")
796796
}
797797

798798
/// asserts that the two access lists are equal, by comparing their sorted

binder/src/utils.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl<'a> GitCheckout<'a> {
274274
let reference = GitReference::Rev(head.to_string());
275275

276276
fetch(&mut repo, url, &reference, false).with_context(|| {
277-
format!("failed to fetch submodule `{}` from {}", child.name().unwrap_or(""), url)
277+
format!("failed to fetch submodule `{}` from {url}", child.name().unwrap_or(""))
278278
})?;
279279

280280
let obj = repo.find_object(head, None)?;
@@ -407,7 +407,7 @@ impl Retry {
407407
self.remaining,
408408
e.root_cause(),
409409
);
410-
println!("{}", msg);
410+
println!("{msg}");
411411
self.remaining -= 1;
412412
Ok(None)
413413
}
@@ -711,10 +711,10 @@ pub fn fetch(
711711
// For branches and tags we can fetch simply one reference and copy it
712712
// locally, no need to fetch other branches/tags.
713713
GitReference::Branch(b) => {
714-
refspecs.push(format!("+refs/heads/{0}:refs/remotes/origin/{0}", b));
714+
refspecs.push(format!("+refs/heads/{b}:refs/remotes/origin/{b}"));
715715
}
716716
GitReference::Tag(t) => {
717-
refspecs.push(format!("+refs/tags/{0}:refs/remotes/origin/tags/{0}", t));
717+
refspecs.push(format!("+refs/tags/{t}:refs/remotes/origin/tags/{t}"));
718718
}
719719

720720
GitReference::DefaultBranch => {
@@ -723,7 +723,7 @@ pub fn fetch(
723723

724724
GitReference::Rev(rev) => {
725725
if rev.starts_with("refs/") {
726-
refspecs.push(format!("+{0}:{0}", rev));
726+
refspecs.push(format!("+{rev}:{rev}"));
727727
} else {
728728
// We don't know what the rev will point to. To handle this
729729
// situation we fetch all branches and tags, and then we pray

0 commit comments

Comments
 (0)