Attribute Macro frame_support::pallet_macros::type_value
source · #[type_value]
Expand description
Allows defining a struct implementing the Get
trait to
ease the use of storage types.
This attribute is meant to be used alongside #[pallet::storage]
to
define a storage’s default value. This attribute can be used multiple times.
Item must be defined as:
#[frame_support::pallet]
mod pallet {
#[pallet::pallet]
pub struct Pallet<T>(_);
#[pallet::storage]
pub(super) type SomeStorage<T: Config> =
StorageValue<_, FixedU128, ValueQuery, DefaultForSomeValue>;
// Define default for ParachainId
#[pallet::type_value]
pub fn DefaultForSomeValue() -> FixedU128 {
FixedU128::from_u32(1)
}
}
§Macro expansion
The macro renames the function to some internal name, generates a struct with the
original name of the function and its generic, and implements Get<$ReturnType>
by
calling the user defined function.
Documentation for this macro can be found at frame_support::pallet_macros::type_value
.