Trait polkadot_sdk_frame::traits::SignedExtension
pub trait SignedExtension: Codec + Debug + Sync + Send + Clone + Eq + PartialEq + StaticTypeInfo {
type AccountId;
type Call: Dispatchable;
type AdditionalSigned: Codec + TypeInfo;
type Pre;
const IDENTIFIER: &'static str;
// Required methods
fn additional_signed(
&self,
) -> Result<Self::AdditionalSigned, TransactionValidityError>;
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<Self::Pre, TransactionValidityError>;
// Provided methods
fn validate(
&self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &<Self::Call as Dispatchable>::Info,
_len: usize,
) -> Result<ValidTransaction, TransactionValidityError> { ... }
fn post_dispatch(
_pre: Option<Self::Pre>,
_info: &<Self::Call as Dispatchable>::Info,
_post_info: &<Self::Call as Dispatchable>::PostInfo,
_len: usize,
_result: &Result<(), DispatchError>,
) -> Result<(), TransactionValidityError> { ... }
fn metadata() -> Vec<TransactionExtensionMetadata> { ... }
fn validate_unsigned(
_call: &Self::Call,
_info: &<Self::Call as Dispatchable>::Info,
_len: usize,
) -> Result<ValidTransaction, TransactionValidityError> { ... }
fn pre_dispatch_unsigned(
call: &Self::Call,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<(), TransactionValidityError> { ... }
}
TransactionExtension
instead.Expand description
Means by which a transaction may be extended. This type embodies both the data and the logic that should be additionally associated with the transaction. It should be plain old data.
Required Associated Typesยง
type AccountId
๐Deprecated: Use TransactionExtension
instead.
type AccountId
TransactionExtension
instead.The type which encodes the sender identity.
type Call: Dispatchable
๐Deprecated: Use TransactionExtension
instead.
type Call: Dispatchable
TransactionExtension
instead.The type which encodes the call to be dispatched.
type AdditionalSigned: Codec + TypeInfo
๐Deprecated: Use TransactionExtension
instead.
type AdditionalSigned: Codec + TypeInfo
TransactionExtension
instead.Any additional data that will go into the signed payload. This may be created dynamically
from the transaction using the additional_signed
function.
type Pre
๐Deprecated: Use TransactionExtension
instead.
type Pre
TransactionExtension
instead.The type that encodes information that can be passed from pre_dispatch to post-dispatch.
Required Associated Constantsยง
const IDENTIFIER: &'static str
๐Deprecated: Use TransactionExtension
instead.
const IDENTIFIER: &'static str
TransactionExtension
instead.Unique identifier of this signed extension.
This will be exposed in the metadata to identify the signed extension used in an extrinsic.
Required Methodsยง
fn additional_signed(
&self,
) -> Result<Self::AdditionalSigned, TransactionValidityError>
๐Deprecated: Use TransactionExtension
instead.
fn additional_signed( &self, ) -> Result<Self::AdditionalSigned, TransactionValidityError>
TransactionExtension
instead.Construct any additional data that should be in the signed payload of the transaction. Can also perform any pre-signature-verification checks and return an error if needed.
fn pre_dispatch(
self,
who: &Self::AccountId,
call: &Self::Call,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<Self::Pre, TransactionValidityError>
๐Deprecated: Use TransactionExtension
instead.
fn pre_dispatch( self, who: &Self::AccountId, call: &Self::Call, info: &<Self::Call as Dispatchable>::Info, len: usize, ) -> Result<Self::Pre, TransactionValidityError>
TransactionExtension
instead.Do any pre-flight stuff for a signed transaction.
Make sure to perform the same checks as in Self::validate
.
Provided Methodsยง
fn validate(
&self,
_who: &Self::AccountId,
_call: &Self::Call,
_info: &<Self::Call as Dispatchable>::Info,
_len: usize,
) -> Result<ValidTransaction, TransactionValidityError>
๐Deprecated: Use TransactionExtension
instead.
fn validate( &self, _who: &Self::AccountId, _call: &Self::Call, _info: &<Self::Call as Dispatchable>::Info, _len: usize, ) -> Result<ValidTransaction, TransactionValidityError>
TransactionExtension
instead.Validate a signed transaction for the transaction queue.
This function can be called frequently by the transaction queue, to obtain transaction validity against current state. It should perform all checks that determine a valid transaction, that can pay for its execution and quickly eliminate ones that are stale or incorrect.
Make sure to perform the same checks in pre_dispatch
function.
fn post_dispatch(
_pre: Option<Self::Pre>,
_info: &<Self::Call as Dispatchable>::Info,
_post_info: &<Self::Call as Dispatchable>::PostInfo,
_len: usize,
_result: &Result<(), DispatchError>,
) -> Result<(), TransactionValidityError>
๐Deprecated: Use TransactionExtension
instead.
fn post_dispatch( _pre: Option<Self::Pre>, _info: &<Self::Call as Dispatchable>::Info, _post_info: &<Self::Call as Dispatchable>::PostInfo, _len: usize, _result: &Result<(), DispatchError>, ) -> Result<(), TransactionValidityError>
TransactionExtension
instead.Do any post-flight stuff for an extrinsic.
If the transaction is signed, then _pre
will contain the output of pre_dispatch
,
and None
otherwise.
This gets given the DispatchResult
_result
from the extrinsic and can, if desired,
introduce a TransactionValidityError
, causing the block to become invalid for including
it.
WARNING: It is dangerous to return an error here. To do so will fundamentally invalidate the transaction and any block that it is included in, causing the block author to not be compensated for their work in validating the transaction or producing the block so far.
It can only be used safely when you know that the extrinsic is one that can only be
introduced by the current block author; generally this implies that it is an inherent and
will come from either an offchain-worker or via InherentData
.
fn metadata() -> Vec<TransactionExtensionMetadata>
๐Deprecated: Use TransactionExtension
instead.
fn metadata() -> Vec<TransactionExtensionMetadata>
TransactionExtension
instead.Returns the metadata for this signed extension.
As a SignedExtension
can be a tuple of SignedExtension
s we need to return a Vec
that holds the metadata of each one. Each individual SignedExtension
must return
exactly one TransactionExtensionMetadata
.
This method provides a default implementation that returns a vec containing a single
TransactionExtensionMetadata
.
fn validate_unsigned(
_call: &Self::Call,
_info: &<Self::Call as Dispatchable>::Info,
_len: usize,
) -> Result<ValidTransaction, TransactionValidityError>
๐Deprecated: Use TransactionExtension
instead.
fn validate_unsigned( _call: &Self::Call, _info: &<Self::Call as Dispatchable>::Info, _len: usize, ) -> Result<ValidTransaction, TransactionValidityError>
TransactionExtension
instead.Validate an unsigned transaction for the transaction queue.
This function can be called frequently by the transaction queue to obtain transaction validity against current state. It should perform all checks that determine a valid unsigned transaction, and quickly eliminate ones that are stale or incorrect.
fn pre_dispatch_unsigned(
call: &Self::Call,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<(), TransactionValidityError>
๐Deprecated: Use TransactionExtension
instead.
fn pre_dispatch_unsigned( call: &Self::Call, info: &<Self::Call as Dispatchable>::Info, len: usize, ) -> Result<(), TransactionValidityError>
TransactionExtension
instead.Do any pre-flight stuff for an unsigned transaction.
Note this function by default delegates to validate_unsigned
, so that
all checks performed for the transaction queue are also performed during
the dispatch phase (applying the extrinsic).
If you ever override this function, you need not perform the same validation as in
validate_unsigned
.