gmsol_callback/instructions/
config.rs1use anchor_lang::prelude::*;
2
3use crate::states::{Config, CONFIG_SEED, MAX_PREFIX_LEN};
4
5#[derive(Accounts)]
7pub struct InitializeConfig<'info> {
8 #[account(mut)]
10 pub payer: Signer<'info>,
11 #[account(
13 init,
14 payer = payer,
15 space = 8 + Config::INIT_SPACE,
16 seeds = [CONFIG_SEED],
17 bump,
18 )]
19 pub config: Account<'info, Config>,
20 pub system_program: Program<'info, System>,
22}
23
24impl InitializeConfig<'_> {
25 pub(crate) fn invoke(ctx: Context<Self>, prefix: String) -> Result<()> {
26 require_gte!(usize::from(MAX_PREFIX_LEN), prefix.len());
27 ctx.accounts.config.prefix = prefix;
28 Ok(())
29 }
30}