diff --git a/crates/anvil/core/src/eth/transaction/mod.rs b/crates/anvil/core/src/eth/transaction/mod.rs index 502cd075daff..afc16b928f12 100644 --- a/crates/anvil/core/src/eth/transaction/mod.rs +++ b/crates/anvil/core/src/eth/transaction/mod.rs @@ -975,7 +975,7 @@ pub fn to_eip_access_list( #[cfg(test)] mod tests { use alloy_consensus::Receipt; - use alloy_primitives::{b256, hex, LogData, Signature}; + use alloy_primitives::{b256, hex, LogData}; use std::str::FromStr; use super::*; diff --git a/crates/anvil/src/eth/backend/mem/in_memory_db.rs b/crates/anvil/src/eth/backend/mem/in_memory_db.rs index f9b1cb6da9ef..e1c7deb8e999 100644 --- a/crates/anvil/src/eth/backend/mem/in_memory_db.rs +++ b/crates/anvil/src/eth/backend/mem/in_memory_db.rs @@ -133,15 +133,8 @@ impl MaybeForkedDatabase for MemDb { #[cfg(test)] mod tests { use super::*; - use crate::{ - eth::backend::db::{Db, SerializableAccountRecord, SerializableState}, - revm::primitives::AccountInfo, - }; - use alloy_primitives::{Address, Bytes, U256}; - use foundry_evm::{ - backend::MemDb, - revm::primitives::{Bytecode, KECCAK_EMPTY}, - }; + use alloy_primitives::Bytes; + use foundry_evm::revm::primitives::{Bytecode, KECCAK_EMPTY}; use std::{collections::BTreeMap, str::FromStr}; // verifies that all substantial aspects of a loaded account remain the state after an account diff --git a/crates/anvil/src/eth/backend/mem/storage.rs b/crates/anvil/src/eth/backend/mem/storage.rs index b84a34dc7312..9e907cff4d6b 100644 --- a/crates/anvil/src/eth/backend/mem/storage.rs +++ b/crates/anvil/src/eth/backend/mem/storage.rs @@ -438,7 +438,7 @@ pub struct MinedTransactionReceipt { mod tests { use super::*; use crate::eth::backend::db::Db; - use alloy_primitives::{Address, B256, U256}; + use alloy_primitives::Address; use foundry_evm::{ backend::MemDb, revm::{ diff --git a/crates/anvil/tests/it/fork.rs b/crates/anvil/tests/it/fork.rs index 0bd6f7dcb78e..ceeeb16e7e1e 100644 --- a/crates/anvil/tests/it/fork.rs +++ b/crates/anvil/tests/it/fork.rs @@ -11,7 +11,6 @@ use alloy_signer::Signer as AlloySigner; use anvil::{eth::EthApi, spawn, NodeConfig, NodeHandle}; use anvil_core::types::Forking; use ethers::{ - core::rand, prelude::{Bytes, LocalWallet, Middleware, SignerMiddleware}, providers::{Http, Provider}, signers::Signer, diff --git a/crates/anvil/tests/it/ipc.rs b/crates/anvil/tests/it/ipc.rs index 6e3204d9d6b3..8b7de088467d 100644 --- a/crates/anvil/tests/it/ipc.rs +++ b/crates/anvil/tests/it/ipc.rs @@ -1,12 +1,11 @@ //! IPC tests +use crate::utils::ethers_ipc_provider; use alloy_primitives::U256; use anvil::{spawn, NodeConfig}; -use ethers::{core::rand, prelude::Middleware}; +use ethers::prelude::Middleware; use futures::StreamExt; -use crate::utils::ethers_ipc_provider; - pub fn rand_ipc_endpoint() -> String { let num: u64 = rand::Rng::gen(&mut rand::thread_rng()); if cfg!(windows) { diff --git a/crates/cast/bin/cmd/logs.rs b/crates/cast/bin/cmd/logs.rs index e7e6aed5d9b7..752d90dfed6c 100644 --- a/crates/cast/bin/cmd/logs.rs +++ b/crates/cast/bin/cmd/logs.rs @@ -285,8 +285,7 @@ pub fn sanitize_token(token: Token) -> Token { #[cfg(test)] mod tests { use super::*; - use ethers_core::types::{H160, H256}; - use std::str::FromStr; + use ethers_core::types::H160; const ADDRESS: &str = "0x4D1A2e2bB4F88F0250f26Ffff098B0b30B26BF38"; const TRANSFER_SIG: &str = "Transfer(address indexed,address indexed,uint256)"; diff --git a/crates/cheatcodes/src/utils.rs b/crates/cheatcodes/src/utils.rs index bb4726431188..9cfeee276b59 100644 --- a/crates/cheatcodes/src/utils.rs +++ b/crates/cheatcodes/src/utils.rs @@ -241,7 +241,7 @@ mod tests { use crate::CheatsConfig; use alloy_primitives::FixedBytes; use hex::FromHex; - use p256::ecdsa::{signature::hazmat::PrehashVerifier, Signature}; + use p256::ecdsa::signature::hazmat::PrehashVerifier; use std::{path::PathBuf, sync::Arc}; fn cheats() -> Cheatcodes { diff --git a/crates/common/src/abi.rs b/crates/common/src/abi.rs index fc3e8083e4a3..66a7c98910e2 100644 --- a/crates/common/src/abi.rs +++ b/crates/common/src/abi.rs @@ -203,7 +203,7 @@ fn coerce_value(ty: &str, arg: &str) -> Result { mod tests { use super::*; use alloy_dyn_abi::EventExt; - use alloy_primitives::{LogData, B256, U256}; + use alloy_primitives::{B256, U256}; #[test] fn test_get_func() { diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index c55dcb752c3c..879d3ecfb7df 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -35,7 +35,6 @@ use std::{ fs, path::{Path, PathBuf}, str::FromStr, - string::ToString, }; // Macros useful for creating a figment. @@ -2574,15 +2573,13 @@ mod tests { use super::*; use crate::{ cache::{CachedChains, CachedEndpoints}, - endpoints::{RpcEndpoint, RpcEndpointConfig, RpcEndpointType}, + endpoints::{RpcEndpointConfig, RpcEndpointType}, etherscan::ResolvedEtherscanConfigs, - fs_permissions::PathPermission, }; - use alloy_primitives::Address; - use figment::{error::Kind::InvalidType, value::Value, Figment}; + use figment::error::Kind::InvalidType; use foundry_compilers::artifacts::{ModelCheckerEngine, YulDetails}; use pretty_assertions::assert_eq; - use std::{collections::BTreeMap, fs::File, io::Write, str::FromStr}; + use std::{collections::BTreeMap, fs::File, io::Write}; use tempfile::tempdir; use NamedChain::Moonbeam; diff --git a/crates/evm/core/src/fork/backend.rs b/crates/evm/core/src/fork/backend.rs index 3a87583b6da4..e319069d065a 100644 --- a/crates/evm/core/src/fork/backend.rs +++ b/crates/evm/core/src/fork/backend.rs @@ -682,7 +682,7 @@ mod tests { }; use foundry_common::provider::alloy::get_http_provider; use foundry_config::{Config, NamedChain}; - use std::{collections::BTreeSet, path::PathBuf, sync::Arc}; + use std::{collections::BTreeSet, path::PathBuf}; const ENDPOINT: Option<&str> = option_env!("ETH_RPC_URL"); diff --git a/crates/evm/core/src/opts.rs b/crates/evm/core/src/opts.rs index 1e52f484bde3..094606828dfd 100644 --- a/crates/evm/core/src/opts.rs +++ b/crates/evm/core/src/opts.rs @@ -5,7 +5,6 @@ use alloy_providers::provider::TempProvider; use alloy_rpc_types::Block; use eyre::WrapErr; use foundry_common::{ - self, provider::alloy::{ProviderBuilder, RpcUrl}, ALCHEMY_FREE_TIER_CUPS, }; diff --git a/crates/fmt/src/formatter.rs b/crates/fmt/src/formatter.rs index 347d7188f14e..00beb4d8c656 100644 --- a/crates/fmt/src/formatter.rs +++ b/crates/fmt/src/formatter.rs @@ -16,7 +16,6 @@ use crate::{ use alloy_primitives::Address; use foundry_config::fmt::{HexUnderscore, MultilineFuncHeaderStyle, SingleLineBlockStyle}; use itertools::{Either, Itertools}; -use solang_parser::pt::ImportPath; use std::{fmt::Write, str::FromStr}; use thiserror::Error; diff --git a/crates/forge/bin/cmd/script/broadcast.rs b/crates/forge/bin/cmd/script/broadcast.rs index 7488bbd1071b..10d0096068b0 100644 --- a/crates/forge/bin/cmd/script/broadcast.rs +++ b/crates/forge/bin/cmd/script/broadcast.rs @@ -1,24 +1,36 @@ use super::{ multi::MultiChainSequence, providers::ProvidersManager, receipts::clear_pendings, - sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, *, + sequence::ScriptSequence, transaction::TransactionWithMetadata, verify::VerifyBundle, + NestedValue, ScriptArgs, ScriptConfig, ScriptResult, }; -use alloy_primitives::{utils::format_units, TxHash}; +use alloy_primitives::{utils::format_units, Address, TxHash, U256}; use ethers_core::types::transaction::eip2718::TypedTransaction; use ethers_providers::{JsonRpcClient, Middleware, Provider}; -use ethers_signers::Signer; -use eyre::{bail, ContextCompat, Result, WrapErr}; +use ethers_signers::{LocalWallet, Signer}; +use eyre::{bail, Context, ContextCompat, Result}; +use forge::{inspectors::cheatcodes::BroadcastableTransactions, traces::CallTraceDecoder}; use foundry_cli::{ init_progress, update_progress, utils::{has_batch_support, has_different_gas_calc}, }; use foundry_common::{ - provider::ethers::{estimate_eip1559_fees, try_get_http_provider, RetryProvider}, + provider::{ + alloy::RpcUrl, + ethers::{estimate_eip1559_fees, try_get_http_provider, RetryProvider}, + }, shell, types::{ToAlloy, ToEthers}, + ContractsByArtifact, }; +use foundry_compilers::{artifacts::Libraries, ArtifactId}; +use foundry_config::Config; use foundry_wallets::WalletSigner; use futures::StreamExt; -use std::{cmp::min, collections::HashSet, ops::Mul, sync::Arc}; +use std::{ + cmp::min, + collections::{HashMap, HashSet, VecDeque}, + sync::Arc, +}; impl ScriptArgs { /// Sends the transactions which haven't been broadcasted yet. @@ -198,7 +210,7 @@ impl ScriptArgs { |acc, receipt| { let gas_used = receipt.gas_used.unwrap_or_default().to_alloy(); let gas_price = receipt.effective_gas_price.unwrap_or_default().to_alloy(); - (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used.mul(gas_price)) + (acc.0 + gas_used, acc.1 + gas_price, acc.2 + gas_used * gas_price) }, ); let paid = format_units(total_paid, 18).unwrap_or_else(|_| "N/A".to_string()); diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index fd66377cdfac..ebd502a92a79 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,4 +1,4 @@ -use super::*; +use super::{ScriptArgs, ScriptConfig}; use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; use forge::link::{LinkOutput, Linker}; diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index ebb9f97aa592..69032462d3e7 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -1,15 +1,23 @@ -use super::{multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, *}; -use alloy_primitives::Bytes; - +use super::{ + multi::MultiChainSequence, sequence::ScriptSequence, verify::VerifyBundle, ScriptArgs, + ScriptConfig, ScriptResult, +}; +use crate::cmd::script::{build::BuildOutput, receipts}; +use alloy_primitives::{Address, Bytes}; use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::{OptionExt, Result}; -use forge::link::Linker; +use forge::{link::Linker, traces::CallTraceDecoder}; use foundry_cli::utils::LoadConfig; use foundry_common::{ contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, }; +use foundry_compilers::{ + artifacts::{ContractBytecodeSome, Libraries}, + contracts::ArtifactContracts, +}; use foundry_debugger::Debugger; +use foundry_evm::inspectors::cheatcodes::BroadcastableTransaction; use std::sync::Arc; /// Helper alias type for the collection of data changed due to the new sender. diff --git a/crates/forge/bin/cmd/script/executor.rs b/crates/forge/bin/cmd/script/executor.rs index 588af4c10d1e..ac86c112a4ea 100644 --- a/crates/forge/bin/cmd/script/executor.rs +++ b/crates/forge/bin/cmd/script/executor.rs @@ -1,22 +1,26 @@ use super::{ artifacts::ArtifactInfo, - runner::SimulationStage, + runner::{ScriptRunner, SimulationStage}, transaction::{AdditionalContract, TransactionWithMetadata}, - *, + ScriptArgs, ScriptConfig, ScriptResult, }; use alloy_primitives::{Address, Bytes, U256}; -use eyre::Result; +use eyre::{Context, Result}; use forge::{ backend::Backend, executors::ExecutorBuilder, inspectors::{cheatcodes::BroadcastableTransactions, CheatsConfig}, - traces::CallTraceDecoder, + traces::{render_trace_arena, CallTraceDecoder}, }; use foundry_cli::utils::{ensure_clean_constructor, needs_setup}; -use foundry_common::{provider::ethers::RpcUrl, shell}; +use foundry_common::{get_contract_name, provider::ethers::RpcUrl, shell, ContractsByArtifact}; +use foundry_compilers::artifacts::ContractBytecodeSome; use futures::future::join_all; use parking_lot::RwLock; -use std::{collections::VecDeque, sync::Arc}; +use std::{ + collections::{BTreeMap, HashMap, VecDeque}, + sync::Arc, +}; impl ScriptArgs { /// Locally deploys and executes the contract method that will collect all broadcastable diff --git a/crates/forge/bin/cmd/script/mod.rs b/crates/forge/bin/cmd/script/mod.rs index bde7436fcbbe..17ff7e569238 100644 --- a/crates/forge/bin/cmd/script/mod.rs +++ b/crates/forge/bin/cmd/script/mod.rs @@ -1,4 +1,3 @@ -use self::{build::BuildOutput, runner::ScriptRunner}; use super::{build::BuildArgs, retry::RetryArgs}; use alloy_dyn_abi::FunctionExt; use alloy_json_abi::{Function, InternalType, JsonAbi}; @@ -21,7 +20,6 @@ use forge::{ }; use foundry_common::{ abi::{encode_function_args, get_func}, - contracts::get_contract_name, errors::UnlinkedByteCode, evm::{Breakpoints, EvmArgs}, fmt::{format_token, format_token_raw}, @@ -30,7 +28,6 @@ use foundry_common::{ }; use foundry_compilers::{ artifacts::{ContractBytecodeSome, Libraries}, - contracts::ArtifactContracts, ArtifactId, }; use foundry_config::{ @@ -50,7 +47,7 @@ use foundry_wallets::MultiWallet; use futures::future; use itertools::Itertools; use serde::{Deserialize, Serialize}; -use std::collections::{BTreeMap, HashMap, HashSet, VecDeque}; +use std::collections::{BTreeMap, HashMap, HashSet}; use yansi::Paint; mod artifacts; @@ -705,7 +702,7 @@ For more information, please see https://eips.ethereum.org/EIPS/eip-3855", mod tests { use super::*; use foundry_cli::utils::LoadConfig; - use foundry_config::{NamedChain, UnresolvedEnvVarError}; + use foundry_config::UnresolvedEnvVarError; use std::fs; use tempfile::tempdir; diff --git a/crates/forge/bin/cmd/script/runner.rs b/crates/forge/bin/cmd/script/runner.rs index 6afb1a4441b0..838dcfdf34b7 100644 --- a/crates/forge/bin/cmd/script/runner.rs +++ b/crates/forge/bin/cmd/script/runner.rs @@ -1,4 +1,4 @@ -use super::*; +use super::ScriptResult; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; use forge::{ @@ -8,6 +8,8 @@ use forge::{ traces::{TraceKind, Traces}, }; use foundry_common::types::ToEthers; +use foundry_config::Config; +use yansi::Paint; /// Represents which simulation stage is the script execution at. pub enum SimulationStage { diff --git a/crates/forge/bin/cmd/verify/etherscan/mod.rs b/crates/forge/bin/cmd/verify/etherscan/mod.rs index 961b6db47d96..919c83b8fb0a 100644 --- a/crates/forge/bin/cmd/verify/etherscan/mod.rs +++ b/crates/forge/bin/cmd/verify/etherscan/mod.rs @@ -486,7 +486,6 @@ async fn ensure_solc_build_metadata(version: Version) -> Result { mod tests { use super::*; use clap::Parser; - use foundry_cli::utils::LoadConfig; use foundry_common::fs; use foundry_test_utils::forgetest_async; use tempfile::tempdir; diff --git a/crates/forge/src/link.rs b/crates/forge/src/link.rs index 3779f69caf26..55f3f5487b3d 100644 --- a/crates/forge/src/link.rs +++ b/crates/forge/src/link.rs @@ -194,10 +194,9 @@ impl Linker { #[cfg(test)] mod tests { - use std::{collections::HashMap, path::PathBuf}; - use super::*; use foundry_compilers::{Project, ProjectPathsConfig}; + use std::collections::HashMap; struct LinkerTest { project: Project, diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 67b96cb2326a..21c34b6a6125 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -24,7 +24,6 @@ use revm::primitives::SpecId; use std::{ collections::BTreeMap, fmt::Debug, - iter::Iterator, path::Path, sync::{mpsc, Arc}, };