1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
use solana_program::pubkey::Pubkey;

use crate::state::{BURN, COLLECTION_AUTHORITY, EDITION, PREFIX, USER};

pub fn find_edition_account(mint: &Pubkey, edition_number: String) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            PREFIX.as_bytes(),
            crate::id().as_ref(),
            mint.as_ref(),
            EDITION.as_bytes(),
            edition_number.as_bytes(),
        ],
        &crate::id(),
    )
}
pub fn find_master_edition_account(mint: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            PREFIX.as_bytes(),
            crate::id().as_ref(),
            mint.as_ref(),
            EDITION.as_bytes(),
        ],
        &crate::id(),
    )
}

pub fn find_metadata_account(mint: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[PREFIX.as_bytes(), crate::id().as_ref(), mint.as_ref()],
        &crate::id(),
    )
}

pub fn find_use_authority_account(mint: &Pubkey, authority: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            PREFIX.as_bytes(),
            crate::id().as_ref(),
            mint.as_ref(),
            USER.as_bytes(),
            authority.as_ref(),
        ],
        &crate::id(),
    )
}

pub fn find_collection_authority_account(mint: &Pubkey, authority: &Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[
            PREFIX.as_bytes(),
            crate::id().as_ref(),
            mint.as_ref(),
            COLLECTION_AUTHORITY.as_bytes(),
            authority.as_ref(),
        ],
        &crate::id(),
    )
}

pub fn find_program_as_burner_account() -> (Pubkey, u8) {
    Pubkey::find_program_address(
        &[PREFIX.as_bytes(), crate::id().as_ref(), BURN.as_bytes()],
        &crate::id(),
    )
}