From 8202db630bb5611ab70ffdd23afbe9323be781b9 Mon Sep 17 00:00:00 2001 From: Nisheeth Barthwal Date: Fri, 20 Sep 2024 16:09:22 +0200 Subject: [PATCH] feat: init forge project with zksync (#586) init forge project with zksync --- crates/forge/bin/cmd/init.rs | 13 ++++++++++++- crates/forge/bin/cmd/install.rs | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/forge/bin/cmd/init.rs b/crates/forge/bin/cmd/init.rs index 1882eca60..54d871158 100644 --- a/crates/forge/bin/cmd/init.rs +++ b/crates/forge/bin/cmd/init.rs @@ -44,7 +44,7 @@ pub struct InitArgs { impl InitArgs { pub fn run(self) -> Result<()> { let Self { root, template, branch, opts, offline, force, vscode } = self; - let DependencyInstallOpts { shallow, no_git, no_commit, quiet } = opts; + let DependencyInstallOpts { shallow, no_git, no_commit, quiet, zksync } = opts; // create the root dir if it does not exist if !root.exists() { @@ -153,6 +153,17 @@ impl InitArgs { } } + // install forge-zksync-std + if zksync && !offline { + if root.join("lib/forge-zksync-std").exists() { + p_println!(!quiet => "\"lib/forge-zksync-std\" already exists, skipping install...."); + self.opts.install(&mut config, vec![])?; + } else { + let dep = "https://github.com/Moonsong-Labs/forge-zksync-std".parse()?; + self.opts.install(&mut config, vec![dep])?; + } + } + // init vscode settings if vscode { init_vscode(&root)?; diff --git a/crates/forge/bin/cmd/install.rs b/crates/forge/bin/cmd/install.rs index 57096f859..77fad0282 100644 --- a/crates/forge/bin/cmd/install.rs +++ b/crates/forge/bin/cmd/install.rs @@ -81,6 +81,10 @@ pub struct DependencyInstallOpts { /// Do not print any messages. #[arg(short, long)] pub quiet: bool, + + /// Install ZKsync specific libraries. + #[arg(long)] + pub zksync: bool, } impl DependencyInstallOpts {