1
1
use borsh:: BorshDeserialize ;
2
+ use borsh:: BorshSerialize ;
2
3
use light_macros:: pubkey;
4
+ use light_sdk:: {
5
+ compressible:: { CompressionInfo , HasCompressionInfo } ,
6
+ LightDiscriminator , LightHasher ,
7
+ } ;
3
8
use light_sdk:: { cpi:: CpiSigner , derive_light_cpi_signer, error:: LightSdkError } ;
4
9
use light_sdk_macros:: add_native_compressible_instructions;
5
10
use solana_program:: {
6
11
account_info:: AccountInfo , entrypoint, entrypoint:: ProgramResult , program_error:: ProgramError ,
7
12
pubkey:: Pubkey ,
8
13
} ;
9
14
10
- pub mod compress_dynamic_pda;
11
- pub mod create_config;
12
15
pub mod create_dynamic_pda;
13
- pub mod decompress_dynamic_pda;
14
- pub mod update_config;
16
+
15
17
pub mod update_pda;
16
18
17
19
pub const ID : Pubkey = pubkey ! ( "FNt7byTHev1k5x2cXZLBr8TdWiC3zoP5vcnZR4P682Uy" ) ;
18
20
pub const LIGHT_CPI_SIGNER : CpiSigner =
19
21
derive_light_cpi_signer ! ( "FNt7byTHev1k5x2cXZLBr8TdWiC3zoP5vcnZR4P682Uy" ) ;
20
22
21
- // Re-export so it's available to the macro
22
- pub use decompress_dynamic_pda:: MyPdaAccount ;
23
-
24
23
// Generate all compression-related instructions and data structures
25
24
#[ add_native_compressible_instructions( MyPdaAccount ) ]
26
25
pub mod compression {
@@ -39,8 +38,6 @@ pub enum InstructionType {
39
38
// Custom instructions
40
39
CreateDynamicPda = 10 ,
41
40
UpdatePda = 11 ,
42
- CompressDynamicPda = 12 ,
43
- DecompressDynamicPda = 13 ,
44
41
}
45
42
46
43
impl TryFrom < u8 > for InstructionType {
@@ -54,8 +51,6 @@ impl TryFrom<u8> for InstructionType {
54
51
3 => Ok ( InstructionType :: CompressMyPdaAccount ) ,
55
52
10 => Ok ( InstructionType :: CreateDynamicPda ) ,
56
53
11 => Ok ( InstructionType :: UpdatePda ) ,
57
- 12 => Ok ( InstructionType :: CompressDynamicPda ) ,
58
- 13 => Ok ( InstructionType :: DecompressDynamicPda ) ,
59
54
_ => Err ( LightSdkError :: ConstraintViolation ) ,
60
55
}
61
56
}
@@ -143,14 +138,30 @@ pub fn process_instruction(
143
138
update_pda:: update_pda :: < false > ( accounts, data) . map_err ( |e| ProgramError :: from ( e) )
144
139
}
145
140
146
- InstructionType :: CompressDynamicPda => {
147
- compress_dynamic_pda:: compress_dynamic_pda ( accounts, data)
148
- . map_err ( |e| ProgramError :: from ( e) )
149
- }
141
+ _ => Err ( ProgramError :: InvalidInstructionData ) ,
142
+ }
143
+ }
150
144
151
- InstructionType :: DecompressDynamicPda => {
152
- decompress_dynamic_pda:: decompress_dynamic_pda ( accounts, data. to_vec ( ) )
153
- . map_err ( |_| ProgramError :: Custom ( 3 ) )
154
- }
145
+ pub const COMPRESSION_DELAY : u64 = 100 ;
146
+
147
+ #[ derive(
148
+ Default , Clone , Debug , BorshSerialize , BorshDeserialize , LightHasher , LightDiscriminator ,
149
+ ) ]
150
+ pub struct MyPdaAccount {
151
+ #[ skip]
152
+ pub compression_info : CompressionInfo ,
153
+ #[ hash]
154
+ pub owner : Pubkey ,
155
+ pub data : u64 ,
156
+ }
157
+
158
+ // Implement the HasCompressionInfo trait
159
+ impl HasCompressionInfo for MyPdaAccount {
160
+ fn compression_info ( & self ) -> & CompressionInfo {
161
+ & self . compression_info
162
+ }
163
+
164
+ fn compression_info_mut ( & mut self ) -> & mut CompressionInfo {
165
+ & mut self . compression_info
155
166
}
156
167
}
0 commit comments