Trait polkadot_service::runtime_traits::Applyable
source · pub trait Applyable: Sized + Send + Sync {
type Call: Dispatchable;
// Required methods
fn validate<V>(
&self,
source: TransactionSource,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<ValidTransaction, TransactionValidityError>
where V: ValidateUnsigned<Call = Self::Call>;
fn apply<V>(
self,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<Result<<Self::Call as Dispatchable>::PostInfo, DispatchErrorWithPostInfo<<Self::Call as Dispatchable>::PostInfo>>, TransactionValidityError>
where V: ValidateUnsigned<Call = Self::Call>;
}
Expand description
An “executable” piece of information, used by the standard Substrate Executive in order to enact a piece of extrinsic information by marshalling and dispatching to a named function call.
Also provides information on to whom this information is attributable and an index that allows each piece of attributable information to be disambiguated.
IMPORTANT: After validation, in both validate and
apply, all transactions should have some authorized origin, except for
inherents. This is necessary in order to protect the chain against spam. If no extension in the
transaction extension pipeline authorized the transaction with an origin, either a system signed
origin or a custom origin, then the transaction must be rejected, as the extensions provided in
substrate which protect the chain, such as CheckNonce
, ChargeTransactionPayment
etc., rely
on the assumption that the system handles system signed transactions, and the pallets handle the
custom origin that they authorized.
Required Associated Types§
sourcetype Call: Dispatchable
type Call: Dispatchable
Type by which we can dispatch. Restricts the UnsignedValidator
type.
Required Methods§
sourcefn validate<V>(
&self,
source: TransactionSource,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<ValidTransaction, TransactionValidityError>where
V: ValidateUnsigned<Call = Self::Call>,
fn validate<V>(
&self,
source: TransactionSource,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<ValidTransaction, TransactionValidityError>where
V: ValidateUnsigned<Call = Self::Call>,
Checks to see if this is a valid transaction. It returns information on it if so.
IMPORTANT: Ensure that some origin has been authorized after validating the transaction. If no origin was authorized, the transaction must be rejected.
sourcefn apply<V>(
self,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<Result<<Self::Call as Dispatchable>::PostInfo, DispatchErrorWithPostInfo<<Self::Call as Dispatchable>::PostInfo>>, TransactionValidityError>where
V: ValidateUnsigned<Call = Self::Call>,
fn apply<V>(
self,
info: &<Self::Call as Dispatchable>::Info,
len: usize,
) -> Result<Result<<Self::Call as Dispatchable>::PostInfo, DispatchErrorWithPostInfo<<Self::Call as Dispatchable>::PostInfo>>, TransactionValidityError>where
V: ValidateUnsigned<Call = Self::Call>,
Executes all necessary logic needed prior to dispatch and deconstructs into function call, index and sender.
IMPORTANT: Ensure that some origin has been authorized after validating the transaction. If no origin was authorized, the transaction must be rejected.