superstate-allowlist-interface 0.1.0

Superstate Allowlist Interface
Documentation
use solana_pubkey::Pubkey;

/// For internal use only.
#[doc(hidden)]
pub const ALLOWLIST_PROGRAM_SEED_PREFIX: &str = "allowlist_program";

/// For internal use only.
#[doc(hidden)]
pub fn get_allowlist_program_pda(program_id: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[ALLOWLIST_PROGRAM_SEED_PREFIX.as_bytes()], program_id)
}

pub const PRIVATE_ALLOWLIST_PREFIX: &str = "private_allowlist";

pub fn get_private_allowlist_pda(mint: &Pubkey, program_id: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[PRIVATE_ALLOWLIST_PREFIX.as_bytes(), mint.as_ref()],
        program_id,
    )
}

/// For internal use only.
#[doc(hidden)]
pub const PUBLIC_ALLOWED_ACCOUNT_SEED_PREFIX: &str = "public_allowed_account";

/// PDA per user allowlisted address
/// For internal use only.
#[doc(hidden)]
pub fn get_public_allowed_account_pda(user_account: &Pubkey, program_id: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            PUBLIC_ALLOWED_ACCOUNT_SEED_PREFIX.as_bytes(),
            user_account.as_ref(),
        ],
        program_id,
    )
}

/// PDA per user allowlisted address
/// For internal use only.
#[doc(hidden)]
pub const PRIVATE_ALLOWED_ACCOUNT_SEED_PREFIX: &str = "private_allowed_account";

/// PDA per user allowlisted address/mint
/// For internal use only.
#[doc(hidden)]
pub fn get_private_allowed_account_pda(
    user_account: &Pubkey,
    mint: &Pubkey,
    program_id: &Pubkey,
) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            PRIVATE_ALLOWED_ACCOUNT_SEED_PREFIX.as_bytes(),
            user_account.as_ref(),
            mint.as_ref(),
        ],
        program_id,
    )
}

pub const ADMIN_SEED_PREFIX: &str = "admin_authority";

/// A global, singleton PDA that stores admin configuration
/// For internal use only.
#[doc(hidden)]
pub fn get_admin_pda(program_id: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[ADMIN_SEED_PREFIX.as_bytes()], program_id)
}