Skip to main content

superstate_allowlist_interface/
address.rs

1use solana_pubkey::Pubkey;
2
3/// For internal use only.
4#[doc(hidden)]
5pub const ALLOWLIST_PROGRAM_SEED_PREFIX: &str = "allowlist_program";
6
7/// For internal use only.
8#[doc(hidden)]
9pub fn get_allowlist_program_pda(program_id: &Pubkey) -> (Pubkey, u8) {
10    Pubkey::find_program_address(&[ALLOWLIST_PROGRAM_SEED_PREFIX.as_bytes()], program_id)
11}
12
13pub const PRIVATE_ALLOWLIST_PREFIX: &str = "private_allowlist";
14
15pub fn get_private_allowlist_pda(mint: &Pubkey, program_id: &Pubkey) -> (Pubkey, u8) {
16    Pubkey::find_program_address(
17        &[PRIVATE_ALLOWLIST_PREFIX.as_bytes(), mint.as_ref()],
18        program_id,
19    )
20}
21
22/// For internal use only.
23#[doc(hidden)]
24pub const PUBLIC_ALLOWED_ACCOUNT_SEED_PREFIX: &str = "public_allowed_account";
25
26/// PDA per user allowlisted address
27/// For internal use only.
28#[doc(hidden)]
29pub fn get_public_allowed_account_pda(user_account: &Pubkey, program_id: &Pubkey) -> (Pubkey, u8) {
30    Pubkey::find_program_address(
31        &[
32            PUBLIC_ALLOWED_ACCOUNT_SEED_PREFIX.as_bytes(),
33            user_account.as_ref(),
34        ],
35        program_id,
36    )
37}
38
39/// PDA per user allowlisted address
40/// For internal use only.
41#[doc(hidden)]
42pub const PRIVATE_ALLOWED_ACCOUNT_SEED_PREFIX: &str = "private_allowed_account";
43
44/// PDA per user allowlisted address/mint
45/// For internal use only.
46#[doc(hidden)]
47pub fn get_private_allowed_account_pda(
48    user_account: &Pubkey,
49    mint: &Pubkey,
50    program_id: &Pubkey,
51) -> (Pubkey, u8) {
52    Pubkey::find_program_address(
53        &[
54            PRIVATE_ALLOWED_ACCOUNT_SEED_PREFIX.as_bytes(),
55            user_account.as_ref(),
56            mint.as_ref(),
57        ],
58        program_id,
59    )
60}
61
62pub const ADMIN_SEED_PREFIX: &str = "admin_authority";
63
64/// A global, singleton PDA that stores admin configuration
65/// For internal use only.
66#[doc(hidden)]
67pub fn get_admin_pda(program_id: &Pubkey) -> (Pubkey, u8) {
68    Pubkey::find_program_address(&[ADMIN_SEED_PREFIX.as_bytes()], program_id)
69}