Skip to main content

antegen_fiber_program/
lib.rs

1pub mod constants;
2pub mod errors;
3pub mod instructions;
4pub mod state;
5
6pub use constants::*;
7use instructions::*;
8use state::*;
9
10use anchor_lang::prelude::*;
11use anchor_lang::solana_program::instruction::Instruction;
12
13declare_id!("AgFv5afjW9DmSPkiEvJ1er5bAAmRUqaBeTB6Cr8e1hKx");
14
15#[program]
16pub mod antegen_fiber {
17    use super::*;
18
19    /// Creates a fiber (instruction account) for a thread.
20    /// Thread PDA must be signer and payer.
21    pub fn create_fiber(
22        ctx: Context<FiberCreate>,
23        fiber_index: u8,
24        instruction: SerializableInstruction,
25        priority_fee: u64,
26    ) -> Result<()> {
27        let instruction: Instruction = instruction.into();
28        instructions::fiber_create::fiber_create(ctx, fiber_index, instruction, priority_fee)
29    }
30
31    /// Updates a fiber's instruction content (or initializes if it doesn't exist).
32    /// Thread PDA must be signer and payer. Resets execution stats.
33    pub fn update_fiber(
34        ctx: Context<FiberUpdate>,
35        fiber_index: u8,
36        instruction: SerializableInstruction,
37        priority_fee: Option<u64>,
38    ) -> Result<()> {
39        let instruction: Instruction = instruction.into();
40        instructions::fiber_update::fiber_update(ctx, fiber_index, instruction, priority_fee)
41    }
42
43    /// Closes a fiber account, returns rent to thread PDA.
44    pub fn close_fiber(ctx: Context<FiberClose>) -> Result<()> {
45        instructions::fiber_close::fiber_close(ctx)
46    }
47
48    /// Copies source fiber's instruction into target, closes source.
49    /// Target keeps its PDA/index, source is deleted.
50    pub fn swap_fiber(ctx: Context<FiberSwap>) -> Result<()> {
51        instructions::fiber_swap::fiber_swap(ctx)
52    }
53}