Skip to content

Commit

Permalink
refactor(chisel): remove 'errored', make session_source non-optional (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jan 16, 2024
1 parent e4de7b7 commit f8dfd2c
Show file tree
Hide file tree
Showing 6 changed files with 290 additions and 359 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/chisel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ vergen = { version = "8", default-features = false, features = ["build", "git",
[dependencies]
# forge
forge-fmt.workspace = true
foundry-block-explorers.workspace = true
foundry-cli.workspace = true
foundry-common.workspace = true
foundry-compilers = { workspace = true, features = ["project-util", "full"] }
Expand Down
11 changes: 6 additions & 5 deletions crates/chisel/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,6 @@ async fn main() -> eyre::Result<()> {
// Variable based on status of the last entry
let prompt = dispatcher.get_prompt();

rl.helper_mut().unwrap().set_errored(dispatcher.errored);

// Read the next line
let next_string = rl.readline(prompt.as_ref());

Expand All @@ -195,7 +193,8 @@ async fn main() -> eyre::Result<()> {
interrupt = false;

// Dispatch and match results
dispatch_repl_line(&mut dispatcher, &line).await;
let errored = dispatch_repl_line(&mut dispatcher, &line).await;
rl.helper_mut().unwrap().set_errored(errored);
}
Err(ReadlineError::Interrupted) => {
if interrupt {
Expand Down Expand Up @@ -232,8 +231,9 @@ impl Provider for ChiselParser {
}

/// Evaluate a single Solidity line.
async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) {
match dispatcher.dispatch(line).await {
async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) -> bool {
let r = dispatcher.dispatch(line).await;
match &r {
DispatchResult::Success(msg) | DispatchResult::CommandSuccess(msg) => {
debug!(%line, ?msg, "dispatch success");
if let Some(msg) = msg {
Expand All @@ -249,6 +249,7 @@ async fn dispatch_repl_line(dispatcher: &mut ChiselDispatcher, line: &str) {
DispatchResult::CommandFailed(msg) | DispatchResult::Failure(Some(msg)) => eprintln!("{}", Paint::red(msg)),
DispatchResult::Failure(None) => eprintln!("{}\nPlease Report this bug as a github issue if it persists: https://github.com/foundry-rs/foundry/issues/new/choose", Paint::red("⚒️ Unknown Chisel Error ⚒️")),
}
r.is_error()
}

/// Evaluate multiple Solidity source files contained within a
Expand Down
Loading

0 comments on commit f8dfd2c

Please sign in to comment.