Skip to content

Commit b6e7c8b

Browse files
authored
refactor: extract linking logic to separate crate (foundry-rs#7329)
* refactor: extract linking logic to separate crate * fix cargo check
1 parent 938f848 commit b6e7c8b

File tree

9 files changed

+37
-9
lines changed

9 files changed

+37
-9
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ foundry-evm-traces = { path = "crates/evm/traces" }
133133
foundry-macros = { path = "crates/macros" }
134134
foundry-test-utils = { path = "crates/test-utils" }
135135
foundry-wallets = { path = "crates/wallets" }
136+
foundry-linking = { path = "crates/linking" }
136137

137138
# solc & compilation utilities
138139
foundry-block-explorers = { version = "0.2.3", default-features = false }

crates/forge/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ foundry-compilers = { workspace = true, features = ["full"] }
2525
foundry-config.workspace = true
2626
foundry-evm.workspace = true
2727
foundry-wallets.workspace = true
28+
foundry-linking.workspace = true
2829

2930
ethers-contract.workspace = true
3031
ethers-core.workspace = true

crates/forge/bin/cmd/script/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::{ScriptArgs, ScriptConfig};
22
use alloy_primitives::{Address, Bytes};
33
use eyre::{Context, ContextCompat, Result};
4-
use forge::link::{LinkOutput, Linker};
54
use foundry_cli::utils::get_cached_entry_by_name;
65
use foundry_common::compile::{self, ContractSources, ProjectCompiler};
76
use foundry_compilers::{
@@ -11,6 +10,7 @@ use foundry_compilers::{
1110
info::ContractInfo,
1211
ArtifactId, Project, ProjectCompileOutput,
1312
};
13+
use foundry_linking::{LinkOutput, Linker};
1414
use std::str::FromStr;
1515

1616
impl ScriptArgs {

crates/forge/bin/cmd/script/cmd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use alloy_primitives::{Address, Bytes};
77
use ethers_providers::Middleware;
88
use ethers_signers::Signer;
99
use eyre::{OptionExt, Result};
10-
use forge::{link::Linker, traces::CallTraceDecoder};
10+
use forge::traces::CallTraceDecoder;
1111
use foundry_cli::utils::LoadConfig;
1212
use foundry_common::{
1313
contracts::flatten_contracts, provider::ethers::try_get_http_provider, types::ToAlloy,
@@ -18,6 +18,7 @@ use foundry_compilers::{
1818
};
1919
use foundry_debugger::Debugger;
2020
use foundry_evm::inspectors::cheatcodes::{BroadcastableTransaction, ScriptWallets};
21+
use foundry_linking::Linker;
2122
use foundry_wallets::WalletSigner;
2223
use std::{collections::HashMap, sync::Arc};
2324

crates/forge/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ pub mod coverage;
1313

1414
pub mod gas_report;
1515

16-
pub mod link;
17-
1816
mod multi_runner;
1917
pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder};
2018

crates/forge/src/multi_runner.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
//! Forge test runner for multiple contracts.
22
3-
use crate::{
4-
link::{LinkOutput, Linker},
5-
result::SuiteResult,
6-
ContractRunner, TestFilter, TestOptions,
7-
};
3+
use crate::{result::SuiteResult, ContractRunner, TestFilter, TestOptions};
84
use alloy_json_abi::{Function, JsonAbi};
95
use alloy_primitives::{Address, Bytes, U256};
106
use eyre::Result;
@@ -19,6 +15,7 @@ use foundry_evm::{
1915
opts::EvmOpts,
2016
revm,
2117
};
18+
use foundry_linking::{LinkOutput, Linker};
2219
use rayon::prelude::*;
2320
use revm::primitives::SpecId;
2421
use std::{

crates/linking/Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "foundry-linking"
3+
description = "Smart contract linking tools"
4+
5+
version.workspace = true
6+
edition.workspace = true
7+
rust-version.workspace = true
8+
authors.workspace = true
9+
license.workspace = true
10+
homepage.workspace = true
11+
repository.workspace = true
12+
13+
[dependencies]
14+
foundry-compilers = { workspace = true, features = ["full"] }
15+
semver = "1"
16+
alloy-primitives = { workspace = true, features = ["rlp"] }
17+
thiserror = "1"

crates/forge/src/link.rs renamed to crates/linking/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
2+
13
use alloy_primitives::{Address, Bytes};
24
use foundry_compilers::{
35
artifacts::{CompactContractBytecode, Libraries},

0 commit comments

Comments
 (0)