Add BPF program entrypoint return type (#8111)
This commit is contained in:
@@ -2,7 +2,8 @@
|
||||
|
||||
extern crate solana_sdk;
|
||||
use solana_sdk::{
|
||||
account_info::AccountInfo, entrypoint, info, program_error::ProgramError, pubkey::Pubkey,
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, info,
|
||||
program_error::ProgramError, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
entrypoint!(process_instruction);
|
||||
@@ -10,7 +11,7 @@ fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
instruction_data: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
) -> ProgramResult {
|
||||
match instruction_data[0] {
|
||||
1 => {
|
||||
info!("modify first account data");
|
||||
|
@@ -6,7 +6,9 @@ use num_traits::FromPrimitive;
|
||||
|
||||
use solana_sdk::{
|
||||
account_info::AccountInfo,
|
||||
entrypoint, info,
|
||||
entrypoint,
|
||||
entrypoint::ProgramResult,
|
||||
info,
|
||||
instruction_processor_utils::DecodeError,
|
||||
program_error::{PrintProgramError, ProgramError},
|
||||
pubkey::Pubkey,
|
||||
@@ -48,9 +50,7 @@ fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
instruction_data: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
ProgramError::CustomError(42).print::<MyError>();
|
||||
|
||||
) -> ProgramResult {
|
||||
match instruction_data[0] {
|
||||
1 => {
|
||||
info!("return success");
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
extern crate solana_sdk;
|
||||
use solana_sdk::{
|
||||
account_info::AccountInfo, entrypoint, program_error::ProgramError, pubkey::Pubkey,
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
entrypoint!(process_instruction);
|
||||
@@ -10,7 +10,7 @@ fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
_instruction_data: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
) -> ProgramResult {
|
||||
// account 0 is the mint and not owned by this program, any debit of its lamports
|
||||
// should result in a failed program execution. Test to ensure that this debit
|
||||
// is seen by the runtime and fails as expected
|
||||
|
@@ -5,8 +5,7 @@
|
||||
extern crate solana_sdk;
|
||||
|
||||
use solana_sdk::{
|
||||
account_info::AccountInfo, entrypoint, info, log::*, program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, info, log::*, pubkey::Pubkey,
|
||||
};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
@@ -26,7 +25,7 @@ fn process_instruction(
|
||||
program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
instruction_data: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
) -> ProgramResult {
|
||||
info!("Program identifier:");
|
||||
program_id.log();
|
||||
|
||||
|
@@ -4,9 +4,10 @@ extern crate solana_sdk;
|
||||
use solana_sdk::{
|
||||
account_info::AccountInfo,
|
||||
clock::{get_segment_from_slot, DEFAULT_SLOTS_PER_EPOCH, DEFAULT_SLOTS_PER_SEGMENT},
|
||||
entrypoint, info,
|
||||
entrypoint,
|
||||
entrypoint::ProgramResult,
|
||||
info,
|
||||
log::Log,
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
rent,
|
||||
sysvar::{
|
||||
@@ -20,7 +21,7 @@ fn process_instruction(
|
||||
_program_id: &Pubkey,
|
||||
accounts: &[AccountInfo],
|
||||
_instruction_data: &[u8],
|
||||
) -> Result<(), ProgramError> {
|
||||
) -> ProgramResult {
|
||||
// Clock
|
||||
info!("Clock identifier:");
|
||||
sysvar::clock::id().log();
|
||||
|
Reference in New Issue
Block a user