cardinal_scanner/instructions/
init_event.rs1use {crate::state::*, anchor_lang::prelude::*};
2
3#[derive(AnchorSerialize, AnchorDeserialize)]
4pub struct InitEventIx {
5 authority: Pubkey,
6 name: String,
7}
8
9#[derive(Accounts)]
10#[instruction(ix: InitEventIx)]
11pub struct InitEventCtx<'info> {
12 #[account(
13 init,
14 payer = payer,
15 space = EVENT_SIZE,
16 seeds = [EVENT_SEED_PREFIX.as_bytes(), ix.name.as_bytes()],
17 bump
18 )]
19 event: Account<'info, Event>,
20
21 #[account(mut)]
22 payer: Signer<'info>,
23 system_program: Program<'info, System>,
24}
25
26pub fn handler(ctx: Context<InitEventCtx>, ix: InitEventIx) -> Result<()> {
27 let event = &mut ctx.accounts.event;
28 event.bump = *ctx.bumps.get("event").unwrap();
29 event.authority = ix.authority;
30 event.name = ix.name;
31
32 Ok(())
33}