solana_svm_callback/
lib.rs1#![cfg_attr(
2 not(feature = "agave-unstable-api"),
3 deprecated(
4 since = "3.1.0",
5 note = "This crate has been marked for formal inclusion in the Agave Unstable API. From \
6 v4.0.0 onward, the `agave-unstable-api` crate feature must be specified to \
7 acknowledge use of an interface that may break without warning."
8 )
9)]
10use {
11 solana_account::AccountSharedData, solana_clock::Slot,
12 solana_precompile_error::PrecompileError, solana_pubkey::Pubkey,
13};
14
15pub trait InvokeContextCallback {
17 fn get_epoch_stake(&self) -> u64 {
19 0
20 }
21
22 fn get_epoch_stake_for_vote_account(&self, _vote_address: &Pubkey) -> u64 {
24 0
25 }
26
27 fn is_precompile(&self, _program_id: &Pubkey) -> bool {
29 false
30 }
31
32 fn process_precompile(
34 &self,
35 _program_id: &Pubkey,
36 _data: &[u8],
37 _instruction_datas: Vec<&[u8]>,
38 ) -> Result<(), PrecompileError> {
39 Err(PrecompileError::InvalidPublicKey)
40 }
41}
42
43pub trait TransactionProcessingCallback: InvokeContextCallback {
45 fn get_account_shared_data(&self, pubkey: &Pubkey) -> Option<(AccountSharedData, Slot)>;
46
47 fn inspect_account(&self, _address: &Pubkey, _account_state: AccountState, _is_writable: bool) {
48 }
49}
50
51#[derive(Debug)]
53pub enum AccountState<'a> {
54 Dead,
56 Alive(&'a AccountSharedData),
58}