use solana_program::pubkey::Pubkey;
use crate::consts::{ALLOCATION, CAMPAIGN, CONFIG, FEE_ACCOUNT, MINT, MINT_AUTHORITY, TREASURY};
pub fn config_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[CONFIG], &crate::id())
}
pub fn fee_account_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[FEE_ACCOUNT], &crate::id())
}
pub fn campaign_pda(campaign_id: &[u8]) -> (Pubkey, u8) {
Pubkey::find_program_address(&[CAMPAIGN, campaign_id], &crate::id())
}
pub fn mint_pda(mint_id: &[u8], noise: &[u8; 4]) -> (Pubkey, u8) {
Pubkey::find_program_address(&[MINT, mint_id, noise], &crate::id())
}
pub fn mint_authority_pda(mint: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[MINT_AUTHORITY, mint.as_ref()], &crate::id())
}
pub fn mint_treasury_pda(mint: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(&[TREASURY, mint.as_ref()], &crate::id())
}
pub fn campaign_treasury_pda(campaign_id: &[u8]) -> (Pubkey, u8) {
Pubkey::find_program_address(&[TREASURY, campaign_id], &crate::id())
}
pub fn allocation_pda(campaign: Pubkey, recipient: Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[ALLOCATION, campaign.as_ref(), recipient.as_ref()],
&crate::id(),
)
}