phase-protocol-sdk 0.3.0

Integration SDK for phase-protocol and fundraising programs
Documentation
use anchor_lang::prelude::Pubkey;
use anchor_lang::prelude::*;

/**
 * Plugin interface for using different minting contracts
 * The program plugin will implement this interface so we can get the needed
 * information to jusdge progress and setup of mint
 *
 */
#[account]
pub struct MintingAccountRecordPlugin {
    pub roadmap: Pubkey,
    /*
        Mint Program address
    */
    pub program_id: Pubkey,
    /*
        Mint pda account
    */
    pub minting_account: Pubkey,

    pub max_supply: u64,
    pub price: u64,
    pub quantity_left: u64,
    pub go_live_date: Option<i64>,
    /*
        Signifies that the minting has completed, either by minting
        out completly or being closed due to time restriction or
        decision by launchpad/team
        Only after this has been flipped can the roadmap be unlocked into
        either resolution or actioned
    */
    pub is_closed: bool,

    /*
        Collection mint associated to the minted nfts
        this is set by the team on the front end
    */
    pub collection_mint: Option<Pubkey>,

    /*
        Account used to delegate authority for the collection to the minting program to verify collection items
        as they are minted
        Suggested to make it the address of this plugin pda account
    */
    pub collection_authority_record_signer: Option<Pubkey>,

    pub bump: u8,

    pub reserved: [u8; 128],
}

impl MintingAccountRecordPlugin {
    pub fn space() -> usize {
        8 +
        std::mem::size_of::<Pubkey>() + // roadmap
        std::mem::size_of::<Pubkey>() + // program_id
        std::mem::size_of::<Pubkey>() +  // minting account
        std::mem::size_of::<u64>() + // max supply
        std::mem::size_of::<u64>() + //price
        std::mem::size_of::<u64>() + //quantity left
        std::mem::size_of::<Option<i64>>() + // go live
        1 + //is_closed
        std::mem::size_of::<Option<Pubkey>>() + // collection_mint
        std::mem::size_of::<Option<Pubkey>>() + // collection_authority_record_signer
        1 + // bump 
        128
    }
}

pub fn get_minting_account_record_plugin(roadmap: &Pubkey, program_id: &Pubkey) -> Pubkey {
    Pubkey::find_program_address(
        &[b"phase_minting_account_record", roadmap.as_ref()],
        &program_id,
    )
    .0
}