Skip to content

Commit

Permalink
zk fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dimazhornyk committed May 30, 2024
1 parent 0c0cd75 commit ae91f3f
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 56 deletions.
6 changes: 4 additions & 2 deletions zk_toolbox/crates/zk_inception/src/accept_ownership.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::messages::MSG_ACCEPTING_GOVERNANCE_SPINNER;
use common::{
forge::{Forge, ForgeScript, ForgeScriptArgs},
spinner::Spinner,
Expand All @@ -13,7 +12,10 @@ use config::{
use ethers::types::{Address, H256};
use xshell::Shell;

use crate::forge_utils::{check_the_balance, fill_forge_private_key};
use crate::{
forge_utils::{check_the_balance, fill_forge_private_key},
messages::MSG_ACCEPTING_GOVERNANCE_SPINNER,
};

pub async fn accept_admin(
shell: &Shell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use config::{ChainConfig, DatabaseConfig, DatabasesConfig};
use serde::{Deserialize, Serialize};
use url::Url;

use crate::defaults::{generate_db_names, DBNames, DATABASE_PROVER_URL, DATABASE_SERVER_URL};
use crate::messages::{
msg_prover_db_name_prompt, msg_prover_db_url_prompt, msg_server_db_name_prompt,
msg_server_db_url_prompt, MSG_GENESIS_USE_DEFAULT_HELP, MSG_PROVER_DB_NAME_HELP,
MSG_PROVER_DB_URL_HELP, MSG_SERVER_DB_NAME_HELP, MSG_SERVER_DB_URL_HELP,
use crate::{
defaults::{generate_db_names, DBNames, DATABASE_PROVER_URL, DATABASE_SERVER_URL},
messages::{
msg_prover_db_name_prompt, msg_prover_db_url_prompt, msg_server_db_name_prompt,
msg_server_db_url_prompt, MSG_GENESIS_USE_DEFAULT_HELP, MSG_PROVER_DB_NAME_HELP,
MSG_PROVER_DB_URL_HELP, MSG_SERVER_DB_NAME_HELP, MSG_SERVER_DB_URL_HELP,
},
};

#[derive(Debug, Clone, Serialize, Deserialize, Parser, Default)]
Expand Down
11 changes: 7 additions & 4 deletions zk_toolbox/crates/zk_inception/src/commands/chain/args/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ use types::L1Network;
use url::Url;

use super::genesis::GenesisArgsFinal;
use crate::messages::{
MSG_DEPLOY_PAYMASTER_PROMPT, MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP,
MSG_L1_RPC_URL_INVALID_ERR, MSG_L1_RPC_URL_PROMPT,
use crate::{
commands::chain::args::genesis::GenesisArgs,
defaults::LOCAL_RPC_URL,
messages::{
MSG_DEPLOY_PAYMASTER_PROMPT, MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP,
MSG_L1_RPC_URL_INVALID_ERR, MSG_L1_RPC_URL_PROMPT,
},
};
use crate::{commands::chain::args::genesis::GenesisArgs, defaults::LOCAL_RPC_URL};

#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
pub struct InitArgs {
Expand Down
12 changes: 7 additions & 5 deletions zk_toolbox/crates/zk_inception/src/commands/chain/create.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use std::cell::OnceCell;

use crate::messages::{
MSG_CHAIN_CREATED, MSG_CREATING_CHAIN, MSG_CREATING_CHAIN_CONFIGURATIONS_SPINNER,
MSG_SELECTED_CONFIG,
};
use common::{logger, spinner::Spinner};
use config::{
create_local_configs_dir, create_wallets, traits::SaveConfigWithBasePath, ChainConfig,
Expand All @@ -12,7 +8,13 @@ use config::{
use types::ChainId;
use xshell::Shell;

use crate::commands::chain::args::create::{ChainCreateArgs, ChainCreateArgsFinal};
use crate::{
commands::chain::args::create::{ChainCreateArgs, ChainCreateArgsFinal},
messages::{
MSG_CHAIN_CREATED, MSG_CREATING_CHAIN, MSG_CREATING_CHAIN_CONFIGURATIONS_SPINNER,
MSG_SELECTED_CONFIG,
},
};

pub fn run(args: ChainCreateArgs, shell: &Shell) -> anyhow::Result<()> {
let mut ecosystem_config = EcosystemConfig::from_file(shell)?;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::messages::{MSG_CHAIN_NOT_INITIALIZED, MSG_DEPLOYING_PAYMASTER};
use anyhow::Context;
use common::{
config::global_config,
Expand All @@ -18,6 +17,7 @@ use xshell::Shell;
use crate::{
config_manipulations::update_paymaster,
forge_utils::{check_the_balance, fill_forge_private_key},
messages::{MSG_CHAIN_NOT_INITIALIZED, MSG_DEPLOYING_PAYMASTER},
};

pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {
Expand Down
5 changes: 2 additions & 3 deletions zk_toolbox/crates/zk_inception/src/commands/chain/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ use config::{
use xshell::Shell;

use super::args::init::InitArgsFinal;
use crate::messages::{MSG_CHAIN_NOT_FOUND_ERR, MSG_SELECTED_CONFIG};
use crate::{
accept_ownership::accept_admin,
commands::chain::{
Expand All @@ -27,8 +26,8 @@ use crate::{
forge_utils::{check_the_balance, fill_forge_private_key},
messages::{
msg_initializing_chain, MSG_ACCEPTING_ADMIN_SPINNER, MSG_CHAIN_INITIALIZED,
MSG_CONTRACTS_CONFIG_NOT_FOUND_ERR, MSG_GENESIS_DATABASE_ERR,
MSG_REGISTERING_CHAIN_SPINNER,
MSG_CHAIN_NOT_FOUND_ERR, MSG_CONTRACTS_CONFIG_NOT_FOUND_ERR, MSG_GENESIS_DATABASE_ERR,
MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG,
},
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::path::Path;

use crate::messages::{MSG_CHAIN_NOT_INITIALIZED, MSG_INITIALIZING_BRIDGES_SPINNER};
use anyhow::Context;
use common::{
cmd::Cmd,
Expand All @@ -21,6 +20,7 @@ use xshell::{cmd, Shell};
use crate::{
config_manipulations::update_l2_shared_bridge,
forge_utils::{check_the_balance, fill_forge_private_key},
messages::{MSG_CHAIN_NOT_INITIALIZED, MSG_INITIALIZING_BRIDGES_SPINNER},
};

pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use common::{slugify, Prompt, PromptConfirm, PromptSelect};
use serde::{Deserialize, Serialize};
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use types::{L1Network, WalletCreation};

use crate::{
commands::chain::{args::create::ChainCreateArgs, ChainCreateArgsFinal},
Expand All @@ -15,7 +16,6 @@ use crate::{
MSG_START_CONTAINERS_PROMPT,
},
};
use types::{L1Network, WalletCreation};

#[derive(Debug, Serialize, Deserialize, Parser)]
pub struct EcosystemCreateArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ use serde::{Deserialize, Serialize};
use types::L1Network;
use url::Url;

use crate::messages::{
MSG_DEPLOY_ECOSYSTEM_PROMPT, MSG_DEPLOY_ERC20_PROMPT, MSG_DEPLOY_PAYMASTER_PROMPT,
MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, MSG_L1_RPC_URL_PROMPT,
use crate::{
commands::chain::args::genesis::GenesisArgs,
defaults::LOCAL_RPC_URL,
messages::{
MSG_DEPLOY_ECOSYSTEM_PROMPT, MSG_DEPLOY_ERC20_PROMPT, MSG_DEPLOY_PAYMASTER_PROMPT,
MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR,
MSG_L1_RPC_URL_PROMPT,
},
};
use crate::{commands::chain::args::genesis::GenesisArgs, defaults::LOCAL_RPC_URL};

#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
pub struct EcosystemArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use common::PromptSelect;
use config::{traits::SaveConfigWithBasePath, EcosystemConfig};
use xshell::Shell;

use crate::commands::ecosystem::args::change_default::ChangeDefaultChain;
use crate::messages::{msg_chain_doesnt_exist_err, MSG_DEFAULT_CHAIN_PROMPT};
use crate::{
commands::ecosystem::args::change_default::ChangeDefaultChain,
messages::{msg_chain_doesnt_exist_err, MSG_DEFAULT_CHAIN_PROMPT},
};

pub fn run(args: ChangeDefaultChain, shell: &Shell) -> anyhow::Result<()> {
let mut ecosystem_config = EcosystemConfig::from_file(shell)?;
Expand Down
28 changes: 15 additions & 13 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@ use config::{
};
use xshell::{cmd, Shell};

use crate::commands::ecosystem::{
args::create::EcosystemCreateArgs,
create_configs::{create_erc20_deployment_config, create_initial_deployments_config},
};
use crate::commands::{
chain::create_chain_inner,
containers::{initialize_docker, start_containers},
};
use crate::messages::{
MSG_CLONING_ERA_REPO_SPINNER, MSG_CREATED_ECOSYSTEM, MSG_CREATING_DEFAULT_CHAIN_SPINNER,
MSG_CREATING_ECOSYSTEM, MSG_CREATING_INITIAL_CONFIGURATIONS_SPINNER,
MSG_ECOSYSTEM_ALREADY_EXISTS_ERR, MSG_ECOSYSTEM_CONFIG_INVALID_ERR, MSG_SELECTED_CONFIG,
MSG_STARTING_CONTAINERS_SPINNER,
use crate::{
commands::{
chain::create_chain_inner,
containers::{initialize_docker, start_containers},
ecosystem::{
args::create::EcosystemCreateArgs,
create_configs::{create_erc20_deployment_config, create_initial_deployments_config},
},
},
messages::{
MSG_CLONING_ERA_REPO_SPINNER, MSG_CREATED_ECOSYSTEM, MSG_CREATING_DEFAULT_CHAIN_SPINNER,
MSG_CREATING_ECOSYSTEM, MSG_CREATING_INITIAL_CONFIGURATIONS_SPINNER,
MSG_ECOSYSTEM_ALREADY_EXISTS_ERR, MSG_ECOSYSTEM_CONFIG_INVALID_ERR, MSG_SELECTED_CONFIG,
MSG_STARTING_CONTAINERS_SPINNER,
},
};

pub fn run(args: EcosystemCreateArgs, shell: &Shell) -> anyhow::Result<()> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::path::Path;

use xshell::Shell;

use crate::messages::{MSG_SAVE_ERC20_CONFIG_ATTENTION, MSG_SAVE_INITIAL_CONFIG_ATTENTION};
use config::{
forge_interface::deploy_ecosystem::input::{Erc20DeploymentConfig, InitialDeploymentConfig},
traits::SaveConfigWithCommentAndBasePath,
};
use xshell::Shell;

use crate::messages::{MSG_SAVE_ERC20_CONFIG_ATTENTION, MSG_SAVE_INITIAL_CONFIG_ATTENTION};

pub fn create_initial_deployments_config(
shell: &Shell,
Expand Down
13 changes: 7 additions & 6 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ use std::{
str::FromStr,
};

use crate::messages::{
msg_ecosystem_initialized, 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, MSG_INITIALIZING_ECOSYSTEM, MSG_INTALLING_DEPS_SPINNER,
};
use anyhow::Context;
use common::{
cmd::Cmd,
Expand Down Expand Up @@ -48,6 +42,13 @@ use crate::{
},
consts::AMOUNT_FOR_DISTRIBUTION_TO_WALLETS,
forge_utils::{check_the_balance, fill_forge_private_key},
messages::{
msg_ecosystem_initialized, 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,
MSG_INITIALIZING_ECOSYSTEM, MSG_INTALLING_DEPS_SPINNER,
},
};

pub async fn run(args: EcosystemInitArgs, shell: &Shell) -> anyhow::Result<()> {
Expand Down
7 changes: 5 additions & 2 deletions zk_toolbox/crates/zk_inception/src/forge_utils.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use crate::messages::{msg_address_doesnt_have_enough_money_prompt, MSG_DEPLOYER_PK_NOT_SET_ERR};
use anyhow::anyhow;
use common::forge::ForgeScript;
use ethers::types::{H256, U256};
use crate::consts::MINIMUM_BALANCE_FOR_WALLET;

use crate::{
consts::MINIMUM_BALANCE_FOR_WALLET,
messages::{msg_address_doesnt_have_enough_money_prompt, MSG_DEPLOYER_PK_NOT_SET_ERR},
};

pub fn fill_forge_private_key(
mut forge: ForgeScript,
Expand Down
2 changes: 1 addition & 1 deletion zk_toolbox/crates/zk_inception/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ pub mod accept_ownership;
mod commands;
mod config_manipulations;
mod consts;
mod messages;
mod defaults;
pub mod forge_utils;
mod messages;
pub mod server;

#[derive(Parser, Debug)]
Expand Down
6 changes: 3 additions & 3 deletions zk_toolbox/crates/zk_inception/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::path::PathBuf;

use anyhow::Context;
use common::cmd::Cmd;
use xshell::{cmd, Shell};

use crate::messages::MSG_FAILED_TO_RUN_SERVER_ERR;
use config::{
traits::FileConfigWithDefaultName, ChainConfig, ContractsConfig, GeneralConfig, GenesisConfig,
SecretsConfig, WalletsConfig,
};
use xshell::{cmd, Shell};

use crate::messages::MSG_FAILED_TO_RUN_SERVER_ERR;

pub struct RunServer {
components: Option<Vec<String>>,
Expand Down

0 comments on commit ae91f3f

Please sign in to comment.