@@ -19,17 +19,14 @@ use foundry_compilers::{
1919 solc:: SolcSettings ,
2020 Artifact , Project , ProjectBuilder , ProjectCompileOutput , ProjectPathsConfig , SolcConfig ,
2121} ;
22- use foundry_zksync_compilers:: {
23- compilers:: {
24- artifact_output:: zk:: ZkArtifactOutput ,
25- zksolc:: { ZkSolc , ZkSolcCompiler } ,
26- } ,
27- libraries:: { self , ZkMissingLibrary } ,
22+ use foundry_zksync_compilers:: compilers:: {
23+ artifact_output:: zk:: ZkArtifactOutput ,
24+ zksolc:: { ZkSolc , ZkSolcCompiler } ,
2825} ;
2926
3027use num_format:: { Locale , ToFormattedString } ;
3128use std:: {
32- collections:: { BTreeMap , HashSet } ,
29+ collections:: BTreeMap ,
3330 fmt:: Display ,
3431 io:: IsTerminal ,
3532 path:: { Path , PathBuf } ,
@@ -336,7 +333,7 @@ impl ProjectCompiler {
336333 let zksolc_version = ZkSolc :: get_version_for_path ( & project. compiler . zksolc ) ?;
337334 Report :: new ( SpinnerReporter :: spawn_with ( format ! ( "Using zksolc-{zksolc_version}" ) ) ) ;
338335 }
339- self . zksync_compile_with ( & project . paths . root , || {
336+ self . zksync_compile_with ( || {
340337 let files_to_compile =
341338 if !files. is_empty ( ) { files } else { project. paths . input_files ( ) } ;
342339 let sources = Source :: read_all ( files_to_compile) ?;
@@ -349,7 +346,6 @@ impl ProjectCompiler {
349346 #[ instrument( target = "forge::compile" , skip_all) ]
350347 fn zksync_compile_with < F > (
351348 self ,
352- root_path : impl AsRef < Path > ,
353349 f : F ,
354350 ) -> Result < ProjectCompileOutput < ZkSolcCompiler , ZkArtifactOutput > >
355351 where
@@ -394,7 +390,7 @@ impl ProjectCompiler {
394390 sh_println ! ( "{output}" ) ?;
395391 }
396392
397- self . zksync_handle_output ( root_path , & output) ?;
393+ self . zksync_handle_output ( & output) ?;
398394 }
399395
400396 Ok ( output)
@@ -403,71 +399,11 @@ impl ProjectCompiler {
403399 /// If configured, this will print sizes or names
404400 fn zksync_handle_output (
405401 & self ,
406- root_path : impl AsRef < Path > ,
407402 output : & ProjectCompileOutput < ZkSolcCompiler , ZkArtifactOutput > ,
408403 ) -> Result < ( ) > {
409404 let print_names = self . print_names . unwrap_or ( false ) ;
410405 let print_sizes = self . print_sizes . unwrap_or ( false ) ;
411406
412- // Process missing libraries
413- // TODO: skip this if project was not compiled using --detect-missing-libraries
414- let mut missing_libs_unique: HashSet < String > = HashSet :: new ( ) ;
415- for ( artifact_id, artifact) in output. artifact_ids ( ) {
416- // TODO: when compiling specific files, the output might still add cached artifacts
417- // that are not part of the file list to the output, which may cause missing libraries
418- // error to trigger for files that were not intended to be compiled.
419- // This behaviour needs to be investigated better on the foundry-compilers side.
420- // For now we filter, checking only the files passed to compile.
421- let is_target_file =
422- self . files . is_empty ( ) || self . files . iter ( ) . any ( |f| artifact_id. path == * f) ;
423- if is_target_file {
424- if let Some ( mls) = artifact. missing_libraries ( ) {
425- missing_libs_unique. extend ( mls. clone ( ) ) ;
426- }
427- }
428- }
429-
430- let missing_libs: Vec < ZkMissingLibrary > = missing_libs_unique
431- . into_iter ( )
432- . map ( |ml| {
433- let mut split = ml. split ( ':' ) ;
434- let contract_path =
435- split. next ( ) . expect ( "Failed to extract contract path for missing library" ) ;
436- let contract_name =
437- split. next ( ) . expect ( "Failed to extract contract name for missing library" ) ;
438-
439- let mut abs_path_buf = PathBuf :: new ( ) ;
440- abs_path_buf. push ( root_path. as_ref ( ) ) ;
441- abs_path_buf. push ( contract_path) ;
442-
443- let art = output. find ( abs_path_buf. as_path ( ) , contract_name) . unwrap_or_else ( || {
444- panic ! (
445- "Could not find contract {contract_name} at path {contract_path} for compilation output"
446- )
447- } ) ;
448-
449- ZkMissingLibrary {
450- contract_path : contract_path. to_string ( ) ,
451- contract_name : contract_name. to_string ( ) ,
452- missing_libraries : art. missing_libraries ( ) . cloned ( ) . unwrap_or_default ( ) ,
453- }
454- } )
455- . collect ( ) ;
456-
457- if !missing_libs. is_empty ( ) {
458- libraries:: add_dependencies_to_missing_libraries_cache (
459- root_path,
460- missing_libs. as_slice ( ) ,
461- )
462- . expect ( "Error while adding missing libraries" ) ;
463- let missing_libs_list = missing_libs
464- . iter ( )
465- . map ( |ml| format ! ( "{}:{}" , ml. contract_path, ml. contract_name) )
466- . collect :: < Vec < String > > ( )
467- . join ( ", " ) ;
468- eyre:: bail!( "Missing libraries detected: {missing_libs_list}\n \n Run the following command in order to deploy each missing library:\n \n forge create <LIBRARY> --private-key <PRIVATE_KEY> --rpc-url <RPC_URL> --chain <CHAIN_ID> --zksync\n \n Then pass the library addresses using the --libraries option" ) ;
469- }
470-
471407 // print any sizes or names
472408 if print_names {
473409 let mut artifacts: BTreeMap < _ , Vec < _ > > = BTreeMap :: new ( ) ;
0 commit comments