phase_protocol_sdk/state/
roadmap.rs1
2use crate::id;
3use anchor_lang::{account, prelude::Pubkey, prelude::*, AnchorDeserialize, AnchorSerialize};
4
5#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
6pub enum RoadmapGovType {
7 NFT,
8
9 SPL,
11}
12
13
14#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
15
16pub enum RoadmapState {
17 Draft,
19
20 LockedForMint,
21
22 Resolution,
23
24 StagedForResolution,
25
26 Actioning,
29
30 Actioned,
33
34 Refunding,
35
36 Complete,
38
39 Canceled,
40}
41
42#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
43pub struct RoadmapConfig {
44 pub usdc_team_withdrawl_account: Pubkey,
45 pub sol_team_withdrawal_account: Pubkey,
46 pub minting_account_plugin_program_address: Option<Pubkey>,
47 pub dev_authority: Pubkey,
49}
50
51
52#[account]
53#[derive(Debug)]
54pub struct Roadmap {
55 pub realm: Pubkey,
56 pub collection: Option<Pubkey>,
57 pub team_authority: Pubkey,
58 pub dao_authority: Pubkey,
59 pub metadata_shadow_drive: Pubkey,
60 pub governance_program_id: Pubkey,
61 pub governance_type: RoadmapGovType,
62 pub state: RoadmapState,
63 pub config: RoadmapConfig,
64 pub staged_phase_count: u8,
65 pub locked_phase_count: u8,
66 pub resolution_proposal: Option<Pubkey>,
67
68 pub locked_total_usdc: u64,
72 pub locked_total_sol: u64,
73
74 pub staged_total_usdc: u64,
76 pub staged_total_sol: u64,
77
78 pub approved_phase_count: u8,
79 pub phase_count: u8,
80 pub phases_complete: u8,
81 pub usdc_roadmap_pool: Pubkey,
82 pub sol_roadmap_pool: Pubkey,
83 pub mint_contract_record: Option<Pubkey>,
84 pub bump: u8,
85 pub initial_payout_percentage : u16,
86 pub has_initial_payout_completed : bool,
87 pub reserved: [u8; 15],
88 pub name: String,
89}
90
91impl Roadmap {
92 pub fn space(name: &str) -> usize {
93 8 +
94 std::mem::size_of::<Pubkey>() + 4 + std::mem::size_of::<Pubkey>() + std::mem::size_of::<Pubkey>() + std::mem::size_of::<Pubkey>() + std::mem::size_of::<Pubkey>() + std::mem::size_of::<Pubkey>() + 1+ 1 + std::mem::size_of::<RoadmapConfig>() +
103 1 + 1 + 4 + std::mem::size_of::<Pubkey>()+ 16 + 16 + 16 + 16 + 1 + 1 + 1 + std::mem::size_of::<Pubkey>()+ std::mem::size_of::<Pubkey>()+ 4 + std::mem::size_of::<Pubkey>()+ 1 + 16 + 1 + 15 + name.len()
121 }
122}
123
124
125pub fn get_roadmap_address(realm: &Pubkey, governance_program: &Pubkey) -> Pubkey {
126 Pubkey::find_program_address(
127 &[b"roadmap", governance_program.as_ref(), realm.as_ref()],
128 &id(),
129 )
130 .0
131}
132
133pub fn get_roadmap_pool_address(roadmap: &Pubkey, mint: &Pubkey) -> Pubkey {
134 Pubkey::find_program_address(&[b"roadmap_pool", roadmap.as_ref(), mint.as_ref()], &id()).0
135}