Skip to content

Commit 8351822

Browse files
committed
Remove redundant functions
Signed-off-by: Danil <[email protected]>
1 parent 5dd0715 commit 8351822

File tree

6 files changed

+40
-95
lines changed

6 files changed

+40
-95
lines changed

zkstack_cli/crates/zkstack/src/commands/ctm/args/mod.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use zksync_basic_types::H160;
77
use zksync_web3_decl::jsonrpsee::core::Serialize;
88

99
use crate::{
10-
commands::ecosystem::args::init::{EcosystemArgs, EcosystemArgsFinal, EcosystemInitArgsFinal},
10+
commands::ecosystem::args::init::{EcosystemArgs, EcosystemArgsFinal},
1111
messages::{MSG_BRIDGEHUB, MSG_DEV_ARG_HELP, MSG_ZKSYNC_OS},
1212
};
1313

@@ -54,16 +54,6 @@ pub struct RegisterCTMArgsFinal {
5454
pub update_submodules: Option<bool>,
5555
}
5656

57-
impl From<EcosystemInitArgsFinal> for RegisterCTMArgsFinal {
58-
fn from(args: EcosystemInitArgsFinal) -> Self {
59-
RegisterCTMArgsFinal {
60-
ecosystem: args.ecosystem,
61-
forge_args: args.forge_args,
62-
update_submodules: None,
63-
}
64-
}
65-
}
66-
6757
#[derive(Debug, Clone, Serialize, Deserialize, Parser)]
6858
pub struct InitNewCTMArgs {
6959
#[clap(flatten)]
@@ -136,17 +126,3 @@ pub struct InitNewCTMArgsFinal {
136126
pub bridgehub_address: Option<H160>,
137127
pub zksync_os: bool,
138128
}
139-
140-
impl From<EcosystemInitArgsFinal> for InitNewCTMArgsFinal {
141-
fn from(args: EcosystemInitArgsFinal) -> Self {
142-
InitNewCTMArgsFinal {
143-
ecosystem: args.ecosystem,
144-
forge_args: args.forge_args,
145-
update_submodules: None,
146-
skip_contract_compilation_override: args.skip_contract_compilation_override,
147-
support_l2_legacy_shared_bridge_test: args.support_l2_legacy_shared_bridge_test,
148-
bridgehub_address: args.bridgehub_address,
149-
zksync_os: args.zksync_os,
150-
}
151-
}
152-
}

zkstack_cli/crates/zkstack/src/commands/ctm/commands/init_new_ctm.rs

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use zkstack_cli_types::{L1Network, ProverMode};
2727
use crate::{
2828
admin_functions::{accept_admin, accept_owner},
2929
commands::{
30-
ctm::args::{InitNewCTMArgs, InitNewCTMArgsFinal},
30+
ctm::args::InitNewCTMArgs,
3131
ecosystem::{
3232
args::init::EcosystemArgsFinal, create_configs::create_initial_deployments_config,
3333
},
@@ -56,32 +56,15 @@ pub async fn run(args: InitNewCTMArgs, shell: &Shell) -> anyhow::Result<()> {
5656
Err(_) => create_initial_deployments_config(shell, &ecosystem_config.config)?,
5757
};
5858

59-
let mut init_ctm_args = args
59+
let init_ctm_args = args
6060
.clone()
6161
.fill_values_with_prompt(ecosystem_config.l1_network)
6262
.await?;
6363

6464
logger::info(MSG_INITIALIZING_CTM);
6565

66-
init_ctm(
67-
&mut init_ctm_args,
68-
shell,
69-
&ecosystem_config,
70-
&initial_deployment_config,
71-
)
72-
.await?;
73-
74-
Ok(())
75-
}
76-
77-
async fn init_ctm(
78-
init_args: &mut InitNewCTMArgsFinal,
79-
shell: &Shell,
80-
ecosystem_config: &EcosystemConfig,
81-
initial_deployment_config: &InitialDeploymentConfig,
82-
) -> anyhow::Result<ContractsConfig> {
8366
let spinner = Spinner::new(MSG_INTALLING_DEPS_SPINNER);
84-
if !init_args.skip_contract_compilation_override {
67+
if !init_ctm_args.skip_contract_compilation_override {
8568
install_yarn_dependencies(shell, &ecosystem_config.link_to_code())?;
8669
build_da_contracts(shell, &ecosystem_config.contracts_path())?;
8770
build_l1_contracts(shell.clone(), &ecosystem_config.contracts_path())?;
@@ -90,25 +73,25 @@ async fn init_ctm(
9073
}
9174
spinner.finish();
9275

93-
let contracts = deploy_new_ctm(
76+
let contracts = deploy_new_ctm_and_accept_admin(
9477
shell,
95-
&mut init_args.ecosystem,
96-
init_args.forge_args.clone(),
97-
ecosystem_config,
98-
initial_deployment_config,
99-
init_args.support_l2_legacy_shared_bridge_test,
100-
init_args.bridgehub_address, // Scripts are expected to consume 0 address for BH
101-
init_args.zksync_os,
78+
&init_ctm_args.ecosystem,
79+
init_ctm_args.forge_args.clone(),
80+
&ecosystem_config,
81+
&initial_deployment_config,
82+
init_ctm_args.support_l2_legacy_shared_bridge_test,
83+
init_ctm_args.bridgehub_address, // Scripts are expected to consume 0 address for BH
84+
init_ctm_args.zksync_os,
10285
)
10386
.await?;
10487
contracts.save_with_base_path(shell, &ecosystem_config.config)?;
105-
Ok(contracts)
88+
Ok(())
10689
}
10790

10891
#[allow(clippy::too_many_arguments)]
109-
pub async fn deploy_new_ctm(
92+
pub async fn deploy_new_ctm_and_accept_admin(
11093
shell: &Shell,
111-
ecosystem: &mut EcosystemArgsFinal,
94+
ecosystem: &EcosystemArgsFinal,
11295
forge_args: ForgeScriptArgs,
11396
ecosystem_config: &EcosystemConfig,
11497
initial_deployment_config: &InitialDeploymentConfig,
@@ -118,7 +101,7 @@ pub async fn deploy_new_ctm(
118101
) -> anyhow::Result<ContractsConfig> {
119102
let l1_rpc_url = ecosystem.l1_rpc_url.clone();
120103
let spinner = Spinner::new(MSG_DEPLOYING_ECOSYSTEM_CONTRACTS_SPINNER);
121-
let contracts_config = deploy_l1(
104+
let contracts_config = deploy_new_ctm(
122105
shell,
123106
&forge_args,
124107
ecosystem_config,
@@ -163,7 +146,7 @@ pub async fn deploy_new_ctm(
163146
}
164147

165148
#[allow(clippy::too_many_arguments)]
166-
pub async fn deploy_l1(
149+
pub async fn deploy_new_ctm(
167150
shell: &Shell,
168151
forge_args: &ForgeScriptArgs,
169152
config: &EcosystemConfig,

zkstack_cli/crates/zkstack/src/commands/ctm/commands/register_ctm.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use zkstack_cli_config::{
1010
use zkstack_cli_types::L1Network;
1111

1212
use crate::{
13-
commands::ctm::args::{RegisterCTMArgs, RegisterCTMArgsFinal},
13+
commands::ctm::args::RegisterCTMArgs,
1414
messages::MSG_REGISTERING_CTM,
1515
utils::forge::{check_the_balance, fill_forge_private_key, WalletOwner},
1616
};
@@ -22,37 +22,18 @@ pub async fn run(args: RegisterCTMArgs, shell: &Shell) -> anyhow::Result<()> {
2222
git::submodule_update(shell, &ecosystem_config.link_to_code())?;
2323
}
2424

25-
let mut final_ecosystem_args = args
25+
let final_ecosystem_args = args
2626
.clone()
2727
.fill_values_with_prompt(ecosystem_config.l1_network)
2828
.await?;
2929

3030
logger::info(MSG_REGISTERING_CTM);
3131

32-
let forge_args = final_ecosystem_args.forge_args.clone();
33-
3432
register_ctm(
35-
&mut final_ecosystem_args,
3633
shell,
37-
forge_args,
34+
&final_ecosystem_args.forge_args,
3835
&ecosystem_config,
39-
)
40-
.await?;
41-
42-
Ok(())
43-
}
44-
45-
pub async fn register_ctm(
46-
init_args: &mut RegisterCTMArgsFinal,
47-
shell: &Shell,
48-
forge_args: ForgeScriptArgs,
49-
ecosystem_config: &EcosystemConfig,
50-
) -> anyhow::Result<()> {
51-
register_ctm_on_existing_bh(
52-
shell,
53-
&forge_args,
54-
ecosystem_config,
55-
&init_args.ecosystem.l1_rpc_url,
36+
&final_ecosystem_args.ecosystem.l1_rpc_url,
5637
None,
5738
true,
5839
)
@@ -61,7 +42,7 @@ pub async fn register_ctm(
6142
Ok(())
6243
}
6344

64-
pub async fn register_ctm_on_existing_bh(
45+
pub async fn register_ctm(
6546
shell: &Shell,
6647
forge_args: &ForgeScriptArgs,
6748
config: &EcosystemConfig,

zkstack_cli/crates/zkstack/src/commands/ctm/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub(crate) mod commands;
44
use clap::Subcommand;
55
use xshell::Shell;
66

7-
pub use crate::commands::ctm::args::RegisterCTMArgsFinal;
87
use crate::commands::ctm::{
98
args::{InitNewCTMArgs, RegisterCTMArgs},
109
commands::{init_new_ctm, register_ctm},

zkstack_cli/crates/zkstack/src/commands/ecosystem/build_transactions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use super::{
1212
create_configs::create_initial_deployments_config,
1313
};
1414
use crate::{
15-
commands::ctm::commands::init_new_ctm::deploy_l1,
15+
commands::ctm::commands::init_new_ctm::deploy_new_ctm,
1616
messages::{
1717
MSG_BUILDING_ECOSYSTEM, MSG_BUILDING_ECOSYSTEM_CONTRACTS_SPINNER, MSG_ECOSYSTEM_TXN_OUTRO,
1818
MSG_ECOSYSTEM_TXN_OUT_PATH_INVALID_ERR, MSG_INTALLING_DEPS_SPINNER,
@@ -46,7 +46,7 @@ pub async fn run(args: BuildTransactionsArgs, shell: &Shell) -> anyhow::Result<(
4646
spinner.finish();
4747

4848
let spinner = Spinner::new(MSG_BUILDING_ECOSYSTEM_CONTRACTS_SPINNER);
49-
let contracts_config = deploy_l1(
49+
let contracts_config = deploy_new_ctm(
5050
shell,
5151
&args.forge_args,
5252
&ecosystem_config,

zkstack_cli/crates/zkstack/src/commands/ecosystem/init.rs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,8 @@ use super::{
2727
use crate::{
2828
admin_functions::{accept_admin, accept_owner},
2929
commands::{
30-
ctm::{
31-
commands::{init_new_ctm::deploy_new_ctm, register_ctm::register_ctm},
32-
RegisterCTMArgsFinal,
30+
ctm::commands::{
31+
init_new_ctm::deploy_new_ctm_and_accept_admin, register_ctm::register_ctm,
3332
},
3433
ecosystem::{
3534
common::deploy_l1_core_contracts,
@@ -102,7 +101,7 @@ pub async fn run(args: EcosystemInitArgs, shell: &Shell) -> anyhow::Result<()> {
102101
}
103102

104103
async fn init_ecosystem(
105-
init_args: &mut EcosystemInitArgsFinal,
104+
init_args: &EcosystemInitArgsFinal,
106105
shell: &Shell,
107106
ecosystem_config: &EcosystemConfig,
108107
initial_deployment_config: &InitialDeploymentConfig,
@@ -119,7 +118,7 @@ async fn init_ecosystem(
119118

120119
let mut contracts = deploy_ecosystem(
121120
shell,
122-
&mut init_args.ecosystem,
121+
&init_args.ecosystem,
123122
init_args.forge_args.clone(),
124123
ecosystem_config,
125124
initial_deployment_config,
@@ -129,9 +128,9 @@ async fn init_ecosystem(
129128
.await?;
130129
contracts.save_with_base_path(shell, &ecosystem_config.config)?;
131130

132-
contracts = deploy_new_ctm(
131+
contracts = deploy_new_ctm_and_accept_admin(
133132
shell,
134-
&mut init_args.ecosystem,
133+
&init_args.ecosystem,
135134
init_args.forge_args.clone(),
136135
ecosystem_config,
137136
initial_deployment_config,
@@ -144,15 +143,22 @@ async fn init_ecosystem(
144143

145144
let forge_args = init_args.forge_args.clone();
146145

147-
let mut reg_args = RegisterCTMArgsFinal::from((*init_args).clone());
148-
register_ctm(&mut reg_args, shell, forge_args, ecosystem_config).await?;
146+
register_ctm(
147+
shell,
148+
&forge_args,
149+
&ecosystem_config,
150+
&init_args.ecosystem.l1_rpc_url,
151+
None,
152+
true,
153+
)
154+
.await?;
149155

150156
Ok(contracts)
151157
}
152158

153159
async fn deploy_ecosystem(
154160
shell: &Shell,
155-
ecosystem: &mut EcosystemArgsFinal,
161+
ecosystem: &EcosystemArgsFinal,
156162
forge_args: ForgeScriptArgs,
157163
ecosystem_config: &EcosystemConfig,
158164
initial_deployment_config: &InitialDeploymentConfig,

0 commit comments

Comments
 (0)