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:
@ -67,6 +67,8 @@ pub struct ThisInvokeContext<'a> {
|
||||
sysvars: RefCell<Vec<(Pubkey, Option<Rc<Vec<u8>>>)>>,
|
||||
blockhash: &'a Hash,
|
||||
fee_calculator: &'a FeeCalculator,
|
||||
// return data and program_id that set it
|
||||
return_data: Option<(Pubkey, Vec<u8>)>,
|
||||
}
|
||||
impl<'a> ThisInvokeContext<'a> {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@ -116,6 +118,7 @@ impl<'a> ThisInvokeContext<'a> {
|
||||
sysvars: RefCell::new(vec![]),
|
||||
blockhash,
|
||||
fee_calculator,
|
||||
return_data: None,
|
||||
};
|
||||
invoke_context.push(program_id, message, instruction, program_indices, accounts)?;
|
||||
Ok(invoke_context)
|
||||
@ -329,6 +332,12 @@ impl<'a> InvokeContext for ThisInvokeContext<'a> {
|
||||
fn get_fee_calculator(&self) -> &FeeCalculator {
|
||||
self.fee_calculator
|
||||
}
|
||||
fn set_return_data(&mut self, return_data: Option<(Pubkey, Vec<u8>)>) {
|
||||
self.return_data = return_data;
|
||||
}
|
||||
fn get_return_data(&self) -> &Option<(Pubkey, Vec<u8>)> {
|
||||
&self.return_data
|
||||
}
|
||||
}
|
||||
pub struct ThisLogger {
|
||||
log_collector: Option<Rc<LogCollector>>,
|
||||
|
Reference in New Issue
Block a user