|
1 | 1 | pub mod utils; |
2 | 2 |
|
3 | | -use solana_program::sysvar::{instructions::get_instruction_relative, SysvarId}; |
4 | | -use { |
5 | | - crate::utils::{ |
6 | | - assert_initialized, assert_is_ata, assert_keys_equal, assert_owned_by, |
7 | | - assert_valid_go_live, punish_bots, spl_token_burn, spl_token_transfer, TokenBurnParams, |
8 | | - TokenTransferParams, |
| 3 | +use crate::utils::{ |
| 4 | + assert_initialized, assert_is_ata, assert_keys_equal, assert_owned_by, assert_valid_go_live, |
| 5 | + punish_bots, spl_token_burn, spl_token_transfer, TokenBurnParams, TokenTransferParams, |
| 6 | +}; |
| 7 | +use anchor_lang::{ |
| 8 | + prelude::*, |
| 9 | + solana_program::{ |
| 10 | + program::{invoke, invoke_signed}, |
| 11 | + serialize_utils::{read_pubkey, read_u16}, |
| 12 | + system_instruction, sysvar, |
9 | 13 | }, |
10 | | - anchor_lang::{ |
11 | | - prelude::*, |
12 | | - solana_program::{ |
13 | | - program::{invoke, invoke_signed}, |
14 | | - serialize_utils::{read_pubkey, read_u16}, |
15 | | - system_instruction, sysvar, |
16 | | - }, |
17 | | - AnchorDeserialize, AnchorSerialize, Discriminator, Key, |
| 14 | + AnchorDeserialize, AnchorSerialize, Discriminator, Key, |
| 15 | +}; |
| 16 | +use anchor_spl::token::Token; |
| 17 | +use arrayref::array_ref; |
| 18 | +use mpl_token_metadata::{ |
| 19 | + assertions::collection::assert_master_edition, |
| 20 | + error::MetadataError, |
| 21 | + instruction::{ |
| 22 | + approve_collection_authority, create_master_edition_v3, create_metadata_accounts_v2, |
| 23 | + revoke_collection_authority, set_and_verify_collection, update_metadata_accounts_v2, |
18 | 24 | }, |
19 | | - anchor_spl::token::Token, |
20 | | - arrayref::array_ref, |
21 | | - mpl_token_metadata::{ |
22 | | - assertions::collection::assert_master_edition, |
23 | | - error::MetadataError, |
24 | | - instruction::{ |
25 | | - approve_collection_authority, create_master_edition_v3, create_metadata_accounts_v2, |
26 | | - revoke_collection_authority, set_and_verify_collection, update_metadata_accounts_v2, |
27 | | - }, |
28 | | - state::{ |
29 | | - Metadata, MAX_CREATOR_LEN, MAX_CREATOR_LIMIT, MAX_NAME_LENGTH, MAX_SYMBOL_LENGTH, |
30 | | - MAX_URI_LENGTH, |
31 | | - }, |
32 | | - utils::{assert_derivation, create_or_allocate_account_raw}, |
| 25 | + state::{ |
| 26 | + Metadata, MAX_CREATOR_LEN, MAX_CREATOR_LIMIT, MAX_NAME_LENGTH, MAX_SYMBOL_LENGTH, |
| 27 | + MAX_URI_LENGTH, |
33 | 28 | }, |
34 | | - spl_token::state::Mint, |
35 | | - std::{cell::RefMut, ops::Deref, str::FromStr}, |
| 29 | + utils::{assert_derivation, create_or_allocate_account_raw}, |
36 | 30 | }; |
| 31 | +use solana_program::sysvar::{instructions::get_instruction_relative, SysvarId}; |
| 32 | +use spl_token::state::Mint; |
| 33 | +use std::{cell::RefMut, ops::Deref, str::FromStr}; |
37 | 34 | anchor_lang::declare_id!("cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ"); |
38 | 35 | const EXPIRE_OFFSET: i64 = 10 * 60; |
39 | 36 | const PREFIX: &str = "candy_machine"; |
@@ -224,27 +221,6 @@ pub mod candy_machine { |
224 | 221 | match assert_is_ata(whitelist_token_account, &payer.key(), &ws.mint) { |
225 | 222 | Ok(wta) => { |
226 | 223 | if wta.amount > 0 { |
227 | | - if ws.mode == WhitelistMintMode::BurnEveryTime { |
228 | | - let whitelist_token_mint = |
229 | | - &ctx.remaining_accounts[remaining_accounts_counter]; |
230 | | - remaining_accounts_counter += 1; |
231 | | - |
232 | | - let whitelist_burn_authority = |
233 | | - &ctx.remaining_accounts[remaining_accounts_counter]; |
234 | | - remaining_accounts_counter += 1; |
235 | | - |
236 | | - assert_keys_equal(whitelist_token_mint.key(), ws.mint)?; |
237 | | - |
238 | | - spl_token_burn(TokenBurnParams { |
239 | | - mint: whitelist_token_mint.clone(), |
240 | | - source: whitelist_token_account.clone(), |
241 | | - amount: 1, |
242 | | - authority: whitelist_burn_authority.clone(), |
243 | | - authority_signer_seeds: None, |
244 | | - token_program: token_program.to_account_info(), |
245 | | - })?; |
246 | | - } |
247 | | - |
248 | 224 | match candy_machine.data.go_live_date { |
249 | 225 | None => { |
250 | 226 | if ctx.accounts.payer.key() != candy_machine.authority |
@@ -277,6 +253,27 @@ pub mod candy_machine { |
277 | 253 | } |
278 | 254 | } |
279 | 255 |
|
| 256 | + if ws.mode == WhitelistMintMode::BurnEveryTime { |
| 257 | + let whitelist_token_mint = |
| 258 | + &ctx.remaining_accounts[remaining_accounts_counter]; |
| 259 | + remaining_accounts_counter += 1; |
| 260 | + |
| 261 | + let whitelist_burn_authority = |
| 262 | + &ctx.remaining_accounts[remaining_accounts_counter]; |
| 263 | + remaining_accounts_counter += 1; |
| 264 | + |
| 265 | + assert_keys_equal(whitelist_token_mint.key(), ws.mint)?; |
| 266 | + |
| 267 | + spl_token_burn(TokenBurnParams { |
| 268 | + mint: whitelist_token_mint.clone(), |
| 269 | + source: whitelist_token_account.clone(), |
| 270 | + amount: 1, |
| 271 | + authority: whitelist_burn_authority.clone(), |
| 272 | + authority_signer_seeds: None, |
| 273 | + token_program: token_program.to_account_info(), |
| 274 | + })?; |
| 275 | + } |
| 276 | + |
280 | 277 | if let Some(dp) = ws.discount_price { |
281 | 278 | price = dp; |
282 | 279 | } |
@@ -566,7 +563,9 @@ pub mod candy_machine { |
566 | 563 | return Ok(()); |
567 | 564 | } |
568 | 565 | /// Check if the metadata acount has data if not bot fee |
569 | | - if ctx.accounts.metadata.owner != &mpl_token_metadata::id() || ctx.accounts.token_metadata_program.data_len() == 0 { |
| 566 | + if ctx.accounts.metadata.owner != &mpl_token_metadata::id() |
| 567 | + || ctx.accounts.token_metadata_program.data_len() == 0 |
| 568 | + { |
570 | 569 | return Ok(()); |
571 | 570 | } |
572 | 571 |
|
|
0 commit comments