Module polkadot_sdk_frame::traits
source · Expand description
All traits often used in FRAME pallets.
Note that types implementing these traits can also be found in this module.
Modules§
- Prelude module for all defensive traits to be imported at once.
- Types and traits for dynamic parameters.
- Traits and associated utilities for scheduling dispatchables in FRAME.
- Contains the
Task
trait, which defines a general-purpose way for defining and executing service work, and supporting types. - Traits for working with tokens and their associated datastructures.
Macros§
- Create new implementations of the
Get
trait.
Structs§
- A lookup implementation returning the
AccountId
from aMultiAddress
. - A non-const
Get
implementation parameterised by aCurrency
impl which provides the result ofactive_issuance
. - Input that adds infinite number of zero after wrapped input.
- Adapter struct for turning an
OrderedMembership
impl into aContains
impl. - Some amount of backing from a group. The precise definition of what it means to “back” something is left flexible.
- An error type that indicates that the origin is invalid.
- Blake2-256 Hash implementation.
- The function and pallet name of the Call.
- A
TryMorph
implementation to reduce a scalar by a particular amount, checking for underflow. - Guard type for clearing all pushed constraints from a
FilterStack
and reinstating them when dropped. - Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- Const getter for a basic type.
- A structure that performs standard conversion using the standard Rust conversion traits.
- The version of a crate.
- “OR gate” implementation of
EnsureOrigin
,Success
type for bothL
andR
must be equal. - “OR gate” implementation of
EnsureOrigin
allowing for differentSuccess
types forL
andR
, with them combined using anEither
type. - Adapter type to transform an
EnqueueMessage
with an origin into aHandleMessage
impl. EnsureOrigin
implementation that checks that an origin has equal or higher privilege compared to the expectedOrigin
.- Implementation of
PrivilegeCmp
that only checks for equal origins. - An implementation of
Contains
which contains only equal members toT
. - A
Contains
implementation that contains everything except the values inExclude
. - Guard type for pushing a constraint to a
FilterStack
and popping when dropped. - The resource footprint of a bunch of blobs. We assume only the number of blobs and their total size in bytes matter.
- A
ContainsPair
implementation that has aContains
implementation for each member of the pair. - Converter
struct
to use aContainsPair
implementation for aContains
bound. - Implement Get by returning Default for any type that implements Default.
- A structure that performs identity conversion.
- A lookup implementation returning the input value.
- Trivial utility for implementing
Contains
/OrderedMembership
with aVec
. - Keccak-256 Hash implementation.
- A storage price that increases linearly with the number of elements and their size.
- An error that indicates that a lookup failed.
- A derivative
EnsureOrigin
implementation. It mutates theSuccess
result of anOriginal
implementation with a givenMutator
. - Implementation of
Morph
which converts between types usingInto
. - A
TryMorph
implementation to enforce an upper limit for a result of the outer morphed type. EnsureOrigin
implementation that always fails.- Special marker struct used when
storage_version
is not defined for a pallet. - Services queues by doing nothing.
- Information regarding an instance of a pallet.
- Zero-sized type used to mark things that “act like” they own a
T
. - The resource footprint of a queue.
- Mutator which reduces a scalar by a particular amount.
- Morpher to disregard the source value and replace with another.
- Morpher to disregard the source value and replace with the default of
V
. - Information about a
SignedExtension
for the runtime metadata. - Metadata about storage from the runtime.
- A shim for placing around a storage item in order to use it as a
StoredValue
. Ideally this wouldn’t be needed asStorageValue
s should blanket implementStoredValue
s, however this would break the ability to have custom impls ofStoredValue
. The other workaround is to implement it directly in the macro. - The storage version of a pallet.
- Implementation of
Morph
to retrieve just the first element of a tuple. - A non-const
Get
implementation parameterised by aCurrency
impl which provides the result oftotal_issuance
. - Storage key with read/write tracking information.
- Input that adds infinite number of zero after wrapped input.
- Transform the origin of an
EnqueueMessage
viaC::convert
. - A structure that performs standard conversion using the standard Rust conversion traits.
- A value could not be decoded.
- A derivative
EnsureOrigin
implementation. It mutates theSuccess
result of anOriginal
implementation with a givenMutator
, allowing the possibility of an error to be returned from the mutator. - Implementation of
TryMorph
which attempts to convert between types usingTryInto
. - Adapter for
Get<u32>
to accessVARIANT_COUNT
fromtrait pub trait VariantCount {
. - Reasons for moving funds out of an account.
- A wrapper for any type
T
which implement encode/decode in a way compatible withVec<u8>
. - A wrapper for any type
T
which implement encode/decode in a way compatible withVec<u8>
.
Enums§
- Status of funds.
- A
Contains
implementation that contains every value. - Errors that can happen when attempting to execute an overweight message with
ServiceQueues::execute_overweight()
. - Simple boolean for whether an account needs to be kept in existence.
- A
Contains
implementation that contains no value. - Errors that can happen when attempting to process a message with
ProcessMessage::process_message()
. - The error type for
SafeMode
. - Return type used when we need to return one of two items, each of the opposite direction or sign, with one (
Same
) being of the same type as theself
or primary argument of the function that returned it. - Either a positive or a negative imbalance.
- The error type for
TransactionPause
. - Which state tests to execute.
- Select which checks should be run when trying a runtime upgrade upgrade.
Constants§
- The storage key postfix that is used to store the
StorageVersion
per pallet.
Traits§
- This type can be converted into and possibly from an AccountId (which itself is generic).
- Trait for touching/creating an asset account with a deposit taken from a designated depositor specified by the client.
- Means of signature verification of an application key.
- 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.
- A meta trait for arithmetic.
- A meta trait for arithmetic. Same as
AtLeast32Bit
, but also bounded to be unsigned. - Implemented by pallets, allows defining logic to run prior to any
OnRuntimeUpgrade
logic. - A “checkable” piece of information, used by the standard Substrate Executive in order to check the validity of a piece of extrinsic information, usually by verifying the signature. Implement for pieces of information that don’t require additional context in order to be checked.
- Something which fulfills the abstract idea of a Substrate block. It has types for
Extrinsic
pieces of information as well as aHeader
. - Something that can convert a
BlockId
to a number or a hash. - Super trait with all the attributes for a block number.
- Get current block number
- A trait to define the build function of a genesis config for both runtime and pallets.
- The trait implemented by the overarching enumeration of the different pallets’ origins. Unlike
OriginTrait
impls, this does not include any kind of dispatch/call filter. Also, this trait is more flexible in terms of how it can be used: it is aParameter
andMember
, so it can be used as dispatchable parameters as well as in storage items. - Trait for type that can handle incremental changes to a set of account IDs.
- Something that can be checked for equality and printed out to a debug channel if bad.
- Extract the digest type for a block. A “checkable” piece of information, used by the standard Substrate Executive in order to check the validity of a piece of extrinsic information, usually by verifying the signature. Implement for pieces of information that require some additional context
Context
in order to be checked. - Performs addition that returns
None
instead of wrapping around on overflow. - Convenience type to work around the highly unergonomic syntax needed to invoke the functions of overloaded generic traits, in this case
TryFrom
andTryInto
. - Performs division that returns
None
instead of panicking on division by zero and instead of wrapping around on underflow and overflow. - Performs multiplication that returns
None
instead of wrapping around on underflow or overflow. - Performs a left shift that returns
None
on shifts larger than or equal to the type width. - Performs a right shift that returns
None
on shifts larger than or equal to the type width. - Performs subtraction that returns
None
instead of wrapping around on underflow. - Trait for things that can be clear (have no bits set). For numeric types, essentially the same as
Zero
. - Some sort of cost taken from account temporarily in order to offset the cost to the chain of holding some data
Footprint
in state. - A trait for querying whether a type can be said to “contain” a value.
- A trait for querying bound for the length of an implementation of
Contains
- A trait for querying whether a type can be said to “contain” a pair-value.
- Infallible conversion trait. Generic over both source and destination types.
- Reversing infallible conversion trait. Generic over both source and destination types.
- Abstraction over a fungible assets system.
- A trait to handle errors and options when you are really sure that a condition must hold, but not brave enough to
expect
on it, or a default fallback value makes more sense. - Defensively calculates the maximum of two values.
- Defensively calculates the minimum of two values.
- Subset of methods similar to
Defensive
that can only work for aOption
. - Subset of methods similar to
Defensive
that can only work for aResult
. - A variant of
Defensive
with the same rationale, for the arithmetic operations where in case an infallible operation fails, it saturates. - Construct an object by defensively truncating an input if the
TryFrom
conversion fails. - Trait used to check whether a given validator is currently disabled and should not be participating in consensus (e.g. because they equivocated).
- A lazy call (module function and argument values) that can be executed via its
dispatch
method. - Can enqueue messages for multiple origins.
- Performs addition that returns
ArithmeticError
instead of wrapping around on overflow. - Performs self addition that returns
ArithmeticError
instead of wrapping around on overflow. - Performs division that returns
ArithmeticError
instead of wrapping around on overflow. - Performs self division that returns
ArithmeticError
instead of wrapping around on overflow. - Extends
FixedPointNumber
with the Ensure family functions. - Similar to
TryFrom
but returning anArithmeticError
error. - A trait to ensure the inherent are before non-inherent in a block.
- Similar to
TryInto
but returning anArithmeticError
error. - Performs multiplication that returns
ArithmeticError
instead of wrapping around on overflow. - Performs self multiplication that returns
ArithmeticError
instead of wrapping around on overflow. - Meta trait that supports all immutable arithmetic
Ensure*
operations - Meta trait that supports all assigned arithmetic
Ensure*
operations - Some sort of check on the origin is performed by this object.
- Some sort of check on the origin is performed by this object.
- Performs subtraction that returns
ArithmeticError
instead of wrapping around on underflow. - Performs self subtraction that returns
ArithmeticError
instead of wrapping around on underflow. - Something that can estimate the fee of a (frame-based) call.
- Something that can estimate at which block scheduling of the next session will happen (i.e when we will try to fetch new validators).
- Something that can estimate at which block the next session rotation will happen (i.e. a new session starts).
- Something that can execute a given block.
- Something that acts like an
Extrinsic
. - An extrinsic on which we can get access to call.
- Implementor is an
Extrinsic
and provides metadata about this extrinsic. - FilterDeprecated
- Trait to add a constraint onto the filter.
- A trait for finding the author of a block header based on the
PreRuntime
digests contained within it. - GenesisBuildDeprecatedA trait to define the build function of a genesis config, T and I are placeholder for pallet trait and pallet instance.
- A trait for querying a single value from a type.
- Retrieve the backing from an object’s ref.
- Gets the function index of the Call.
- Gets the metadata for the Call - function name and pallet name.
- Gets the function name of the Call.
- A marker trait for something that knows the type of the node block.
- A marker trait for something that knows the type of the runtime block.
- Provides information about a pallet’s storage versions.
- A simple, generic one-parameter event notifier/handler.
- Handles incoming messages for a single origin.
- Abstraction around hashing
- Super trait with all the attributes for a hashing output.
- Something which fulfills the abstract idea of a Substrate header. It has types for a
Number
, aHash
and aHashing
. It provides access to anextrinsics_root
,state_root
andparent_hash
, as well as adigest
and a blocknumber
. - The pallet hooks trait. This is merely an umbrella trait for:
- Some type that is able to be collapsed into an account ID. It is not possible to recreate the original value from the account ID.
- A trait for a not-quite Linear Type that tracks an imbalance.
- A trait representing an incrementable type.
- Trait for type that can handle the initialization of account IDs at genesis.
- A inspect interface for a currency whose accounts can have liquidity restrictions.
- An instance of a pallet in the storage.
- Simple trait for providing a filter over a reference to some type, given an instance of itself.
- A trait implementing integer square root.
- A trait to check if an extrinsic is an inherent.
- Determine if a
MemberId
is a valid member. - Something that can be checked to be a of sub type
T
. - Trait to be used when types are exactly same.
- Something which can compute and check proofs of a historical key owner and return full identification data of that key owner.
- Trait to be used by block producing consensus engine modules to determine how late the current block is (e.g. in a slot-based proposal mechanism how many slots were skipped since the previous block).
- A lazy value.
- Anything that can have a
::len()
method. - A currency whose accounts can have liquidity restrictions.
- Trait to handle NFT locking mechanism to ensure interactions with the asset can be implemented downstream to extend logic of Uniques/Nfts current functionality.
- Means of changing one type into another in a manner dependent on the source type.
- Fallible conversion trait returning an Option. Generic over both source and destination types.
- Reversing fallible conversion trait returning an Option. Generic over both source and destination types.
- A type that implements Display when in std environment.
- Definition for a bi-directional, fallible conversion between two types.
- A type that implements FromStr when in std environment.
- A type that implements Hash when in std environment.
- A type that implements Serialize when in std environment or serde feature is activated.
- A type that implements Serialize, DeserializeOwned and Debug when in std environment or serde feature is activated.
- A type that can be used in runtime structures.
- Extensible conversion trait. Generic over only source type, with destination type being associated.
- Off-chain computation trait.
- See
Hooks::on_finalize
. - A trait that will be called at genesis.
- See
Hooks::on_idle
. - See
Hooks::on_initialize
. - The account with the given id was reaped.
- Handler for when a new account has been created.
- Periodically executes logic. Is not guaranteed to run within a specific timeframe and should only be used on logic that has no deadline.
- A trait which is called when the timestamp is set in the runtime.
- Handler for when some currency “account” decreased in balance for some reason.
- Defines a multiplicative identity element for
Self
. - A session handler for specific key type.
- Opaque data type that may be destructured into a series of raw byte slices (which represent individual keys).
- Methods available on
frame_system::Config::RuntimeOrigin
. - Trait indicating that the implementing type is going to be included as a field in a variant of the
#[pallet::error]
enum type. - Provides information about the pallet itself and its setup in the runtime.
- Provides information about the pallet itself and its setup in the runtime.
- Provide information about a bunch of pallets.
- Similar to
StorageInfoTrait
, a trait to give partial information about storage. - Provides a callback to execute logic after the all inherents.
- Provides a callback to execute logic before the all transactions.
- Provides a callback to execute logic before the all inherents.
- A interface for looking up preimages from their hash on chain.
- A interface for managing preimages to hashes on chain.
- Trait for things which can be printed from the runtime.
- Something that can compare privileges of two origins.
- Can process messages from a specific origin.
- A interface for looking up preimages from their hash on chain.
- Provides information on paused queues.
- A trait that is able to provide randomness.
- Ranked membership data structure.
- Handler that can deal with the swap of two members.
- A currency where funds can be reserved from the user.
- Can put the runtime into a safe mode.
- A trait to notify when the runtime enters or exits safe mode.
- Convenience type to work around the highly unergonomic syntax needed to invoke the functions of overloaded generic traits, in this case
SaturatedFrom
andSaturatedInto
. - Saturating arithmetic operations, returning maximum or minimum values instead of overflowing.
- Multiply and divide by a number that isn’t necessarily the same type. Basically just the same as
Mul
andDiv
except it can be used for all basic numeric types. - Can service queues and execute overweight messages.
- Something that acts like a
SignaturePayload
of anExtrinsic
. - 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.
- A meta trait for all bit ops.
- A trait for a set which can enumerate its members in order.
- Means of changing one type into another in a manner dependent on the source type. This variant is different to
Lookup
in that it doesn’t (can cannot) require any context. - A trait to give information about storage.
- An instance of a storage in a pallet.
- A interface for managing preimages to hashes on chain.
- An abstraction of a value stored within storage, but possibly as part of a larger composite item.
- A general-purpose trait which defines a type of service work (i.e., work to performed by an off-chain worker) including methods for enumerating, validating, indexing, and running tasks of this type.
- Can pause specific transactions from being processed.
- Try and collect into a collection
C
. - Fallible conversion trait which returns the argument in the case of being unable to convert. Generic over both source and destination types.
- Reversing fallible conversion trait which returns the argument in the case of being unable to convert back. Generic over both source and destination types.
- Decode the entire data under the given storage type.
- A type for which some values make sense to be able to drop without further consideration.
- Extensible conversion trait. Generic over only source type, with destination type being associated.
- Execute some checks to ensure the internal state of a pallet is consistent.
- A trait for querying a single value from a type defined in the trait.
- This trait is intended for use within
VersionedMigration
to execute storage migrations without automatic version checks. Implementations should ensure migration logic is safe and idempotent. - Type that can be dispatched with an origin but without checking the origin filter.
- Just like
From
except that if the source value is too big to fit into the destination type then it’ll saturate the destination. - Just like
Into
except that if the source value is too big to fit into the destination type then it’ll saturate the destination. - Trait to deal with unix time.
- Provide validation for unsigned extrinsics.
- Implementors of this trait provide information about whether or not some validator has been registered with them. The Session module is an implementor.
- A trait for online node inspection in a session.
ValidatorSet
combined with an identification.- Trait to get the number of variants in any enum.
- Means of signature verification.
- A trait for verifying the seal of a header and returning the author.
- A vesting schedule over a currency. This allows a particular currency to have vesting limits applied to it.
- Allows a pallet to specify storage keys to whitelist during benchmarking. This means those keys will be excluded from the benchmarking performance calculation.
- Defines an additive identity element for
Self
.
Functions§
- Raises a value to the power of exp, returning
None
if an overflow occurred. - Raises a value to the power of exp, returning
ArithmeticError
if an overflow occurred.
Type Aliases§
- AllowAllDeprecated
- DenyAllDeprecated
- Shortcut to reference the
Info
type of aDispatchable
. - EnsureOneOfDeprecated“OR gate” implementation of
EnsureOrigin
allowing for differentSuccess
types forL
andR
, with them combined using anEither
type. - Extract the hashing type for a block.
- An identifier for a lock. Used for disambiguating different locks so that they can be individually replaced or removed.
- Extract the number type for a block.
- Shortcut to reference the
PostInfo
type of aDispatchable
.