1use solana_program::{
2 account_info::AccountInfo, declare_id, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey,
3};
4use solana_program_error::ProgramError;
5
6use crate::instructions::{
7 CreateConfig, DeleteConfig, Freeze, FreezePermissionless, FreezePermissionlessIdempotent,
8 SetAuthority, SetGatingProgram, Thaw, ThawPermissionless, ThawPermissionlessIdempotent,
9 TogglePermissionlessInstructions,
10};
11
12pub mod error;
13pub mod instructions;
14pub mod state;
15
16declare_id!("TACLkU6CiCdkQN2MjoyDkVg2yAH9zkxiHDsiztQ52TP");
17
18#[cfg(not(feature = "no-entrypoint"))]
19entrypoint!(process_instruction);
20fn process_instruction<'a>(
21 _program_id: &'a Pubkey,
22 accounts: &'a [AccountInfo<'a>],
23 instruction_data: &'a [u8],
24) -> ProgramResult {
25 let [discriminator, remaining_data @ ..] = instruction_data else {
26 return Err(ProgramError::InvalidInstructionData);
27 };
28
29 match *discriminator {
30 CreateConfig::DISCRIMINATOR => CreateConfig::try_from(accounts)?.process(remaining_data),
31 Freeze::DISCRIMINATOR => Freeze::try_from(accounts)?.process(),
32 Thaw::DISCRIMINATOR => Thaw::try_from(accounts)?.process(),
33 ThawPermissionless::DISCRIMINATOR => ThawPermissionless::try_from(accounts)?.process(false),
34 ThawPermissionlessIdempotent::DISCRIMINATOR => {
35 ThawPermissionless::try_from(accounts)?.process(true)
36 }
37 FreezePermissionless::DISCRIMINATOR => {
38 FreezePermissionless::try_from(accounts)?.process(false)
39 }
40 FreezePermissionlessIdempotent::DISCRIMINATOR => {
41 FreezePermissionless::try_from(accounts)?.process(true)
42 }
43 SetAuthority::DISCRIMINATOR => SetAuthority::try_from(accounts)?.process(remaining_data),
44 SetGatingProgram::DISCRIMINATOR => {
45 SetGatingProgram::try_from(accounts)?.process(remaining_data)
46 }
47 DeleteConfig::DISCRIMINATOR => DeleteConfig::try_from(accounts)?.process(remaining_data),
48 TogglePermissionlessInstructions::DISCRIMINATOR => {
49 TogglePermissionlessInstructions::try_from(accounts)?.process(remaining_data)
50 }
51 _ => {
52 println!("Invalid instruction discriminator: {:?}", discriminator);
53 Err(ProgramError::InvalidInstructionData)
54 }
55 }
56}