Skip to content

Commit

Permalink
feat(zk-toolbox): Deploy custom token (#2329)
Browse files Browse the repository at this point in the history
## What ❔

Small fixes for local deployment 

## Why ❔

<!-- Why are these changes done? What goal do they contribute to? What
are the principles behind them? -->
<!-- Example: PR templates ensure PR reviewers, observers, and future
iterators are in context about the evolution of repos. -->

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.

---------

Signed-off-by: Danil <deniallugo@gmail.com>
  • Loading branch information
Deniallugo committed Jun 28, 2024
1 parent 9bbdf22 commit 3a8fed4
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
Empty file added chains/era/configs/.gitkeep
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,21 @@ impl Default for Erc20DeploymentConfig {
symbol: String::from("DAI"),
decimals: 18,
implementation: String::from("TestnetERC20Token.sol"),
mint: 10000000000,
mint: U256::from_str("9000000000000000000000").unwrap(),
},
Erc20DeploymentTokensConfig {
name: String::from("WBTC"),
symbol: String::from("WBTC"),
decimals: 8,
implementation: String::from("TestnetERC20Token.sol"),
mint: 10000000000,
mint: U256::from_str("9000000000000000000000").unwrap(),
},
Erc20DeploymentTokensConfig {
name: String::from("Wrapped Ether"),
symbol: String::from("WETH"),
decimals: 18,
implementation: String::from("WETH9.sol"),
mint: 0,
mint: U256::zero(),
},
],
}
Expand All @@ -106,7 +106,7 @@ pub struct Erc20DeploymentTokensConfig {
pub symbol: String,
pub decimals: u64,
pub implementation: String,
pub mint: u64,
pub mint: U256,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand Down Expand Up @@ -209,6 +209,7 @@ pub struct DeployErc20Config {
pub create2_factory_salt: H256,
pub create2_factory_addr: Address,
pub tokens: HashMap<String, TokenDeployErc20Config>,
pub additional_addresses_for_minting: Vec<Address>,
}

impl FileConfig for DeployErc20Config {}
Expand All @@ -217,6 +218,7 @@ impl DeployErc20Config {
pub fn new(
erc20_deployment_config: &Erc20DeploymentConfig,
contracts_config: &ContractsConfig,
additional_addresses_for_minting: Vec<Address>,
) -> Self {
let mut tokens = HashMap::new();
for token in &erc20_deployment_config.tokens {
Expand All @@ -235,6 +237,7 @@ impl DeployErc20Config {
create2_factory_addr: contracts_config.create2_factory_addr,
create2_factory_salt: contracts_config.create2_factory_salt,
tokens,
additional_addresses_for_minting,
}
}
}
Expand All @@ -245,5 +248,5 @@ pub struct TokenDeployErc20Config {
pub symbol: String,
pub decimals: u64,
pub implementation: String,
pub mint: u64,
pub mint: U256,
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use ethers::types::{Address, H256};
use ethers::types::{Address, H256, U256};
use serde::{Deserialize, Serialize};

use crate::{
Expand Down Expand Up @@ -85,7 +85,7 @@ pub struct TokenDeployErc20Output {
pub symbol: String,
pub decimals: u64,
pub implementation: String,
pub mint: u64,
pub mint: U256,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand Down
6 changes: 6 additions & 0 deletions zk_toolbox/crates/zk_inception/src/commands/chain/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ pub async fn init(
contracts_config.l1.base_token_addr = chain_config.base_token.address;
contracts_config.save_with_base_path(shell, &chain_config.configs)?;

crate::commands::ecosystem::init::distribute_eth(
&ecosystem_config,
&chain_config,
init_args.l1_rpc_url.clone(),
)
.await?;
let mut secrets = chain_config.get_secrets_config()?;
secrets.set_l1_rpc_url(init_args.l1_rpc_url.clone());
secrets.save_with_base_path(shell, &chain_config.configs)?;
Expand Down
20 changes: 11 additions & 9 deletions zk_toolbox/crates/zk_inception/src/commands/ecosystem/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,6 @@ pub async fn run(args: EcosystemInitArgs, shell: &Shell) -> anyhow::Result<()> {
l1_rpc_url: final_ecosystem_args.ecosystem.l1_rpc_url.clone(),
};

distribute_eth(
&ecosystem_config,
&chain_config,
final_ecosystem_args.ecosystem.l1_rpc_url.clone(),
)
.await?;

chain::init::init(
&mut chain_init_args,
shell,
Expand Down Expand Up @@ -195,8 +188,17 @@ async fn deploy_erc20(
l1_rpc_url: String,
) -> anyhow::Result<DeployErc20Output> {
let deploy_config_path = DEPLOY_ERC20_SCRIPT_PARAMS.input(&ecosystem_config.link_to_code);
DeployErc20Config::new(erc20_deployment_config, contracts_config)
.save(shell, deploy_config_path)?;
let wallets = ecosystem_config.get_wallets()?;
DeployErc20Config::new(
erc20_deployment_config,
contracts_config,
vec![
wallets.governor.address,
wallets.operator.address,
wallets.blob_operator.address,
],
)
.save(shell, deploy_config_path)?;

let mut forge = Forge::new(&ecosystem_config.path_to_foundry())
.script(&DEPLOY_ERC20_SCRIPT_PARAMS.script(), forge_args.clone())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mod args;
mod change_default;
mod create;
pub mod create_configs;
mod init;
pub(crate) mod init;

#[derive(Subcommand, Debug)]
#[allow(clippy::large_enum_variant)]
Expand Down

0 comments on commit 3a8fed4

Please sign in to comment.