Attribute Macro frame_support::pallet_macros::type_value

source ·
Expand description

The #[pallet::type_value] attribute lets you define 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:

fn $MyDefaultName<$some_generic>() -> $default_type $optional_where_clause { $expr }

I.e.: a function definition with generics none or T: Config and a returned type.


fn MyDefault<T: Config>() -> T::Balance { 3.into() }

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.