1
1
use super :: { EtherscanSourceProvider , VerifyArgs } ;
2
2
use crate :: provider:: VerificationContext ;
3
- use eyre:: { Context , Result } ;
3
+ use eyre:: Result ;
4
4
use foundry_block_explorers:: verify:: CodeFormat ;
5
5
use foundry_compilers:: {
6
6
AggregatedCompilerOutput ,
@@ -10,6 +10,7 @@ use foundry_compilers::{
10
10
Compiler , CompilerInput ,
11
11
solc:: { SolcCompiler , SolcLanguage , SolcVersionedInput } ,
12
12
} ,
13
+ flatten:: Flattener ,
13
14
solc:: Solc ,
14
15
} ;
15
16
use semver:: { BuildMetadata , Version } ;
@@ -32,18 +33,18 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource {
32
33
bch,
33
34
) ;
34
35
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 ( ) ;
42
39
43
40
if !args. force {
44
41
// 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| {
47
48
eyre:: eyre!(
48
49
"Failed to compile the flattened code locally: `{}`\
49
50
To skip this solc dry, have a look at the `--force` flag of this command.",
@@ -52,7 +53,7 @@ impl EtherscanSourceProvider for EtherscanFlattenedSource {
52
53
} ) ?;
53
54
}
54
55
55
- Ok ( ( source , context. target_name . clone ( ) , CodeFormat :: SingleFile ) )
56
+ Ok ( ( flattened , context. target_name . clone ( ) , CodeFormat :: SingleFile ) )
56
57
}
57
58
}
58
59
0 commit comments