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

Commit d209ddf

Browse files
authored
[transfer-hook] Remove deprecated functions from cli (#6525)
* removed allow deprecated * remove deprecated validators * spelling * added allow_all() to SignerSourceParserBuilder
1 parent ff397a9 commit d209ddf

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#![allow(deprecated)]
2-
31
pub mod meta;
42

53
use {
64
crate::meta::parse_transfer_hook_account_arg,
75
clap::{crate_description, crate_name, crate_version, Arg, Command},
86
solana_clap_v3_utils::{
9-
input_parsers::{parse_url_or_moniker, pubkey_of_signer},
10-
input_validators::{is_valid_pubkey, is_valid_signer, normalize_to_url_if_moniker},
7+
input_parsers::{
8+
parse_url_or_moniker, pubkey_of_signer, signer::SignerSourceParserBuilder,
9+
},
10+
input_validators::normalize_to_url_if_moniker,
1111
keypair::DefaultSigner,
1212
},
1313
solana_client::nonblocking::rpc_client::RpcClient,
@@ -28,10 +28,6 @@ use {
2828
std::{process::exit, rc::Rc},
2929
};
3030

31-
fn clap_is_valid_pubkey(arg: &str) -> Result<(), String> {
32-
is_valid_pubkey(arg)
33-
}
34-
3531
// Helper function to calculate the required lamports for rent
3632
async fn calculate_rent_lamports(
3733
rpc_client: &RpcClient,
@@ -209,7 +205,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
209205
Arg::new("fee_payer")
210206
.long("fee-payer")
211207
.value_name("KEYPAIR")
212-
.validator(|s| is_valid_signer(s))
208+
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
213209
.takes_value(true)
214210
.global(true)
215211
.help("Filepath or URL to a keypair to pay transaction fee [default: client keypair]"),
@@ -237,7 +233,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
237233
.about("Create the extra account metas account for a transfer hook program")
238234
.arg(
239235
Arg::with_name("program_id")
240-
.validator(clap_is_valid_pubkey)
236+
.value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build())
241237
.value_name("TRANSFER_HOOK_PROGRAM")
242238
.takes_value(true)
243239
.index(1)
@@ -246,7 +242,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
246242
)
247243
.arg(
248244
Arg::with_name("token")
249-
.validator(clap_is_valid_pubkey)
245+
.value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build())
250246
.value_name("TOKEN_MINT_ADDRESS")
251247
.takes_value(true)
252248
.index(2)
@@ -265,7 +261,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
265261
266262
Additional accounts with known fixed addresses can be passed at the command line in the format "<PUBKEY>:<ROLE>". The role must be "readonly", "writable". "readonlySigner", or "writableSigner".
267263
268-
Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows:
264+
Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows:
269265
270266
```json
271267
{
@@ -310,7 +306,7 @@ extraMetas:
310306
Arg::new("mint_authority")
311307
.long("mint-authority")
312308
.value_name("KEYPAIR")
313-
.validator(|s| is_valid_signer(s))
309+
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
314310
.takes_value(true)
315311
.global(true)
316312
.help("Filepath or URL to mint-authority keypair [default: client keypair]"),
@@ -321,7 +317,7 @@ extraMetas:
321317
.about("Update the extra account metas account for a transfer hook program")
322318
.arg(
323319
Arg::with_name("program_id")
324-
.validator(clap_is_valid_pubkey)
320+
.value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build())
325321
.value_name("TRANSFER_HOOK_PROGRAM")
326322
.takes_value(true)
327323
.index(1)
@@ -330,7 +326,7 @@ extraMetas:
330326
)
331327
.arg(
332328
Arg::with_name("token")
333-
.validator(clap_is_valid_pubkey)
329+
.value_parser(SignerSourceParserBuilder::default().allow_pubkey().allow_file_path().build())
334330
.value_name("TOKEN_MINT_ADDRESS")
335331
.takes_value(true)
336332
.index(2)
@@ -349,7 +345,7 @@ extraMetas:
349345
350346
Additional accounts with known fixed addresses can be passed at the command line in the format "<PUBKEY>:<ROLE>". The role must be "readonly", "writable". "readonlySigner", or "writableSigner".
351347
352-
Additional acounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows:
348+
Additional accounts requiring seed configurations can be defined in a configuration file using either JSON or YAML. The format is as follows:
353349
354350
```json
355351
{
@@ -394,7 +390,7 @@ extraMetas:
394390
Arg::new("mint_authority")
395391
.long("mint-authority")
396392
.value_name("KEYPAIR")
397-
.validator(|s| is_valid_signer(s))
393+
.value_parser(SignerSourceParserBuilder::default().allow_all().build())
398394
.takes_value(true)
399395
.global(true)
400396
.help("Filepath or URL to mint-authority keypair [default: client keypair]"),

0 commit comments

Comments
 (0)