pub struct MessageDiscriminant { /* private fields */ }
Expand description
Used to distinguish message types that are sign by account keys, to avoid an abuse of signed messages as something else.
This prefix must be be at the first four bytes of a message body that is signed under this signature scheme.
The scheme is a draft introduced to avoid security issues with the implementation of meta transactions (NEP-366) but will eventually be standardized with NEP-461 that solves the problem more generally.
Implementations§
source§impl MessageDiscriminant
impl MessageDiscriminant
sourcepub fn new_on_chain(nep: u32) -> Result<Self, CreateDiscriminantError>
pub fn new_on_chain(nep: u32) -> Result<Self, CreateDiscriminantError>
Create a discriminant for an on-chain actionable message that was introduced in the specified NEP.
Allows creating discriminants currently unknown in this crate, which can be useful to prototype new standards. For example, when the client project still relies on an older version of this crate while nightly nearcore already supports a new NEP.
sourcepub fn new_off_chain(nep: u32) -> Result<Self, CreateDiscriminantError>
pub fn new_off_chain(nep: u32) -> Result<Self, CreateDiscriminantError>
Create a discriminant for an off-chain message that was introduced in the specified NEP.
Allows creating discriminants currently unknown in this crate, which can be useful to prototype new standards. For example, when the client project still relies on an older version of this crate while nightly nearcore already supports a new NEP.
sourcepub fn raw_discriminant(&self) -> u32
pub fn raw_discriminant(&self) -> u32
Returns the raw integer value of the discriminant as an integer value.
sourcepub fn is_transaction(&self) -> bool
pub fn is_transaction(&self) -> bool
Whether this discriminant marks a traditional SignedTransaction
.
sourcepub fn on_chain_nep(&self) -> Option<u32>
pub fn on_chain_nep(&self) -> Option<u32>
If this discriminant marks a message intended for on-chain use, return the NEP in which the message type was introduced.
sourcepub fn off_chain_nep(&self) -> Option<u32>
pub fn off_chain_nep(&self) -> Option<u32>
If this discriminant marks a message intended for off-chain use, return the NEP in which the message type was introduced.
clippy: MAX_OFF_CHAIN_DISCRIMINANT currently is u32::MAX which makes the comparison pointless, however I think it helps code readability to have it spelled out anyway
Trait Implementations§
source§impl BorshDeserialize for MessageDiscriminant
impl BorshDeserialize for MessageDiscriminant
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
source§impl BorshSerialize for MessageDiscriminant
impl BorshSerialize for MessageDiscriminant
source§impl Clone for MessageDiscriminant
impl Clone for MessageDiscriminant
source§fn clone(&self) -> MessageDiscriminant
fn clone(&self) -> MessageDiscriminant
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for MessageDiscriminant
impl Debug for MessageDiscriminant
source§impl<'de> Deserialize<'de> for MessageDiscriminant
impl<'de> Deserialize<'de> for MessageDiscriminant
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<SignableMessageType> for MessageDiscriminant
impl From<SignableMessageType> for MessageDiscriminant
source§fn from(ty: SignableMessageType) -> Self
fn from(ty: SignableMessageType) -> Self
source§impl Hash for MessageDiscriminant
impl Hash for MessageDiscriminant
source§impl Ord for MessageDiscriminant
impl Ord for MessageDiscriminant
source§fn cmp(&self, other: &MessageDiscriminant) -> Ordering
fn cmp(&self, other: &MessageDiscriminant) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for MessageDiscriminant
impl PartialEq for MessageDiscriminant
source§fn eq(&self, other: &MessageDiscriminant) -> bool
fn eq(&self, other: &MessageDiscriminant) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for MessageDiscriminant
impl PartialOrd for MessageDiscriminant
source§fn partial_cmp(&self, other: &MessageDiscriminant) -> Option<Ordering>
fn partial_cmp(&self, other: &MessageDiscriminant) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl Serialize for MessageDiscriminant
impl Serialize for MessageDiscriminant
source§impl TryFrom<MessageDiscriminant> for SignableMessageType
impl TryFrom<MessageDiscriminant> for SignableMessageType
§type Error = ReadDiscriminantError
type Error = ReadDiscriminantError
impl Copy for MessageDiscriminant
impl Eq for MessageDiscriminant
impl StructuralPartialEq for MessageDiscriminant
Auto Trait Implementations§
impl Freeze for MessageDiscriminant
impl RefUnwindSafe for MessageDiscriminant
impl Send for MessageDiscriminant
impl Sync for MessageDiscriminant
impl Unpin for MessageDiscriminant
impl UnwindSafe for MessageDiscriminant
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more