Skip to main content

Signed

Struct Signed 

Source
pub struct Signed<T>
where T: Encodable,
{ pub payload: T, pub signature: SignatureType, pub hash: OnceLock<FixedBytes<32>>, }
Expand description

A transaction with a signature and hash seal.

Fields§

§payload: T

The payload is the raw transaction that submitted by the user.

§signature: SignatureType

The signature(s) - either single or multi-sig

§hash: OnceLock<FixedBytes<32>>

The hash of the transaction, which is used to identify the transaction. And it’s calculated by the payload and the signature, and no need to be serialized and stored in the database.

Implementations§

Source§

impl<T> Signed<T>
where T: Encodable,

Source

pub fn is_multi_sig(&self) -> bool

Check if this is a multi-sig transaction

Source

pub fn multi_sig_info(&self) -> Option<(Address, &[MultiSigSignatureEntry])>

Get the multi-sig account and signatures if this is a multi-sig transaction

Source

pub fn signature_count(&self) -> usize

Get the number of signatures in this transaction

Source§

impl<T> Signed<T>
where T: Encodable + TxHashable,

Source

pub fn new(payload: T, signature: Signature) -> Signed<T>

Creates a new signed transaction with a single signature.

The transaction hash is computed immediately and cached in OnceLock.

Source

pub fn new_multi_sig( payload: T, multisig_account: Address, signatures: Vec<MultiSigSignatureEntry>, ) -> Signed<T>

Creates a new multi-sig transaction with multiple signatures.

The transaction hash includes all signatures to ensure uniqueness.

§Arguments
  • payload - The transaction payload
  • multisig_account - The multi-sig account address (sender)
  • signatures - The list of signatures from authorized signers
Source

pub fn new_unchecked( payload: T, signature: Signature, hash: FixedBytes<32>, ) -> Signed<T>

Creates a new signed transaction with the given payload and signature, and the hash of the transaction is already calculated. The function will not calculate the hash again, so the caller should ensure the hash is correct.

It’s mainly used for testing.

Source

pub fn new_unhashed(payload: T, signature: Signature) -> Signed<T>

Creates a new signed transaction with the given payload and signature, but without hashing the transaction. And when getting the hash at the first time, it will be calculated.

Source

pub fn payload(&self) -> &T

Returns the payload of the signed transaction.

Source

pub fn signature(&self) -> &SignatureType

Returns the signature(s) of the signed transaction.

Source

pub fn signature_type(&self) -> &SignatureType

Returns the signature(s) of the signed transaction. Alias for signature() for backwards compatibility.

Source

pub fn hash(&self) -> &FixedBytes<32>

Returns the hash of the signed transaction, the hash is calculated when first time called (for deserialized transactions), and cached in OnceLock.

Source

pub fn slow_hash(&self) -> FixedBytes<32>

Returns the hash of the raw transaction with signature. This is slower than hash() as it recalculates every time.

Trait Implementations§

Source§

impl<T> AsRef<T> for Signed<T>
where T: Encodable,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<T> Clone for Signed<T>
where T: Clone + Encodable,

Source§

fn clone(&self) -> Signed<T>

Returns a duplicate 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<T> Debug for Signed<T>
where T: Debug + Encodable,

Source§

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

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

impl<'de, T> Deserialize<'de> for Signed<T>
where T: Encodable + Deserialize<'de>,

Source§

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

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

impl From<Signed<PaymentPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<PaymentPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenAuthorityPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenAuthorityPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenBlacklistPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenBlacklistPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenBurnPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenBurnPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenClawbackPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenClawbackPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenMetadataUpdatePayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenMetadataUpdatePayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenMintPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenMintPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenPausePayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenPausePayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl From<Signed<TokenWhitelistPayload>> for RawTransactionEnvelope

Source§

fn from(signed: Signed<TokenWhitelistPayload>) -> RawTransactionEnvelope

Converts to this type from the input type.
Source§

impl<T> Hash for Signed<T>
where T: Hash + Encodable + TxHashable,

Source§

fn hash<H>(&self, state: &mut H)
where H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T> PartialEq for Signed<T>
where T: PartialEq + Encodable,

Source§

fn eq(&self, other: &Signed<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Signed<T>
where T: Encodable + Serialize,

Source§

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

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

impl<T> SignerRecoverable for Signed<T>
where T: Signable + Encodable,

Source§

fn recover_signer(&self) -> Result<Address, SigError>

Recover the signer from the transaction payload and the signature.

For single-sig transactions: recovers the single signer. For multi-sig transactions: returns the multi-sig account address (not individual signers).

Source§

impl<T> Eq for Signed<T>
where T: Eq + Encodable,

Source§

impl<T> StructuralPartialEq for Signed<T>
where T: Encodable,

Auto Trait Implementations§

§

impl<T> !Freeze for Signed<T>

§

impl<T> RefUnwindSafe for Signed<T>
where T: RefUnwindSafe,

§

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

§

impl<T> Sync for Signed<T>
where T: Sync,

§

impl<T> Unpin for Signed<T>
where T: Unpin,

§

impl<T> UnwindSafe for Signed<T>
where T: UnwindSafe,

Blanket Implementations§

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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

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

Compare self to key and return true if they are equal.
Source§

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

Source§

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<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'de, T> BorrowedRpcObject<'de> for T
where T: RpcBorrow<'de> + RpcSend,

Source§

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

Source§

impl<'de, T> RpcBorrow<'de> for T
where T: Deserialize<'de> + Debug + Send + Sync + Unpin,

Source§

impl<T> RpcObject for T
where T: RpcSend + RpcRecv,

Source§

impl<T> RpcRecv for T
where T: DeserializeOwned + Debug + Send + Sync + Unpin + 'static,

Source§

impl<T> RpcSend for T
where T: Serialize + Clone + Debug + Send + Sync + Unpin,