-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
48 lines (43 loc) · 1.45 KB
/
lib.rs
File metadata and controls
48 lines (43 loc) · 1.45 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
40
41
42
43
44
45
46
47
48
#![allow(unexpected_cfgs, deprecated)]
use anchor_lang::prelude::*;
use light_token::instruction::TransferCheckedCpi;
declare_id!("HXmfewpozFdxhM8BayL9v5541gwoGMXTrUoip5KySs2f");
#[program]
pub mod light_token_anchor_transfer_checked {
use super::*;
pub fn transfer_checked(
ctx: Context<TransferCheckedAccounts>,
amount: u64,
decimals: u8,
) -> Result<()> {
TransferCheckedCpi {
source: ctx.accounts.source.to_account_info(),
mint: ctx.accounts.mint.to_account_info(),
destination: ctx.accounts.destination.to_account_info(),
amount,
decimals,
authority: ctx.accounts.authority.to_account_info(),
system_program: ctx.accounts.system_program.to_account_info(),
fee_payer: ctx.accounts.fee_payer.to_account_info(),
}
.invoke()?;
Ok(())
}
}
#[derive(Accounts)]
pub struct TransferCheckedAccounts<'info> {
/// CHECK: Light token program for CPI
pub light_token_program: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub source: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
pub mint: AccountInfo<'info>,
/// CHECK: Validated by light-token CPI
#[account(mut)]
pub destination: AccountInfo<'info>,
pub authority: Signer<'info>,
#[account(mut)]
pub fee_payer: Signer<'info>,
pub system_program: Program<'info, System>,
}