#![cfg_attr(
not(feature = "agave-unstable-api"),
deprecated(
since = "3.1.0",
note = "This crate has been marked for formal inclusion in the Agave Unstable API. From \
v4.0.0 onward, the `agave-unstable-api` crate feature must be specified to \
acknowledge use of an interface that may break without warning."
)
)]
use {
solana_account::AccountSharedData, solana_clock::Slot,
solana_precompile_error::PrecompileError, solana_pubkey::Pubkey,
};
pub trait InvokeContextCallback {
fn get_epoch_stake(&self) -> u64 {
0
}
fn get_epoch_stake_for_vote_account(&self, _vote_address: &Pubkey) -> u64 {
0
}
fn is_precompile(&self, _program_id: &Pubkey) -> bool {
false
}
fn process_precompile(
&self,
_program_id: &Pubkey,
_data: &[u8],
_instruction_datas: Vec<&[u8]>,
) -> Result<(), PrecompileError> {
Err(PrecompileError::InvalidPublicKey)
}
}
pub trait TransactionProcessingCallback: InvokeContextCallback {
fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<(AccountSharedData, Slot)>;
fn inspect_account(&self, _address: &Pubkey, _account_state: AccountState, _is_writable: bool) {
}
}
#[derive(Debug)]
pub enum AccountState<'a> {
Dead,
Alive(&'a AccountSharedData),
}