1
2
3
4
5
6
7
8
9
10
11
12
13
14
use anchor_lang::prelude::Pubkey;

pub trait Abbreviated {
    fn abbreviated(&self) -> String;
}

impl Abbreviated for Pubkey {
    fn abbreviated(&self) -> String {
        let s = self.to_string();
        let len = s.len();
        format!("{}..{}", s.get(0..4).unwrap(), s.get(len - 4..len).unwrap()).to_string()
        // format!("{}{}", s.get(len - 8..len).unwrap()).to_string()
    }
}