@@ -7,7 +7,13 @@ pub trait InstructionProcessor<'a, Ix, T>: Sized {
77 /// Constructions the instruction process type from a slice of accounts
88 fn from_accounts ( accounts : & ' a [ AccountInfo ] ) -> Result < Self , ProgramError > ;
99
10+ /// The main entrypoint for processing this specific instruction, ensuring that
11+ ///
12+ /// * The instruction name is logged
13+ /// * Validations are performed
14+ /// * Business logic is invoked
1015 fn try_process ( & self , instruction : Ix ) -> ProgramResult {
16+ self . log_ix ( ) ;
1117 let validations_result = self . validations ( & instruction) ?;
1218 self . process ( instruction, validations_result)
1319 }
@@ -22,10 +28,15 @@ pub trait InstructionProcessor<'a, Ix, T>: Sized {
2228 /// to create an account, without having to re-derive the PDA
2329 ///
2430 fn validations ( & self , instruction : & Ix ) -> Result < Option < T > , ProgramError > ;
31+
32+ /// Logs the instruction name being invoked
33+ fn log_ix ( & self ) ;
2534}
2635
2736#[ cfg( test) ]
2837mod test {
38+ use pinocchio:: msg;
39+
2940 use super :: * ;
3041 #[ derive( Clone , Debug , PartialEq , Eq ) ]
3142 pub enum TestInstruction {
@@ -72,6 +83,9 @@ mod test {
7283 fn validations ( & self , instruction : & TestInstruction ) -> Result < Option < ( ) > , ProgramError > {
7384 Ok ( None )
7485 }
86+ fn log_ix ( & self ) {
87+ msg ! ( "Instruction: HelloAccounts" )
88+ }
7589 }
7690 impl < ' a > InstructionProcessor < ' a , TestInstruction , HelloAccountsValidationResult >
7791 for HelloAccounts < ' a >
@@ -92,5 +106,8 @@ mod test {
92106 ) -> Result < Option < HelloAccountsValidationResult > , ProgramError > {
93107 Ok ( None )
94108 }
109+ fn log_ix ( & self ) {
110+ msg ! ( "Instruction: HelloAccounts" )
111+ }
95112 }
96113}
0 commit comments