Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(zk_toolbox): Use slug crate instead of self written function #2309

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
903 changes: 224 additions & 679 deletions yarn.lock

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions zk_toolbox/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions zk_toolbox/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ types = { path = "crates/types" }
# External dependencies
anyhow = "1.0.82"
clap = { version = "4.4", features = ["derive", "wrap_help"] }
slugify-rs = "0.0.3"
cliclack = "0.2.5"
console = "0.15.8"
ethers = "2.0"
Expand Down
10 changes: 4 additions & 6 deletions zk_toolbox/crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pub use prerequisites::check_prerequisites;
pub use prompt::{init_prompt_theme, Prompt, PromptConfirm, PromptSelect};
pub use term::{logger, spinner};

pub mod cmd;
pub mod config;
pub mod db;
Expand All @@ -7,11 +11,5 @@ pub mod files;
pub mod forge;
mod prerequisites;
mod prompt;
mod slugify;
mod term;
pub mod wallets;

pub use prerequisites::check_prerequisites;
pub use prompt::{init_prompt_theme, Prompt, PromptConfirm, PromptSelect};
pub use slugify::slugify;
pub use term::{logger, spinner};
3 changes: 0 additions & 3 deletions zk_toolbox/crates/common/src/slugify.rs

This file was deleted.

1 change: 1 addition & 0 deletions zk_toolbox/crates/zk_inception/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ strum.workspace = true
toml.workspace = true
url.workspace = true
thiserror.workspace = true
slugify-rs.workspace = true
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::{path::PathBuf, str::FromStr};

use clap::Parser;
use common::{slugify, Prompt, PromptConfirm, PromptSelect};
use common::{Prompt, PromptConfirm, PromptSelect};
use serde::{Deserialize, Serialize};
use slugify_rs::slugify;
use strum::IntoEnumIterator;
use strum_macros::{Display, EnumIter};
use types::{BaseToken, L1BatchCommitDataGeneratorMode, L1Network, ProverMode, WalletCreation};
Expand All @@ -26,7 +27,7 @@ use crate::{
pub struct ChainCreateArgs {
#[arg(long)]
pub chain_name: Option<String>,
#[arg(value_parser = clap::value_parser!(u32).range(1..))]
#[arg(value_parser = clap::value_parser ! (u32).range(1..))]
pub chain_id: Option<u32>,
#[clap(long, help = MSG_PROVER_MODE_HELP, value_enum)]
pub prover_mode: Option<ProverMode>,
Expand Down Expand Up @@ -55,7 +56,7 @@ impl ChainCreateArgs {
let mut chain_name = self
.chain_name
.unwrap_or_else(|| Prompt::new(MSG_CHAIN_NAME_PROMPT).ask());
chain_name = slugify(&chain_name);
chain_name = slugify!(&chain_name, separator = "_");

let chain_id = self.chain_id.unwrap_or_else(|| {
Prompt::new(MSG_CHAIN_ID_PROMPT)
Expand Down
29 changes: 18 additions & 11 deletions zk_toolbox/crates/zk_inception/src/commands/chain/args/genesis.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use clap::Parser;
use common::{db::DatabaseConfig, slugify, Prompt};
use common::{db::DatabaseConfig, Prompt};
use config::ChainConfig;
use serde::{Deserialize, Serialize};
use slugify_rs::slugify;
use url::Url;

use crate::{
Expand Down Expand Up @@ -48,21 +49,27 @@ impl GenesisArgs {
.default(DATABASE_SERVER_URL.as_str())
.ask()
});
let server_db_name = slugify(&self.server_db_name.unwrap_or_else(|| {
Prompt::new(&msg_server_db_name_prompt(&chain_name))
.default(&server_name)
.ask()
}));
let server_db_name = slugify!(
&self.server_db_name.unwrap_or_else(|| {
Prompt::new(&msg_server_db_name_prompt(&chain_name))
.default(&server_name)
.ask()
}),
separator = "_"
);
let prover_db_url = self.prover_db_url.unwrap_or_else(|| {
Prompt::new(&msg_prover_db_url_prompt(&chain_name))
.default(DATABASE_PROVER_URL.as_str())
.ask()
});
let prover_db_name = slugify(&self.prover_db_name.unwrap_or_else(|| {
Prompt::new(&msg_prover_db_name_prompt(&chain_name))
.default(&prover_name)
.ask()
}));
let prover_db_name = slugify!(
&self.prover_db_name.unwrap_or_else(|| {
Prompt::new(&msg_prover_db_name_prompt(&chain_name))
.default(&prover_name)
.ask()
}),
separator = "_"
);
GenesisArgsFinal {
server_db: DatabaseConfig::new(server_db_url, server_db_name),
prover_db: DatabaseConfig::new(prover_db_url, prover_db_name),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::path::PathBuf;

use clap::Parser;
use common::{slugify, Prompt, PromptConfirm, PromptSelect};
use common::{Prompt, PromptConfirm, PromptSelect};
use serde::{Deserialize, Serialize};
use slugify_rs::slugify;
use strum::IntoEnumIterator;
use strum_macros::EnumIter;
use types::{L1Network, WalletCreation};
Expand Down Expand Up @@ -37,7 +38,7 @@ impl EcosystemCreateArgs {
let mut ecosystem_name = self
.ecosystem_name
.unwrap_or_else(|| Prompt::new(MSG_ECOSYSTEM_NAME_PROMPT).ask());
ecosystem_name = slugify(&ecosystem_name);
ecosystem_name = slugify!(&ecosystem_name, separator = "_");

let link_to_code = self.link_to_code.unwrap_or_else(|| {
let link_to_code_selection =
Expand Down
Loading