6
6
} ,
7
7
solana_clap_v3_utils:: {
8
8
fee_payer:: fee_payer_arg,
9
- input_validators:: {
10
- is_amount, is_amount_or_all, is_parsable, is_pubkey, is_url_or_moniker,
11
- is_valid_pubkey, is_valid_signer,
12
- } ,
9
+ input_parsers:: Amount ,
10
+ input_validators:: { is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer} ,
13
11
memo:: memo_arg,
14
12
nonce:: * ,
15
13
offline:: { self , * } ,
@@ -306,16 +304,12 @@ pub fn mint_address_arg<'a>() -> Arg<'a> {
306
304
. help ( MINT_ADDRESS_ARG . help )
307
305
}
308
306
309
- fn is_mint_decimals ( string : & str ) -> Result < ( ) , String > {
310
- is_parsable :: < u8 > ( string)
311
- }
312
-
313
307
pub fn mint_decimals_arg < ' a > ( ) -> Arg < ' a > {
314
308
Arg :: with_name ( MINT_DECIMALS_ARG . name )
315
309
. long ( MINT_DECIMALS_ARG . long )
316
310
. takes_value ( true )
317
311
. value_name ( "MINT_DECIMALS" )
318
- . validator ( is_mint_decimals )
312
+ . value_parser ( clap :: value_parser! ( u8 ) )
319
313
. help ( MINT_DECIMALS_ARG . help )
320
314
}
321
315
@@ -344,7 +338,7 @@ pub fn transfer_lamports_arg<'a>() -> Arg<'a> {
344
338
. long ( TRANSFER_LAMPORTS_ARG . long )
345
339
. takes_value ( true )
346
340
. value_name ( "LAMPORTS" )
347
- . validator ( |s| is_amount ( s ) )
341
+ . value_parser ( clap :: value_parser! ( u64 ) )
348
342
. help ( TRANSFER_LAMPORTS_ARG . help )
349
343
}
350
344
@@ -477,7 +471,7 @@ impl BenchSubCommand for App<'_> {
477
471
)
478
472
. arg (
479
473
Arg :: with_name ( "n" )
480
- . validator ( is_parsable :: < usize > )
474
+ . value_parser ( clap :: value_parser! ( usize ) )
481
475
. value_name ( "N" )
482
476
. takes_value ( true )
483
477
. index ( 2 )
@@ -500,7 +494,7 @@ impl BenchSubCommand for App<'_> {
500
494
)
501
495
. arg (
502
496
Arg :: with_name ( "n" )
503
- . validator ( is_parsable :: < usize > )
497
+ . value_parser ( clap :: value_parser! ( usize ) )
504
498
. value_name ( "N" )
505
499
. takes_value ( true )
506
500
. index ( 2 )
@@ -523,7 +517,7 @@ impl BenchSubCommand for App<'_> {
523
517
)
524
518
. arg (
525
519
Arg :: with_name ( "n" )
526
- . validator ( is_parsable :: < usize > )
520
+ . value_parser ( clap :: value_parser! ( usize ) )
527
521
. value_name ( "N" )
528
522
. takes_value ( true )
529
523
. index ( 2 )
@@ -532,7 +526,7 @@ impl BenchSubCommand for App<'_> {
532
526
)
533
527
. arg (
534
528
Arg :: with_name ( "amount" )
535
- . validator ( |s| is_amount ( s ) )
529
+ . value_parser ( Amount :: parse )
536
530
. value_name ( "TOKEN_AMOUNT" )
537
531
. takes_value ( true )
538
532
. index ( 3 )
@@ -563,7 +557,7 @@ impl BenchSubCommand for App<'_> {
563
557
)
564
558
. arg (
565
559
Arg :: with_name ( "n" )
566
- . validator ( is_parsable :: < usize > )
560
+ . value_parser ( clap :: value_parser! ( usize ) )
567
561
. value_name ( "N" )
568
562
. takes_value ( true )
569
563
. index ( 2 )
@@ -572,7 +566,7 @@ impl BenchSubCommand for App<'_> {
572
566
)
573
567
. arg (
574
568
Arg :: with_name ( "amount" )
575
- . validator ( |s| is_amount ( s ) )
569
+ . value_parser ( Amount :: parse )
576
570
. value_name ( "TOKEN_AMOUNT" )
577
571
. takes_value ( true )
578
572
. index ( 3 )
@@ -676,7 +670,7 @@ pub fn app<'a>(
676
670
. takes_value ( true )
677
671
. global ( true )
678
672
. value_name ( "COMPUTE-UNIT-LIMIT" )
679
- . validator ( is_parsable :: < u32 > )
673
+ . value_parser ( clap :: value_parser! ( u32 ) )
680
674
. help ( COMPUTE_UNIT_LIMIT_ARG . help )
681
675
)
682
676
. arg (
@@ -685,7 +679,7 @@ pub fn app<'a>(
685
679
. takes_value ( true )
686
680
. global ( true )
687
681
. value_name ( "COMPUTE-UNIT-PRICE" )
688
- . validator ( is_parsable :: < u64 > )
682
+ . value_parser ( clap :: value_parser! ( u64 ) )
689
683
. help ( COMPUTE_UNIT_PRICE_ARG . help )
690
684
)
691
685
. bench_subcommand ( )
@@ -717,7 +711,7 @@ pub fn app<'a>(
717
711
. arg (
718
712
Arg :: with_name ( "decimals" )
719
713
. long ( "decimals" )
720
- . validator ( is_mint_decimals )
714
+ . value_parser ( clap :: value_parser! ( u8 ) )
721
715
. value_name ( "DECIMALS" )
722
716
. takes_value ( true )
723
717
. default_value ( default_decimals)
@@ -839,7 +833,7 @@ pub fn app<'a>(
839
833
. number_of_values ( 1 )
840
834
. conflicts_with ( "transfer_fee" )
841
835
. requires ( "transfer_fee_basis_points" )
842
- . validator ( |s| is_amount ( s ) )
836
+ . value_parser ( Amount :: parse )
843
837
. help (
844
838
"Add a UI amount maximum transfer fee to the mint. \
845
839
The mint authority can set and collect fees"
@@ -1090,7 +1084,7 @@ pub fn app<'a>(
1090
1084
)
1091
1085
. arg (
1092
1086
Arg :: with_name ( "max_size" )
1093
- . validator ( |s| is_amount ( s ) )
1087
+ . value_parser ( clap :: value_parser! ( u64 ) )
1094
1088
. value_name ( "MAX_SIZE" )
1095
1089
. takes_value ( true )
1096
1090
. required ( true )
@@ -1136,7 +1130,7 @@ pub fn app<'a>(
1136
1130
)
1137
1131
. arg (
1138
1132
Arg :: with_name ( "new_max_size" )
1139
- . validator ( |s| is_amount ( s ) )
1133
+ . value_parser ( clap :: value_parser! ( u64 ) )
1140
1134
. value_name ( "NEW_MAX_SIZE" )
1141
1135
. takes_value ( true )
1142
1136
. required ( true )
@@ -1350,7 +1344,7 @@ pub fn app<'a>(
1350
1344
)
1351
1345
. arg (
1352
1346
Arg :: with_name ( "amount" )
1353
- . validator ( |s| is_amount_or_all ( s ) )
1347
+ . value_parser ( Amount :: parse )
1354
1348
. value_name ( "TOKEN_AMOUNT" )
1355
1349
. takes_value ( true )
1356
1350
. index ( 2 )
@@ -1434,8 +1428,8 @@ pub fn app<'a>(
1434
1428
. arg (
1435
1429
Arg :: with_name ( "expected_fee" )
1436
1430
. long ( "expected-fee" )
1437
- . validator ( |s| is_amount ( s ) )
1438
- . value_name ( "TOKEN_AMOUNT " )
1431
+ . value_parser ( Amount :: parse )
1432
+ . value_name ( "EXPECTED_FEE " )
1439
1433
. takes_value ( true )
1440
1434
. help ( "Expected fee amount collected during the transfer" ) ,
1441
1435
)
@@ -1480,7 +1474,7 @@ pub fn app<'a>(
1480
1474
)
1481
1475
. arg (
1482
1476
Arg :: with_name ( "amount" )
1483
- . validator ( |s| is_amount_or_all ( s ) )
1477
+ . value_parser ( Amount :: parse )
1484
1478
. value_name ( "TOKEN_AMOUNT" )
1485
1479
. takes_value ( true )
1486
1480
. index ( 2 )
@@ -1514,7 +1508,7 @@ pub fn app<'a>(
1514
1508
)
1515
1509
. arg (
1516
1510
Arg :: with_name ( "amount" )
1517
- . validator ( |s| is_amount ( s ) )
1511
+ . value_parser ( Amount :: parse )
1518
1512
. value_name ( "TOKEN_AMOUNT" )
1519
1513
. takes_value ( true )
1520
1514
. index ( 2 )
@@ -1624,7 +1618,7 @@ pub fn app<'a>(
1624
1618
. about ( "Wrap native SOL in a SOL token account" )
1625
1619
. arg (
1626
1620
Arg :: with_name ( "amount" )
1627
- . validator ( |s| is_amount ( s ) )
1621
+ . value_parser ( Amount :: parse )
1628
1622
. value_name ( "AMOUNT" )
1629
1623
. takes_value ( true )
1630
1624
. index ( 1 )
@@ -1706,7 +1700,7 @@ pub fn app<'a>(
1706
1700
)
1707
1701
. arg (
1708
1702
Arg :: with_name ( "amount" )
1709
- . validator ( |s| is_amount ( s ) )
1703
+ . value_parser ( Amount :: parse )
1710
1704
. value_name ( "TOKEN_AMOUNT" )
1711
1705
. takes_value ( true )
1712
1706
. index ( 2 )
@@ -2337,8 +2331,8 @@ pub fn app<'a>(
2337
2331
)
2338
2332
. arg (
2339
2333
Arg :: with_name ( "maximum_fee" )
2340
- . value_name ( "TOKEN_AMOUNT " )
2341
- . validator ( |s| is_amount ( s ) )
2334
+ . value_name ( "MAXIMUM_FEE " )
2335
+ . value_parser ( Amount :: parse )
2342
2336
. takes_value ( true )
2343
2337
. required ( true )
2344
2338
. help ( "The new maximum transfer fee in UI amount" ) ,
@@ -2606,7 +2600,7 @@ pub fn app<'a>(
2606
2600
)
2607
2601
. arg (
2608
2602
Arg :: with_name ( "amount" )
2609
- . validator ( |s| is_amount_or_all ( s ) )
2603
+ . value_parser ( Amount :: parse )
2610
2604
. value_name ( "TOKEN_AMOUNT" )
2611
2605
. takes_value ( true )
2612
2606
. index ( 2 )
@@ -2643,7 +2637,7 @@ pub fn app<'a>(
2643
2637
)
2644
2638
. arg (
2645
2639
Arg :: with_name ( "amount" )
2646
- . validator ( |s| is_amount_or_all ( s ) )
2640
+ . value_parser ( Amount :: parse )
2647
2641
. value_name ( "TOKEN_AMOUNT" )
2648
2642
. takes_value ( true )
2649
2643
. index ( 2 )
0 commit comments