use crate::id;
use anchor_lang::{account, prelude::Pubkey, prelude::*, AnchorDeserialize, AnchorSerialize};
#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
pub enum RoadmapGovType {
NFT,
SPL,
}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
pub enum RoadmapState {
Draft,
LockedForMint,
Resolution,
StagedForResolution,
Actioning,
Actioned,
Refunding,
Complete,
Canceled,
}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Debug)]
pub struct RoadmapConfig {
pub usdc_team_withdrawl_account: Pubkey,
pub sol_team_withdrawal_account: Pubkey,
pub minting_account_plugin_program_address: Option<Pubkey>,
pub dev_authority: Pubkey,
}
#[account]
#[derive(Debug)]
pub struct Roadmap {
pub realm: Pubkey,
pub collection: Option<Pubkey>,
pub team_authority: Pubkey,
pub dao_authority: Pubkey,
pub metadata_shadow_drive: Pubkey,
pub governance_program_id: Pubkey,
pub governance_type: RoadmapGovType,
pub state: RoadmapState,
pub config: RoadmapConfig,
pub staged_phase_count: u8,
pub locked_phase_count: u8,
pub resolution_proposal: Option<Pubkey>,
pub locked_total_usdc: u64,
pub locked_total_sol: u64,
pub staged_total_usdc: u64,
pub staged_total_sol: u64,
pub approved_phase_count: u8,
pub phase_count: u8,
pub phases_complete: u8,
pub usdc_roadmap_pool: Pubkey,
pub sol_roadmap_pool: Pubkey,
pub mint_contract_record: Option<Pubkey>,
pub bump: u8,
pub initial_payout_percentage : u16,
pub has_initial_payout_completed : bool,
pub reserved: [u8; 15],
pub name: String,
}
impl Roadmap {
pub fn space(name: &str) -> usize {
8 +
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>() +
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()
}
}
pub fn get_roadmap_address(realm: &Pubkey, governance_program: &Pubkey) -> Pubkey {
Pubkey::find_program_address(
&[b"roadmap", governance_program.as_ref(), realm.as_ref()],
&id(),
)
.0
}
pub fn get_roadmap_pool_address(roadmap: &Pubkey, mint: &Pubkey) -> Pubkey {
Pubkey::find_program_address(&[b"roadmap_pool", roadmap.as_ref(), mint.as_ref()], &id()).0
}