foundry_wallets/
raw_wallet.rsuse crate::{utils, PendingSigner, WalletSigner};
use clap::Parser;
use eyre::Result;
use serde::Serialize;
#[derive(Clone, Debug, Default, Serialize, Parser)]
#[command(next_help_heading = "Wallet options - raw", about = None, long_about = None)]
pub struct RawWalletOpts {
#[arg(long, short)]
pub interactive: bool,
#[arg(long, value_name = "RAW_PRIVATE_KEY")]
pub private_key: Option<String>,
#[arg(long, alias = "mnemonic-path")]
pub mnemonic: Option<String>,
#[arg(long, value_name = "PASSPHRASE")]
pub mnemonic_passphrase: Option<String>,
#[arg(long = "mnemonic-derivation-path", alias = "hd-path", value_name = "PATH")]
pub hd_path: Option<String>,
#[arg(long, conflicts_with = "hd_path", default_value_t = 0, value_name = "INDEX")]
pub mnemonic_index: u32,
}
impl RawWalletOpts {
pub fn signer(&self) -> Result<Option<WalletSigner>> {
if self.interactive {
return Ok(Some(PendingSigner::Interactive.unlock()?));
}
if let Some(private_key) = &self.private_key {
return Ok(Some(utils::create_private_key_signer(private_key)?));
}
if let Some(mnemonic) = &self.mnemonic {
return Ok(Some(utils::create_mnemonic_signer(
mnemonic,
self.mnemonic_passphrase.as_deref(),
self.hd_path.as_deref(),
self.mnemonic_index,
)?));
}
Ok(None)
}
}