4
4
} ,
5
5
solana_clap_v3_utils:: {
6
6
fee_payer:: fee_payer_arg,
7
- input_parsers:: Amount ,
7
+ input_parsers:: { signer :: SignerSourceParserBuilder , Amount } ,
8
8
input_validators:: { is_pubkey, is_url_or_moniker, is_valid_pubkey, is_valid_signer} ,
9
9
memo:: memo_arg,
10
10
nonce:: * ,
@@ -280,6 +280,17 @@ pub fn owner_address_arg<'a>() -> Arg<'a> {
280
280
. help ( OWNER_ADDRESS_ARG . help )
281
281
}
282
282
283
+ // Temporary function that uses proper parsing to minimize commit size
284
+ // TODO: use this to replace `owner_address_arg`
285
+ pub fn owner_address_arg_temp < ' a > ( ) -> Arg < ' a > {
286
+ Arg :: with_name ( OWNER_ADDRESS_ARG . name )
287
+ . long ( OWNER_ADDRESS_ARG . long )
288
+ . takes_value ( true )
289
+ . value_name ( "OWNER_ADDRESS" )
290
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
291
+ . help ( OWNER_ADDRESS_ARG . help )
292
+ }
293
+
283
294
pub fn owner_keypair_arg_with_value_name < ' a > ( value_name : & ' static str ) -> Arg < ' a > {
284
295
Arg :: with_name ( OWNER_KEYPAIR_ARG . name )
285
296
. long ( OWNER_KEYPAIR_ARG . long )
@@ -1226,7 +1237,7 @@ pub fn app<'a>(
1226
1237
"Lock the owner of this token account from ever being changed"
1227
1238
) ,
1228
1239
)
1229
- . arg ( owner_address_arg ( ) )
1240
+ . arg ( owner_address_arg_temp ( ) )
1230
1241
. nonce_args ( true )
1231
1242
)
1232
1243
. subcommand (
@@ -1757,7 +1768,7 @@ pub fn app<'a>(
1757
1768
. arg (
1758
1769
Arg :: with_name ( "recipient" )
1759
1770
. long ( "recipient" )
1760
- . validator ( |s| is_valid_pubkey ( s ) )
1771
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
1761
1772
. value_name ( "REFUND_ACCOUNT_ADDRESS" )
1762
1773
. takes_value ( true )
1763
1774
. help ( "The address of the account to receive remaining SOL [default: --owner]" ) ,
@@ -1805,7 +1816,7 @@ pub fn app<'a>(
1805
1816
. arg (
1806
1817
Arg :: with_name ( "recipient" )
1807
1818
. long ( "recipient" )
1808
- . validator ( |s| is_valid_pubkey ( s ) )
1819
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
1809
1820
. value_name ( "REFUND_ACCOUNT_ADDRESS" )
1810
1821
. takes_value ( true )
1811
1822
. help ( "The address of the account to receive remaining SOL [default: --owner]" ) ,
@@ -1832,17 +1843,17 @@ pub fn app<'a>(
1832
1843
. about ( "Get token account balance" )
1833
1844
. arg (
1834
1845
Arg :: with_name ( "token" )
1835
- . validator ( |s| is_valid_pubkey ( s ) )
1846
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
1836
1847
. value_name ( "TOKEN_MINT_ADDRESS" )
1837
1848
. takes_value ( true )
1838
1849
. index ( 1 )
1839
1850
. required_unless ( "address" )
1840
1851
. help ( "Token of associated account. To query a specific account, use the `--address` parameter instead" ) ,
1841
1852
)
1842
- . arg ( owner_address_arg ( ) . conflicts_with ( "address" ) )
1853
+ . arg ( owner_address_arg_temp ( ) . conflicts_with ( "address" ) )
1843
1854
. arg (
1844
1855
Arg :: with_name ( "address" )
1845
- . validator ( |s| is_valid_pubkey ( s ) )
1856
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
1846
1857
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
1847
1858
. takes_value ( true )
1848
1859
. long ( "address" )
@@ -1903,7 +1914,7 @@ pub fn app<'a>(
1903
1914
"Print token account addresses only"
1904
1915
) ,
1905
1916
)
1906
- . arg ( owner_address_arg ( ) )
1917
+ . arg ( owner_address_arg_temp ( ) )
1907
1918
)
1908
1919
. subcommand (
1909
1920
SubCommand :: with_name ( CommandName :: Address . into ( ) )
@@ -1919,7 +1930,7 @@ pub fn app<'a>(
1919
1930
[Default: return the client keypair address]")
1920
1931
)
1921
1932
. arg (
1922
- owner_address_arg ( )
1933
+ owner_address_arg_temp ( )
1923
1934
. requires ( "token" )
1924
1935
. help ( "Return the associated token address for the given owner. \
1925
1936
[Default: return the associated token address for the client keypair]") ,
@@ -1931,7 +1942,7 @@ pub fn app<'a>(
1931
1942
. setting ( AppSettings :: Hidden )
1932
1943
. arg (
1933
1944
Arg :: with_name ( "token" )
1934
- . validator ( |s| is_valid_pubkey ( s ) )
1945
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
1935
1946
. value_name ( "TOKEN_MINT_ADDRESS" )
1936
1947
. takes_value ( true )
1937
1948
. index ( 1 )
@@ -2026,7 +2037,7 @@ pub fn app<'a>(
2026
2037
. about ( "Enable required transfer memos for token account" )
2027
2038
. arg (
2028
2039
Arg :: with_name ( "account" )
2029
- . validator ( |s| is_valid_pubkey ( s ) )
2040
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
2030
2041
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
2031
2042
. takes_value ( true )
2032
2043
. index ( 1 )
@@ -2044,7 +2055,7 @@ pub fn app<'a>(
2044
2055
. about ( "Disable required transfer memos for token account" )
2045
2056
. arg (
2046
2057
Arg :: with_name ( "account" )
2047
- . validator ( |s| is_valid_pubkey ( s ) )
2058
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
2048
2059
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
2049
2060
. takes_value ( true )
2050
2061
. index ( 1 )
@@ -2062,7 +2073,7 @@ pub fn app<'a>(
2062
2073
. about ( "Enable CPI Guard for token account" )
2063
2074
. arg (
2064
2075
Arg :: with_name ( "account" )
2065
- . validator ( |s| is_valid_pubkey ( s ) )
2076
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
2066
2077
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
2067
2078
. takes_value ( true )
2068
2079
. index ( 1 )
@@ -2080,7 +2091,7 @@ pub fn app<'a>(
2080
2091
. about ( "Disable CPI Guard for token account" )
2081
2092
. arg (
2082
2093
Arg :: with_name ( "account" )
2083
- . validator ( |s| is_valid_pubkey ( s ) )
2094
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
2084
2095
. value_name ( "TOKEN_ACCOUNT_ADDRESS" )
2085
2096
. takes_value ( true )
2086
2097
. index ( 1 )
@@ -2355,15 +2366,15 @@ pub fn app<'a>(
2355
2366
. about ( "Withdraw lamports from a Token Program owned account" )
2356
2367
. arg (
2357
2368
Arg :: with_name ( "from" )
2358
- . validator ( |s| is_valid_pubkey ( s ) )
2369
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
2359
2370
. value_name ( "SOURCE_ACCOUNT_ADDRESS" )
2360
2371
. takes_value ( true )
2361
2372
. required ( true )
2362
2373
. help ( "Specify the address of the account to recover lamports from" ) ,
2363
2374
)
2364
2375
. arg (
2365
2376
Arg :: with_name ( "recipient" )
2366
- . validator ( |s| is_valid_pubkey ( s ) )
2377
+ . value_parser ( SignerSourceParserBuilder :: default ( ) . allow_all ( ) . build ( ) )
2367
2378
. value_name ( "REFUND_ACCOUNT_ADDRESS" )
2368
2379
. takes_value ( true )
2369
2380
. required ( true )
0 commit comments