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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use {
crate::state::*,
anchor_lang::{prelude::*, solana_program::system_program},
std::mem::size_of,
};
#[derive(Accounts)]
#[instruction(
authority_bump: u8,
config_bump: u8,
treasury_bump: u8,
)]
pub struct Initialize<'info> {
#[account(
init,
seeds = [SEED_AUTHORITY],
bump = authority_bump,
payer = signer,
space = 8 + size_of::<Authority>(),
)]
pub authority: Account<'info, Authority>,
#[account(
init,
seeds = [SEED_CONFIG],
bump = config_bump,
payer = signer,
space = 8 + size_of::<Config>(),
)]
pub config: Account<'info, Config>,
#[account(mut)]
pub signer: Signer<'info>,
#[account(address = system_program::ID)]
pub system_program: Program<'info, System>,
#[account(
init,
seeds = [SEED_TREASURY],
bump = treasury_bump,
payer = signer,
space = 8 + size_of::<Treasury>(),
)]
pub treasury: Account<'info, Treasury>,
}
pub fn handler(
ctx: Context<Initialize>,
authority_bump: u8,
config_bump: u8,
treasury_bump: u8,
) -> ProgramResult {
let authority = &mut ctx.accounts.authority;
let config = &mut ctx.accounts.config;
let signer = &ctx.accounts.signer;
let treasury = &mut ctx.accounts.treasury;
authority.bump = authority_bump;
config.admin_authority = signer.key();
config.frame_interval = 60;
config.program_fee = 0;
config.worker_fee = 0;
config.bump = config_bump;
treasury.bump = treasury_bump;
return Ok(());
}