quarry_mint_wrapper/state.rs
1//! State structs.
2
3use crate::*;
4
5/// Mint wrapper
6///
7/// ```ignore
8/// seeds = [
9/// b"MintWrapper",
10/// base.key().to_bytes().as_ref(),
11/// &[bump]
12/// ],
13///
14#[account]
15#[derive(Copy, Default, Debug)]
16pub struct MintWrapper {
17 /// Base account.
18 pub base: Pubkey,
19 /// Bump for allowing the proxy mint authority to sign.
20 pub bump: u8,
21 /// Maximum number of tokens that can be issued.
22 pub hard_cap: u64,
23
24 /// Admin account.
25 pub admin: Pubkey,
26 /// Next admin account.
27 pub pending_admin: Pubkey,
28
29 /// Mint of the token.
30 pub token_mint: Pubkey,
31 /// Number of [Minter]s.
32 pub num_minters: u64,
33
34 /// Total allowance outstanding.
35 pub total_allowance: u64,
36 /// Total amount of tokens minted through the [MintWrapper].
37 pub total_minted: u64,
38}
39
40impl MintWrapper {
41 /// Number of bytes that a [MintWrapper] struct takes up.
42 pub const LEN: usize = 32 + 1 + 8 + 32 + 32 + 32 + 8 + 8 + 8;
43}
44
45/// One who can mint.
46///
47/// ```ignore
48/// seeds = [
49/// b"MintWrapperMinter",
50/// auth.mint_wrapper.key().to_bytes().as_ref(),
51/// minter_authority.key().to_bytes().as_ref(),
52/// &[bump]
53/// ],
54/// ```
55#[account]
56#[derive(Copy, Default, Debug)]
57pub struct Minter {
58 /// The mint wrapper.
59 pub mint_wrapper: Pubkey,
60 /// Address that can mint.
61 pub minter_authority: Pubkey,
62 /// Bump seed.
63 pub bump: u8,
64
65 /// Auto-incrementing index of the [Minter].
66 pub index: u64,
67
68 /// Limit of number of tokens that this [Minter] can mint.
69 pub allowance: u64,
70 /// Cumulative sum of the number of tokens ever minted by this [Minter].
71 pub total_minted: u64,
72}
73
74impl Minter {
75 /// Number of bytes that a [Minter] struct takes up.
76 pub const LEN: usize = 32 + 32 + 1 + 8 + 8 + 8;
77}
78
79#[cfg(test)]
80mod tests {
81 use super::*;
82
83 #[test]
84 fn test_mint_wrapper_len() {
85 assert_eq!(
86 MintWrapper::default().try_to_vec().unwrap().len(),
87 MintWrapper::LEN
88 );
89 }
90
91 #[test]
92 fn test_minter_len() {
93 assert_eq!(Minter::default().try_to_vec().unwrap().len(), Minter::LEN);
94 }
95}