Skip to content

Commit 0e5262d

Browse files
committed
fix(forge): same way to flatten for all commands
1 parent 1039517 commit 0e5262d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

crates/verify/src/etherscan/flatten.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{EtherscanSourceProvider, VerifyArgs};
22
use crate::provider::VerificationContext;
3-
use eyre::{Context, Result};
3+
use eyre::Result;
44
use foundry_block_explorers::verify::CodeFormat;
55
use foundry_compilers::{
66
AggregatedCompilerOutput,
@@ -10,6 +10,7 @@ use foundry_compilers::{
1010
Compiler, CompilerInput,
1111
solc::{SolcCompiler, SolcLanguage, SolcVersionedInput},
1212
},
13+
flatten::Flattener,
1314
solc::Solc,
1415
};
1516
use semver::{BuildMetadata, Version};
@@ -32,18 +33,18 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource {
3233
bch,
3334
);
3435

35-
let source = context
36-
.project
37-
.paths
38-
.clone()
39-
.with_language::<SolcLanguage>()
40-
.flatten(&context.target_path)
41-
.wrap_err("Failed to flatten contract")?;
36+
let flattener = Flattener::new(context.project.clone(), &context.target_path)
37+
.map_err(|err| eyre::eyre!("Failed to flatten: {err}"))?;
38+
let flattened = flattener.flatten();
4239

4340
if !args.force {
4441
// solc dry run of flattened code
45-
self.check_flattened(source.clone(), &context.compiler_version, &context.target_path)
46-
.map_err(|err| {
42+
self.check_flattened(
43+
flattened.clone(),
44+
&context.compiler_version,
45+
&context.target_path,
46+
)
47+
.map_err(|err| {
4748
eyre::eyre!(
4849
"Failed to compile the flattened code locally: `{}`\
4950
To skip this solc dry, have a look at the `--force` flag of this command.",
@@ -52,7 +53,7 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource {
5253
})?;
5354
}
5455

55-
Ok((source, context.target_name.clone(), CodeFormat::SingleFile))
56+
Ok((flattened, context.target_name.clone(), CodeFormat::SingleFile))
5657
}
5758
}
5859

0 commit comments

Comments
 (0)