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
use {
    crate::{state::*},
    anchor_lang::{prelude::*},
};

#[derive(Accounts)]
#[instruction(mint: Pubkey)]
pub struct InitMintCounterCtx<'info> {
    #[account(
        init,
        payer = payer,
        seeds = [MINT_COUNTER_SEED.as_bytes(), mint.as_ref()], bump,
        space = MINT_COUNTER_SIZE,
    )]
    mint_counter: Box<Account<'info, MintCounter>>,

    #[account(mut)]
    payer: Signer<'info>,
    system_program: Program<'info, System>,
}

pub fn handler(ctx: Context<InitMintCounterCtx>, _mint: Pubkey) -> Result<()> {
    let mint_counter = &mut ctx.accounts.mint_counter;
    mint_counter.bump = *ctx.bumps.get("mint_counter").unwrap();
    mint_counter.count = 0;
    return Ok(())
}