pub struct InstructionContext<'a> { /* private fields */ }Expand description
Context provided to instruction hook functions
Implementations§
Source§impl<'a> InstructionContext<'a>
impl<'a> InstructionContext<'a>
pub fn new( accounts: HashMap<String, String>, state_id: u32, reverse_lookup_tx: &'a mut dyn ReverseLookupUpdater, ) -> Self
pub fn with_metrics( accounts: HashMap<String, String>, state_id: u32, reverse_lookup_tx: &'a mut dyn ReverseLookupUpdater, registers: &'a mut Vec<RegisterValue>, state_reg: Register, compiled_paths: &'a HashMap<String, CompiledPath>, instruction_data: &'a Value, slot: Option<u64>, signature: Option<String>, timestamp: i64, ) -> Self
Sourcepub fn account(&self, name: &str) -> Option<String>
pub fn account(&self, name: &str) -> Option<String>
Get an account address by its name from the instruction
Sourcepub fn register_pda_reverse_lookup(
&mut self,
pda_address: &str,
seed_value: &str,
)
pub fn register_pda_reverse_lookup( &mut self, pda_address: &str, seed_value: &str, )
Register a reverse lookup: PDA address -> seed value This also flushes any pending account updates for this PDA
The pending account updates are accumulated internally and can be retrieved
via take_pending_updates() after all hooks have executed.
Sourcepub fn take_pending_updates(&mut self) -> Vec<PendingAccountUpdate>
pub fn take_pending_updates(&mut self) -> Vec<PendingAccountUpdate>
Take all accumulated pending updates
This should be called after all instruction hooks have executed to retrieve any pending account updates that need to be reprocessed.
pub fn dirty_tracker(&self) -> &DirtyTracker
pub fn dirty_tracker_mut(&mut self) -> &mut DirtyTracker
Sourcepub fn state_value(&self) -> Option<&Value>
pub fn state_value(&self) -> Option<&Value>
Get the current state register value (for generating mutations)
Sourcepub fn get<T: DeserializeOwned>(&self, field_path: &str) -> Option<T>
pub fn get<T: DeserializeOwned>(&self, field_path: &str) -> Option<T>
Get a field value from the entity state This allows reading aggregated values or other entity fields
pub fn set<T: Serialize>(&mut self, field_path: &str, value: T)
pub fn increment(&mut self, field_path: &str, amount: i64)
pub fn append<T: Serialize>(&mut self, field_path: &str, value: T)
Sourcepub fn data<T: DeserializeOwned>(&self, field: &str) -> Option<T>
pub fn data<T: DeserializeOwned>(&self, field: &str) -> Option<T>
Access instruction data field
Auto Trait Implementations§
impl<'a> Freeze for InstructionContext<'a>
impl<'a> !RefUnwindSafe for InstructionContext<'a>
impl<'a> !Send for InstructionContext<'a>
impl<'a> !Sync for InstructionContext<'a>
impl<'a> Unpin for InstructionContext<'a>
impl<'a> !UnwindSafe for InstructionContext<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more