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

Adds import callback resolution to resolc compiler #146

Closed
wants to merge 2 commits into from
Closed
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
16 changes: 14 additions & 2 deletions crates/solidity/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub use self::warning::Warning;
pub mod test_utils;
pub mod tests;

use std::collections::BTreeSet;
use std::collections::{BTreeMap, BTreeSet};
use std::path::PathBuf;

/// Runs the Yul mode.
Expand Down Expand Up @@ -149,7 +149,7 @@ pub fn standard_output<T: Compiler>(
suppressed_warnings,
)?;

let source_code_files = solc_input
let mut source_code_files: BTreeMap<String, String> = solc_input
.sources
.iter()
.map(|(path, source)| (path.to_owned(), source.content.to_owned()))
Expand Down Expand Up @@ -180,6 +180,18 @@ pub fn standard_output<T: Compiler>(
}
}

// load import callbacks unspecified in input
if let Some(sources) = &solc_output.sources {
for source_path in sources.keys() {
if !source_code_files.contains_key(source_path) {
let source = std::fs::read_to_string(source_path).map_err(|e| {
anyhow::anyhow!("Can't read source file at `{}`: {}", source_path, e)
})?;
let _ = source_code_files.insert(source_path.clone(), source);
}
}
}

let project = solc_output.try_to_project(
source_code_files,
libraries,
Expand Down