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(forge): temporary fix for ledger when using --hd-paths on forge script #2790

Merged
merged 1 commit into from
Aug 15, 2022
Merged
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
15 changes: 12 additions & 3 deletions cli/src/opts/multi_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use ethers::{
signers::{HDPath as LedgerHDPath, Ledger, LocalWallet, Trezor, TrezorHDPath},
types::Address,
};
use eyre::Result;
use eyre::{Context, Result};

use foundry_common::RetryProvider;
use foundry_config::Config;
Expand Down Expand Up @@ -299,7 +299,16 @@ impl MultiWallet {

pub async fn ledgers(&self, chain_id: u64) -> Result<Option<Vec<Ledger>>> {
if self.ledger {
create_hw_wallets!(self, chain_id, get_from_ledger, wallets);
let mut args = self.clone();

if let Some(paths) = &args.hd_paths {
if paths.len() > 1 {
eyre::bail!("Ledger only supports one signer.");
}
args.mnemonic_indexes = None;
}

create_hw_wallets!(args, chain_id, get_from_ledger, wallets);
return Ok(Some(wallets))
}
Ok(None)
Expand Down Expand Up @@ -338,6 +347,6 @@ impl MultiWallet {
None => LedgerHDPath::LedgerLive(mnemonic_index.unwrap_or(0)),
};

Ok(Some(Ledger::new(derivation, chain_id).await?))
Ok(Some(Ledger::new(derivation, chain_id).await.wrap_err("Ledger device not available.")?))
}
}