-
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.19 KB
/
lib.rs
File metadata and controls
39 lines (34 loc) · 1.19 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::ApproveCpi;
declare_id!("37XmzKqSG2VD1ZBvzyfbt1HN1mT1bqVAmfzX2ziB3KT1");
#[program]
pub mod light_token_anchor_approve {
use super::*;
pub fn approve(ctx: Context<ApproveAccounts>, amount: u64) -> Result<()> {
ApproveCpi {
token_account: ctx.accounts.token_account.to_account_info(),
delegate: ctx.accounts.delegate.to_account_info(),
owner: ctx.accounts.owner.to_account_info(),
system_program: ctx.accounts.system_program.to_account_info(),
amount,
fee_payer: ctx.accounts.fee_payer.to_account_info(),
}
.invoke()?;
Ok(())
}
}
#[derive(Accounts)]
pub struct ApproveAccounts<'info> {
/// CHECK: Light token program for CPI
pub light_token_program: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub token_account: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
pub delegate: AccountInfo<'info>,
pub owner: Signer<'info>,
#[account(mut)]
pub fee_payer: Signer<'info>,
pub system_program: Program<'info, System>,
}