Skip to main content

dloom_locker/
lib.rs

1// FILE: programs/dloom_locker/src/lib.rs
2use anchor_lang::prelude::*;
3
4pub mod errors;
5pub mod events;
6pub mod instructions;
7pub mod state;
8
9use instructions::*;
10
11declare_id!("AVfmdPiqXfc15Pt8PPRXxTP5oMs4D1CdijARiz8mFMFD"); 
12
13#[program]
14pub mod dloom_locker {
15    use super::*;
16
17    pub fn handle_lock_tokens(ctx: Context<LockTokens>, amount: u64, unlock_timestamp: i64, lock_id: u64) -> Result<()> {
18        instructions::lock_tokens::handle_lock_tokens(ctx, amount, unlock_timestamp, lock_id)
19    }
20
21    pub fn handle_withdraw_tokens(ctx: Context<WithdrawTokens>, lock_id: u64, amount: u64,) -> Result<()> {
22        instructions::withdraw_tokens::handle_withdraw_tokens(ctx, lock_id, amount)
23    }
24
25    pub fn handle_close_vault(ctx: Context<CloseVault>, lock_id: u64) -> Result<()> {
26        instructions::close_vault::handle_close_vault(ctx, lock_id)
27    }
28
29    // Burns tokens from the user's connected wallet
30    pub fn handle_burn_from_wallet(ctx: Context<BurnFromWallet>, amount: u64) -> Result<()> {
31        instructions::burn_from_wallet::handle_burn_from_wallet(ctx, amount)
32    }
33
34    // Burns tokens currently sitting in the Lock Vault
35    pub fn handle_burn_from_lock(ctx: Context<BurnFromLock>, amount: u64, lock_id: u64) -> Result<()> {
36        instructions::burn_from_lock::handle_burn_from_lock(ctx, amount, lock_id)
37    }
38
39    // NEW: Burns multiple tokens from a user's wallet in a single transaction
40    pub fn handle_burn_batch<'info>(
41        ctx: Context<'_, '_, '_, 'info, BurnBatch<'info>>,
42        amounts: Vec<u64>,
43    ) -> Result<()> {
44        instructions::burn_batch::handle_burn_batch(ctx, amounts)
45    }
46}