Struct solders_message::MessageV0
source · pub struct MessageV0(pub Message);
Expand description
A Solana transaction message (v0).
This message format supports succinct account loading with on-chain address lookup tables
Args:
header (MessageHeader): The message header, identifying signed and read-only account_keys
.
Header values only describe static account_keys
, they do not describe
any additional account keys loaded via address table lookups.
account_keys (SequencePubkey): List of accounts loaded by this transaction.
recent_blockhash (Hash): Hash of a recent block.
instructions (SequenceInstruction): The instructions to include in the message.
address_table_lookups (SequenceMessageAddressTableLookup): List of address table lookups used to load additional accounts
for this transaction.
Example: >>> from solders.message import MessageV0, MessageHeader, MessageAddressTableLookup >>> from solders.instruction import CompiledInstruction >>> from solders.hash import Hash >>> from solders.pubkey import Pubkey >>> program_id = Pubkey.default() >>> arbitrary_instruction_data = bytes([1]) >>> accounts = [] >>> instructions=[CompiledInstruction(program_id_index=4, accounts=bytes([1, 2, 3, 5, 6]), data=bytes([]))] >>> account_keys = [Pubkey.new_unique()] >>> header = MessageHeader(1, 0, 0) >>> lookups = [MessageAddressTableLookup(Pubkey.new_unique(), bytes([1, 2, 3]), bytes([0]))] >>> blockhash = Hash.default() # replace with a real blockhash >>> message = MessageV0(header, account_keys, blockhash, instructions, lookups)
Tuple Fields§
§0: Message
Implementations§
source§impl MessageV0
impl MessageV0
pub fn new( header: MessageHeader, account_keys: Vec<Pubkey>, recent_blockhash: SolderHash, instructions: Vec<CompiledInstruction>, address_table_lookups: Vec<MessageAddressTableLookup> ) -> Self
pub fn header(&self) -> MessageHeader
pub fn account_keys(&self) -> Vec<Pubkey>
pub fn recent_blockhash(&self) -> SolderHash
pub fn instructions(&self) -> Vec<CompiledInstruction>
pub fn address_table_lookups(&self) -> Vec<MessageAddressTableLookup>
sourcepub fn try_compile(
payer: &Pubkey,
instructions: Vec<Instruction>,
address_lookup_table_accounts: Vec<AddressLookupTableAccount>,
recent_blockhash: SolderHash
) -> PyResult<Self>
pub fn try_compile( payer: &Pubkey, instructions: Vec<Instruction>, address_lookup_table_accounts: Vec<AddressLookupTableAccount>, recent_blockhash: SolderHash ) -> PyResult<Self>
Create a signable transaction message from a payer
public key, recent_blockhash
,
list of instructions
, and a list of address_lookup_table_accounts
.
Args: payer (Pubkey): The fee payer. instructions (SequenceInstruction): The instructions to include in the message. address_table_lookups (SequenceMessageAddressTableLookup): List of address table lookups used to load additional accounts for this transaction. recent_blockhash (Hash): Hash of a recent block.
Example: >>> from solders.pubkey import Pubkey >>> from solders.instruction import Instruction, AccountMeta >>> from solders.message import Message >>> from solders.address_lookup_table_account import AddressLookupTableAccount >>> from solders.hash import Hash >>> keys = [Pubkey.new_unique() for i in range(7)] >>> payer = keys[0] >>> program_id = keys[6] >>> ix_accounts = [AccountMeta(keys[1], True, True), AccountMeta(keys[2], True, False), AccountMeta(keys[3], False, True),AccountMeta(keys[4], False, True),AccountMeta(keys[5], False, False),] >>> instructions = [Instruction(program_id, bytes([]), ix_accounts)] >>> lookup_acc0 = AddressLookupTableAccount(key=Pubkey.new_unique(), addresses=[keys[4], keys[5], keys[6]]) >>> lookup_acc1 = AddressLookupTableAccount(key=Pubkey.new_unique(), addresses=[]) >>> lookup_accs = [lookup_acc0, lookup_acc1] >>> recent_blockhash = Hash.new_unique() >>> msg = MessageV0.try_compile(payer, instructions, lookup_accs, recent_blockhash)
sourcepub fn sanitize(&self) -> PyResult<()>
pub fn sanitize(&self) -> PyResult<()>
Sanitize message fields and compiled instruction indexes.
sourcepub fn is_key_called_as_program(&self, key_index: usize) -> bool
pub fn is_key_called_as_program(&self, key_index: usize) -> bool
Returns true if the account at the specified index is called as a program by an instruction
sourcepub fn is_maybe_writable(&self, key_index: usize) -> bool
pub fn is_maybe_writable(&self, key_index: usize) -> bool
Returns true if the account at the specified index was requested as writable. Before loading addresses, we can’t demote write locks for dynamically loaded addresses so this should not be used by the runtime.
sourcepub fn is_signer(&self, index: usize) -> bool
pub fn is_signer(&self, index: usize) -> bool
Returns true if the account at the specified index signed this message.
sourcepub fn is_non_loader_key(&self, key_index: usize) -> bool
pub fn is_non_loader_key(&self, key_index: usize) -> bool
Returns true if the account at the specified index is not invoked as a program or, if invoked, is passed to a program.
sourcepub fn hash(&self) -> SolderHash
pub fn hash(&self) -> SolderHash
Compute the blake3 hash of this transaction’s message.
Returns: Hash: The blake3 hash.
sourcepub fn hash_raw_message(message_bytes: &[u8]) -> SolderHash
pub fn hash_raw_message(message_bytes: &[u8]) -> SolderHash
Compute the blake3 hash of a raw transaction message.
Returns: Hash: The blake3 hash.
sourcepub fn new_default() -> Self
pub fn new_default() -> Self
Create a new default MessageV0
.
Returns:
MessageV0: default MessageV0
.
pub fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult<bool>
pub fn __bytes__<'a>(&self, py: Python<'a>) -> &'a PyBytes
pub fn __str__(&self) -> String
pub fn __repr__(&self) -> String
pub fn __reduce__(&self) -> PyResult<(PyObject, PyObject)>
sourcepub fn from_bytes(data: &[u8]) -> PyResult<Self>
pub fn from_bytes(data: &[u8]) -> PyResult<Self>
Deserialize from bytes.
Args: data (bytes): the serialized object.
Returns: the deserialized object.
Trait Implementations§
source§impl CommonMethods<'_> for MessageV0
impl CommonMethods<'_> for MessageV0
fn py_to_json(&self) -> String
fn py_from_json(raw: &'a str) -> Result<Self, PyErr>
source§impl CommonMethodsCore for MessageV0
impl CommonMethodsCore for MessageV0
source§impl<'de> Deserialize<'de> for MessageV0
impl<'de> Deserialize<'de> for MessageV0
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl From<Message> for MessageV0
impl From<Message> for MessageV0
source§fn from(original: MessageV0Original) -> MessageV0
fn from(original: MessageV0Original) -> MessageV0
source§impl From<MessageV0> for VersionedMessage
impl From<MessageV0> for VersionedMessage
source§impl From<MessageV0> for VersionedMessage
impl From<MessageV0> for VersionedMessage
source§impl From<VersionedMessage> for MessageV0
impl From<VersionedMessage> for MessageV0
source§fn from(v: VersionedMessage) -> Self
fn from(v: VersionedMessage) -> Self
source§impl From<VersionedMessage> for MessageV0
impl From<VersionedMessage> for MessageV0
source§fn from(v: VersionedMessageOriginal) -> Self
fn from(v: VersionedMessageOriginal) -> Self
source§impl PartialEq for MessageV0
impl PartialEq for MessageV0
source§impl PyBytesBincode for MessageV0
impl PyBytesBincode for MessageV0
fn pybytes_bincode<'a>(&self, py: Python<'a>) -> &'a PyBytes
source§impl PyBytesGeneral for MessageV0
impl PyBytesGeneral for MessageV0
fn pybytes_general<'a>(&self, py: Python<'a>) -> &'a PyBytes
source§impl PyClassImpl for MessageV0
impl PyClassImpl for MessageV0
source§const IS_BASETYPE: bool = true
const IS_BASETYPE: bool = true
source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type ThreadChecker = ThreadCheckerStub<MessageV0>
type ThreadChecker = ThreadCheckerStub<MessageV0>
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
source§impl PyClassNewTextSignature<MessageV0> for PyClassImplCollector<MessageV0>
impl PyClassNewTextSignature<MessageV0> for PyClassImplCollector<MessageV0>
fn new_text_signature(self) -> Option<&'static str>
source§impl PyFromBytesBincode<'_> for MessageV0
impl PyFromBytesBincode<'_> for MessageV0
source§impl PyFromBytesGeneral for MessageV0
impl PyFromBytesGeneral for MessageV0
fn py_from_bytes_general(raw: &[u8]) -> PyResult<Self>
source§impl PyMethods<MessageV0> for PyClassImplCollector<MessageV0>
impl PyMethods<MessageV0> for PyClassImplCollector<MessageV0>
fn py_methods(self) -> &'static PyClassItems
source§impl PyTypeInfo for MessageV0
impl PyTypeInfo for MessageV0
§type AsRefTarget = PyCell<MessageV0>
type AsRefTarget = PyCell<MessageV0>
source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
object
is an instance of this type or a subclass of this type.source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
object
is an instance of this type.