solana_svm_transaction/svm_message/
sanitized_message.rs

1use {
2    crate::{
3        instruction::SVMInstruction, message_address_table_lookup::SVMMessageAddressTableLookup,
4        svm_message::SVMMessage,
5    },
6    solana_hash::Hash,
7    solana_message::{AccountKeys, SanitizedMessage},
8    solana_pubkey::Pubkey,
9};
10
11// Implement for the "reference" `SanitizedMessage` type.
12impl SVMMessage for SanitizedMessage {
13    fn num_transaction_signatures(&self) -> u64 {
14        u64::from(self.header().num_required_signatures)
15    }
16
17    fn num_write_locks(&self) -> u64 {
18        SanitizedMessage::num_write_locks(self)
19    }
20
21    fn recent_blockhash(&self) -> &Hash {
22        SanitizedMessage::recent_blockhash(self)
23    }
24
25    fn num_instructions(&self) -> usize {
26        SanitizedMessage::instructions(self).len()
27    }
28
29    fn instructions_iter(&self) -> impl Iterator<Item = SVMInstruction> {
30        SanitizedMessage::instructions(self)
31            .iter()
32            .map(SVMInstruction::from)
33    }
34
35    fn program_instructions_iter(&self) -> impl Iterator<Item = (&Pubkey, SVMInstruction)> + Clone {
36        SanitizedMessage::program_instructions_iter(self)
37            .map(|(pubkey, ix)| (pubkey, SVMInstruction::from(ix)))
38    }
39
40    fn account_keys(&self) -> AccountKeys {
41        SanitizedMessage::account_keys(self)
42    }
43
44    fn fee_payer(&self) -> &Pubkey {
45        SanitizedMessage::fee_payer(self)
46    }
47
48    fn is_writable(&self, index: usize) -> bool {
49        SanitizedMessage::is_writable(self, index)
50    }
51
52    fn is_signer(&self, index: usize) -> bool {
53        SanitizedMessage::is_signer(self, index)
54    }
55
56    fn is_invoked(&self, key_index: usize) -> bool {
57        SanitizedMessage::is_invoked(self, key_index)
58    }
59
60    fn num_lookup_tables(&self) -> usize {
61        SanitizedMessage::message_address_table_lookups(self).len()
62    }
63
64    fn message_address_table_lookups(&self) -> impl Iterator<Item = SVMMessageAddressTableLookup> {
65        SanitizedMessage::message_address_table_lookups(self)
66            .iter()
67            .map(SVMMessageAddressTableLookup::from)
68    }
69}