Skip to content

Commit

Permalink
Merge branch 'main' into elfedy-gas-params
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrigada authored Dec 11, 2024
2 parents e47f7bc + c9def31 commit 43df077
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
16 changes: 15 additions & 1 deletion crates/forge/bin/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl InitArgs {
}
}

// install forge-zksync-std
// NOTE(zk): install forge-zksync-std
if zksync && !offline {
if root.join("lib/forge-zksync-std").exists() {
sh_println!("\"lib/forge-zksync-std\" already exists, skipping install....")?;
Expand All @@ -161,6 +161,20 @@ impl InitArgs {
let dep = "https://github.com/Moonsong-Labs/forge-zksync-std".parse()?;
self.opts.install(&mut config, vec![dep])?;
}

//Add zkout/ to .gitignore under compiler files if it doesn't exist
let gitignore_path = root.join(".gitignore");
if gitignore_path.exists() {
let mut content = fs::read_to_string(&gitignore_path)?;
if !content.contains("zkout/") {
// Find the compiler files section and add zkout/
if let Some(pos) = content.find("out/") {
let insert_pos = pos + "out/".len();
content.insert_str(insert_pos, "\nzkout/");
fs::write(&gitignore_path, content)?;
}
}
}
}

// init vscode settings
Expand Down
13 changes: 13 additions & 0 deletions crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3203,3 +3203,16 @@ forgetest_init!(gas_report_include_tests, |prj, cmd| {
.is_json(),
);
});

forgetest_init!(zk_can_init_with_zksync, |prj, cmd| {
cmd.args(["init", "--zksync", "--force"]).assert_success();

// Check that zkout/ is in .gitignore
let gitignore_path = prj.root().join(".gitignore");
assert!(gitignore_path.exists());
let gitignore_contents = std::fs::read_to_string(&gitignore_path).unwrap();
assert!(gitignore_contents.contains("zkout/"));

// Assert that forge-zksync-std is installed
assert!(prj.root().join("lib/forge-zksync-std").exists());
});

0 comments on commit 43df077

Please sign in to comment.