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): Make token multiplier optional #2843

Merged
merged 1 commit into from
Sep 11, 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
6 changes: 5 additions & 1 deletion zk_toolbox/crates/config/src/wallet_creation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ pub fn create_localhost_wallets(
blob_operator: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 2)?,
fee_account: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 3)?,
governor: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 4)?,
token_multiplier_setter: Wallet::from_mnemonic(&eth_mnemonic.test_mnemonic, &base_path, 5)?,
token_multiplier_setter: Some(Wallet::from_mnemonic(
&eth_mnemonic.test_mnemonic,
&base_path,
5,
)?),
})
}
6 changes: 3 additions & 3 deletions zk_toolbox/crates/config/src/wallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct WalletsConfig {
pub blob_operator: Wallet,
pub fee_account: Wallet,
pub governor: Wallet,
pub token_multiplier_setter: Wallet,
pub token_multiplier_setter: Option<Wallet>,
}

impl WalletsConfig {
Expand All @@ -27,7 +27,7 @@ impl WalletsConfig {
blob_operator: Wallet::random(rng),
fee_account: Wallet::random(rng),
governor: Wallet::random(rng),
token_multiplier_setter: Wallet::random(rng),
token_multiplier_setter: Some(Wallet::random(rng)),
}
}

Expand All @@ -39,7 +39,7 @@ impl WalletsConfig {
blob_operator: Wallet::empty(),
fee_account: Wallet::empty(),
governor: Wallet::empty(),
token_multiplier_setter: Wallet::empty(),
token_multiplier_setter: Some(Wallet::empty()),
}
}
pub fn deployer_private_key(&self) -> Option<H256> {
Expand Down
37 changes: 20 additions & 17 deletions zk_toolbox/crates/zk_inception/src/commands/chain/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::{
MSG_CHAIN_NOT_FOUND_ERR, MSG_DISTRIBUTING_ETH_SPINNER, MSG_GENESIS_DATABASE_ERR,
MSG_MINT_BASE_TOKEN_SPINNER, MSG_PORTAL_FAILED_TO_CREATE_CONFIG_ERR,
MSG_REGISTERING_CHAIN_SPINNER, MSG_SELECTED_CONFIG,
MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER,
MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND,
},
utils::forge::{check_the_balance, fill_forge_private_key},
};
Expand Down Expand Up @@ -112,22 +112,25 @@ pub async fn init(
.await?;
spinner.finish();

let spinner = Spinner::new(MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER);
set_token_multiplier_setter(
shell,
ecosystem_config,
chain_config.get_wallets_config()?.governor_private_key(),
contracts_config.l1.chain_admin_addr,
ecosystem_config
.get_wallets()
.unwrap()
.token_multiplier_setter
.address,
&init_args.forge_args.clone(),
init_args.l1_rpc_url.clone(),
)
.await?;
spinner.finish();
if chain_config.base_token != BaseToken::eth() {
let spinner = Spinner::new(MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER);
set_token_multiplier_setter(
shell,
ecosystem_config,
chain_config.get_wallets_config()?.governor_private_key(),
contracts_config.l1.chain_admin_addr,
chain_config
.get_wallets_config()
.unwrap()
.token_multiplier_setter
.context(MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND)?
.address,
&init_args.forge_args.clone(),
init_args.l1_rpc_url.clone(),
)
.await?;
spinner.finish();
}

deploy_l2_contracts::deploy_l2_contracts(
shell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{
messages::{
MSG_CHAIN_NOT_INITIALIZED, MSG_L1_SECRETS_MUST_BE_PRESENTED,
MSG_TOKEN_MULTIPLIER_SETTER_UPDATED_TO, MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER,
MSG_WALLETS_CONFIG_MUST_BE_PRESENT,
MSG_WALLETS_CONFIG_MUST_BE_PRESENT, MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND,
},
utils::forge::{check_the_balance, fill_forge_private_key},
};
Expand Down Expand Up @@ -47,6 +47,7 @@ pub async fn run(args: ForgeScriptArgs, shell: &Shell) -> anyhow::Result<()> {
.get_wallets()
.context(MSG_WALLETS_CONFIG_MUST_BE_PRESENT)?
.token_multiplier_setter
.context(MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND)?
.address;

let spinner = Spinner::new(MSG_UPDATING_TOKEN_MULTIPLIER_SETTER_SPINNER);
Expand Down
2 changes: 2 additions & 0 deletions zk_toolbox/crates/zk_inception/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ pub(super) const MSG_CHAIN_ID_VALIDATOR_ERR: &str = "Invalid chain id";
pub(super) const MSG_BASE_TOKEN_ADDRESS_VALIDATOR_ERR: &str = "Invalid base token address";
pub(super) const MSG_WALLET_CREATION_VALIDATOR_ERR: &str =
"Localhost wallet is not supported for external networks";
pub(super) const MSG_WALLET_TOKEN_MULTIPLIER_SETTER_NOT_FOUND: &str =
"Token Multiplier Setter not found. Specify it in a wallet config";

/// Chain genesis related messages
pub(super) const MSG_L1_SECRETS_MUST_BE_PRESENTED: &str = "L1 secret must be presented";
Expand Down
Loading