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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use borsh::{BorshDeserialize, BorshSerialize};
use solana_client::rpc_client::RpcClient;
use solana_program::pubkey::Pubkey;
use tabled::Tabled;

#[derive(BorshDeserialize, BorshSerialize, Tabled)]
pub struct MintWrapper {
    /// Base account.
    pub base: Pubkey,
    /// Bump for allowing the proxy mint authority to sign.
    pub bump: u8,
    /// Maximum number of tokens that can be issued.
    pub hard_cap: u64,

    /// Admin account.
    pub admin: Pubkey,
    /// Next admin account.
    pub pending_admin: Pubkey,

    /// Mint of the token.
    pub token_mint: Pubkey,
    /// Number of [Minter]s.
    pub num_minters: u64,

    /// Total allowance outstanding.
    pub total_allowance: u64,
    /// Total amount of tokens minted through the [MintWrapper].
    pub total_minted: u64,
}


impl MintWrapper {
    pub fn get_info(rpc_client: &RpcClient, pubkey: &Pubkey) -> Self {
        let data_slice = &rpc_client.get_account_data(pubkey).unwrap()[8..];
        MintWrapper::try_from_slice(data_slice).unwrap()
    }
    pub fn new() -> Self {
        Self {
            base: Default::default(),
            bump: 0,
            hard_cap: 0,
            admin: Default::default(),
            pending_admin: Default::default(),
            token_mint: Default::default(),
            num_minters: 0,
            total_allowance: 0,
            total_minted: 0
        }
    }
}


#[derive(BorshDeserialize, BorshSerialize, Tabled)]
pub struct Minter {
    /// The mint wrapper.
    pub mint_wrapper: Pubkey,
    /// Address that can mint.
    pub minter_authority: Pubkey,
    /// Bump seed.
    pub bump: u8,

    /// Auto-incrementing index of the [Minter].
    pub index: u64,

    /// Limit of number of tokens that this [Minter] can mint.
    pub allowance: u64,
    /// Cumulative sum of the number of tokens ever minted by this [Minter].
    pub total_minted: u64,
}


impl Minter {
    pub fn get_info(rpc_client: &RpcClient, pubkey: &Pubkey) -> Self {
        let data_slice = &rpc_client.get_account_data(pubkey).unwrap()[8..];
        Minter::try_from_slice(data_slice).unwrap()
    }
    pub fn new() -> Self {
        Self {
            mint_wrapper: Default::default(),
            minter_authority: Default::default(),
            bump: 0,
            index: 0,
            allowance: 0,
            total_minted: 0
        }
    }
}