lib.rs 92.6 KiB
Newer Older
/// `#[frame_support::pallet]` attribute macro that encloses your pallet module. This
/// argument cannot be specified anywhere else, including but not limited to the
/// `#[pallet::pallet]` attribute macro.
///
/// <div class="example-wrap" style="display:inline-block"><pre class="compile_fail"
/// style="white-space:normal;font:inherit;">
/// <strong>WARNING</strong>:
/// You should never deploy or use dev mode pallets in production. Doing so can break your
/// chain. Once you are done tinkering, you should
/// remove the 'dev_mode' argument from your #[pallet] declaration and fix any compile
/// errors before attempting to use your pallet in a production scenario.
/// </pre></div>
///
/// # 2 - Pallet struct placeholder declaration
///
/// The pallet struct placeholder `#[pallet::pallet]` is mandatory and allows you to
/// specify pallet information.
/// The struct must be defined as follows:
/// #[frame_support::pallet]
/// mod pallet {
/// 	#[pallet::pallet]         // <- the macro
/// 	pub struct Pallet<T>(_);  // <- the struct definition
/// 	#[pallet::config]
/// 	pub trait Config: frame_system::Config {}
/// I.e. a regular struct definition named `Pallet`, with generic T and no where clause.
/// The macro adds this attribute to the Pallet struct definition:
/// ```ignore
/// #[derive(
/// 	frame_support::CloneNoBound,
/// 	frame_support::EqNoBound,
/// 	frame_support::PartialEqNoBound,
/// 	frame_support::RuntimeDebugNoBound,
/// )]
/// ```
/// and replaces the type `_` with `PhantomData<T>`.
/// It also implements on the pallet:
/// * [`GetStorageVersion`](frame_support::traits::GetStorageVersion)
/// * [`OnGenesis`](frame_support::traits::OnGenesis): contains some logic to write the pallet
///   version into storage.
/// * [`PalletInfoAccess`](frame_support::traits::PalletInfoAccess) to ease access to pallet
///   information given by [`frame_support::traits::PalletInfo`]. (The implementation uses the
///   associated type [`frame_support::traits::PalletInfo`]).
/// * [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) to give information about
///   storages.
///
/// If the attribute `set_storage_max_encoded_len` is set then the macro calls
/// [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) for each storage in the
/// implementation of [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) for the
/// pallet. Otherwise it implements
/// [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) for the pallet using the
/// [`PartialStorageInfoTrait`](frame_support::traits::PartialStorageInfoTrait)
/// implementation of storages.
pub use frame_support_procedural::pallet;
/// Contains macro stubs for all of the `pallet::` macros
pub mod pallet_macros {
	/// Declare the storage as whitelisted from benchmarking.
	///
	/// Doing so will exclude reads of that value's storage key from counting towards weight
	/// calculations during benchmarking.
	///
	/// This attribute should only be attached to storages that are known to be
	/// read/used in every block. This will result in a more accurate benchmarking weight.
	///
	/// ### Example
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::storage]
	/// 	#[pallet::whitelist_storage]
	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	pub use frame_support_procedural::whitelist_storage;

	/// Allows specifying the weight of a call.
	///
	/// Each dispatchable needs to define a weight with the `#[pallet::weight($expr)]`
	/// attribute. The first argument must be `origin: OriginFor<T>`.
	///
	/// ## Example
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// # 	use frame_system::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::call]
	/// 	impl<T: Config> Pallet<T> {
	/// 		#[pallet::weight({0})] // <- set actual weight here
	/// 		#[pallet::call_index(0)]
	/// 		pub fn something(
	/// 			_: OriginFor<T>,
	/// 			foo: u32,
	/// 		) -> DispatchResult {
	/// 			unimplemented!()
	/// 		}
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	pub use frame_support_procedural::weight;

	/// Allows whitelisting a storage item from decoding during try-runtime checks.
	///
	/// The optional attribute `#[pallet::disable_try_decode_storage]` will declare the
	/// storage as whitelisted from decoding during try-runtime checks. This should only be
	/// attached to transient storage which cannot be migrated during runtime upgrades.
	///
	/// ### Example
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::storage]
	/// 	#[pallet::disable_try_decode_storage]
	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	pub use frame_support_procedural::disable_try_decode_storage;

	/// Declares a storage as unbounded in potential size.
	///
	/// When implementing the storage info (when `#[pallet::generate_storage_info]` is
1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501
	/// specified on the pallet struct placeholder), the size of the storage will be declared
	/// as unbounded. This can be useful for storage which can never go into PoV (Proof of
	/// Validity).
	///
	/// ## Example
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::storage]
	/// 	#[pallet::unbounded]
	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	pub use frame_support_procedural::unbounded;

	/// Defines what storage prefix to use for a storage item when building the trie.
	///
	/// This is helpful if you wish to rename the storage field but don't want to perform a
	/// migration.
	///
	/// ## Example
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::storage]
	/// 	#[pallet::storage_prefix = "foo"]
	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	pub use frame_support_procedural::storage_prefix;

	/// Ensures the generated `DefaultConfig` will not have any bounds for
	/// that trait item.
	///
	/// Attaching this attribute to a trait item ensures that the generated trait
	/// `DefaultConfig` will not have any bounds for this trait item.
	///
	/// As an example, if you have a trait item `type AccountId: SomeTrait;` in your `Config`
	/// trait, the generated `DefaultConfig` will only have `type AccountId;` with no trait
	/// bound.
	pub use frame_support_procedural::no_default_bounds;

	/// Ensures the trait item will not be used as a default with the
	/// `#[derive_impl(..)]` attribute macro.
	///
	/// The optional attribute `#[pallet::no_default]` can be attached to trait items within a
	/// `Config` trait impl that has [`#[pallet::config(with_default)]`](`config`)
	/// attached.
	pub use frame_support_procedural::no_default;

	/// Declares a module as importable into a pallet via
	/// [`#[import_section]`](`import_section`).
	///
	/// Note that sections are imported by their module name/ident, and should be referred to
	/// by their _full path_ from the perspective of the target pallet. Do not attempt to make
	/// use of `use` statements to bring pallet sections into scope, as this will not work
	/// (unless you do so as part of a wildcard import, in which case it will work).
	///
	/// ## Naming Logistics
	///
	/// Also note that because of how `#[pallet_section]` works, pallet section names must be
	/// globally unique _within the crate in which they are defined_. For more information on
	/// why this must be the case, see macro_magic's
	/// [`#[export_tokens]`](https://docs.rs/macro_magic/latest/macro_magic/attr.export_tokens.html) macro.
	///
	/// Optionally, you may provide an argument to `#[pallet_section]` such as
	/// `#[pallet_section(some_ident)]`, in the event that there is another pallet section in
	/// same crate with the same ident/name. The ident you specify can then be used instead of
	/// the module's ident name when you go to import it via
	/// [`#[import_section]`](`import_section`).
	pub use frame_support_procedural::pallet_section;

	/// The `#[pallet::inherent]` attribute allows the pallet to provide
	/// [inherents](https://docs.substrate.io/fundamentals/transaction-types/#inherent-transactions).
	///
	/// An inherent is some piece of data that is inserted by a block authoring node at block
	/// creation time and can either be accepted or rejected by validators based on whether the
	/// data falls within an acceptable range.
	///
	/// The most common inherent is the `timestamp` that is inserted into every block. Since
	/// there is no way to validate timestamps, validators simply check that the timestamp
	/// reported by the block authoring node falls within an acceptable range.
	///
	/// Example usage:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// # 	use frame_support::inherent::IsFatalError;
	/// # 	use sp_timestamp::InherentError;
	/// # 	use sp_std::result;
	/// #
	/// 	// Example inherent identifier
	/// 	pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0";
	///
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::inherent]
	/// 	impl<T: Config> ProvideInherent for Pallet<T> {
	/// 		type Call = Call<T>;
	/// 		type Error = InherentError;
	/// 		const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
	///
	/// 		fn create_inherent(data: &InherentData) -> Option<Self::Call> {
	/// 			unimplemented!()
	/// 		}
	///
	/// 		fn check_inherent(
	/// 			call: &Self::Call,
	/// 			data: &InherentData,
	/// 		) -> result::Result<(), Self::Error> {
	/// 			unimplemented!()
	/// 		}
	///
	/// 		fn is_inherent(call: &Self::Call) -> bool {
	/// 			unimplemented!()
	/// 		}
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	///
	/// I.e. a trait implementation with bound `T: Config`, of trait `ProvideInherent` for type
	/// `Pallet<T>`, and some optional where clause.
	///
	/// ## Macro expansion
	///
	/// The macro currently makes no use of this information, but it might use this information
	/// in the future to give information directly to `construct_runtime`.
	pub use frame_support_procedural::inherent;

	/// Splits a pallet declaration into multiple parts.
	///
	/// An attribute macro that can be attached to a module declaration. Doing so will
	/// import the contents of the specified external pallet section that is defined
	/// elsewhere using [`#[pallet_section]`](`pallet_section`).
	///
	/// ## Example
	/// ```
	/// # use frame_support::pallet_macros::pallet_section;
	/// # use frame_support::pallet_macros::import_section;
	/// #
	/// /// A [`pallet_section`] that defines the events for a pallet.
	/// /// This can later be imported into the pallet using [`import_section`].
	/// #[pallet_section]
	/// mod events {
	/// 	#[pallet::event]
	/// 	#[pallet::generate_deposit(pub(super) fn deposit_event)]
	/// 	pub enum Event<T: Config> {
	/// 		/// Event documentation should end with an array that provides descriptive names for event
	/// 		/// parameters. [something, who]
	/// 		SomethingStored { something: u32, who: T::AccountId },
	/// 	}
	/// }
	///
	/// #[import_section(events)]
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {
	/// # 		type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
	/// # 	}
	/// }
	/// ```
	///
	/// This will result in the contents of `some_section` being _verbatim_ imported into
	/// the pallet above. Note that since the tokens for `some_section` are essentially
	/// copy-pasted into the target pallet, you cannot refer to imports that don't also
	/// exist in the target pallet, but this is easily resolved by including all relevant
	/// `use` statements within your pallet section, so they are imported as well, or by
	/// otherwise ensuring that you have the same imports on the target pallet.
	///
	/// It is perfectly permissible to import multiple pallet sections into the same pallet,
	/// which can be done by having multiple `#[import_section(something)]` attributes
	/// attached to the pallet.
	///
	/// Note that sections are imported by their module name/ident, and should be referred to
	/// by their _full path_ from the perspective of the target pallet.
	pub use frame_support_procedural::import_section;

	/// Allows defining getter functions on `Pallet` storage.
	///
	/// ## Example
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::storage]
	/// 	#[pallet::getter(fn my_getter_fn_name)]
	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	///
	/// See [`pallet::storage`](`frame_support::pallet_macros::storage`) for more info.
	pub use frame_support_procedural::getter;

	/// Defines constants that are added to the constant field of
	/// [`PalletMetadata`](frame_metadata::v15::PalletMetadata) struct for this pallet.
	///
	/// Must be defined like:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// #
	/// 	#[pallet::extra_constants]
	/// 	impl<T: Config> Pallet<T> // $optional_where_clause
	/// 	{
	/// 	#[pallet::constant_name(SomeU32ConstantName)]
	/// 		/// Some doc
	/// 		fn some_u32_constant() -> u32 {
	/// 			100u32
	/// 		}
	/// 	}
	/// }
	/// ```
	///
	/// I.e. a regular rust `impl` block with some optional where clause and functions with 0
	/// args, 0 generics, and some return type.
	pub use frame_support_procedural::extra_constants;

	#[rustfmt::skip]
	/// Allows bypassing the `frame_system::Config` supertrait check.
	///
	/// To bypass the syntactic `frame_system::Config` supertrait check, use the attribute
	/// `pallet::disable_frame_system_supertrait_check`.
	///
	/// Note this bypass is purely syntactic, and does not actually remove the requirement that your
	/// pallet implements `frame_system::Config`. When using this check, your config is still required to implement
	/// `frame_system::Config` either via
	/// - Implementing a trait that itself implements `frame_system::Config`
	/// - Tightly coupling it with another pallet which itself implements `frame_system::Config`
	///
	/// e.g.
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// # 	use frame_system::pallet_prelude::*;
	/// 	trait OtherTrait: frame_system::Config {}
	///
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::config]
	/// 	#[pallet::disable_frame_system_supertrait_check]
	/// 	pub trait Config: OtherTrait {}
	/// }
	/// ```
	///
	/// To learn more about supertraits, see the
	/// [trait_based_programming](../../polkadot_sdk_docs/reference_docs/trait_based_programming/index.html)
	/// reference doc.
	pub use frame_support_procedural::disable_frame_system_supertrait_check;

	/// The mandatory attribute allowing definition of configurable types for the pallet.
	///
	/// Item must be defined as:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::config]
	/// 	pub trait Config: frame_system::Config // + $optionally_some_other_supertraits
	/// 	// $optional_where_clause
	/// 	{
	/// 		// config items here
	/// 	}
	/// }
	/// ```
	///
	/// I.e. a regular trait definition named `Config`, with the supertrait
	/// [`frame_system::pallet::Config`](../../frame_system/pallet/trait.Config.html), and
	/// optionally other supertraits and a where clause. (Specifying other supertraits here is
	/// known as [tight coupling](https://docs.substrate.io/reference/how-to-guides/pallet-design/use-tight-coupling/))
	///
	/// The associated type `RuntimeEvent` is reserved. If defined, it must have the bounds
	/// `From<Event>` and `IsType<<Self as frame_system::Config>::RuntimeEvent>`.
	///
	/// [`#[pallet::event]`](`event`) must be present if `RuntimeEvent`
	/// exists as a config item in your `#[pallet::config]`.
	///
	/// ## Optional: `with_default`
	///
	/// An optional `with_default` argument may also be specified. Doing so will automatically
	/// generate a `DefaultConfig` trait inside your pallet which is suitable for use with
	/// [`#[derive_impl(..)`](`frame_support::derive_impl`) to derive a default testing
	/// config:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// # 	use frame_system::pallet_prelude::*;
	/// # 	use core::fmt::Debug;
	/// # 	use frame_support::traits::Contains;
	/// #
	/// # 	pub trait SomeMoreComplexBound {}
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::config(with_default)] // <- with_default is optional
	/// 	pub trait Config: frame_system::Config {
	/// 		/// The overarching event type.
	/// 		#[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeEvent
	/// 		type RuntimeEvent: From<Event<Self>> + IsType<<Self as frame_system::Config>::RuntimeEvent>;
	///
	/// 		/// A more complex type.
	/// 		#[pallet::no_default] // Example of type where no default should be provided
	/// 		type MoreComplexType: SomeMoreComplexBound;
	///
	/// 		/// A simple type.
	/// 		// Default with bounds is supported for simple types
	/// 		type SimpleType: From<u32>;
	/// 	}
	///
	/// 	#[pallet::event]
	/// 	pub enum Event<T: Config> {
	/// 		SomeEvent(u16, u32),
	/// 	}
	/// }
	/// ```
	///
	/// As shown above:
	/// * you may attach the [`#[pallet::no_default]`](`no_default`)
	/// attribute to specify that a particular trait item _cannot_ be used as a default when a
	/// test `Config` is derived using the [`#[derive_impl(..)]`](`frame_support::derive_impl`)
	/// attribute macro. This will cause that particular trait item to simply not appear in
	/// default testing configs based on this config (the trait item will not be included in
	/// `DefaultConfig`).
	/// * you may attach the [`#[pallet::no_default_bounds]`](`no_default_bounds`)
	/// attribute to specify that a particular trait item can be used as a default when a
	/// test `Config` is derived using the [`#[derive_impl(..)]`](`frame_support::derive_impl`)
	/// attribute macro. But its bounds cannot be enforced at this point and should be
	/// discarded when generating the default config trait.
	/// * you may not specify any attribute to generate a trait item in the default config
	///   trait.
	///
	/// In case origin of error is not clear it is recommended to disable all default with
	/// [`#[pallet::no_default]`](`no_default`) and enable them one by one.
	///
	/// ### `DefaultConfig` Caveats
	///
	/// The auto-generated `DefaultConfig` trait:
	/// - is always a _subset_ of your pallet's `Config` trait.
	/// - can only contain items that don't rely on externalities, such as
	///   `frame_system::Config`.
	///
	/// Trait items that _do_ rely on externalities should be marked with
	/// [`#[pallet::no_default]`](`no_default`)
	///
	/// Consequently:
	/// - Any items that rely on externalities _must_ be marked with
	///   [`#[pallet::no_default]`](`no_default`) or your trait will fail to compile when used
	///   with [`derive_impl`](`frame_support::derive_impl`).
	/// - Items marked with [`#[pallet::no_default]`](`no_default`) are entirely excluded from
	///   the `DefaultConfig` trait, and therefore any impl of `DefaultConfig` doesn't need to
	///   implement such items.
	///
	/// For more information, see:
	/// * [`frame_support::derive_impl`].
	/// * [`#[pallet::no_default]`](`no_default`)
	/// * [`#[pallet::no_default_bounds]`](`no_default_bounds`)
	pub use frame_support_procedural::config;

	/// Allows defining an enum that gets composed as an aggregate enum by `construct_runtime`.
	///
	/// The `#[pallet::composite_enum]` attribute allows you to define an enum that gets
	/// composed as an aggregate enum by `construct_runtime`. This is similar in principle with
	/// [frame_support_procedural::event] and [frame_support_procedural::error].
	///
	/// The attribute currently only supports enum definitions, and identifiers that are named
	/// `FreezeReason`, `HoldReason`, `LockId` or `SlashReason`. Arbitrary identifiers for the
	/// enum are not supported. The aggregate enum generated by
	/// [`frame_support::construct_runtime`] will have the name of `RuntimeFreezeReason`,
	/// `RuntimeHoldReason`, `RuntimeLockId` and `RuntimeSlashReason` respectively.
	///
	/// NOTE: The aggregate enum generated by `construct_runtime` generates a conversion
	/// function from the pallet enum to the aggregate enum, and automatically derives the
	/// following traits:
	///
	/// ```ignore
	/// Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo,
	/// RuntimeDebug
	/// ```
	///
	/// For ease of usage, when no `#[derive]` attributes are found for the enum under
	/// [`#[pallet::composite_enum]`](composite_enum), the aforementioned traits are
	/// automatically derived for it. The inverse is also true: if there are any `#[derive]`
	/// attributes found for the enum, then no traits will automatically be derived for it.
	///
	/// e.g, defining `HoldReason` in a pallet
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::composite_enum]
	/// 	pub enum HoldReason {
	/// 		/// The NIS Pallet has reserved it for a non-fungible receipt.
	/// 		#[codec(index = 0)]
	/// 		SomeHoldReason,
	/// 		#[codec(index = 1)]
	/// 		SomeOtherHoldReason,
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	pub use frame_support_procedural::composite_enum;

	/// Allows the pallet to validate unsigned transactions.
	///
	/// Item must be defined as:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::validate_unsigned]
	/// 	impl<T: Config> sp_runtime::traits::ValidateUnsigned for Pallet<T> {
	/// 		type Call = Call<T>;
	///
	/// 		fn validate_unsigned(_source: TransactionSource, _call: &Self::Call) -> TransactionValidity {
	/// 			// Your implementation details here
	/// 			unimplemented!()
	/// 		}
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	///
	/// I.e. a trait implementation with bound `T: Config`, of trait
	/// [`ValidateUnsigned`](frame_support::pallet_prelude::ValidateUnsigned) for
	/// type `Pallet<T>`, and some optional where clause.
	///
	/// NOTE: There is also the [`sp_runtime::traits::SignedExtension`] trait that can be used
	/// to add some specific logic for transaction validation.
	///
	/// ## Macro expansion
	///
	/// The macro currently makes no use of this information, but it might use this information
	/// in the future to give information directly to [`frame_support::construct_runtime`].
	pub use frame_support_procedural::validate_unsigned;

	/// Allows defining a struct implementing the [`Get`](frame_support::traits::Get) trait to
	/// ease the use of storage types.
	///
	/// This attribute is meant to be used alongside [`#[pallet::storage]`](`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 {
	/// # 	use sp_runtime::FixedU128;
	/// # 	use frame_support::pallet_prelude::*;
	/// #
	/// 	#[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)
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	///
	/// ## 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.
	pub use frame_support_procedural::type_value;

	/// Allows defining a storage version for the pallet.
	///
	/// Because the `pallet::pallet` macro implements
	/// [`GetStorageVersion`](frame_support::traits::GetStorageVersion), the current storage
	/// version needs to be communicated to the macro. This can be done by using the
	/// `pallet::storage_version` attribute:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::StorageVersion;
	/// # 	use frame_support::traits::GetStorageVersion;
	/// #
	/// 	const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
	///
	/// 	#[pallet::pallet]
	/// 	#[pallet::storage_version(STORAGE_VERSION)]
	/// 	pub struct Pallet<T>(_);
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	///
	/// If not present, the current storage version is set to the default value.
	pub use frame_support_procedural::storage_version;

	/// The `#[pallet::hooks]` attribute allows you to specify a
	/// [`frame_support::traits::Hooks`] implementation for `Pallet` that specifies
	/// pallet-specific logic.
	///
	/// The item the attribute attaches to must be defined as follows:
	///
	/// ```
	/// #[frame_support::pallet]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// # 	use frame_system::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::hooks]
	/// 	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
	/// 		// Implement hooks here
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	/// I.e. a regular trait implementation with generic bound: `T: Config`, for the trait
	/// `Hooks<BlockNumberFor<T>>` (they are defined in preludes), for the type `Pallet<T>`.
	///
	/// Optionally, you could add a where clause.
	///
	/// ## Macro expansion
	///
	/// The macro implements the traits
	/// [`OnInitialize`](frame_support::traits::OnInitialize),
	/// [`OnIdle`](frame_support::traits::OnIdle),
	/// [`OnFinalize`](frame_support::traits::OnFinalize),
	/// [`OnRuntimeUpgrade`](frame_support::traits::OnRuntimeUpgrade),
	/// [`OffchainWorker`](frame_support::traits::OffchainWorker), and
	/// [`IntegrityTest`](frame_support::traits::IntegrityTest) using
	/// the provided [`Hooks`](frame_support::traits::Hooks) implementation.
	///
	/// NOTE: `OnRuntimeUpgrade` is implemented with `Hooks::on_runtime_upgrade` and some
	/// additional logic. E.g. logic to write the pallet version into storage.
	///
	/// NOTE: The macro also adds some tracing logic when implementing the above traits. The
	/// following hooks emit traces: `on_initialize`, `on_finalize` and `on_runtime_upgrade`.
	pub use frame_support_procedural::hooks;

	/// Generates a helper function on `Pallet` that handles deposit events.
	///
	/// NOTE: For instantiable pallets, the event must be generic over `T` and `I`.
	///
	/// ## Macro expansion
	///
	/// The macro will add on enum `Event` the attributes:
	/// * `#[derive(`[`frame_support::CloneNoBound`]`)]`
	/// * `#[derive(`[`frame_support::EqNoBound`]`)]`
	/// * `#[derive(`[`frame_support::PartialEqNoBound`]`)]`
	/// * `#[derive(`[`frame_support::RuntimeDebugNoBound`]`)]`
	/// * `#[derive(`[`codec::Encode`]`)]`
	/// * `#[derive(`[`codec::Decode`]`)]`
	///
	/// The macro implements `From<Event<..>>` for ().
	///
	/// The macro implements a metadata function on `Event` returning the `EventMetadata`.
	///
	/// If `#[pallet::generate_deposit]` is present then the macro implements `fn
	/// deposit_event` on `Pallet`.
	pub use frame_support_procedural::generate_deposit;

	/// Allows defining logic to make an extrinsic call feeless.
	///
	/// Each dispatchable may be annotated with the `#[pallet::feeless_if($closure)]`
	/// attribute, which explicitly defines the condition for the dispatchable to be feeless.
	///
	/// The arguments for the closure must be the referenced arguments of the dispatchable
	/// function.
	///
	/// The closure must return `bool`.
	///
	/// ### Example
	///
	/// ```
	/// #[frame_support::pallet(dev_mode)]
	/// mod pallet {
	/// # 	use frame_support::pallet_prelude::*;
	/// # 	use frame_system::pallet_prelude::*;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::call]
	/// 	impl<T: Config> Pallet<T> {
	/// 		#[pallet::call_index(0)]
	/// 		/// Marks this call as feeless if `foo` is zero.
	/// 		#[pallet::feeless_if(|_origin: &OriginFor<T>, foo: &u32| -> bool {
	/// 			*foo == 0
	/// 		})]
	/// 		pub fn something(
	/// 			_: OriginFor<T>,
	/// 			foo: u32,
	/// 		) -> DispatchResult {
	/// 			unimplemented!()
	/// 		}
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	///
	/// Please note that this only works for signed dispatchables and requires a signed
	/// extension such as [`pallet_skip_feeless_payment::SkipCheckIfFeeless`] to wrap the
	/// existing payment extension. Else, this is completely ignored and the dispatchable is
	/// still charged.
	///
	/// ### Macro expansion
	///
	/// The macro implements the [`pallet_skip_feeless_payment::CheckIfFeeless`] trait on the
	/// dispatchable and calls the corresponding closure in the implementation.
	///
	/// [`pallet_skip_feeless_payment::SkipCheckIfFeeless`]: ../../pallet_skip_feeless_payment/struct.SkipCheckIfFeeless.html
	/// [`pallet_skip_feeless_payment::CheckIfFeeless`]: ../../pallet_skip_feeless_payment/struct.SkipCheckIfFeeless.html
	pub use frame_support_procedural::feeless_if;

	/// Allows defining an error enum that will be returned from the dispatchable when an error
	/// occurs.
	///
	/// The information for this error type is then stored in runtime metadata.
	///
	/// Item must be defined as so:
	///
	/// ```
	/// #[frame_support::pallet(dev_mode)]
	/// mod pallet {
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::error]
	/// 	pub enum Error<T> {
	/// 		/// SomeFieldLessVariant doc
	/// 		SomeFieldLessVariant,
	/// 		/// SomeVariantWithOneField doc
	/// 		SomeVariantWithOneField(u32),
	/// 	}
	/// #
	/// # 	#[pallet::config]
	/// # 	pub trait Config: frame_system::Config {}
	/// }
	/// ```
	/// I.e. a regular enum named `Error`, with generic `T` and fieldless or multiple-field
	/// variants.
	///
	/// Any field type in the enum variants must implement [`scale_info::TypeInfo`] in order to
	/// be properly used in the metadata, and its encoded size should be as small as possible,
	/// preferably 1 byte in size in order to reduce storage size. The error enum itself has an
	/// absolute maximum encoded size specified by
	/// [`frame_support::MAX_MODULE_ERROR_ENCODED_SIZE`].
	///
	/// (1 byte can still be 256 different errors. The more specific the error, the easier it
	/// is to diagnose problems and give a better experience to the user. Don't skimp on having
	/// lots of individual error conditions.)
	///
	/// Field types in enum variants must also implement [`frame_support::PalletError`],
	/// otherwise the pallet will fail to compile. Rust primitive types have already
	/// implemented the [`frame_support::PalletError`] trait along with some commonly used
	/// stdlib types such as [`Option`] and [`sp_std::marker::PhantomData`], and hence
	/// in most use cases, a manual implementation is not necessary and is discouraged.
	///
	/// The generic `T` must not bound anything and a `where` clause is not allowed. That said,
	/// bounds and/or a where clause should not needed for any use-case.
	///
	/// ## Macro expansion
	///
	/// The macro implements the [`Debug`] trait and functions `as_u8` using variant position,
	/// and `as_str` using variant doc.
	///
	/// The macro also implements `From<Error<T>>` for `&'static str` and `From<Error<T>>` for
	/// `DispatchError`.
	pub use frame_support_procedural::error;

	/// Allows defining pallet events.
	///
	/// Pallet events are stored under the `system` / `events` key when the block is applied
	/// (and then replaced when the next block writes it's events).
	///
	/// The Event enum can be defined as follows:
	///
	/// ```
	/// #[frame_support::pallet(dev_mode)]
	/// mod pallet {
	/// #     use frame_support::pallet_prelude::IsType;
	/// #
	/// 	#[pallet::pallet]
	/// 	pub struct Pallet<T>(_);
	///
	/// 	#[pallet::event]
	/// 	#[pallet::generate_deposit(fn deposit_event)] // Optional
	/// 	pub enum Event<T> {
	/// 		/// SomeEvent doc
	/// 		SomeEvent(u16, u32), // SomeEvent with two fields
	/// 	}
	///
	/// 	#[pallet::config]
	/// 	pub trait Config: frame_system::Config {
	/// 		/// The overarching runtime event type.
	/// 		type RuntimeEvent: From<Event<Self>>
	/// 			+ IsType<<Self as frame_system::Config>::RuntimeEvent>;
	/// 	}
	/// }
	/// ```
	///
	/// I.e. an enum (with named or unnamed fields variant), named `Event`, with generic: none
	/// or `T` or `T: Config`, and optional w here clause.
	///
	/// `RuntimeEvent` must be defined in the `Config`, as shown in the example.
	///
	/// Each field must implement [`Clone`], [`Eq`], [`PartialEq`], [`codec::Encode`],
	/// [`codec::Decode`], and [`Debug`] (on std only). For ease of use, bound by the trait
	/// `Member`, available in [`frame_support::pallet_prelude`].
	pub use frame_support_procedural::event;
	/// Allows a pallet to declare a set of functions as a *dispatchable extrinsic*.
	///
	/// In slightly simplified terms, this macro declares the set of "transactions" of a
	/// pallet.
	///
	/// > The exact definition of **extrinsic** can be found in
	/// > [`sp_runtime::generic::UncheckedExtrinsic`].
	///
	/// A **dispatchable** is a common term in FRAME, referring to process of constructing a
	/// function, and dispatching it with the correct inputs. This is commonly used with
	/// extrinsics, for example "an extrinsic has been dispatched". See
	/// [`sp_runtime::traits::Dispatchable`] and [`crate::traits::UnfilteredDispatchable`].
	///
	/// ## Call Enum
	///
	/// The macro is called `call` (rather than `#[pallet::extrinsics]`) because of the
	/// generation of a `enum Call`. This enum contains only the encoding of the function
	/// arguments of the dispatchable, alongside the information needed to route it to the
	/// correct function.
	///
	/// ```
	/// #[frame_support::pallet(dev_mode)]
	/// pub mod custom_pallet {
	/// #   use frame_support::pallet_prelude::*;
	/// #   use frame_system::pallet_prelude::*;
	/// #   #[pallet::config]
	/// #   pub trait Config: frame_system::Config {}
	/// #   #[pallet::pallet]
	/// #   pub struct Pallet<T>(_);
	/// #   use frame_support::traits::BuildGenesisConfig;
	///     #[pallet::call]
	///     impl<T: Config> Pallet<T> {
	///         pub fn some_dispatchable(_origin: OriginFor<T>, _input: u32) -> DispatchResult {
	///             Ok(())
	///         }
	///         pub fn other(_origin: OriginFor<T>, _input: u64) -> DispatchResult {
	///             Ok(())
	///         }
	///     }
	///
	///     // generates something like:
	///     // enum Call<T: Config> {
	///     //  some_dispatchable { input: u32 }
	///     //  other { input: u64 }
	///     // }
	/// }
	///
	/// fn main() {
	/// #   use frame_support::{derive_impl, construct_runtime};
	/// #   use frame_support::__private::codec::Encode;
	/// #   use frame_support::__private::TestExternalities;
	/// #   use frame_support::traits::UnfilteredDispatchable;
	/// #    impl custom_pallet::Config for Runtime {}