Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: extract linking logic to separate crate #7329

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
1 change: 1 addition & 0 deletions crates/forge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/script/build.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -11,6 +10,7 @@ use foundry_compilers::{
info::ContractInfo,
ArtifactId, Project, ProjectCompileOutput,
};
use foundry_linking::{LinkOutput, Linker};
use std::str::FromStr;

impl ScriptArgs {
Expand Down
3 changes: 2 additions & 1 deletion crates/forge/bin/cmd/script/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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};

Expand Down
2 changes: 0 additions & 2 deletions crates/forge/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ pub mod coverage;

pub mod gas_report;

pub mod link;

mod multi_runner;
pub use multi_runner::{MultiContractRunner, MultiContractRunnerBuilder};

Expand Down
7 changes: 2 additions & 5 deletions crates/forge/src/multi_runner.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -19,6 +15,7 @@ use foundry_evm::{
opts::EvmOpts,
revm,
};
use foundry_linking::{LinkOutput, Linker};
use rayon::prelude::*;
use revm::primitives::SpecId;
use std::{
Expand Down
17 changes: 17 additions & 0 deletions crates/linking/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions crates/forge/src/link.rs → crates/linking/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg_attr(not(test), warn(unused_crate_dependencies))]

use alloy_primitives::{Address, Bytes};
use foundry_compilers::{
artifacts::{CompactContractBytecode, Libraries},
Expand Down
Loading