Skip to main content

gmsol_decode/decoder/
transaction_access.rs

1pub use anchor_lang::prelude::AccountMeta;
2use solana_sdk::instruction::CompiledInstruction;
3pub use solana_sdk::{message::v0::MessageAddressTableLookup, signature::Signature};
4pub use solana_transaction_status_client_types::UiTransactionStatusMeta;
5
6use crate::DecodeError;
7
8/// Access a transaction.
9pub trait TransactionAccess {
10    /// Gets the slot of the transaction where the events were generated.
11    fn slot(&self) -> Result<u64, DecodeError>;
12
13    /// Gets the index in the block of the transaction where the events were generated.
14    ///
15    /// ## Note
16    /// The `index` may be `None` because for old transaction info format,
17    /// the `index` of the transaction is not provided.
18    fn index(&self) -> Result<Option<usize>, DecodeError>;
19
20    /// Gets the signature of the transaction where the events were generated.
21    fn signature(&self) -> Result<&Signature, DecodeError>;
22
23    /// Returns the number of signers.
24    fn num_signers(&self, is_writable: bool) -> Result<usize, DecodeError>;
25
26    /// Returns the number of accounts.
27    fn num_accounts(&self) -> usize;
28
29    /// Gets message signature.
30    fn message_signature(&self, idx: usize) -> Option<&Signature>;
31
32    /// Gets account meta by index.
33    fn account_meta(&self, idx: usize) -> Result<Option<AccountMeta>, DecodeError>;
34
35    /// Returns the number of address table lookups.
36    fn num_address_table_lookups(&self) -> usize;
37
38    /// Gets address table lookup by index.
39    fn address_table_lookup(&self, idx: usize) -> Option<&MessageAddressTableLookup>;
40
41    /// Returns the number of instructions.
42    fn num_instructions(&self) -> usize;
43
44    /// Gets instruction by index.
45    fn instruction(&self, idx: usize) -> Option<&CompiledInstruction>;
46
47    /// Returns transaction status meta if available.
48    fn transaction_status_meta(&self) -> Option<&UiTransactionStatusMeta>;
49}