@@ -94,14 +94,13 @@ fn check_fee_payer_balance(config: &Config, required_balance: u64) -> Result<(),
9494 }
9595}
9696
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
10099 . get_program_accounts_with_config (
101100 & stake_program_id ( ) ,
102101 RpcProgramAccountsConfig {
103102 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
105104 bytes: MemcmpEncodedBytes :: Binary (
106105 bs58:: encode( authority. to_bytes( ) ) . into_string( ) ,
107106 ) ,
@@ -692,7 +691,7 @@ fn command_list(config: &Config, pool: &Pubkey) -> CommandResult {
692691 )
693692 . unwrap ( ) ;
694693
695- let accounts = get_authority_accounts ( config, & pool_withdraw_authority) ;
694+ let accounts = get_authority_accounts ( & config. rpc_client , & pool_withdraw_authority) ;
696695
697696 if accounts. is_empty ( ) {
698697 return Err ( "No accounts found." . to_string ( ) . into ( ) ) ;
@@ -785,20 +784,17 @@ struct WithdrawAccount {
785784}
786785
787786fn prepare_withdraw_accounts (
788- config : & Config ,
787+ rpc_client : & RpcClient ,
789788 stake_pool : & StakePool ,
790789 pool_withdraw_authority : & Pubkey ,
791790 pool_amount : u64 ,
792791) -> 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) ;
794793 if accounts. is_empty ( ) {
795794 return Err ( "No accounts found." . to_string ( ) . into ( ) ) ;
796795 }
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 ) ?;
802798 let pool_mint = TokenMint :: unpack_from_slice ( pool_mint_data. as_slice ( ) ) . unwrap ( ) ;
803799 pick_withdraw_accounts (
804800 & mut accounts,
@@ -905,8 +901,12 @@ fn command_withdraw(
905901 }
906902
907903 // 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+ ) ?;
910910
911911 // Construct transaction to withdraw from withdraw_accounts account list
912912 let mut instructions: Vec < Instruction > = vec ! [ ] ;
0 commit comments