clockwork_pool/instructions/
pool_create.rs1use {
2 crate::state::*,
3 anchor_lang::{prelude::*, solana_program::system_program},
4 std::mem::size_of,
5};
6
7#[derive(Accounts)]
8#[instruction(name: String, size: usize)]
9pub struct PoolCreate<'info> {
10 #[account(seeds = [SEED_CONFIG], bump, has_one = pool_authority)]
11 pub config: Account<'info, Config>,
12
13 #[account(mut)]
14 pub payer: Signer<'info>,
15
16 #[account(
17 init,
18 seeds = [SEED_POOL, name.as_bytes()],
19 bump,
20 payer = payer,
21 space = 8 + size_of::<Pool>() + (size_of::<Pubkey>() * size) + name.as_bytes().len(),
22 )]
23 pub pool: Account<'info, Pool>,
24
25 #[account()]
26 pub pool_authority: Signer<'info>,
27
28 #[account(address = system_program::ID)]
29 pub system_program: Program<'info, System>,
30}
31
32pub fn handler(ctx: Context<PoolCreate>, name: String, size: usize) -> Result<()> {
33 let pool = &mut ctx.accounts.pool;
35
36 pool.init(name, size)?;
38
39 Ok(())
40}