diff --git a/Cargo.lock b/Cargo.lock index b936a44b1634..c35e148ff2ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2932,6 +2932,7 @@ dependencies = [ "foundry-config", "foundry-debugger", "foundry-evm", + "foundry-linking", "foundry-test-utils", "foundry-wallets", "futures", @@ -3414,6 +3415,16 @@ dependencies = [ "yansi 0.5.1", ] +[[package]] +name = "foundry-linking" +version = "0.2.0" +dependencies = [ + "alloy-primitives", + "foundry-compilers", + "semver 1.0.22", + "thiserror", +] + [[package]] name = "foundry-macros" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index ba0cddfa212c..e0c94e7466dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -133,6 +133,7 @@ foundry-evm-traces = { path = "crates/evm/traces" } foundry-macros = { path = "crates/macros" } foundry-test-utils = { path = "crates/test-utils" } foundry-wallets = { path = "crates/wallets" } +foundry-linking = { path = "crates/linking" } # solc & compilation utilities foundry-block-explorers = { version = "0.2.3", default-features = false } diff --git a/crates/forge/Cargo.toml b/crates/forge/Cargo.toml index 29d01b5c55c3..6d4e40f6b97f 100644 --- a/crates/forge/Cargo.toml +++ b/crates/forge/Cargo.toml @@ -25,6 +25,7 @@ foundry-compilers = { workspace = true, features = ["full"] } foundry-config.workspace = true foundry-evm.workspace = true foundry-wallets.workspace = true +foundry-linking.workspace = true ethers-contract.workspace = true ethers-core.workspace = true diff --git a/crates/forge/bin/cmd/script/build.rs b/crates/forge/bin/cmd/script/build.rs index 4b188d955323..a2bdc1490d4b 100644 --- a/crates/forge/bin/cmd/script/build.rs +++ b/crates/forge/bin/cmd/script/build.rs @@ -1,7 +1,6 @@ use super::{ScriptArgs, ScriptConfig}; use alloy_primitives::{Address, Bytes}; use eyre::{Context, ContextCompat, Result}; -use forge::link::{LinkOutput, Linker}; use foundry_cli::utils::get_cached_entry_by_name; use foundry_common::compile::{self, ContractSources, ProjectCompiler}; use foundry_compilers::{ @@ -11,6 +10,7 @@ use foundry_compilers::{ info::ContractInfo, ArtifactId, Project, ProjectCompileOutput, }; +use foundry_linking::{LinkOutput, Linker}; use std::str::FromStr; impl ScriptArgs { diff --git a/crates/forge/bin/cmd/script/cmd.rs b/crates/forge/bin/cmd/script/cmd.rs index 70fce668017f..f864f29f8bc0 100644 --- a/crates/forge/bin/cmd/script/cmd.rs +++ b/crates/forge/bin/cmd/script/cmd.rs @@ -7,7 +7,7 @@ use alloy_primitives::{Address, Bytes}; use ethers_providers::Middleware; use ethers_signers::Signer; use eyre::{OptionExt, Result}; -use forge::{link::Linker, traces::CallTraceDecoder}; +use forge::traces::CallTraceDecoder; use foundry_cli::utils::LoadConfig; use foundry_common::{ contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy, @@ -18,6 +18,7 @@ use foundry_compilers::{ }; use foundry_debugger::Debugger; use foundry_evm::inspectors::cheatcodes::{BroadcastableTransaction, ScriptWallets}; +use foundry_linking::Linker; use foundry_wallets::WalletSigner; use std::{collections::HashMap, sync::Arc}; diff --git a/crates/forge/src/lib.rs b/crates/forge/src/lib.rs index 00481591e079..39854abac8a1 100644 --- a/crates/forge/src/lib.rs +++ b/crates/forge/src/lib.rs @@ -13,8 +13,6 @@ pub mod coverage; pub mod gas_report; -pub mod link; - mod multi_runner; pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder}; diff --git a/crates/forge/src/multi_runner.rs b/crates/forge/src/multi_runner.rs index 6a8e821b23a0..36d2f2fd897d 100644 --- a/crates/forge/src/multi_runner.rs +++ b/crates/forge/src/multi_runner.rs @@ -1,10 +1,6 @@ //! Forge test runner for multiple contracts. -use crate::{ - link::{LinkOutput, Linker}, - result::SuiteResult, - ContractRunner, TestFilter, TestOptions, -}; +use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions}; use alloy_json_abi::{Function, JsonAbi}; use alloy_primitives::{Address, Bytes, U256}; use eyre::Result; @@ -19,6 +15,7 @@ use foundry_evm::{ opts::EvmOpts, revm, }; +use foundry_linking::{LinkOutput, Linker}; use rayon::prelude::*; use revm::primitives::SpecId; use std::{ diff --git a/crates/linking/Cargo.toml b/crates/linking/Cargo.toml new file mode 100644 index 000000000000..31edf1c5d1b3 --- /dev/null +++ b/crates/linking/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "foundry-linking" +description = "Smart contract linking tools" + +version.workspace = true +edition.workspace = true +rust-version.workspace = true +authors.workspace = true +license.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +foundry-compilers = { workspace = true, features = ["full"] } +semver = "1" +alloy-primitives = { workspace = true, features = ["rlp"] } +thiserror = "1" \ No newline at end of file diff --git a/crates/forge/src/link.rs b/crates/linking/src/lib.rs similarity index 99% rename from crates/forge/src/link.rs rename to crates/linking/src/lib.rs index 55f3f5487b3d..110a6d8f28b5 100644 --- a/crates/forge/src/link.rs +++ b/crates/linking/src/lib.rs @@ -1,3 +1,5 @@ +#![cfg_attr(not(test), warn(unused_crate_dependencies))] + use alloy_primitives::{Address, Bytes}; use foundry_compilers::{ artifacts::{CompactContractBytecode, Libraries},