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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
use solana_program::pubkey::Pubkey;
use crate::{instruction::MetadataDelegateRole, state::TOKEN_RECORD_SEED};
pub const PREFIX: &str = "metadata";
pub const EDITION: &str = "edition";
pub const USER: &str = "user";
pub const BURN: &str = "burn";
pub const COLLECTION_AUTHORITY: &str = "collection_authority";
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(),
)
}
pub fn find_metadata_delegate_record_account(
mint: &Pubkey,
role: MetadataDelegateRole,
update_authority: &Pubkey,
delegate: &Pubkey,
) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
mint.as_ref(),
role.to_string().as_bytes(),
update_authority.as_ref(),
delegate.as_ref(),
],
&crate::id(),
)
}
pub fn find_token_record_account(mint: &Pubkey, token: &Pubkey) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[
PREFIX.as_bytes(),
crate::id().as_ref(),
mint.as_ref(),
TOKEN_RECORD_SEED.as_bytes(),
token.as_ref(),
],
&crate::id(),
)
}