forked from coral-xyz/anchor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.rs
50 lines (40 loc) · 1.09 KB
/
lib.rs
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
use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
#[program]
pub mod callee {
use super::*;
#[derive(AnchorSerialize, AnchorDeserialize)]
pub struct StructReturn {
pub value: u64,
}
pub fn initialize(_ctx: Context<Initialize>) -> Result<()> {
Ok(())
}
pub fn return_u64(_ctx: Context<CpiReturn>) -> Result<u64> {
Ok(10)
}
pub fn return_struct(_ctx: Context<CpiReturn>) -> Result<StructReturn> {
let s = StructReturn { value: 11 };
Ok(s)
}
pub fn return_vec(_ctx: Context<CpiReturn>) -> Result<Vec<u8>> {
Ok(vec![12, 13, 14, 100])
}
}
#[derive(Accounts)]
pub struct Initialize<'info> {
#[account(init, payer = user, space = 8 + 8)]
pub account: Account<'info, CpiReturnAccount>,
#[account(mut)]
pub user: Signer<'info>,
pub system_program: Program<'info, System>,
}
#[derive(Accounts)]
pub struct CpiReturn<'info> {
#[account(mut)]
pub account: Account<'info, CpiReturnAccount>,
}
#[account]
pub struct CpiReturnAccount {
pub value: u64,
}