Skip to content

Commit

Permalink
Revert "Tame overeager wallet manager (solana-labs#9262)"
Browse files Browse the repository at this point in the history
This reverts commit ec4745d.
  • Loading branch information
CriesofCarrots committed Apr 18, 2020
1 parent 6de5a78 commit 70b7f8e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 43 deletions.
23 changes: 0 additions & 23 deletions clap-utils/src/keypair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ pub fn parse_keypair_path(path: &str) -> KeypairUrl {
}
}

pub fn check_for_usb<S>(mut items: impl Iterator<Item = S>) -> bool
where
S: Into<String>,
{
items.any(|arg| matches!(parse_keypair_path(&arg.into()), KeypairUrl::Usb(_)))
}

pub fn presigner_from_pubkey_sigs(
pubkey: &Pubkey,
signers: &[(Pubkey, Signature)],
Expand Down Expand Up @@ -263,20 +256,4 @@ mod tests {
sanitize_seed_phrase(seed_phrase)
);
}

#[test]
fn test_check_for_usb() {
let args: Vec<&str> = vec![];
assert_eq!(check_for_usb(args.into_iter()), false);
let args = vec!["usb://"];
assert_eq!(check_for_usb(args.into_iter()), true);
let args = vec!["other"];
assert_eq!(check_for_usb(args.into_iter()), false);
let args = vec!["other", "usb://", "another"];
assert_eq!(check_for_usb(args.into_iter()), true);
let args = vec!["other", "another"];
assert_eq!(check_for_usb(args.into_iter()), false);
let args = vec!["usb://", "usb://"];
assert_eq!(check_for_usb(args.into_iter()), true);
}
}
18 changes: 4 additions & 14 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use clap::{crate_description, crate_name, AppSettings, Arg, ArgGroup, ArgMatches
use console::style;

use solana_clap_utils::{
input_validators::is_url,
keypair::{check_for_usb, SKIP_SEED_PHRASE_VALIDATION_ARG},
offline::SIGN_ONLY_ARG,
input_validators::is_url, keypair::SKIP_SEED_PHRASE_VALIDATION_ARG, offline::SIGN_ONLY_ARG,
DisplayError,
};
use solana_cli::{
Expand Down Expand Up @@ -254,20 +252,12 @@ fn main() -> Result<(), Box<dyn error::Error>> {
)
.get_matches();

do_main(&matches, check_for_usb(std::env::args()))
.map_err(|err| DisplayError::new_as_boxed(err).into())
do_main(&matches).map_err(|err| DisplayError::new_as_boxed(err).into())
}

fn do_main(
matches: &ArgMatches<'_>,
need_wallet_manager: bool,
) -> Result<(), Box<dyn error::Error>> {
fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
if parse_settings(&matches)? {
let wallet_manager = if need_wallet_manager {
maybe_wallet_manager()?
} else {
None
};
let wallet_manager = maybe_wallet_manager()?;

let (mut config, signers) = parse_args(&matches, wallet_manager)?;
config.signers = signers.iter().map(|s| s.as_ref()).collect();
Expand Down
8 changes: 2 additions & 6 deletions keygen/src/keygen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use num_cpus;
use solana_clap_utils::{
input_validators::is_derivation,
keypair::{
check_for_usb, keypair_from_seed_phrase, prompt_passphrase, signer_from_path,
keypair_from_seed_phrase, prompt_passphrase, signer_from_path,
SKIP_SEED_PHRASE_VALIDATION_ARG,
},
DisplayError,
Expand Down Expand Up @@ -407,11 +407,7 @@ fn do_main(matches: &ArgMatches<'_>) -> Result<(), Box<dyn error::Error>> {
Config::default()
};

let wallet_manager = if check_for_usb(std::env::args()) {
maybe_wallet_manager()?
} else {
None
};
let wallet_manager = maybe_wallet_manager()?;

match matches.subcommand() {
("pubkey", Some(matches)) => {
Expand Down

0 comments on commit 70b7f8e

Please sign in to comment.