Refactor: Remove program_id from process_instruction() (#20540)
* Replaces usage of program_id parameter by invoke_context.get_caller()?. * Removes "pubkey: &Pubkey" parameter from "process_instruction()".
This commit is contained in:
committed by
GitHub
parent
c16510152e
commit
f30f3bddbb
@@ -13,7 +13,6 @@ use solana_frozen_abi::abi_example::AbiExample;
|
||||
|
||||
fn process_instruction_with_program_logging(
|
||||
process_instruction: ProcessInstructionWithContext,
|
||||
program_id: &Pubkey,
|
||||
first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext,
|
||||
@@ -21,15 +20,12 @@ fn process_instruction_with_program_logging(
|
||||
debug_assert_eq!(first_instruction_account, 1);
|
||||
|
||||
let logger = invoke_context.get_logger();
|
||||
let program_id = invoke_context.get_caller()?;
|
||||
stable_log::program_invoke(&logger, program_id, invoke_context.invoke_depth());
|
||||
|
||||
let result = process_instruction(
|
||||
program_id,
|
||||
first_instruction_account,
|
||||
instruction_data,
|
||||
invoke_context,
|
||||
);
|
||||
let result = process_instruction(first_instruction_account, instruction_data, invoke_context);
|
||||
|
||||
let program_id = invoke_context.get_caller()?;
|
||||
match &result {
|
||||
Ok(()) => stable_log::program_success(&logger, program_id),
|
||||
Err(err) => stable_log::program_failure(&logger, program_id, err),
|
||||
@@ -39,13 +35,11 @@ fn process_instruction_with_program_logging(
|
||||
|
||||
macro_rules! with_program_logging {
|
||||
($process_instruction:expr) => {
|
||||
|program_id: &Pubkey,
|
||||
first_instruction_account: usize,
|
||||
|first_instruction_account: usize,
|
||||
instruction_data: &[u8],
|
||||
invoke_context: &mut dyn InvokeContext| {
|
||||
process_instruction_with_program_logging(
|
||||
$process_instruction,
|
||||
program_id,
|
||||
first_instruction_account,
|
||||
instruction_data,
|
||||
invoke_context,
|
||||
@@ -94,7 +88,7 @@ impl AbiExample for Builtin {
|
||||
Self {
|
||||
name: String::default(),
|
||||
id: Pubkey::default(),
|
||||
process_instruction_with_context: |_, _, _, _| Ok(()),
|
||||
process_instruction_with_context: |_, _, _| Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,7 +135,6 @@ fn genesis_builtins() -> Vec<Builtin> {
|
||||
|
||||
/// place holder for secp256k1, remove when the precompile program is deactivated via feature activation
|
||||
fn dummy_process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
_first_instruction_account: usize,
|
||||
_data: &[u8],
|
||||
_invoke_context: &mut dyn InvokeContext,
|
||||
|
Reference in New Issue
Block a user