solana_svm_callback/
lib.rs1use {
2 solana_account::AccountSharedData, solana_clock::Slot,
3 solana_precompile_error::PrecompileError, solana_pubkey::Pubkey,
4};
5
6pub trait InvokeContextCallback {
8 fn get_epoch_stake(&self) -> u64 {
10 0
11 }
12
13 fn get_epoch_stake_for_vote_account(&self, _vote_address: &Pubkey) -> u64 {
15 0
16 }
17
18 fn is_precompile(&self, _program_id: &Pubkey) -> bool {
20 false
21 }
22
23 fn process_precompile(
25 &self,
26 _program_id: &Pubkey,
27 _data: &[u8],
28 _instruction_datas: Vec<&[u8]>,
29 ) -> Result<(), PrecompileError> {
30 Err(PrecompileError::InvalidPublicKey)
31 }
32}
33
34pub trait TransactionProcessingCallback: InvokeContextCallback {
36 fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<(AccountSharedData, Slot)>;
37
38 fn add_builtin_account(&self, _name: &str, _program_id: &Pubkey) {}
39
40 fn inspect_account(&self, _address: &Pubkey, _account_state: AccountState, _is_writable: bool) {
41 }
42}
43
44#[derive(Debug)]
46pub enum AccountState<'a> {
47 Dead,
49 Alive(&'a AccountSharedData),
51}