diff --git a/ethers-solc/src/utils.rs b/ethers-solc/src/utils.rs index a5e5978c..c15a2697 100644 --- a/ethers-solc/src/utils.rs +++ b/ethers-solc/src/utils.rs @@ -341,6 +341,7 @@ pub fn create_parent_dir_all(file: impl AsRef) -> Result<(), SolcError> { #[cfg(test)] mod tests { use super::*; + use solang_parser::pt::SourceUnitPart; use std::{ collections::HashSet, fs::{create_dir_all, File}, @@ -383,6 +384,22 @@ mod tests { assert_eq!(files, expected); } + #[test] + fn can_parse_curly_bracket_imports() { + let s = + r#"import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";"#; + + let (unit, _) = solang_parser::parse(s, 0).unwrap(); + assert_eq!(unit.0.len(), 1); + match unit.0[0] { + SourceUnitPart::ImportDirective(_, _) => {} + _ => unreachable!("failed to parse import"), + } + let imports: Vec<_> = find_import_paths(s).map(|m| m.as_str()).collect(); + + assert_eq!(imports, vec!["@openzeppelin/contracts/utils/ReentrancyGuard.sol"]) + } + #[test] fn can_find_single_quote_imports() { let content = r#"