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

chore: use foundry fs #6158

Merged
merged 1 commit into from
Oct 28, 2023
Merged
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
7 changes: 5 additions & 2 deletions crates/forge/bin/cmd/script/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use foundry_cli::utils::get_cached_entry_by_name;
use foundry_common::{
compact_to_contract,
compile::{self, ContractSources},
fs,
};
use foundry_compilers::{
artifacts::{CompactContractBytecode, ContractBytecode, ContractBytecodeSome, Libraries},
Expand All @@ -14,7 +15,7 @@ use foundry_compilers::{
ArtifactId, Project, ProjectCompileOutput,
};
use foundry_utils::{PostLinkInput, ResolvedDependency};
use std::{collections::BTreeMap, fs, str::FromStr};
use std::{collections::BTreeMap, str::FromStr};
use tracing::{trace, warn};

impl ScriptArgs {
Expand Down Expand Up @@ -42,7 +43,9 @@ impl ScriptArgs {
.ast
.ok_or(eyre::eyre!("Source from artifact has no AST."))?
.absolute_path;
let source_code = fs::read_to_string(abs_path)?;
let source_code = fs::read_to_string(abs_path).wrap_err_with(|| {
format!("Failed to read artifact source file for `{}`", id.identifier())
})?;
let contract = artifact.clone().into_contract_bytecode();
let source_contract = compact_to_contract(contract)?;
sources
Expand Down