Skip to content

Commit

Permalink
fix(zk_toolbox): Do not panic if mint is not successful (#2973)
Browse files Browse the repository at this point in the history
## What ❔

Use governor for minting process and do not panic if minting is not
successful

## 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 authored Sep 26, 2024
1 parent 692ea73 commit 57b99d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions zk_toolbox/crates/common/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ethers::{
};
use types::TokenInfo;

use crate::wallets::Wallet;
use crate::{logger, wallets::Wallet};

pub fn create_ethers_client(
private_key: H256,
Expand Down Expand Up @@ -103,13 +103,12 @@ pub async fn mint_token(

let mut pending_txs = vec![];
for call in &pending_calls {
pending_txs.push(
call.send()
.await?
// It's safe to set such low number of confirmations and low interval for localhost
.confirmations(3)
.interval(Duration::from_millis(30)),
);
let call = call.send().await;
match call {
// It's safe to set such low number of confirmations and low interval for localhost
Ok(call) => pending_txs.push(call.confirmations(3).interval(Duration::from_millis(30))),
Err(e) => logger::error(format!("Minting is not successful {e}")),
}
}

futures::future::join_all(pending_txs).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub async fn mint_base_token(
let amount = AMOUNT_FOR_DISTRIBUTION_TO_WALLETS * base_token.nominator as u128
/ base_token.denominator as u128;
common::ethereum::mint_token(
wallets.operator,
wallets.governor,
base_token.address,
addresses,
l1_rpc_url,
Expand Down

0 comments on commit 57b99d4

Please sign in to comment.