Add return data implementation
This consists of: - syscalls - passing return data from invoked to invoker - printing to stable log - rust and C SDK changes
This commit is contained in:
@ -18,6 +18,7 @@ pub const VERIFY_PRIVILEGE_DEESCALATION_ESCALATION_SIGNER: u8 = 9;
|
||||
pub const VERIFY_PRIVILEGE_DEESCALATION_ESCALATION_WRITABLE: u8 = 10;
|
||||
pub const WRITE_ACCOUNT: u8 = 11;
|
||||
pub const CREATE_AND_INIT: u8 = 12;
|
||||
pub const SET_RETURN_DATA: u8 = 13;
|
||||
|
||||
pub fn create_instruction(
|
||||
program_id: Pubkey,
|
||||
|
@ -8,7 +8,7 @@ use solana_program::{
|
||||
bpf_loader, entrypoint,
|
||||
entrypoint::{ProgramResult, MAX_PERMITTED_DATA_INCREASE},
|
||||
msg,
|
||||
program::{invoke, invoke_signed},
|
||||
program::{get_return_data, invoke, invoke_signed, set_return_data},
|
||||
program_error::ProgramError,
|
||||
pubkey::Pubkey,
|
||||
system_instruction,
|
||||
@ -27,6 +27,8 @@ fn process_instruction(
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
assert_eq!(get_return_data(), None);
|
||||
|
||||
match instruction_data[0] {
|
||||
VERIFY_TRANSLATIONS => {
|
||||
msg!("verify data translations");
|
||||
@ -286,6 +288,11 @@ fn process_instruction(
|
||||
}
|
||||
}
|
||||
}
|
||||
SET_RETURN_DATA => {
|
||||
msg!("Set return data");
|
||||
|
||||
set_return_data(b"Set by invoked");
|
||||
}
|
||||
_ => panic!(),
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user