Skip to content

Commit a737111

Browse files
committed
stash
1 parent 885f5e7 commit a737111

File tree

10 files changed

+648
-56
lines changed

10 files changed

+648
-56
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
use light_compressed_token_types::account_infos::{AccountInfos, TransferAccountInfosIndex};
1+
use light_compressed_token_types::account_infos::{
2+
TransferAccountInfos as TransferAccountInfosTypes, TransferAccountInfosIndex,
3+
};
24
use solana_account_info::AccountInfo;
35

46
pub mod account_metas;
57
pub mod instruction;
68

79
pub type TransferAccountInfos<'a, 'b> =
8-
AccountInfos<'a, AccountInfo<'b>, TransferAccountInfosIndex>;
10+
TransferAccountInfosTypes<'a, AccountInfo<'b>, TransferAccountInfosIndex>;
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
use crate::account_infos::generic_struct::AccountInfoIndexGetter;
2+
3+
#[repr(usize)]
4+
pub enum BatchCompressAccountInfosIndex {
5+
FeePayer,
6+
Authority,
7+
CpiAuthorityPda,
8+
Mint,
9+
TokenPoolPda,
10+
TokenProgram,
11+
LightSystemProgram,
12+
RegisteredProgramPda,
13+
NoopProgram,
14+
AccountCompressionAuthority,
15+
AccountCompressionProgram,
16+
MerkleTree,
17+
SelfProgram,
18+
SystemProgram,
19+
}
20+
21+
impl AccountInfoIndexGetter for BatchCompressAccountInfosIndex {
22+
const SYSTEM_ACCOUNTS_LEN: usize = 14;
23+
24+
fn cpi_authority_index() -> usize {
25+
BatchCompressAccountInfosIndex::CpiAuthorityPda as usize
26+
}
27+
28+
fn light_system_program_index() -> usize {
29+
BatchCompressAccountInfosIndex::LightSystemProgram as usize
30+
}
31+
32+
fn registered_program_pda_index() -> usize {
33+
BatchCompressAccountInfosIndex::RegisteredProgramPda as usize
34+
}
35+
36+
fn noop_program_index() -> usize {
37+
BatchCompressAccountInfosIndex::NoopProgram as usize
38+
}
39+
40+
fn account_compression_authority_index() -> usize {
41+
BatchCompressAccountInfosIndex::AccountCompressionAuthority as usize
42+
}
43+
44+
fn account_compression_program_index() -> usize {
45+
BatchCompressAccountInfosIndex::AccountCompressionProgram as usize
46+
}
47+
48+
fn ctoken_program_index() -> usize {
49+
BatchCompressAccountInfosIndex::SelfProgram as usize
50+
}
51+
52+
fn token_pool_pda_index() -> usize {
53+
BatchCompressAccountInfosIndex::TokenPoolPda as usize
54+
}
55+
56+
fn decompression_recipient_index() -> usize {
57+
// BatchCompress doesn't use decompression recipient
58+
0
59+
}
60+
61+
fn spl_token_program_index() -> usize {
62+
BatchCompressAccountInfosIndex::TokenProgram as usize
63+
}
64+
65+
fn system_program_index() -> usize {
66+
BatchCompressAccountInfosIndex::SystemProgram as usize
67+
}
68+
69+
fn cpi_context_index() -> usize {
70+
// BatchCompress doesn't use cpi context
71+
0
72+
}
73+
}
74+
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use crate::account_infos::generic_struct::AccountInfoIndexGetter;
2+
3+
#[repr(usize)]
4+
pub enum BurnAccountInfosIndex {
5+
FeePayer,
6+
Authority,
7+
CpiAuthorityPda,
8+
Mint,
9+
TokenPoolPda,
10+
TokenProgram,
11+
LightSystemProgram,
12+
RegisteredProgramPda,
13+
NoopProgram,
14+
AccountCompressionAuthority,
15+
AccountCompressionProgram,
16+
SelfProgram,
17+
SystemProgram,
18+
}
19+
20+
impl AccountInfoIndexGetter for BurnAccountInfosIndex {
21+
const SYSTEM_ACCOUNTS_LEN: usize = 13;
22+
23+
fn cpi_authority_index() -> usize {
24+
BurnAccountInfosIndex::CpiAuthorityPda as usize
25+
}
26+
27+
fn light_system_program_index() -> usize {
28+
BurnAccountInfosIndex::LightSystemProgram as usize
29+
}
30+
31+
fn registered_program_pda_index() -> usize {
32+
BurnAccountInfosIndex::RegisteredProgramPda as usize
33+
}
34+
35+
fn noop_program_index() -> usize {
36+
BurnAccountInfosIndex::NoopProgram as usize
37+
}
38+
39+
fn account_compression_authority_index() -> usize {
40+
BurnAccountInfosIndex::AccountCompressionAuthority as usize
41+
}
42+
43+
fn account_compression_program_index() -> usize {
44+
BurnAccountInfosIndex::AccountCompressionProgram as usize
45+
}
46+
47+
fn ctoken_program_index() -> usize {
48+
BurnAccountInfosIndex::SelfProgram as usize
49+
}
50+
51+
fn token_pool_pda_index() -> usize {
52+
BurnAccountInfosIndex::TokenPoolPda as usize
53+
}
54+
55+
fn decompression_recipient_index() -> usize {
56+
// Burn instruction doesn't use decompression recipient
57+
0
58+
}
59+
60+
fn spl_token_program_index() -> usize {
61+
BurnAccountInfosIndex::TokenProgram as usize
62+
}
63+
64+
fn system_program_index() -> usize {
65+
BurnAccountInfosIndex::SystemProgram as usize
66+
}
67+
68+
fn cpi_context_index() -> usize {
69+
// Burn instruction doesn't use cpi context
70+
0
71+
}
72+
}
73+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use anchor_lang::{AnchorDeserialize, AnchorSerialize};
2+
3+
#[derive(Debug, Default, Copy, Clone, AnchorSerialize, AnchorDeserialize)]
4+
pub struct AccountInfosConfig {
5+
pub cpi_context: bool,
6+
}
7+
8+
impl AccountInfosConfig {
9+
pub const fn new() -> Self {
10+
Self {
11+
cpi_context: false,
12+
}
13+
}
14+
15+
pub const fn new_with_cpi_context() -> Self {
16+
Self {
17+
cpi_context: true,
18+
}
19+
}
20+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
use crate::account_infos::generic_struct::AccountInfoIndexGetter;
2+
3+
#[repr(usize)]
4+
pub enum FreezeAccountInfosIndex {
5+
FeePayer,
6+
Authority,
7+
CpiAuthorityPda,
8+
LightSystemProgram,
9+
RegisteredProgramPda,
10+
NoopProgram,
11+
AccountCompressionAuthority,
12+
AccountCompressionProgram,
13+
SelfProgram,
14+
SystemProgram,
15+
Mint,
16+
}
17+
18+
impl AccountInfoIndexGetter for FreezeAccountInfosIndex {
19+
const SYSTEM_ACCOUNTS_LEN: usize = 11;
20+
21+
fn cpi_authority_index() -> usize {
22+
FreezeAccountInfosIndex::CpiAuthorityPda as usize
23+
}
24+
25+
fn light_system_program_index() -> usize {
26+
FreezeAccountInfosIndex::LightSystemProgram as usize
27+
}
28+
29+
fn registered_program_pda_index() -> usize {
30+
FreezeAccountInfosIndex::RegisteredProgramPda as usize
31+
}
32+
33+
fn noop_program_index() -> usize {
34+
FreezeAccountInfosIndex::NoopProgram as usize
35+
}
36+
37+
fn account_compression_authority_index() -> usize {
38+
FreezeAccountInfosIndex::AccountCompressionAuthority as usize
39+
}
40+
41+
fn account_compression_program_index() -> usize {
42+
FreezeAccountInfosIndex::AccountCompressionProgram as usize
43+
}
44+
45+
fn ctoken_program_index() -> usize {
46+
FreezeAccountInfosIndex::SelfProgram as usize
47+
}
48+
49+
fn token_pool_pda_index() -> usize {
50+
// Freeze instruction doesn't use token pool pda
51+
0
52+
}
53+
54+
fn decompression_recipient_index() -> usize {
55+
// Freeze instruction doesn't use decompression recipient
56+
0
57+
}
58+
59+
fn spl_token_program_index() -> usize {
60+
// Freeze instruction doesn't use spl token program
61+
0
62+
}
63+
64+
fn system_program_index() -> usize {
65+
FreezeAccountInfosIndex::SystemProgram as usize
66+
}
67+
68+
fn cpi_context_index() -> usize {
69+
// Freeze instruction doesn't use cpi context
70+
0
71+
}
72+
}
73+
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
use crate::account_infos::generic_struct::AccountInfoIndexGetter;
2+
3+
#[repr(usize)]
4+
pub enum GenericAccountInfosIndex {
5+
FeePayer,
6+
Authority,
7+
CpiAuthorityPda,
8+
LightSystemProgram,
9+
RegisteredProgramPda,
10+
NoopProgram,
11+
AccountCompressionAuthority,
12+
AccountCompressionProgram,
13+
SelfProgram,
14+
SystemProgram,
15+
}
16+
17+
impl AccountInfoIndexGetter for GenericAccountInfosIndex {
18+
const SYSTEM_ACCOUNTS_LEN: usize = 10;
19+
20+
fn cpi_authority_index() -> usize {
21+
GenericAccountInfosIndex::CpiAuthorityPda as usize
22+
}
23+
24+
fn light_system_program_index() -> usize {
25+
GenericAccountInfosIndex::LightSystemProgram as usize
26+
}
27+
28+
fn registered_program_pda_index() -> usize {
29+
GenericAccountInfosIndex::RegisteredProgramPda as usize
30+
}
31+
32+
fn noop_program_index() -> usize {
33+
GenericAccountInfosIndex::NoopProgram as usize
34+
}
35+
36+
fn account_compression_authority_index() -> usize {
37+
GenericAccountInfosIndex::AccountCompressionAuthority as usize
38+
}
39+
40+
fn account_compression_program_index() -> usize {
41+
GenericAccountInfosIndex::AccountCompressionProgram as usize
42+
}
43+
44+
fn ctoken_program_index() -> usize {
45+
GenericAccountInfosIndex::SelfProgram as usize
46+
}
47+
48+
fn token_pool_pda_index() -> usize {
49+
// Generic instruction doesn't use token pool pda
50+
0
51+
}
52+
53+
fn decompression_recipient_index() -> usize {
54+
// Generic instruction doesn't use decompression recipient
55+
0
56+
}
57+
58+
fn spl_token_program_index() -> usize {
59+
// Generic instruction doesn't use spl token program
60+
0
61+
}
62+
63+
fn system_program_index() -> usize {
64+
GenericAccountInfosIndex::SystemProgram as usize
65+
}
66+
67+
fn cpi_context_index() -> usize {
68+
// Generic instruction doesn't use cpi context
69+
0
70+
}
71+
}
72+

0 commit comments

Comments
 (0)