-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
39 lines (34 loc) · 1.21 KB
/
lib.rs
File metadata and controls
39 lines (34 loc) · 1.21 KB
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
#![allow(unexpected_cfgs, deprecated)]
use anchor_lang::prelude::*;
use light_token::instruction::CloseAccountCpi;
declare_id!("GXLCuNhnkRVp596eCdbNsZ9ua1ePbKbb344VKS7V3zQQ");
#[program]
pub mod light_token_anchor_close {
use super::*;
pub fn close_account(ctx: Context<CloseAccountAccounts>) -> Result<()> {
CloseAccountCpi {
token_program: ctx.accounts.light_token_program.to_account_info(),
account: ctx.accounts.account.to_account_info(),
destination: ctx.accounts.destination.to_account_info(),
owner: ctx.accounts.owner.to_account_info(),
rent_sponsor: ctx.accounts.rent_sponsor.to_account_info(),
}
.invoke()?;
Ok(())
}
}
#[derive(Accounts)]
pub struct CloseAccountAccounts<'info> {
/// CHECK: Light token program for CPI
pub light_token_program: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub account: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub destination: AccountInfo<'info>,
pub owner: Signer<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub rent_sponsor: AccountInfo<'info>,
}