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
//! This program allows users to create transaction queues on Solana. Queues are dynamic, long-running
//! transaction threads that can persist across blocks and even run indefinitely. Developers can use queues
//! to schedule transactions and automate smart-contracts without relying on centralized infrastructure.

pub mod errors;
pub mod objects;

mod instructions;

use anchor_lang::prelude::*;
use clockwork_utils::*;
use instructions::*;
use objects::*;

declare_id!("3XXuUFfweXBwFgFfYaejLvZE4cGZiHgKiGfMtdxNzYmv");

/// Program for creating transaction queues on Solana.
#[program]
pub mod queue_program {
    use super::*;

    /// Cranks a transaction queue.
    pub fn queue_crank(ctx: Context<QueueCrank>, data_hash: Option<u64>) -> Result<()> {
        queue_crank::handler(ctx, data_hash)
    }

    /// Creates a new transaction queue.
    pub fn queue_create(
        ctx: Context<QueueCreate>,
        id: String,
        kickoff_instruction: InstructionData,
        trigger: Trigger,
    ) -> Result<()> {
        queue_create::handler(ctx, id, kickoff_instruction, trigger)
    }

    /// Closes an existing queue account and returns the lamports to the owner.
    pub fn queue_delete(ctx: Context<QueueDelete>) -> Result<()> {
        queue_delete::handler(ctx)
    }

    /// Pauses an active queue.
    pub fn queue_pause(ctx: Context<QueuePause>) -> Result<()> {
        queue_pause::handler(ctx)
    }

    /// Resumes a paused queue.
    pub fn queue_resume(ctx: Context<QueueResume>) -> Result<()> {
        queue_resume::handler(ctx)
    }

    /// Allows an owner to update the mutable properties of a queue.
    pub fn queue_update(ctx: Context<QueueUpdate>, settings: QueueSettings) -> Result<()> {
        queue_update::handler(ctx, settings)
    }

    /// Allows an owner to withdraw from a queue's lamport balance.
    pub fn queue_withdraw(ctx: Context<QueueWithdraw>, amount: u64) -> Result<()> {
        queue_withdraw::handler(ctx, amount)
    }
}