solana_svm_callback/
lib.rs1#![cfg(feature = "agave-unstable-api")]
2use {
3 solana_account::AccountSharedData, solana_clock::Slot,
4 solana_precompile_error::PrecompileError, solana_pubkey::Pubkey,
5};
6
7pub trait InvokeContextCallback {
9 fn get_epoch_stake(&self) -> u64 {
11 0
12 }
13
14 fn get_epoch_stake_for_vote_account(&self, _vote_address: &Pubkey) -> u64 {
16 0
17 }
18
19 fn is_precompile(&self, _program_id: &Pubkey) -> bool {
21 false
22 }
23
24 fn process_precompile(
26 &self,
27 _program_id: &Pubkey,
28 _data: &[u8],
29 _instruction_datas: Vec<&[u8]>,
30 ) -> Result<(), PrecompileError> {
31 Err(PrecompileError::InvalidPublicKey)
32 }
33}
34
35pub trait TransactionProcessingCallback: InvokeContextCallback {
37 fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<(AccountSharedData, Slot)>;
38
39 fn inspect_account(&self, _address: &Pubkey, _account_state: AccountState, _is_writable: bool) {
40 }
41}
42
43#[derive(Debug)]
45pub enum AccountState<'a> {
46 Dead,
48 Alive(&'a AccountSharedData),
50}