clmm-mine 0.1.13

Blockchain, Clmm for Solana
Documentation
use colored::Colorize;
use solana_client::rpc_client::RpcClient;
use solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig};
use solana_client::rpc_filter::{RpcFilterType};
use tabled::{Alignment, Modify, Panel, Style, Table};
use tabled::object::Segment;
use tabled::style::Color;
use borsh::{BorshDeserialize};
use common::command::{CliConfig, ProcessResult};
use common::contract::state::farming::mine::Quarry;
use common::program::{MINE_PROGRAM_ID};
use solana_account_decoder::UiAccountEncoding;


#[allow(deprecated)]
pub fn process_farming_quarry_mine_list(
    rpc_client: &RpcClient,
    _: &CliConfig,
) -> ProcessResult {
    let accounts = rpc_client.get_program_accounts_with_config(
        &MINE_PROGRAM_ID,
        RpcProgramAccountsConfig {
            filters: Some(
                vec![
                    RpcFilterType::DataSize(
                        (Quarry::LEN + 8) as u64
                    )
                ]
            ),
            account_config: RpcAccountInfoConfig {
                encoding: Some(UiAccountEncoding::Base64),
                data_slice: None,
                commitment: None,
                min_context_slot: None
            },
            with_context: None
        }
    );
    println!("{:?}", accounts);

    let mut list = Vec::new();
    for account in accounts.unwrap() {
        let data_slice = &account.1.data[8..];
        list.push(Quarry::try_from_slice(data_slice).unwrap());
    };

    let color = Color::try_from(" ".cyan().to_string()).unwrap();

    Ok(Table::new(list)
        .with(Style::modern())
        .with(color)
        .with(Panel("Quarry List", 0))
        .with(Modify::new(Segment::all()).with(Alignment::center()))
        .to_string())
}