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