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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
//! This code was AUTOGENERATED using the kinobi library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun kinobi to update it.
//!
//! [https://github.com/metaplex-foundation/kinobi]
//!

pub(crate) mod approve_collection_authority;
pub(crate) mod approve_use_authority;
pub(crate) mod bubblegum_set_collection_size;
pub(crate) mod burn_edition_nft;
pub(crate) mod burn_nft;
pub(crate) mod burn_v1;
pub(crate) mod close_escrow_account;
pub(crate) mod collect;
pub(crate) mod convert_master_edition_v1_to_v2;
pub(crate) mod create_escrow_account;
pub(crate) mod create_master_edition_v3;
pub(crate) mod create_metadata_account_v3;
pub(crate) mod create_v1;
pub(crate) mod delegate_authority_item_v1;
pub(crate) mod delegate_collection_item_v1;
pub(crate) mod delegate_collection_v1;
pub(crate) mod delegate_data_item_v1;
pub(crate) mod delegate_data_v1;
pub(crate) mod delegate_locked_transfer_v1;
pub(crate) mod delegate_programmable_config_item_v1;
pub(crate) mod delegate_programmable_config_v1;
pub(crate) mod delegate_sale_v1;
pub(crate) mod delegate_staking_v1;
pub(crate) mod delegate_standard_v1;
pub(crate) mod delegate_transfer_v1;
pub(crate) mod delegate_utility_v1;
pub(crate) mod deprecated_mint_new_edition_from_master_edition_via_printing_token;
pub(crate) mod freeze_delegated_account;
pub(crate) mod lock_v1;
pub(crate) mod migrate;
pub(crate) mod mint_new_edition_from_master_edition_via_token;
pub(crate) mod mint_new_edition_from_master_edition_via_vault_proxy;
pub(crate) mod mint_v1;
pub(crate) mod print_v1;
pub(crate) mod puff_metadata;
pub(crate) mod remove_creator_verification;
pub(crate) mod revoke_authority_item_v1;
pub(crate) mod revoke_collection_authority;
pub(crate) mod revoke_collection_item_v1;
pub(crate) mod revoke_collection_v1;
pub(crate) mod revoke_data_item_v1;
pub(crate) mod revoke_data_v1;
pub(crate) mod revoke_locked_transfer_v1;
pub(crate) mod revoke_migration_v1;
pub(crate) mod revoke_programmable_config_item_v1;
pub(crate) mod revoke_programmable_config_v1;
pub(crate) mod revoke_sale_v1;
pub(crate) mod revoke_staking_v1;
pub(crate) mod revoke_standard_v1;
pub(crate) mod revoke_transfer_v1;
pub(crate) mod revoke_use_authority;
pub(crate) mod revoke_utility_v1;
pub(crate) mod set_and_verify_collection;
pub(crate) mod set_and_verify_sized_collection_item;
pub(crate) mod set_collection_size;
pub(crate) mod set_token_standard;
pub(crate) mod sign_metadata;
pub(crate) mod thaw_delegated_account;
pub(crate) mod transfer_out_of_escrow;
pub(crate) mod transfer_v1;
pub(crate) mod unlock_v1;
pub(crate) mod unverify_collection;
pub(crate) mod unverify_collection_v1;
pub(crate) mod unverify_creator_v1;
pub(crate) mod unverify_sized_collection_item;
pub(crate) mod update_as_authority_item_delegate_v2;
pub(crate) mod update_as_collection_delegate_v2;
pub(crate) mod update_as_collection_item_delegate_v2;
pub(crate) mod update_as_data_delegate_v2;
pub(crate) mod update_as_data_item_delegate_v2;
pub(crate) mod update_as_programmable_config_delegate_v2;
pub(crate) mod update_as_programmable_config_item_delegate_v2;
pub(crate) mod update_as_update_authority_v2;
pub(crate) mod update_metadata_account_v2;
pub(crate) mod update_primary_sale_happened_via_token;
pub(crate) mod update_v1;
pub(crate) mod use_v1;
pub(crate) mod utilize;
pub(crate) mod verify_collection;
pub(crate) mod verify_collection_v1;
pub(crate) mod verify_creator_v1;
pub(crate) mod verify_sized_collection_item;

pub use self::approve_collection_authority::*;
pub use self::approve_use_authority::*;
pub use self::bubblegum_set_collection_size::*;
pub use self::burn_edition_nft::*;
pub use self::burn_nft::*;
pub use self::burn_v1::*;
pub use self::close_escrow_account::*;
pub use self::collect::*;
pub use self::convert_master_edition_v1_to_v2::*;
pub use self::create_escrow_account::*;
pub use self::create_master_edition_v3::*;
pub use self::create_metadata_account_v3::*;
pub use self::create_v1::*;
pub use self::delegate_authority_item_v1::*;
pub use self::delegate_collection_item_v1::*;
pub use self::delegate_collection_v1::*;
pub use self::delegate_data_item_v1::*;
pub use self::delegate_data_v1::*;
pub use self::delegate_locked_transfer_v1::*;
pub use self::delegate_programmable_config_item_v1::*;
pub use self::delegate_programmable_config_v1::*;
pub use self::delegate_sale_v1::*;
pub use self::delegate_staking_v1::*;
pub use self::delegate_standard_v1::*;
pub use self::delegate_transfer_v1::*;
pub use self::delegate_utility_v1::*;
pub use self::deprecated_mint_new_edition_from_master_edition_via_printing_token::*;
pub use self::freeze_delegated_account::*;
pub use self::lock_v1::*;
pub use self::migrate::*;
pub use self::mint_new_edition_from_master_edition_via_token::*;
pub use self::mint_new_edition_from_master_edition_via_vault_proxy::*;
pub use self::mint_v1::*;
pub use self::print_v1::*;
pub use self::puff_metadata::*;
pub use self::remove_creator_verification::*;
pub use self::revoke_authority_item_v1::*;
pub use self::revoke_collection_authority::*;
pub use self::revoke_collection_item_v1::*;
pub use self::revoke_collection_v1::*;
pub use self::revoke_data_item_v1::*;
pub use self::revoke_data_v1::*;
pub use self::revoke_locked_transfer_v1::*;
pub use self::revoke_migration_v1::*;
pub use self::revoke_programmable_config_item_v1::*;
pub use self::revoke_programmable_config_v1::*;
pub use self::revoke_sale_v1::*;
pub use self::revoke_staking_v1::*;
pub use self::revoke_standard_v1::*;
pub use self::revoke_transfer_v1::*;
pub use self::revoke_use_authority::*;
pub use self::revoke_utility_v1::*;
pub use self::set_and_verify_collection::*;
pub use self::set_and_verify_sized_collection_item::*;
pub use self::set_collection_size::*;
pub use self::set_token_standard::*;
pub use self::sign_metadata::*;
pub use self::thaw_delegated_account::*;
pub use self::transfer_out_of_escrow::*;
pub use self::transfer_v1::*;
pub use self::unlock_v1::*;
pub use self::unverify_collection::*;
pub use self::unverify_collection_v1::*;
pub use self::unverify_creator_v1::*;
pub use self::unverify_sized_collection_item::*;
pub use self::update_as_authority_item_delegate_v2::*;
pub use self::update_as_collection_delegate_v2::*;
pub use self::update_as_collection_item_delegate_v2::*;
pub use self::update_as_data_delegate_v2::*;
pub use self::update_as_data_item_delegate_v2::*;
pub use self::update_as_programmable_config_delegate_v2::*;
pub use self::update_as_programmable_config_item_delegate_v2::*;
pub use self::update_as_update_authority_v2::*;
pub use self::update_metadata_account_v2::*;
pub use self::update_primary_sale_happened_via_token::*;
pub use self::update_v1::*;
pub use self::use_v1::*;
pub use self::utilize::*;
pub use self::verify_collection::*;
pub use self::verify_collection_v1::*;
pub use self::verify_creator_v1::*;
pub use self::verify_sized_collection_item::*;

#[derive(Clone, Copy)]
pub enum InstructionAccount {
    Readonly(solana_program::pubkey::Pubkey),
    ReadonlySigner(solana_program::pubkey::Pubkey),
    Writable(solana_program::pubkey::Pubkey),
    WritableSigner(solana_program::pubkey::Pubkey),
}

impl InstructionAccount {
    pub fn to_account_meta(&self) -> solana_program::instruction::AccountMeta {
        let (pubkey, writable, signer) = match self {
            InstructionAccount::Readonly(pubkey) => (pubkey, false, false),
            InstructionAccount::ReadonlySigner(pubkey) => (pubkey, false, true),
            InstructionAccount::Writable(pubkey) => (pubkey, true, false),
            InstructionAccount::WritableSigner(pubkey) => (pubkey, true, true),
        };

        if writable {
            solana_program::instruction::AccountMeta::new(*pubkey, signer)
        } else {
            solana_program::instruction::AccountMeta::new_readonly(*pubkey, signer)
        }
    }
}

#[derive(Clone, Copy)]
pub enum InstructionAccountInfo<'a, 'b> {
    Readonly(&'b solana_program::account_info::AccountInfo<'a>),
    ReadonlySigner(&'b solana_program::account_info::AccountInfo<'a>),
    Writable(&'b solana_program::account_info::AccountInfo<'a>),
    WritableSigner(&'b solana_program::account_info::AccountInfo<'a>),
}

impl<'a, 'b> InstructionAccountInfo<'a, 'b> {
    pub fn to_account_meta(&self) -> solana_program::instruction::AccountMeta {
        let (pubkey, writable, signer) = match self {
            InstructionAccountInfo::Readonly(account_info) => (account_info.key, false, false),
            InstructionAccountInfo::ReadonlySigner(account_info) => (account_info.key, false, true),
            InstructionAccountInfo::Writable(account_info) => (account_info.key, true, false),
            InstructionAccountInfo::WritableSigner(account_info) => (account_info.key, true, true),
        };

        if writable {
            solana_program::instruction::AccountMeta::new(*pubkey, signer)
        } else {
            solana_program::instruction::AccountMeta::new_readonly(*pubkey, signer)
        }
    }
    pub fn account_info(&self) -> &'b solana_program::account_info::AccountInfo<'a> {
        match self {
            InstructionAccountInfo::Readonly(account_info)
            | InstructionAccountInfo::ReadonlySigner(account_info)
            | InstructionAccountInfo::Writable(account_info)
            | InstructionAccountInfo::WritableSigner(account_info) => account_info,
        }
    }
}