light_system_program/
lib.rs

1use anchor_lang::prelude::*;
2
3pub mod account_traits;
4pub mod constants;
5pub mod errors;
6pub mod instructions;
7pub mod utils;
8pub use instructions::*;
9pub mod cpi_context_account;
10use light_compressed_account::instruction_data::{
11    with_account_info::InstructionDataInvokeCpiWithAccountInfo,
12    with_readonly::InstructionDataInvokeCpiWithReadOnly,
13};
14
15declare_id!("SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7");
16
17#[program]
18pub mod light_system_program {
19    #![allow(unused_variables)]
20
21    use super::*;
22
23    pub fn init_cpi_context_account(ctx: Context<InitializeCpiContextAccount>) -> Result<()> {
24        unimplemented!("anchor wrapper not implemented")
25    }
26
27    pub fn invoke(ctx: Context<InvokeInstruction>, inputs: Vec<u8>) -> Result<()> {
28        unimplemented!("anchor wrapper not implemented")
29    }
30
31    pub fn invoke_cpi(ctx: Context<InvokeCpiInstruction>, inputs: Vec<u8>) -> Result<()> {
32        unimplemented!("anchor wrapper not implemented")
33    }
34
35    pub fn invoke_cpi_with_read_only(
36        ctx: Context<InvokeCpiInstruction>,
37        inputs: InstructionDataInvokeCpiWithReadOnly,
38    ) -> Result<()> {
39        unimplemented!("anchor wrapper not implemented")
40    }
41    pub fn invoke_cpi_with_account_info(
42        ctx: Context<InvokeCpiInstruction>,
43        inputs: InstructionDataInvokeCpiWithAccountInfo,
44    ) -> Result<()> {
45        unimplemented!("anchor wrapper not implemented")
46    }
47
48    // /// This function is a stub to allow Anchor to include the input types in
49    // /// the IDL. It should not be included in production builds nor be called in
50    // /// practice.
51    // #[cfg(feature = "idl-build")]
52    // pub fn stub_idl_build<'info>(
53    //     _ctx: Context<'_, '_, '_, 'info, InvokeInstruction<'info>>,
54    //     _inputs1: InstructionDataInvoke,
55    //     _inputs2: InstructionDataInvokeCpi,
56    //     _inputs3: PublicTransactionEvent,
57    // ) -> Result<()> {
58    //     Err(SystemProgramError::InstructionNotCallable.into())
59    // }
60}
61
62#[test]
63fn test_borsh_equivalence() {
64    use anchor_lang::prelude::borsh::BorshSerialize;
65    let struct_a = InstructionDataInvokeCpiWithAccountInfo {
66        mode: 1,
67        bump: 255,
68        invoking_program_id: light_compressed_account::pubkey::Pubkey::new_unique(),
69        ..Default::default()
70    };
71    #[derive(BorshSerialize)]
72    pub struct AnchorWrapped {
73        inputs: InstructionDataInvokeCpiWithAccountInfo,
74    }
75
76    let struct_b = AnchorWrapped {
77        inputs: struct_a.clone(),
78    };
79
80    let struct_a_bytes: Vec<u8> = struct_a.try_to_vec().unwrap();
81    let struct_b_bytes: Vec<u8> = struct_b.try_to_vec().unwrap();
82    assert_eq!(struct_a_bytes, struct_b_bytes);
83}