1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
use std::str::FromStr;
use clap::ArgMatches;
use colored::Colorize;
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use tabled::{Alignment, Modify, Panel, Rotate, Style, Table};
use tabled::object::Segment;
use tabled::style::Color;
use borsh::BorshDeserialize;
use common::command::{CliCommand, CliCommandInfo, CliError, ProcessResult};
use common::contract::state::partner::Partner;
pub fn parse_partner_info<'a>(
matches: &'a ArgMatches,
) -> Result<CliCommandInfo<'a>, CliError> {
let partner_key = matches.value_of("partner_key");
Ok(CliCommandInfo {
command: CliCommand::PairPartnerInfo {
partner: Pubkey::from_str(partner_key.unwrap()).unwrap(),
},
signers: vec![],
})
}
pub fn process_partner_info(rpc_client: &RpcClient, partner: Pubkey) -> ProcessResult {
let data = rpc_client.get_account_data(&partner).unwrap();
let partner_account: Partner = Partner::deserialize(&mut &data[8..]).unwrap();
let color = Color::try_from(" ".cyan().to_string()).unwrap();
Ok(Table::new(vec![partner_account])
.with(Rotate::Bottom)
.with(Rotate::Right)
.with(Style::modern())
.with(color)
.with(Panel("Partner Account Info", 0))
.with(Modify::new(Segment::all()).with(Alignment::center()))
.to_string())
}