Skip to content

Commit

Permalink
add a error msg for preexisting contract config no exists
Browse files Browse the repository at this point in the history
  • Loading branch information
fyInALT committed Aug 14, 2024
1 parent dd911fa commit 28f7dab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
28 changes: 21 additions & 7 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ use crate::{
},
consts::AMOUNT_FOR_DISTRIBUTION_TO_WALLETS,
messages::{
msg_ecosystem_initialized, msg_initializing_chain, MSG_CHAIN_NOT_INITIALIZED,
msg_ecosystem_initialized, msg_ecosystem_no_found_preexisting_contract,
msg_initializing_chain, MSG_CHAIN_NOT_INITIALIZED,
MSG_DEPLOYING_ECOSYSTEM_CONTRACTS_SPINNER, MSG_DEPLOYING_ERC20,
MSG_DEPLOYING_ERC20_SPINNER, MSG_DISTRIBUTING_ETH_SPINNER,
MSG_ECOSYSTEM_CONTRACTS_PATH_INVALID_ERR, MSG_ECOSYSTEM_CONTRACTS_PATH_PROMPT,
Expand Down Expand Up @@ -276,17 +277,30 @@ async fn deploy_ecosystem(
}
};

let ecosystem_preexisting_configs_path =
ecosystem_config
.get_preexisting_configs_path()
.join(format!(
"{}.yaml",
ecosystem_config.l1_network.to_string().to_lowercase()
));

// currently there are not some preexisting ecosystem contracts in
// chains, so we need check if this file exists.
if ecosystem_contracts_path.is_none() && !ecosystem_preexisting_configs_path.exists() {
anyhow::bail!(msg_ecosystem_no_found_preexisting_contract(
&ecosystem_config.l1_network.to_string()
))
}

let ecosystem_contracts_path =
ecosystem_contracts_path.unwrap_or_else(|| match ecosystem_config.l1_network {
L1Network::Localhost => {
ContractsConfig::get_path_with_base_path(&ecosystem_config.config)
}
L1Network::Sepolia | L1Network::Holesky | L1Network::Mainnet => ecosystem_config
.get_preexisting_configs_path()
.join(format!(
"{}.yaml",
ecosystem_config.l1_network.to_string().to_lowercase()
)),
L1Network::Sepolia | L1Network::Holesky | L1Network::Mainnet => {
ecosystem_preexisting_configs_path
}
});

ContractsConfig::read(shell, ecosystem_contracts_path)
Expand Down
4 changes: 4 additions & 0 deletions zk_toolbox/crates/zk_inception/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ pub(super) const MSG_ERA_OBSERVABILITY_ALREADY_SETUP: &str = "Era observability
pub(super) const MSG_DOWNLOADING_ERA_OBSERVABILITY_SPINNER: &str =
"Downloading era observability...";

pub(super) fn msg_ecosystem_no_found_preexisting_contract(chains: &str) -> String {
format!("Not found preexisting ecosystem Contracts with chains {chains}")
}

pub(super) fn msg_initializing_chain(chain_name: &str) -> String {
format!("Initializing chain {chain_name}")
}
Expand Down

0 comments on commit 28f7dab

Please sign in to comment.