1- #![ allow( unexpected_cfgs) ] // silence clippy for target_os solana and other solana program custom features
1+ #![ allow( unexpected_cfgs) ]
2+
3+ // Exactly one of `sdk` or `program` must be enabled
4+ #[ cfg( all( feature = "sdk" , feature = "program" ) ) ]
5+ compile_error ! ( "Features `sdk` and `program` are mutually exclusive. Enable exactly one." ) ;
6+
7+ #[ cfg( all( not( feature = "sdk" ) , not( feature = "program" ) ) ) ]
8+ compile_error ! (
9+ "Enable either `program` (default) or `sdk`. Building with neither is not supported."
10+ ) ;
11+
12+ #[ cfg( not( feature = "sdk" ) ) ]
13+ use {
14+ crate :: discriminator:: DlpDiscriminator ,
15+ solana_program:: {
16+ account_info:: AccountInfo , entrypoint:: ProgramResult , program_error:: ProgramError ,
17+ pubkey:: Pubkey ,
18+ } ,
19+ } ;
220
3- use crate :: discriminator:: DlpDiscriminator ;
4- use pinocchio_log:: log;
5- use solana_program:: account_info:: AccountInfo ;
621use solana_program:: declare_id;
7- use solana_program:: entrypoint:: ProgramResult ;
8- use solana_program:: program_error:: ProgramError ;
9- use solana_program:: pubkey:: Pubkey ;
1022
1123#[ cfg( feature = "logging" ) ]
1224use solana_program:: msg;
1325
1426pub mod args;
1527pub mod consts;
28+ #[ cfg( not( feature = "sdk" ) ) ]
1629mod discriminator;
30+ #[ cfg( not( feature = "sdk" ) ) ]
1731pub mod error;
32+ #[ cfg( not( feature = "sdk" ) ) ]
1833pub mod instruction_builder;
1934pub mod pda;
2035pub mod state;
2136
37+ #[ cfg( not( feature = "sdk" ) ) ]
2238mod diff;
39+ #[ cfg( not( feature = "sdk" ) ) ]
2340mod processor;
2441
42+ #[ cfg( not( feature = "sdk" ) ) ]
2543pub use diff:: * ;
2644
2745#[ cfg( feature = "log-cost" ) ]
@@ -32,20 +50,22 @@ mod entrypoint;
3250
3351declare_id ! ( "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh" ) ;
3452
53+ #[ cfg( not( feature = "sdk" ) ) ]
3554pub mod fast {
3655 pinocchio_pubkey:: declare_id!( "DELeGGvXpWV2fqJUhqcF5ZSYMS4JTLjteaAMARRSaeSh" ) ;
3756}
3857
39- #[ cfg( all ( not ( feature = "no-entrypoint" ) , feature = " solana-security-txt") ) ]
58+ #[ cfg( feature = "solana-security-txt" ) ]
4059solana_security_txt:: security_txt! {
4160 name: "MagicBlock Delegation Program" ,
42- project_url: "https://magicblock.gg " ,
61+ project_url: "https://magicblock.xyz " ,
4362 contacts: "email:dev@magicblock.gg,twitter:@magicblock" ,
4463 policy: "https://github.com/magicblock-labs/delegation-program/blob/master/LICENSE.md" ,
4564 preferred_languages: "en" ,
4665 source_code: "https://github.com/magicblock-labs/delegation-program"
4766}
4867
68+ #[ cfg( not( feature = "sdk" ) ) ]
4969pub fn fast_process_instruction (
5070 program_id : & pinocchio:: pubkey:: Pubkey ,
5171 accounts : & [ pinocchio:: account_info:: AccountInfo ] ,
@@ -62,7 +82,7 @@ pub fn fast_process_instruction(
6282 let discriminator = match DlpDiscriminator :: try_from ( discriminator_bytes[ 0 ] ) {
6383 Ok ( discriminator) => discriminator,
6484 Err ( _) => {
65- log ! ( "Failed to read and parse discriminator" ) ;
85+ pinocchio_log :: log!( "Failed to read and parse discriminator" ) ;
6686 return Some ( Err (
6787 pinocchio:: program_error:: ProgramError :: InvalidInstructionData ,
6888 ) ) ;
@@ -95,6 +115,7 @@ pub fn fast_process_instruction(
95115 }
96116}
97117
118+ #[ cfg( not( feature = "sdk" ) ) ]
98119pub fn slow_process_instruction (
99120 program_id : & Pubkey ,
100121 accounts : & [ AccountInfo ] ,
@@ -139,7 +160,8 @@ pub fn slow_process_instruction(
139160 processor:: process_call_handler ( program_id, accounts, data) ?
140161 }
141162 _ => {
142- log ! ( "PANIC: Instruction must be processed by fast_process_instruction" ) ;
163+ #[ cfg( feature = "logging" ) ]
164+ msg ! ( "PANIC: Instruction must be processed by fast_process_instruction" ) ;
143165 return Err ( ProgramError :: InvalidInstructionData ) ;
144166 }
145167 }
0 commit comments