Cli: Add resolve-signer subcommand (#8859)
* Expose remote-wallet device pretty path * Add resolve-signer helpers * Add cli resolve-signer subcommand * Print pretty-path in waiting msg
This commit is contained in:
@ -394,6 +394,7 @@ pub enum CliCommand {
|
||||
Cancel(Pubkey),
|
||||
Confirm(Signature),
|
||||
Pay(PayCommand),
|
||||
ResolveSigner(Option<String>),
|
||||
ShowAccount {
|
||||
pubkey: Pubkey,
|
||||
output_file: Option<String>,
|
||||
@ -863,6 +864,13 @@ pub fn parse_command(
|
||||
signers: vec![],
|
||||
})
|
||||
}
|
||||
("resolve-signer", Some(matches)) => {
|
||||
let signer_path = resolve_signer(matches, "signer", wallet_manager)?;
|
||||
Ok(CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(signer_path),
|
||||
signers: vec![],
|
||||
})
|
||||
}
|
||||
("send-signature", Some(matches)) => {
|
||||
let to = value_of(matches, "to").unwrap();
|
||||
let process_id = value_of(matches, "process_id").unwrap();
|
||||
@ -2027,6 +2035,13 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
||||
*nonce_account,
|
||||
*nonce_authority,
|
||||
),
|
||||
CliCommand::ResolveSigner(path) => {
|
||||
if let Some(path) = path {
|
||||
Ok(path.to_string())
|
||||
} else {
|
||||
Ok("Signer is valid".to_string())
|
||||
}
|
||||
}
|
||||
CliCommand::ShowAccount {
|
||||
pubkey,
|
||||
output_file,
|
||||
@ -2381,6 +2396,19 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
|
||||
.arg(nonce_arg())
|
||||
.arg(nonce_authority_arg()),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("resolve-signer")
|
||||
.about("Checks that a signer is valid, and returns its specific path; useful for signers that may be specified generally, eg. usb://ledger")
|
||||
.arg(
|
||||
Arg::with_name("signer")
|
||||
.index(1)
|
||||
.value_name("KEYPAIR or PUBKEY or REMOTE WALLET PATH")
|
||||
.takes_value(true)
|
||||
.required(true)
|
||||
.validator(is_valid_signer)
|
||||
.help("The signer path to resolve")
|
||||
)
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("send-signature")
|
||||
.about("Send a signature to authorize a transfer")
|
||||
@ -2759,6 +2787,31 @@ mod tests {
|
||||
}
|
||||
);
|
||||
|
||||
// Test ResolveSigner Subcommand, KeypairUrl::Filepath
|
||||
let test_resolve_signer =
|
||||
test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "resolve-signer", &keypair_file]);
|
||||
assert_eq!(
|
||||
parse_command(&test_resolve_signer, "", None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(Some(keypair_file.clone())),
|
||||
signers: vec![],
|
||||
}
|
||||
);
|
||||
// Test ResolveSigner Subcommand, KeypairUrl::Pubkey (Presigner)
|
||||
let test_resolve_signer =
|
||||
test_commands
|
||||
.clone()
|
||||
.get_matches_from(vec!["test", "resolve-signer", &pubkey_string]);
|
||||
assert_eq!(
|
||||
parse_command(&test_resolve_signer, "", None).unwrap(),
|
||||
CliCommandInfo {
|
||||
command: CliCommand::ResolveSigner(Some(pubkey.to_string())),
|
||||
signers: vec![],
|
||||
}
|
||||
);
|
||||
|
||||
// Test Simple Pay Subcommand
|
||||
let test_pay =
|
||||
test_commands
|
||||
|
Reference in New Issue
Block a user