-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
859ce92
commit 3b09f5b
Showing
15 changed files
with
424 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6903,7 +6903,7 @@ jest-each@^29.7.0: | |
jest-util "^29.7.0" | ||
pretty-format "^29.7.0" | ||
|
||
jest-environment-node@^29.7.0: | ||
jest-environment-node@^29.0.3, jest-environment-node@^29.7.0: | ||
version "29.7.0" | ||
resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-29.7.0.tgz#0b93e111dda8ec120bc8300e6d1fb9576e164376" | ||
integrity sha512-DOSwCRqXirTOyheM+4d5YZOrWcdu0LNZ87ewUoywbcb2XR4wKgqiG8vNeYwhjFMbEkfju7wx2GYH0P2gevGvFw== | ||
|
@@ -9816,7 +9816,7 @@ string-length@^4.0.1: | |
char-regex "^1.0.2" | ||
strip-ansi "^6.0.0" | ||
|
||
"string-width-cjs@npm:string-width@^4.2.0": | ||
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: | ||
version "4.2.3" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" | ||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== | ||
|
@@ -9833,15 +9833,6 @@ string-width@^2.1.0, string-width@^2.1.1: | |
is-fullwidth-code-point "^2.0.0" | ||
strip-ansi "^4.0.0" | ||
|
||
string-width@^4.0.0, string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.2, string-width@^4.2.3: | ||
version "4.2.3" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010" | ||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g== | ||
dependencies: | ||
emoji-regex "^8.0.0" | ||
is-fullwidth-code-point "^3.0.0" | ||
strip-ansi "^6.0.1" | ||
|
||
string-width@^5.0.1, string-width@^5.1.2: | ||
version "5.1.2" | ||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-5.1.2.tgz#14f8daec6d81e7221d2a357e668cab73bdbca794" | ||
|
@@ -9908,7 +9899,7 @@ string_decoder@~1.1.1: | |
dependencies: | ||
safe-buffer "~5.1.0" | ||
|
||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1": | ||
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1: | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" | ||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== | ||
|
@@ -9929,13 +9920,6 @@ strip-ansi@^5.1.0: | |
dependencies: | ||
ansi-regex "^4.1.0" | ||
|
||
strip-ansi@^6.0.0, strip-ansi@^6.0.1: | ||
version "6.0.1" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9" | ||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A== | ||
dependencies: | ||
ansi-regex "^5.0.1" | ||
|
||
strip-ansi@^7.0.1: | ||
version "7.1.0" | ||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45" | ||
|
@@ -10781,16 +10765,7 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343" | ||
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw== | ||
|
||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0": | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" | ||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | ||
dependencies: | ||
ansi-styles "^4.0.0" | ||
string-width "^4.1.0" | ||
strip-ansi "^6.0.0" | ||
|
||
wrap-ansi@^7.0.0: | ||
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0: | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43" | ||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
zk_toolbox/crates/zk_inception/src/commands/chain/args/init_configs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use clap::Parser; | ||
use common::Prompt; | ||
use config::ChainConfig; | ||
use serde::{Deserialize, Serialize}; | ||
use types::L1Network; | ||
use url::Url; | ||
|
||
use super::{genesis::GenesisArgsFinal, init::InitArgsFinal}; | ||
use crate::{ | ||
commands::chain::args::{genesis::GenesisArgs, init::PortOffset}, | ||
defaults::LOCAL_RPC_URL, | ||
messages::{ | ||
MSG_GENESIS_ARGS_HELP, MSG_L1_RPC_URL_HELP, MSG_L1_RPC_URL_INVALID_ERR, | ||
MSG_L1_RPC_URL_PROMPT, | ||
}, | ||
}; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, Parser)] | ||
pub struct InitConfigsArgs { | ||
#[clap(flatten, next_help_heading = MSG_GENESIS_ARGS_HELP)] | ||
#[serde(flatten)] | ||
pub genesis_args: GenesisArgs, | ||
#[clap(long, help = MSG_L1_RPC_URL_HELP)] | ||
pub l1_rpc_url: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
pub struct InitConfigsArgsFinal { | ||
pub genesis_args: GenesisArgsFinal, | ||
pub l1_rpc_url: String, | ||
pub port_offset: u16, | ||
} | ||
|
||
impl InitConfigsArgs { | ||
pub fn fill_values_with_prompt(self, config: &ChainConfig) -> InitConfigsArgsFinal { | ||
let l1_rpc_url = self.l1_rpc_url.unwrap_or_else(|| { | ||
let mut prompt = Prompt::new(MSG_L1_RPC_URL_PROMPT); | ||
if config.l1_network == L1Network::Localhost { | ||
prompt = prompt.default(LOCAL_RPC_URL); | ||
} | ||
prompt | ||
.validate_with(|val: &String| -> Result<(), String> { | ||
Url::parse(val) | ||
.map(|_| ()) | ||
.map_err(|_| MSG_L1_RPC_URL_INVALID_ERR.to_string()) | ||
}) | ||
.ask() | ||
}); | ||
|
||
InitConfigsArgsFinal { | ||
genesis_args: self.genesis_args.fill_values_with_prompt(config), | ||
l1_rpc_url, | ||
port_offset: PortOffset::from_chain_id(config.id as u16).into(), | ||
} | ||
} | ||
} | ||
|
||
impl InitConfigsArgsFinal { | ||
pub fn from_chain_init_args(init_args: &InitArgsFinal) -> InitConfigsArgsFinal { | ||
InitConfigsArgsFinal { | ||
genesis_args: init_args.genesis_args.clone(), | ||
l1_rpc_url: init_args.l1_rpc_url.clone(), | ||
port_offset: init_args.port_offset.clone(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ pub mod build_transactions; | |
pub mod create; | ||
pub mod genesis; | ||
pub mod init; | ||
pub mod init_configs; |
Oops, something went wrong.