37
37
spl_stake_pool:: {
38
38
self , find_stake_program_address, find_transient_stake_program_address,
39
39
find_withdraw_authority_program_address,
40
- instruction:: PreferredValidatorType ,
40
+ instruction:: { DepositType , PreferredValidatorType } ,
41
41
stake_program:: { self , StakeState } ,
42
42
state:: { Fee , FeeType , StakePool , ValidatorList } ,
43
43
} ,
@@ -1378,7 +1378,7 @@ fn command_set_deposit_authority(
1378
1378
config : & Config ,
1379
1379
stake_pool_address : & Pubkey ,
1380
1380
new_sol_deposit_authority : Option < Pubkey > ,
1381
- for_stake_deposit : bool ,
1381
+ deposit_type : DepositType ,
1382
1382
) -> CommandResult {
1383
1383
let mut signers = vec ! [ config. fee_payer. as_ref( ) , config. manager. as_ref( ) ] ;
1384
1384
unique_signers ! ( signers) ;
@@ -1389,7 +1389,7 @@ fn command_set_deposit_authority(
1389
1389
stake_pool_address,
1390
1390
& config. manager . pubkey ( ) ,
1391
1391
new_sol_deposit_authority. as_ref ( ) ,
1392
- for_stake_deposit ,
1392
+ deposit_type ,
1393
1393
) ] ,
1394
1394
& signers,
1395
1395
) ?;
@@ -2039,8 +2039,8 @@ fn main() {
2039
2039
. help ( "Public key for the new stake pool staker." ) ,
2040
2040
)
2041
2041
)
2042
- . subcommand ( SubCommand :: with_name ( "set-sol- deposit-authority" )
2043
- . about ( "Change sol deposit authority account for the stake pool. Must be signed by the manager." )
2042
+ . subcommand ( SubCommand :: with_name ( "set-deposit-authority" )
2043
+ . about ( "Change deposit authority account for the stake pool. Must be signed by the manager." )
2044
2044
. arg (
2045
2045
Arg :: with_name ( "pool" )
2046
2046
. index ( 1 )
@@ -2051,39 +2051,17 @@ fn main() {
2051
2051
. help ( "Stake pool address." ) ,
2052
2052
)
2053
2053
. arg (
2054
- Arg :: with_name ( "new_sol_deposit_authority " )
2054
+ Arg :: with_name ( "deposit_type " )
2055
2055
. index ( 2 )
2056
- . validator ( is_pubkey)
2057
- . value_name ( "ADDRESS" )
2058
- . takes_value ( true )
2059
- . help ( "The public key for the new stake pool sol deposit authority." ) ,
2060
- )
2061
- . arg (
2062
- Arg :: with_name ( "unset" )
2063
- . long ( "unset" )
2064
- . takes_value ( false )
2065
- . help ( "Unset the sol deposit authority." )
2066
- )
2067
- . group ( ArgGroup :: with_name ( "validator" )
2068
- . arg ( "new_sol_deposit_authority" )
2069
- . arg ( "unset" )
2070
- . required ( true )
2071
- )
2072
- )
2073
- . subcommand ( SubCommand :: with_name ( "set-stake-deposit-authority" )
2074
- . about ( "Change stake deposit authority account for the stake pool. Must be signed by the manager." )
2075
- . arg (
2076
- Arg :: with_name ( "pool" )
2077
- . index ( 1 )
2078
- . validator ( is_pubkey)
2079
- . value_name ( "POOL_ADDRESS" )
2056
+ . value_name ( "DEPOSIT_TYPE" )
2057
+ . possible_values ( & [ "stake" , "sol" ] ) // DepositType enum
2080
2058
. takes_value ( true )
2081
2059
. required ( true )
2082
- . help ( "Stake pool address ." ) ,
2060
+ . help ( "Deposit type to be updated ." ) ,
2083
2061
)
2084
2062
. arg (
2085
2063
Arg :: with_name ( "new_stake_deposit_authority" )
2086
- . index ( 2 )
2064
+ . index ( 3 )
2087
2065
. validator ( is_pubkey)
2088
2066
. value_name ( "ADDRESS_OR_NONE" )
2089
2067
. takes_value ( true )
@@ -2115,7 +2093,7 @@ fn main() {
2115
2093
. arg ( Arg :: with_name ( "fee_type" )
2116
2094
. index ( 2 )
2117
2095
. value_name ( "FEE_TYPE" )
2118
- . possible_values ( & [ "epoch" , "stake-deposit" , "sol-deposit" , "withdrawal" ] ) // PreferredValidatorType enum
2096
+ . possible_values ( & [ "epoch" , "stake-deposit" , "sol-deposit" , "withdrawal" ] ) // FeeType enum
2119
2097
. takes_value ( true )
2120
2098
. required ( true )
2121
2099
. help ( "Fee type to be updated." ) ,
@@ -2139,7 +2117,7 @@ fn main() {
2139
2117
. help ( "Fee denominator, fee amount is numerator divided by denominator." ) ,
2140
2118
)
2141
2119
)
2142
- . subcommand ( SubCommand :: with_name ( "set-stake- referral-fee" )
2120
+ . subcommand ( SubCommand :: with_name ( "set-referral-fee" )
2143
2121
. about ( "Change the referral fee assessed by the stake pool for stake deposits. Must be signed by the manager." )
2144
2122
. arg (
2145
2123
Arg :: with_name ( "pool" )
@@ -2150,29 +2128,17 @@ fn main() {
2150
2128
. required ( true )
2151
2129
. help ( "Stake pool address." ) ,
2152
2130
)
2153
- . arg (
2154
- Arg :: with_name ( "fee" )
2155
- . index ( 2 )
2156
- . validator ( is_valid_percentage)
2157
- . value_name ( "FEE_PERCENTAGE" )
2158
- . takes_value ( true )
2159
- . required ( true )
2160
- . help ( "Fee percentage, maximum 100" ) ,
2161
- )
2162
- ) . subcommand ( SubCommand :: with_name ( "set-sol-referral-fee" )
2163
- . about ( "Change the referral fee assessed by the stake pool for SOL deposits. Must be signed by the manager." )
2164
- . arg (
2165
- Arg :: with_name ( "pool" )
2166
- . index ( 1 )
2167
- . validator ( is_pubkey)
2168
- . value_name ( "POOL_ADDRESS" )
2169
- . takes_value ( true )
2170
- . required ( true )
2171
- . help ( "Stake pool address." ) ,
2131
+ . arg ( Arg :: with_name ( "fee_type" )
2132
+ . index ( 2 )
2133
+ . value_name ( "FEE_TYPE" )
2134
+ . possible_values ( & [ "stake" , "sol" ] ) // FeeType enum, kind of
2135
+ . takes_value ( true )
2136
+ . required ( true )
2137
+ . help ( "Fee type to be updated." ) ,
2172
2138
)
2173
2139
. arg (
2174
2140
Arg :: with_name ( "fee" )
2175
- . index ( 2 )
2141
+ . index ( 3 )
2176
2142
. validator ( is_valid_percentage)
2177
2143
. value_name ( "FEE_PERCENTAGE" )
2178
2144
. takes_value ( true )
@@ -2408,26 +2374,20 @@ fn main() {
2408
2374
let new_staker = pubkey_of ( arg_matches, "new_staker" ) . unwrap ( ) ;
2409
2375
command_set_staker ( & config, & stake_pool_address, & new_staker)
2410
2376
}
2411
- ( "set-stake- deposit-authority" , Some ( arg_matches) ) => {
2377
+ ( "set-deposit-authority" , Some ( arg_matches) ) => {
2412
2378
let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
2413
2379
let new_stake_deposit_authority = pubkey_of ( arg_matches, "new_stake_deposit_authority" ) ;
2380
+ let deposit_type = match arg_matches. value_of ( "deposit_type" ) . unwrap ( ) {
2381
+ "sol" => DepositType :: Sol ,
2382
+ "stake" => DepositType :: Stake ,
2383
+ _ => unreachable ! ( ) ,
2384
+ } ;
2414
2385
let _unset = arg_matches. is_present ( "unset" ) ;
2415
2386
command_set_deposit_authority (
2416
2387
& config,
2417
2388
& stake_pool_address,
2418
2389
new_stake_deposit_authority,
2419
- true ,
2420
- )
2421
- }
2422
- ( "set-sol-deposit-authority" , Some ( arg_matches) ) => {
2423
- let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
2424
- let new_sol_deposit_authority = pubkey_of ( arg_matches, "new_sol_deposit_authority" ) ;
2425
- let _unset = arg_matches. is_present ( "unset" ) ;
2426
- command_set_deposit_authority (
2427
- & config,
2428
- & stake_pool_address,
2429
- new_sol_deposit_authority,
2430
- false ,
2390
+ deposit_type,
2431
2391
)
2432
2392
}
2433
2393
( "set-fee" , Some ( arg_matches) ) => {
@@ -2452,21 +2412,18 @@ fn main() {
2452
2412
_ => unreachable ! ( ) ,
2453
2413
}
2454
2414
}
2455
- ( "set-stake- referral-fee" , Some ( arg_matches) ) => {
2415
+ ( "set-referral-fee" , Some ( arg_matches) ) => {
2456
2416
let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
2457
2417
let fee = value_t_or_exit ! ( arg_matches, "fee" , u8 ) ;
2458
2418
if fee > 100u8 {
2459
2419
panic ! ( "Invalid fee {}%. Fee needs to be in range [0-100]" , fee) ;
2460
2420
}
2461
- command_set_fee ( & config, & stake_pool_address, FeeType :: StakeReferral ( fee) )
2462
- }
2463
- ( "set-sol-referral-fee" , Some ( arg_matches) ) => {
2464
- let stake_pool_address = pubkey_of ( arg_matches, "pool" ) . unwrap ( ) ;
2465
- let fee = value_t_or_exit ! ( arg_matches, "fee" , u8 ) ;
2466
- if fee > 100u8 {
2467
- panic ! ( "Invalid fee {}%. Fee needs to be in range [0-100]" , fee) ;
2468
- }
2469
- command_set_fee ( & config, & stake_pool_address, FeeType :: SolReferral ( fee) )
2421
+ let fee_type = match arg_matches. value_of ( "fee_type" ) . unwrap ( ) {
2422
+ "sol" => FeeType :: SolReferral ( fee) ,
2423
+ "stake" => FeeType :: StakeReferral ( fee) ,
2424
+ _ => unreachable ! ( ) ,
2425
+ } ;
2426
+ command_set_fee ( & config, & stake_pool_address, fee_type)
2470
2427
}
2471
2428
_ => unreachable ! ( ) ,
2472
2429
}
0 commit comments