Skip to content

Commit

Permalink
feat(zk_toolbox): Dev command
Browse files Browse the repository at this point in the history
Signed-off-by: Danil <[email protected]>
  • Loading branch information
Deniallugo committed Jun 28, 2024
1 parent 3a8fed4 commit 090548e
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
46 changes: 31 additions & 15 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/args/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,22 @@ pub struct EcosystemArgs {
}

impl EcosystemArgs {
pub fn fill_values_with_prompt(self, l1_network: L1Network) -> EcosystemArgsFinal {
pub fn fill_values_with_prompt(self, l1_network: L1Network, dev: bool) -> EcosystemArgsFinal {
let deploy_ecosystem = self.deploy_ecosystem.unwrap_or_else(|| {
PromptConfirm::new(MSG_DEPLOY_ECOSYSTEM_PROMPT)
.default(true)
.ask()
if dev {
return true;
} else {
PromptConfirm::new(MSG_DEPLOY_ECOSYSTEM_PROMPT)
.default(true)
.ask()
}
});

let l1_rpc_url = self.l1_rpc_url.unwrap_or_else(|| {
let mut prompt = Prompt::new(MSG_L1_RPC_URL_PROMPT);
if dev {
return LOCAL_RPC_URL.to_string();
}
if l1_network == L1Network::Localhost {
prompt = prompt.default(LOCAL_RPC_URL);
}
Expand Down Expand Up @@ -81,27 +88,35 @@ pub struct EcosystemInitArgs {
#[clap(flatten, next_help_heading = MSG_GENESIS_ARGS_HELP)]
#[serde(flatten)]
pub genesis_args: GenesisArgs,
#[clap(long, help = "Deploy everything")]
pub dev: bool,
}

impl EcosystemInitArgs {
pub fn fill_values_with_prompt(self, l1_network: L1Network) -> EcosystemInitArgsFinal {
let deploy_paymaster = self.deploy_paymaster.unwrap_or_else(|| {
PromptConfirm::new(MSG_DEPLOY_PAYMASTER_PROMPT)
.default(true)
.ask()
});
let deploy_erc20 = self.deploy_erc20.unwrap_or_else(|| {
PromptConfirm::new(MSG_DEPLOY_ERC20_PROMPT)
.default(true)
.ask()
});
let ecosystem = self.ecosystem.fill_values_with_prompt(l1_network);
let (deploy_paymaster, deploy_erc20) = if self.dev {
(true, true)
} else {
let deploy_paymaster = self.deploy_paymaster.unwrap_or_else(|| {
PromptConfirm::new(MSG_DEPLOY_PAYMASTER_PROMPT)
.default(true)
.ask()
});
let deploy_erc20 = self.deploy_erc20.unwrap_or_else(|| {
PromptConfirm::new(MSG_DEPLOY_ERC20_PROMPT)
.default(true)
.ask()
});
(deploy_paymaster, deploy_erc20)
};
let ecosystem = self.ecosystem.fill_values_with_prompt(l1_network, self.dev);

EcosystemInitArgsFinal {
deploy_paymaster,
deploy_erc20,
ecosystem,
forge_args: self.forge_args.clone(),
dev: self.dev,
}
}
}
Expand All @@ -112,4 +127,5 @@ pub struct EcosystemInitArgsFinal {
pub deploy_erc20: bool,
pub ecosystem: EcosystemArgsFinal,
pub forge_args: ForgeScriptArgs,
pub dev: bool,
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ pub async fn run(args: EcosystemInitArgs, shell: &Shell) -> anyhow::Result<()> {
Err(_) => create_initial_deployments_config(shell, &ecosystem_config.config)?,
};

let genesis_args = args.genesis_args.clone();
let mut genesis_args = args.genesis_args.clone();
if args.dev {
genesis_args.use_default = true;
}
let mut final_ecosystem_args = args.fill_values_with_prompt(ecosystem_config.l1_network);

logger::info(MSG_INITIALIZING_ECOSYSTEM);
Expand Down

0 comments on commit 090548e

Please sign in to comment.