Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit b7a3ad5

Browse files
committed
update get_signer to use SignerSource::try_get_signer
1 parent 58b292d commit b7a3ad5

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

token/cli/src/clap_app.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use {
44
},
55
solana_clap_v3_utils::{
66
fee_payer::fee_payer_arg,
7+
input_parsers::signer::SignerSourceParserBuilder,
78
input_validators::{
89
is_amount, is_amount_or_all, is_parsable, is_pubkey, is_url_or_moniker,
910
is_valid_pubkey, is_valid_signer,
@@ -691,7 +692,7 @@ pub fn app<'a>(
691692
.arg(
692693
Arg::with_name("token_keypair")
693694
.value_name("TOKEN_KEYPAIR")
694-
.validator(|s| is_valid_signer(s))
695+
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
695696
.takes_value(true)
696697
.index(1)
697698
.help(
@@ -1215,7 +1216,7 @@ pub fn app<'a>(
12151216
.arg(
12161217
Arg::with_name("account_keypair")
12171218
.value_name("ACCOUNT_KEYPAIR")
1218-
.validator(|s| is_valid_signer(s))
1219+
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
12191220
.takes_value(true)
12201221
.index(2)
12211222
.help(
@@ -1250,7 +1251,7 @@ pub fn app<'a>(
12501251
.arg(
12511252
Arg::with_name("multisig_member")
12521253
.value_name("MULTISIG_MEMBER_PUBKEY")
1253-
.validator(|s| is_valid_pubkey(s))
1254+
.validator(|s| is_valid_signer(s))
12541255
.takes_value(true)
12551256
.index(2)
12561257
.required(true)
@@ -1262,7 +1263,7 @@ pub fn app<'a>(
12621263
Arg::with_name("address_keypair")
12631264
.long("address-keypair")
12641265
.value_name("ADDRESS_KEYPAIR")
1265-
.validator(|s| is_valid_signer(s))
1266+
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
12661267
.takes_value(true)
12671268
.help(
12681269
"Specify the address keypair. \

token/cli/src/command.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use {
1717
UiAccountData,
1818
},
1919
solana_clap_v3_utils::{
20-
input_parsers::{pubkey_of_signer, pubkeys_of_multiple_signers},
20+
input_parsers::{pubkey_of_signer, pubkeys_of_multiple_signers, signer::SignerSource},
2121
keypair::signer_from_path,
2222
},
2323
solana_cli_output::{
@@ -101,12 +101,10 @@ fn get_signer(
101101
keypair_name: &str,
102102
wallet_manager: &mut Option<Rc<RemoteWalletManager>>,
103103
) -> Option<(Arc<dyn Signer>, Pubkey)> {
104-
matches.value_of(keypair_name).map(|path| {
105-
let signer = signer_from_path(matches, path, keypair_name, wallet_manager)
106-
.unwrap_or_else(print_error_and_exit);
107-
let signer_pubkey = signer.pubkey();
108-
(Arc::from(signer), signer_pubkey)
109-
})
104+
SignerSource::try_get_signer(matches, keypair_name, wallet_manager)
105+
.ok()
106+
.flatten()
107+
.map(|(signer, pubkey)| (signer.into(), pubkey))
110108
}
111109

112110
fn parse_amount_or_all(matches: &ArgMatches) -> Option<f64> {

0 commit comments

Comments
 (0)