Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ _
.vite
.wrangler
build
*.zip
*.zip
93 changes: 51 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ foundry-block-explorers = { version = "0.22.0", default-features = false }
foundry-compilers = { version = "0.19.1", default-features = false }
foundry-fork-db = "0.18"
solang-parser = { version = "=0.3.9", package = "foundry-solang-parser" }
solar = { package = "solar-compiler", version = "=0.1.6", default-features = false }
# TODO: remove in next solar release: https://github.com/paradigmxyz/solar/pull/444
solar-interface = { version = "=0.1.6", default-features = false }
solar = { package = "solar-compiler", version = "=0.1.7", default-features = false }

## alloy
alloy-consensus = { version = "1.0.23", default-features = false }
Expand Down Expand Up @@ -415,7 +413,7 @@ rexpect = { git = "https://github.com/rust-cli/rexpect", rev = "2ed0b1898d7edaf6

## foundry
# foundry-block-explorers = { git = "https://github.com/foundry-rs/block-explorers.git", rev = "f5b46b2" }
# foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", rev = "e4a9b04" }
# foundry-compilers = { git = "https://github.com/foundry-rs/compilers.git", branch = "dani/bump-solar" }
# foundry-fork-db = { git = "https://github.com/foundry-rs/foundry-fork-db", rev = "eee6563" }

## solar
Expand Down
14 changes: 7 additions & 7 deletions crates/chisel/src/solidity_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,19 @@ impl SolidityHelper {
let mut stack = vec![];
for token in Cursor::new(input) {
match token.kind {
OpenParen | OpenBrace | OpenBracket => stack.push(token.kind),
CloseParen | CloseBrace | CloseBracket => match (stack.pop(), token.kind) {
(Some(OpenParen), CloseParen)
| (Some(OpenBrace), CloseBrace)
| (Some(OpenBracket), CloseBracket) => {}
OpenDelim(delim) => stack.push(delim),
CloseDelim(delim) => match (stack.pop(), delim) {
(Some(open), close) if open == close => {}
(Some(wanted), _) => {
let wanted = wanted.to_open_str();
return ValidationResult::Invalid(Some(format!(
"Mismatched brackets: {wanted:?} is not properly closed"
"Mismatched brackets: `{wanted}` is not properly closed"
)));
}
(None, c) => {
let c = c.to_close_str();
return ValidationResult::Invalid(Some(format!(
"Mismatched brackets: {c:?} is unpaired"
"Mismatched brackets: `{c}` is unpaired"
)));
}
},
Expand Down
10 changes: 10 additions & 0 deletions crates/common/src/errors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ fn all_sources<E: private::ErrorChain + ?Sized>(err: &E) -> Vec<String> {
err.chain().map(|cause| cause.to_string().trim().to_string()).collect()
}

/// Converts solar errors to an eyre error.
pub fn convert_solar_errors(dcx: &solar::interface::diagnostics::DiagCtxt) -> eyre::Result<()> {
match dcx.emitted_errors() {
Some(Ok(())) => Ok(()),
Some(Err(e)) if !e.is_empty() => eyre::bail!("solar run failed:\n\n{e}"),
_ if dcx.has_errors().is_err() => eyre::bail!("solar run failed"),
_ => Ok(()),
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
7 changes: 4 additions & 3 deletions crates/common/src/preprocessor/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::errors::convert_solar_errors;
use foundry_compilers::{
Compiler, ProjectPathsConfig, SourceParser, apply_updates,
artifacts::SolcLanguage,
Expand All @@ -22,7 +23,7 @@ use deps::{PreprocessorDependencies, remove_bytecode_dependencies};
/// Returns the range of the given span in the source map.
#[track_caller]
fn span_to_range(source_map: &SourceMap, span: Span) -> Range<usize> {
source_map.span_to_source(span).unwrap().1
source_map.span_to_range(span).unwrap()
}

/// Preprocessor that replaces static bytecode linking in tests and scripts (`new Contract`) with
Expand Down Expand Up @@ -97,8 +98,8 @@ impl Preprocessor<SolcCompiler> for DynamicTestLinkingPreprocessor {
});

// Warn if any diagnostics emitted during content parsing.
if let Err(err) = compiler.sess().emitted_errors().unwrap() {
warn!("failed preprocessing:\n{err}");
if let Err(err) = convert_solar_errors(compiler.dcx()) {
warn!(%err, "failed preprocessing");
}

Ok(())
Expand Down
Loading
Loading