tensor_eigen/formatting/
wallet.rs

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
42
43
44
45
46
47
48
49
50
use console::Style;
use solana_sdk::native_token::lamports_to_sol;

use crate::{formatting::pad_label, Shard};

use super::{AccountEntry, CustomFormat};

const LABEL_LENGTH: usize = 15;

impl CustomFormat for Shard {
    fn custom_format(&self) -> String {
        // Use the default text color but set this up for future use.
        let color = Style::new();

        format!(
            "{}
{}: {}
{}: {}
{}: {}",
            color.apply_to("Tensor Fee Shard"),
            pad_label("address", LABEL_LENGTH),
            color.apply_to(self.address.to_string()),
            pad_label("lamports", LABEL_LENGTH),
            color.apply_to(self.account.lamports),
            pad_label("SOL", LABEL_LENGTH),
            color.apply_to(lamports_to_sol(self.account.lamports)),
        )
    }
}

impl CustomFormat for AccountEntry {
    fn custom_format(&self) -> String {
        // Use the default text color but set this up for future use.
        let color = Style::new();

        format!(
            "{}
{}: {}
{}: {}
{}: {}",
            color.apply_to("Wallet---------"),
            pad_label("lamports", LABEL_LENGTH),
            color.apply_to(self.account.lamports),
            pad_label("SOL", LABEL_LENGTH),
            color.apply_to(lamports_to_sol(self.account.lamports)),
            pad_label("pda", LABEL_LENGTH),
            color.apply_to((!self.address.is_on_curve()).to_string()),
        )
    }
}