@@ -94,14 +94,13 @@ fn check_fee_payer_balance(config: &Config, required_balance: u64) -> Result<(),
94
94
}
95
95
}
96
96
97
- fn get_authority_accounts ( config : & Config , authority : & Pubkey ) -> Vec < ( Pubkey , Account ) > {
98
- config
99
- . rpc_client
97
+ fn get_authority_accounts ( rpc_client : & RpcClient , authority : & Pubkey ) -> Vec < ( Pubkey , Account ) > {
98
+ rpc_client
100
99
. get_program_accounts_with_config (
101
100
& stake_program_id ( ) ,
102
101
RpcProgramAccountsConfig {
103
102
filters : Some ( vec ! [ RpcFilterType :: Memcmp ( Memcmp {
104
- offset: 44 , // 44 is Withdrawer authority offset in stake accoun stake
103
+ offset: 44 , // 44 is Withdrawer authority offset in stake account stake
105
104
bytes: MemcmpEncodedBytes :: Binary (
106
105
bs58:: encode( authority. to_bytes( ) ) . into_string( ) ,
107
106
) ,
@@ -692,7 +691,7 @@ fn command_list(config: &Config, pool: &Pubkey) -> CommandResult {
692
691
)
693
692
. unwrap ( ) ;
694
693
695
- let accounts = get_authority_accounts ( config, & pool_withdraw_authority) ;
694
+ let accounts = get_authority_accounts ( & config. rpc_client , & pool_withdraw_authority) ;
696
695
697
696
if accounts. is_empty ( ) {
698
697
return Err ( "No accounts found." . to_string ( ) . into ( ) ) ;
@@ -785,20 +784,17 @@ struct WithdrawAccount {
785
784
}
786
785
787
786
fn prepare_withdraw_accounts (
788
- config : & Config ,
787
+ rpc_client : & RpcClient ,
789
788
stake_pool : & StakePool ,
790
789
pool_withdraw_authority : & Pubkey ,
791
790
pool_amount : u64 ,
792
791
) -> Result < Vec < WithdrawAccount > , Error > {
793
- let mut accounts = get_authority_accounts ( config , & pool_withdraw_authority) ;
792
+ let mut accounts = get_authority_accounts ( rpc_client , & pool_withdraw_authority) ;
794
793
if accounts. is_empty ( ) {
795
794
return Err ( "No accounts found." . to_string ( ) . into ( ) ) ;
796
795
}
797
- let min_balance = config
798
- . rpc_client
799
- . get_minimum_balance_for_rent_exemption ( STAKE_STATE_LEN ) ?
800
- + 1 ;
801
- let pool_mint_data = config. rpc_client . get_account_data ( & stake_pool. pool_mint ) ?;
796
+ let min_balance = rpc_client. get_minimum_balance_for_rent_exemption ( STAKE_STATE_LEN ) ? + 1 ;
797
+ let pool_mint_data = rpc_client. get_account_data ( & stake_pool. pool_mint ) ?;
802
798
let pool_mint = TokenMint :: unpack_from_slice ( pool_mint_data. as_slice ( ) ) . unwrap ( ) ;
803
799
pick_withdraw_accounts (
804
800
& mut accounts,
@@ -905,8 +901,12 @@ fn command_withdraw(
905
901
}
906
902
907
903
// Get the list of accounts to withdraw from
908
- let withdraw_accounts: Vec < WithdrawAccount > =
909
- prepare_withdraw_accounts ( config, & pool_data, & pool_withdraw_authority, pool_amount) ?;
904
+ let withdraw_accounts: Vec < WithdrawAccount > = prepare_withdraw_accounts (
905
+ & config. rpc_client ,
906
+ & pool_data,
907
+ & pool_withdraw_authority,
908
+ pool_amount,
909
+ ) ?;
910
910
911
911
// Construct transaction to withdraw from withdraw_accounts account list
912
912
let mut instructions: Vec < Instruction > = vec ! [ ] ;
0 commit comments