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

Commit 68cae53

Browse files
[transfer-hook-cli] Replace pubkey_of_signer with pubkey_from_source (#6625)
replace `pubkey_of_signer` with `pubkey_from_source`
1 parent 02c871f commit 68cae53

File tree

1 file changed

+33
-10
lines changed

1 file changed

+33
-10
lines changed

token/transfer-hook/cli/src/main.rs

+33-10
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use {
55
clap::{crate_description, crate_name, crate_version, Arg, Command},
66
solana_clap_v3_utils::{
77
input_parsers::{
8-
parse_url_or_moniker, pubkey_of_signer, signer::SignerSourceParserBuilder,
8+
parse_url_or_moniker,
9+
signer::{SignerSource, SignerSourceParserBuilder},
910
},
1011
input_validators::normalize_to_url_if_moniker,
11-
keypair::DefaultSigner,
12+
keypair::{pubkey_from_source, DefaultSigner},
1213
},
1314
solana_client::nonblocking::rpc_client::RpcClient,
1415
solana_remote_wallet::remote_wallet::RemoteWalletManager,
@@ -443,12 +444,23 @@ extraMetas:
443444

444445
match (command, matches) {
445446
("create-extra-metas", arg_matches) => {
446-
let program_id = pubkey_of_signer(arg_matches, "program_id", &mut wallet_manager)
447-
.unwrap()
447+
let program_id_source = arg_matches
448+
.try_get_one::<SignerSource>("program_id")?
448449
.unwrap();
449-
let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager)
450-
.unwrap()
450+
let program_id = pubkey_from_source(
451+
arg_matches,
452+
program_id_source,
453+
"program_id",
454+
&mut wallet_manager,
455+
)
456+
.unwrap();
457+
458+
let token_source = arg_matches
459+
.try_get_one::<SignerSource>("program_id")?
451460
.unwrap();
461+
let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager)
462+
.unwrap();
463+
452464
let transfer_hook_accounts = arg_matches
453465
.get_many::<Vec<ExtraAccountMeta>>("transfer_hook_accounts")
454466
.unwrap_or_default()
@@ -483,12 +495,23 @@ extraMetas:
483495
println!("Signature: {signature}");
484496
}
485497
("update-extra-metas", arg_matches) => {
486-
let program_id = pubkey_of_signer(arg_matches, "program_id", &mut wallet_manager)
487-
.unwrap()
498+
let program_id_source = arg_matches
499+
.try_get_one::<SignerSource>("program_id")?
488500
.unwrap();
489-
let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager)
490-
.unwrap()
501+
let program_id = pubkey_from_source(
502+
arg_matches,
503+
program_id_source,
504+
"program_id",
505+
&mut wallet_manager,
506+
)
507+
.unwrap();
508+
509+
let token_source = arg_matches
510+
.try_get_one::<SignerSource>("program_id")?
491511
.unwrap();
512+
let token = pubkey_from_source(arg_matches, token_source, "token", &mut wallet_manager)
513+
.unwrap();
514+
492515
let transfer_hook_accounts = arg_matches
493516
.get_many::<Vec<ExtraAccountMeta>>("transfer_hook_accounts")
494517
.unwrap_or_default()

0 commit comments

Comments
 (0)