solana_svm_callback/
lib.rs1use {
2 solana_account::AccountSharedData, solana_precompile_error::PrecompileError,
3 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 account_matches_owners(&self, account: &Pubkey, owners: &[Pubkey]) -> Option<usize>;
37
38 fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<AccountSharedData>;
39
40 fn add_builtin_account(&self, _name: &str, _program_id: &Pubkey) {}
41
42 fn inspect_account(&self, _address: &Pubkey, _account_state: AccountState, _is_writable: bool) {
43 }
44
45 #[deprecated(
46 since = "2.3.0",
47 note = "Use `get_epoch_stake_for_vote_account` on the `InvokeContextCallback` trait instead"
48 )]
49 fn get_current_epoch_vote_account_stake(&self, vote_address: &Pubkey) -> u64 {
50 Self::get_epoch_stake_for_vote_account(self, vote_address)
51 }
52}
53
54#[derive(Debug)]
56pub enum AccountState<'a> {
57 Dead,
59 Alive(&'a AccountSharedData),
61}