spherenet-program-whitelist-interface 0.1.0

Interface of SphereNet's Program Whitelist Program
Documentation
//! Address derivation functions

use pinocchio::pubkey::{find_program_address, Pubkey};

/// Derives the whitelist entry account address and bump seed
/// for the given entry address, whitelist address, and program id
pub fn get_whitelist_entry_address_and_bump_seed(
    program_id: &Pubkey,
    whitelist_address: &Pubkey,
    program_authority_address: &Pubkey,
) -> (Pubkey, u8) {
    get_whitelist_entry_address_and_bump_seed_internal(
        program_id,
        whitelist_address,
        program_authority_address,
    )
}

/// Derives the whitelist entry account address for the given entry address
pub fn get_whitelist_entry_address(program_authority_address: &Pubkey) -> Pubkey {
    get_whitelist_entry_address_with_program_id(program_authority_address)
}

/// Derives the whitelist entry account address for the given entry address
pub fn get_whitelist_entry_address_with_program_id(program_authority_address: &Pubkey) -> Pubkey {
    get_whitelist_entry_address_and_bump_seed(
        &crate::program::id(),
        &crate::whitelist::id(),
        program_authority_address,
    )
    .0
}

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