From b03a34780387c495e0ef44d4813e767072511fef Mon Sep 17 00:00:00 2001 From: Jack May Date: Thu, 11 Jun 2020 15:31:13 -0700 Subject: [PATCH] Document InvokeContext trait (#10514) --- sdk/src/entrypoint_native.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sdk/src/entrypoint_native.rs b/sdk/src/entrypoint_native.rs index 278a5214f..db07497ca 100644 --- a/sdk/src/entrypoint_native.rs +++ b/sdk/src/entrypoint_native.rs @@ -148,18 +148,25 @@ macro_rules! declare_loader( pub type ProcessInstruction = fn(&Pubkey, &[KeyedAccount], &[u8]) -> Result<(), InstructionError>; -/// Cross-program invocation context passed to loaders +/// Invocation context passed to loaders pub trait InvokeContext { + /// Push a program ID on to the invocation stack fn push(&mut self, key: &Pubkey) -> Result<(), InstructionError>; + /// Pop a program ID off of the invocation stack fn pop(&mut self); + /// Verify and update PreAccount state based on program execution fn verify_and_update( &mut self, message: &Message, instruction: &CompiledInstruction, accounts: &[Rc>], ) -> Result<(), InstructionError>; + /// Get the program ID of the currently executing program fn get_caller(&self) -> Result<&Pubkey, InstructionError>; + /// Get a list of built-in programs fn get_programs(&self) -> &[(Pubkey, ProcessInstruction)]; + /// Check if logging is enabled fn log_enabled(&self) -> bool; + /// Log a message fn log(&mut self, message: &str); }