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
use std::collections::HashMap;

use {
    super::{Indexing, Service},
    anchor_lang::prelude::*,
    hpl_utils::Default,
};

/// Project State Account
#[account]
pub struct Project {
    pub bump: u8,
    pub authority: Pubkey,        // 32 bytes
    pub key: Pubkey,              // 32 bytes
    pub driver: Pubkey,           // 32 bytes
    pub name: String,             // 64 Bytes
    pub mint_indexing: Indexing, // Rest we have 8830 bytes left for staking and size of indexing is about n/255*32+2 must be less then 8830 so maximum nfts we can theoritically index are 70,000
    pub services: Vec<Service>, // 2 + 33*n Bytes while n=number of services, let's say project has 30 services so it'll be 33*30+2 = 992 Bytes
    pub collections: Vec<Pubkey>, // 2+32*n Bytes while n=number of collections, let's say project has 5 collections so it'll be 32*5+2 = 162 Bytes
    pub creators: Vec<Pubkey>, // 2+32*n Bytes while n=number of creators, let's say project has 5 creators so it'll be 32*5+2 = 162 Bytes
    pub allowed_programs: Vec<Pubkey>,
    pub profile_data_config: HashMap<String, ProfileDataType>,
}

impl Default for Project {
    const LEN: usize = 256 + 8; // base size + 8 align

    fn set_defaults(&mut self) {
        self.bump = 0;
        self.key = Pubkey::default();
        self.driver = Pubkey::default();
        self.name = "".to_string();
        self.mint_indexing = Indexing::default();
        self.services = vec![];
        self.collections = vec![];
        self.creators = vec![];
        self.allowed_programs = vec![];
        self.profile_data_config = HashMap::new();
    }
}

#[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug, PartialEq)]
pub enum ProfileDataType {
    SingleValue,
    MultiValue,
    Entity {
        merkle_tree_max_depth: u32,
        merkle_tree_max_buffer_size: u32,
    },
}
impl ProfileDataType {
    pub const LEN: usize = 12 + 4;
}