Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
IPC-373: Fix balances returned with bogus rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
adlrocha committed Nov 6, 2023
1 parent 1bd03e7 commit de0ea1f
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ipc/cli/src/commands/wallet/balances.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl CommandLineHandler for WalletBalances {
WalletType::Evm => {
let wallet = provider.evm_wallet()?;
let addresses = wallet.read().unwrap().list()?;
let mut no_balance = addresses.clone();
let r = addresses
.iter()
.map(|addr| {
Expand All @@ -50,16 +49,19 @@ impl CommandLineHandler for WalletBalances {

let v: Vec<anyhow::Result<(TokenAmount, &EthKeyAddress)>> = join_all(r).await;

for r in v.into_iter().filter_map(|r| r.ok()) {
let (balance, addr) = r;
if addr.to_string() != "default-key" {
println!("{} - Balance: {}", addr.to_string(), balance);
no_balance.retain(|a| a != addr);
for r in v.into_iter() {
match r {
Ok(i) => {
let (balance, addr) = i;
if addr.to_string() != "default-key" {
println!("{} - Balance: {}", addr.to_string(), balance);
}
}
Err(e) => {
return Err(e);
}
}
}
for addr in no_balance {
println!("{} - Balance: 0", addr.to_string());
}
}
WalletType::Fvm => {
let wallet = provider.fvm_wallet()?;
Expand Down

0 comments on commit de0ea1f

Please sign in to comment.