// This file is autogenerated with https://github.com/acheroncrypto/native-to-anchor

use anchor_lang::prelude::*;

declare_id!("11111111111111111111111111111111");

#[program]
pub mod spl_feature_proposal {
    use super::*;

    pub fn propose(
        ctx: Context<Propose>,
        tokens_to_mint: u64,
        acceptance_criteria: AcceptanceCriteria,
    ) -> Result<()> {
        Ok(())
    }

    pub fn tally(ctx: Context<Tally>) -> Result<()> {
        Ok(())
    }
}

#[derive(Accounts)]
pub struct Propose<'info> {
    #[account(mut)]
    funding_address: Signer<'info>,
    #[account(mut)]
    feature_proposal_address: Signer<'info>,
    #[account(mut)]
    mint_address: AccountInfo<'info>,
    #[account(mut)]
    distributor_token_address: AccountInfo<'info>,
    #[account(mut)]
    acceptance_token_address: AccountInfo<'info>,
    #[account(mut)]
    feature: AccountInfo<'info>,
    system_program: Program<'info, System>,
    token_program: Program<'info, Token>,
    rent: Sysvar<'info, Rent>,
}

#[derive(Accounts)]
pub struct Tally<'info> {
    #[account(mut)]
    feature_proposal_address: AccountInfo<'info>,
    acceptance_token_address: AccountInfo<'info>,
    #[account(mut)]
    feature: AccountInfo<'info>,
    system_program: Program<'info, System>,
    clock: Sysvar<'info, Clock>,
}

#[account]
pub enum FeatureProposal {
    /// Default account state after creating it
    Uninitialized,
    /// Feature proposal is now pending
    Pending(AcceptanceCriteria),
    /// Feature proposal was accepted and the feature is now active
    Accepted {
        /// The balance of the feature proposal's token account at the time of activation.
        #[allow(dead_code)] // not dead code..
        tokens_upon_acceptance: u64,
    },
    /// Feature proposal was not accepted before the deadline
    Expired,
}

#[derive(AnchorSerialize, AnchorDeserialize)]
pub struct AcceptanceCriteria {
    /// The balance of the feature proposal's token account must be greater than this amount, and
    /// tallied before the deadline for the feature to be accepted.
    pub tokens_required: u64,

    /// If the required tokens are not tallied by this deadline then the proposal will expire.
    pub deadline: i64,
}
