|
|
@@ -0,0 +1,66 @@
|
|
|
+use {
|
|
|
+ crate::{
|
|
|
+ instruction::SVMInstruction, message_address_table_lookup::SVMMessageAddressTableLookup,
|
|
|
+ },
|
|
|
+ core::fmt::Debug,
|
|
|
+ solana_sdk::{hash::Hash, message::AccountKeys, pubkey::Pubkey},
|
|
|
+};
|
|
|
+
|
|
|
+mod sanitized_message;
|
|
|
+mod sanitized_transaction;
|
|
|
+
|
|
|
+// - Debug to support legacy logging
|
|
|
+pub trait SVMMessage: Debug {
|
|
|
+ /// Return the number of signatures in the message.
|
|
|
+ fn num_signatures(&self) -> u64;
|
|
|
+
|
|
|
+ /// Returns the number of requested write-locks in this message.
|
|
|
+ /// This does not consider if write-locks are demoted.
|
|
|
+ fn num_write_locks(&self) -> u64;
|
|
|
+
|
|
|
+ /// Return the recent blockhash.
|
|
|
+ fn recent_blockhash(&self) -> &Hash;
|
|
|
+
|
|
|
+ /// Return the number of instructions in the message.
|
|
|
+ fn num_instructions(&self) -> usize;
|
|
|
+
|
|
|
+ /// Return an iterator over the instructions in the message.
|
|
|
+ fn instructions_iter(&self) -> impl Iterator<Item = SVMInstruction>;
|
|
|
+
|
|
|
+ /// Return an iterator over the instructions in the message, paired with
|
|
|
+ /// the pubkey of the program.
|
|
|
+ fn program_instructions_iter(&self) -> impl Iterator<Item = (&Pubkey, SVMInstruction)>;
|
|
|
+
|
|
|
+ /// Return the account keys.
|
|
|
+ fn account_keys(&self) -> AccountKeys;
|
|
|
+
|
|
|
+ /// Return the fee-payer
|
|
|
+ fn fee_payer(&self) -> &Pubkey;
|
|
|
+
|
|
|
+ /// Returns `true` if the account at `index` is writable.
|
|
|
+ fn is_writable(&self, index: usize) -> bool;
|
|
|
+
|
|
|
+ /// Returns `true` if the account at `index` is signer.
|
|
|
+ fn is_signer(&self, index: usize) -> bool;
|
|
|
+
|
|
|
+ /// Returns true if the account at the specified index is invoked as a
|
|
|
+ /// program in top-level instructions of this message.
|
|
|
+ fn is_invoked(&self, key_index: usize) -> bool;
|
|
|
+
|
|
|
+ /// Returns true if the account at the specified index is an input to some
|
|
|
+ /// program instruction in this message.
|
|
|
+ fn is_instruction_account(&self, key_index: usize) -> bool {
|
|
|
+ if let Ok(key_index) = u8::try_from(key_index) {
|
|
|
+ self.instructions_iter()
|
|
|
+ .any(|ix| ix.accounts.contains(&key_index))
|
|
|
+ } else {
|
|
|
+ false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /// Get the number of lookup tables.
|
|
|
+ fn num_lookup_tables(&self) -> usize;
|
|
|
+
|
|
|
+ /// Get message address table lookups used in the message
|
|
|
+ fn message_address_table_lookups(&self) -> impl Iterator<Item = SVMMessageAddressTableLookup>;
|
|
|
+}
|