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

source

pub fn new( header: MessageHeader, account_keys: Vec<Pubkey>, recent_blockhash: SolderHash, instructions: Vec<CompiledInstruction>, address_table_lookups: Vec<MessageAddressTableLookup> ) -> Self

source

pub fn header(&self) -> MessageHeader

source

pub fn account_keys(&self) -> Vec<Pubkey>

source

pub fn recent_blockhash(&self) -> SolderHash

source

pub fn instructions(&self) -> Vec<CompiledInstruction>

source

pub fn address_table_lookups(&self) -> Vec<MessageAddressTableLookup>

source

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)

source

pub fn sanitize(&self) -> PyResult<()>

Sanitize message fields and compiled instruction indexes.

source

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

source

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.

source

pub fn is_signer(&self, index: usize) -> bool

Returns true if the account at the specified index signed this message.

source

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.

source

pub fn hash(&self) -> SolderHash

Compute the blake3 hash of this transaction’s message.

Returns: Hash: The blake3 hash.

source

pub fn hash_raw_message(message_bytes: &[u8]) -> SolderHash

Compute the blake3 hash of a raw transaction message.

Returns: Hash: The blake3 hash.

source

pub fn new_default() -> Self

Create a new default MessageV0.

Returns: MessageV0: default MessageV0.

source

pub fn __richcmp__(&self, other: &Self, op: CompareOp) -> PyResult<bool>

source

pub fn __bytes__<'a>(&self, py: Python<'a>) -> &'a PyBytes

source

pub fn __str__(&self) -> String

source

pub fn __repr__(&self) -> String

source

pub fn __reduce__(&self) -> PyResult<(PyObject, PyObject)>

source

pub fn from_bytes(data: &[u8]) -> PyResult<Self>

Deserialize from bytes.

Args: data (bytes): the serialized object.

Returns: the deserialized object.

source

pub fn to_json(&self) -> String

Convert to a JSON string.

source

pub fn from_json(raw: &str) -> PyResult<Self>

Build from a JSON string.

Trait Implementations§

source§

impl Clone for MessageV0

source§

fn clone(&self) -> MessageV0

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CommonMethods<'_> for MessageV0

source§

fn py_to_json(&self) -> String

source§

fn py_from_json(raw: &'a str) -> Result<Self, PyErr>

source§

impl CommonMethodsCore for MessageV0

source§

fn pybytes<'b>(&self, py: Python<'b>) -> &'b PyBytes

source§

fn pystr(&self) -> String

source§

fn pyrepr(&self) -> String

source§

fn py_from_bytes(raw: &[u8]) -> Result<Self, PyErr>

source§

fn pyreduce(&self) -> Result<(Py<PyAny>, Py<PyAny>), PyErr>

source§

impl Debug for MessageV0

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for MessageV0

source§

fn default() -> MessageV0

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for MessageV0

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for MessageV0

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<Message> for MessageV0

source§

fn from(original: MessageV0Original) -> MessageV0

Converts to this type from the input type.
source§

impl From<MessageV0> for Message

source§

fn from(original: MessageV0) -> Self

Converts to this type from the input type.
source§

impl From<MessageV0> for VersionedMessage

source§

fn from(m: MessageV0) -> Self

Converts to this type from the input type.
source§

impl From<MessageV0> for VersionedMessage

source§

fn from(m: MessageV0) -> Self

Converts to this type from the input type.
source§

impl From<VersionedMessage> for MessageV0

source§

fn from(v: VersionedMessage) -> Self

Converts to this type from the input type.
source§

impl From<VersionedMessage> for MessageV0

source§

fn from(v: VersionedMessageOriginal) -> Self

Converts to this type from the input type.
source§

impl IntoPy<Py<PyAny>> for MessageV0

source§

fn into_py(self, py: Python<'_>) -> PyObject

Performs the conversion.
source§

impl PartialEq for MessageV0

source§

fn eq(&self, other: &MessageV0) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PyBytesBincode for MessageV0

source§

fn pybytes_bincode<'a>(&self, py: Python<'a>) -> &'a PyBytes

source§

impl PyBytesGeneral for MessageV0

source§

fn pybytes_general<'a>(&self, py: Python<'a>) -> &'a PyBytes

source§

impl PyClass for MessageV0

§

type Frozen = False

Whether the pyclass is frozen. Read more
source§

impl PyClassImpl for MessageV0

source§

const IS_BASETYPE: bool = true

#[pyclass(subclass)]
source§

const IS_SUBCLASS: bool = false

#[pyclass(extends=…)]
source§

const IS_MAPPING: bool = false

#[pyclass(mapping)]
source§

const IS_SEQUENCE: bool = false

#[pyclass(sequence)]
§

type Layout = PyCell<MessageV0>

Layout
§

type BaseType = PyAny

Base class
§

type ThreadChecker = ThreadCheckerStub<MessageV0>

This handles following two situations: Read more
§

type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild

Immutable or mutable
§

type Dict = PyClassDummySlot

Specify this class has #[pyclass(dict)] or not.
§

type WeakRef = PyClassDummySlot

Specify this class has #[pyclass(weakref)] or not.
§

type BaseNativeType = PyAny

The closest native ancestor. This is PyAny by default, and when you declare #[pyclass(extends=PyDict)], it’s PyDict.
source§

fn items_iter() -> PyClassItemsIter

source§

fn doc(py: Python<'_>) -> PyResult<&'static CStr>

Rendered class doc
source§

fn lazy_type_object() -> &'static LazyTypeObject<Self>

source§

fn dict_offset() -> Option<isize>

source§

fn weaklist_offset() -> Option<isize>

source§

impl PyClassNewTextSignature<MessageV0> for PyClassImplCollector<MessageV0>

source§

fn new_text_signature(self) -> Option<&'static str>

source§

impl PyFromBytesBincode<'_> for MessageV0

source§

fn py_from_bytes_bincode(raw: &'b [u8]) -> Result<Self, PyErr>

source§

impl PyFromBytesGeneral for MessageV0

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a MessageV0

§

type Holder = Option<PyRef<'py, MessageV0>>

source§

fn extract(obj: &'py PyAny, holder: &'a mut Self::Holder) -> PyResult<Self>

source§

impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut MessageV0

§

type Holder = Option<PyRefMut<'py, MessageV0>>

source§

fn extract(obj: &'py PyAny, holder: &'a mut Self::Holder) -> PyResult<Self>

source§

impl PyMethods<MessageV0> for PyClassImplCollector<MessageV0>

source§

fn py_methods(self) -> &'static PyClassItems

source§

impl PyTypeInfo for MessageV0

§

type AsRefTarget = PyCell<MessageV0>

Utility type to make Py::as_ref work.
source§

const NAME: &'static str = "MessageV0"

Class name.
source§

const MODULE: Option<&'static str> = _

Module name, if any.
source§

fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject

Returns the PyTypeObject instance for this type.
source§

fn type_object(py: Python<'_>) -> &PyType

Returns the safe abstraction over the type object.
source§

fn is_type_of(object: &PyAny) -> bool

Checks if object is an instance of this type or a subclass of this type.
source§

fn is_exact_type_of(object: &PyAny) -> bool

Checks if object is an instance of this type.
source§

impl RichcmpEqualityOnly for MessageV0

source§

fn richcmp(&self, other: &Self, op: CompareOp) -> Result<bool, PyErr>

source§

impl Serialize for MessageV0

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for MessageV0

source§

impl StructuralEq for MessageV0

source§

impl StructuralPartialEq for MessageV0

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> AbiEnumVisitor for T
where T: Serialize + AbiExample + ?Sized,

§

default fn visit_for_abi( &self, digester: &mut AbiDigester ) -> Result<AbiDigester, DigestError>

§

impl<T> AbiEnumVisitor for T
where T: Serialize + ?Sized,

§

default fn visit_for_abi( &self, _digester: &mut AbiDigester ) -> Result<AbiDigester, DigestError>

§

impl<T> AbiExample for T

§

default fn example() -> T

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<'a, T> FromPyObject<'a> for T
where T: PyClass + Clone,

source§

fn extract(obj: &'a PyAny) -> Result<T, PyErr>

Extracts Self from the source PyObject.
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> OkWrap<T> for T
where T: IntoPy<Py<PyAny>>,

§

type Error = PyErr

source§

fn wrap(self, py: Python<'_>) -> Result<Py<PyAny>, PyErr>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> PyErrArguments for T
where T: IntoPy<Py<PyAny>> + Send + Sync,

source§

fn arguments(self, py: Python<'_>) -> Py<PyAny>

Arguments for exception
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> Ungil for T
where T: Send,