Skip to content

Commit

Permalink
Make deploy_l2_contracts independent from Ecosystem
Browse files Browse the repository at this point in the history
  • Loading branch information
matias-gonz committed Nov 22, 2024
1 parent 9010f44 commit 700f63b
Showing 1 changed file with 21 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use config::{
},
script_params::DEPLOY_L2_CONTRACTS_SCRIPT_PARAMS,
},
get_default_era_chain_id,
traits::{ReadConfig, SaveConfig, SaveConfigWithBasePath},
zkstack_config::ZkStackConfig,
ChainConfig, ContractsConfig, WalletsConfig,
Expand Down Expand Up @@ -46,87 +47,45 @@ pub async fn run(
shell: &Shell,
deploy_option: Deploy2ContractsOption,
) -> anyhow::Result<()> {
let ecosystem_config = ZkStackConfig::ecosystem(shell)?;
let chain_config = ecosystem_config
.load_current_chain()
.context(MSG_CHAIN_NOT_INITIALIZED)?;
let chain = ZkStackConfig::current_chain(shell).context(MSG_CHAIN_NOT_INITIALIZED)?;
let ecosystem = ZkStackConfig::ecosystem(shell).ok();

let mut contracts = chain_config.get_contracts_config()?;
let era_chain_id = ecosystem_config.era_chain_id;
let wallets = ecosystem_config.get_wallets()?;
let mut contracts = chain.get_contracts_config()?;
let era_chain_id = ecosystem
.as_ref()
.map_or(get_default_era_chain_id(), |e| e.era_chain_id);
let wallets = ecosystem.as_ref().map_or(
WalletsConfig::read(shell, chain.l1_wallets_path.clone()),
|e| e.get_wallets(),
)?;

let spinner = Spinner::new(MSG_DEPLOYING_L2_CONTRACT_SPINNER);

match deploy_option {
Deploy2ContractsOption::All => {
deploy_l2_contracts(
shell,
&chain_config,
era_chain_id,
&wallets,
&mut contracts,
args,
)
.await?;
deploy_l2_contracts(shell, &chain, era_chain_id, &wallets, &mut contracts, args)
.await?;
}
Deploy2ContractsOption::Upgrader => {
deploy_upgrader(
shell,
&chain_config,
era_chain_id,
&wallets,
&mut contracts,
args,
)
.await?;
deploy_upgrader(shell, &chain, era_chain_id, &wallets, &mut contracts, args).await?;
}
Deploy2ContractsOption::ConsensusRegistry => {
deploy_consensus_registry(
shell,
&chain_config,
era_chain_id,
&wallets,
&mut contracts,
args,
)
.await?;
deploy_consensus_registry(shell, &chain, era_chain_id, &wallets, &mut contracts, args)
.await?;
}
Deploy2ContractsOption::Multicall3 => {
deploy_multicall3(
shell,
&chain_config,
era_chain_id,
&wallets,
&mut contracts,
args,
)
.await?;
deploy_multicall3(shell, &chain, era_chain_id, &wallets, &mut contracts, args).await?;
}
Deploy2ContractsOption::TimestampAsserter => {
deploy_timestamp_asserter(
shell,
&chain_config,
era_chain_id,
&wallets,
&mut contracts,
args,
)
.await?;
deploy_timestamp_asserter(shell, &chain, era_chain_id, &wallets, &mut contracts, args)
.await?;
}
Deploy2ContractsOption::InitiailizeBridges => {
initialize_bridges(
shell,
&chain_config,
era_chain_id,
&wallets,
&mut contracts,
args,
)
.await?
initialize_bridges(shell, &chain, era_chain_id, &wallets, &mut contracts, args).await?
}
}

contracts.save_with_base_path(shell, &chain_config.configs)?;
contracts.save_with_base_path(shell, &chain.configs)?;
spinner.finish();

Ok(())
Expand Down

0 comments on commit 700f63b

Please sign in to comment.