Skip to main content

frame_support/
lib.rs

1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: Apache-2.0
5
6// Licensed under the Apache License, Version 2.0 (the "License");
7// you may not use this file except in compliance with the License.
8// You may obtain a copy of the License at
9//
10// 	http://www.apache.org/licenses/LICENSE-2.0
11//
12// Unless required by applicable law or agreed to in writing, software
13// distributed under the License is distributed on an "AS IS" BASIS,
14// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15// See the License for the specific language governing permissions and
16// limitations under the License.
17
18//! Support code for the runtime.
19//!
20//! ## Note on Tuple Traits
21//!
22//! Many of the traits defined in [`traits`] have auto-implementations on tuples as well. Usually,
23//! the tuple is a function of number of pallets in the runtime. By default, the traits are
24//! implemented for tuples of up to 64 items.
25// If you have more pallets in your runtime, or for any other reason need more, enabled `tuples-96`
26// or the `tuples-128` complication flag. Note that these features *will increase* the compilation
27// of this crate.
28
29#![cfg_attr(not(feature = "std"), no_std)]
30
31/// Export ourself as `frame_support` to make tests happy.
32#[doc(hidden)]
33extern crate self as frame_support;
34
35#[doc(hidden)]
36extern crate alloc;
37
38/// Maximum nesting level for extrinsics.
39pub const MAX_EXTRINSIC_DEPTH: u32 = 256;
40
41/// Private exports that are being used by macros.
42///
43/// The exports are not stable and should not be relied on.
44#[doc(hidden)]
45pub mod __private {
46	pub use alloc::{
47		boxed::Box,
48		fmt::Debug,
49		rc::Rc,
50		string::String,
51		vec,
52		vec::{IntoIter, Vec},
53	};
54	pub use codec;
55	pub use frame_metadata as metadata;
56	pub use impl_trait_for_tuples;
57	pub use log;
58	pub use paste;
59	pub use scale_info;
60	pub use serde;
61	pub use serde_json;
62	pub use sp_core::{Get, OpaqueMetadata, Void};
63	pub use sp_crypto_hashing_proc_macro;
64	pub use sp_inherents;
65	#[cfg(feature = "std")]
66	pub use sp_io::TestExternalities;
67	pub use sp_io::{self, hashing, storage::root as storage_root};
68	pub use sp_metadata_ir as metadata_ir;
69	#[cfg(feature = "std")]
70	pub use sp_runtime::{bounded_btree_map, bounded_vec};
71	pub use sp_runtime::{
72		traits::{AsSystemOriginSigner, AsTransactionAuthorizedOrigin, Dispatchable},
73		DispatchError, StateVersion, TransactionOutcome,
74	};
75	#[cfg(feature = "std")]
76	pub use sp_state_machine::BasicExternalities;
77	pub use sp_std;
78	pub use sp_tracing;
79	pub use tt_call::*;
80}
81
82#[macro_use]
83pub mod dispatch;
84pub mod crypto;
85pub mod dispatch_context;
86mod hash;
87pub mod inherent;
88pub mod instances;
89mod macros;
90pub mod migrations;
91pub mod storage;
92#[cfg(test)]
93mod tests;
94pub mod traits;
95pub mod view_functions;
96pub mod weights;
97#[doc(hidden)]
98pub mod unsigned {
99	#[allow(deprecated)]
100	#[doc(hidden)]
101	pub use crate::sp_runtime::traits::ValidateUnsigned;
102	#[doc(hidden)]
103	pub use crate::sp_runtime::transaction_validity::{
104		TransactionSource, TransactionValidity, TransactionValidityError, UnknownTransaction,
105	};
106}
107
108#[cfg(any(feature = "std", feature = "runtime-benchmarks", feature = "try-runtime", test))]
109pub use self::storage::storage_noop_guard::StorageNoopGuard;
110pub use self::{
111	dispatch::{Callable, Parameter},
112	hash::{
113		Blake2_128, Blake2_128Concat, Blake2_256, Hashable, Identity, ReversibleStorageHasher,
114		StorageHasher, Twox128, Twox256, Twox64Concat,
115	},
116	storage::{
117		bounded_btree_map::BoundedBTreeMap,
118		bounded_btree_set::BoundedBTreeSet,
119		bounded_vec::{BoundedSlice, BoundedVec},
120		migration,
121		weak_bounded_vec::WeakBoundedVec,
122		IterableStorageDoubleMap, IterableStorageMap, IterableStorageNMap, StorageDoubleMap,
123		StorageMap, StorageNMap, StoragePrefixedMap, StorageValue,
124	},
125};
126pub use sp_runtime::{
127	self, print, traits::Printable, ConsensusEngineId, MAX_MODULE_ERROR_ENCODED_SIZE,
128};
129
130use codec::{Decode, Encode};
131use scale_info::TypeInfo;
132use sp_runtime::TypeId;
133
134/// A unified log target for support operations.
135pub const LOG_TARGET: &str = "runtime::frame-support";
136
137/// A type that cannot be instantiated.
138#[derive(Encode, Decode, Debug, PartialEq, Eq, Clone, TypeInfo)]
139pub enum Never {}
140
141/// A pallet identifier. These are per pallet and should be stored in a registry somewhere.
142#[derive(Clone, Copy, Eq, PartialEq, Encode, Decode, TypeInfo)]
143pub struct PalletId(pub [u8; 8]);
144
145impl TypeId for PalletId {
146	const TYPE_ID: [u8; 4] = *b"modl";
147}
148
149/// Generate a [`#[pallet::storage]`](pallet_macros::storage) alias outside of a pallet.
150///
151/// This storage alias works similarly to the [`#[pallet::storage]`](pallet_macros::storage)
152/// attribute macro. It supports [`StorageValue`](storage::types::StorageValue),
153/// [`StorageMap`](storage::types::StorageMap),
154/// [`StorageDoubleMap`](storage::types::StorageDoubleMap) and
155/// [`StorageNMap`](storage::types::StorageNMap). The main difference to the normal
156/// [`#[pallet::storage]`](pallet_macros::storage) is the flexibility around declaring the
157/// storage prefix to use. The storage prefix determines where to find the value in the
158/// storage. [`#[pallet::storage]`](pallet_macros::storage) uses the name of the pallet as
159/// declared in [`construct_runtime!`].
160///
161/// The flexibility around declaring the storage prefix makes this macro very useful for
162/// writing migrations etc.
163///
164/// # Examples
165///
166/// There are different ways to declare the `prefix` to use. The `prefix` type can either be
167/// declared explicitly by passing it to the macro as an attribute or by letting the macro
168/// guess on what the `prefix` type is. The `prefix` is always passed as the first generic
169/// argument to the type declaration. When using [`#[pallet::storage]`](pallet_macros::storage)
170/// this first generic argument is always `_`. Besides declaring the `prefix`, the rest of the
171/// type declaration works as with [`#[pallet::storage]`](pallet_macros::storage).
172///
173/// 1. Use the `verbatim` prefix type. This prefix type uses the given identifier as the
174/// `prefix`:
175#[doc = docify::embed!("src/tests/storage_alias.rs", verbatim_attribute)]
176/// 2. Use the `pallet_name` prefix type. This prefix type uses the name of the pallet as
177/// configured in    [`construct_runtime!`] as the `prefix`:
178#[doc = docify::embed!("src/tests/storage_alias.rs", pallet_name_attribute)]
179/// It requires that the given prefix type implements
180/// [`PalletInfoAccess`](traits::PalletInfoAccess) (which is always the case for FRAME pallet
181/// structs). In the example above, `Pallet<T>` is the prefix type.
182///
183/// 3. Use the `dynamic` prefix type. This prefix type calls [`Get::get()`](traits::Get::get)
184///    to get the `prefix`:
185#[doc = docify::embed!("src/tests/storage_alias.rs", dynamic_attribute)]
186/// It requires that the given prefix type implements [`Get<'static str>`](traits::Get).
187///
188/// 4. Let the macro "guess" what kind of prefix type to use. This only supports verbatim or
189///    pallet name. The macro uses the presence of generic arguments to the prefix type as an
190///    indication that it should use the pallet name as the `prefix`:
191#[doc = docify::embed!("src/tests/storage_alias.rs", storage_alias_guess)]
192pub use frame_support_procedural::storage_alias;
193
194pub use frame_support_procedural::stored;
195
196pub use frame_support_procedural::derive_impl;
197
198/// Experimental macros for defining dynamic params that can be used in pallet configs.
199#[cfg(feature = "experimental")]
200pub mod dynamic_params {
201	pub use frame_support_procedural::{
202		dynamic_aggregated_params_internal, dynamic_pallet_params, dynamic_params,
203	};
204}
205
206#[doc(inline)]
207pub use frame_support_procedural::{
208	construct_runtime, match_and_insert, transactional, PalletError,
209};
210
211pub use frame_support_procedural::runtime;
212
213#[doc(hidden)]
214pub use frame_support_procedural::{__create_tt_macro, __generate_dummy_part_checker};
215
216/// Derive [`Clone`] but do not bound any generic.
217///
218/// This is useful for type generic over runtime:
219/// ```
220/// # use frame_support::CloneNoBound;
221/// trait Config {
222/// 		type C: Clone;
223/// }
224///
225/// // Foo implements [`Clone`] because `C` bounds [`Clone`].
226/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Clone`].
227/// #[derive(CloneNoBound)]
228/// struct Foo<T: Config> {
229/// 		c: T::C,
230/// }
231/// ```
232pub use frame_support_procedural::CloneNoBound;
233
234/// Derive [`Eq`] but do not bound any generic.
235///
236/// This is useful for type generic over runtime:
237/// ```
238/// # use frame_support::{EqNoBound, PartialEqNoBound};
239/// trait Config {
240/// 		type C: Eq;
241/// }
242///
243/// // Foo implements [`Eq`] because `C` bounds [`Eq`].
244/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Eq`].
245/// #[derive(PartialEqNoBound, EqNoBound)]
246/// struct Foo<T: Config> {
247/// 		c: T::C,
248/// }
249/// ```
250pub use frame_support_procedural::EqNoBound;
251
252/// Derive [`PartialEq`] but do not bound any generic.
253///
254/// This is useful for type generic over runtime:
255/// ```
256/// # use frame_support::PartialEqNoBound;
257/// trait Config {
258/// 		type C: PartialEq;
259/// }
260///
261/// // Foo implements [`PartialEq`] because `C` bounds [`PartialEq`].
262/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`PartialEq`].
263/// #[derive(PartialEqNoBound)]
264/// struct Foo<T: Config> {
265/// 		c: T::C,
266/// }
267/// ```
268pub use frame_support_procedural::PartialEqNoBound;
269
270/// Derive [`Ord`] but do not bound any generic.
271///
272/// This is useful for type generic over runtime:
273/// ```
274/// # use frame_support::{OrdNoBound, PartialOrdNoBound, EqNoBound, PartialEqNoBound};
275/// trait Config {
276/// 		type C: Ord;
277/// }
278///
279/// // Foo implements [`Ord`] because `C` bounds [`Ord`].
280/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Ord`].
281/// #[derive(EqNoBound, OrdNoBound, PartialEqNoBound, PartialOrdNoBound)]
282/// struct Foo<T: Config> {
283/// 		c: T::C,
284/// }
285/// ```
286pub use frame_support_procedural::OrdNoBound;
287
288/// Derive [`PartialOrd`] but do not bound any generic.
289///
290/// This is useful for type generic over runtime:
291/// ```
292/// # use frame_support::{OrdNoBound, PartialOrdNoBound, EqNoBound, PartialEqNoBound};
293/// trait Config {
294/// 		type C: PartialOrd;
295/// }
296///
297/// // Foo implements [`PartialOrd`] because `C` bounds [`PartialOrd`].
298/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`PartialOrd`].
299/// #[derive(PartialOrdNoBound, PartialEqNoBound, EqNoBound)]
300/// struct Foo<T: Config> {
301/// 		c: T::C,
302/// }
303/// ```
304pub use frame_support_procedural::PartialOrdNoBound;
305
306/// Derive [`Debug`] but do not bound any generic.
307///
308/// This is useful for type generic over runtime:
309/// ```
310/// # use frame_support::DebugNoBound;
311/// # use core::fmt::Debug;
312/// trait Config {
313/// 		type C: Debug;
314/// }
315///
316/// // Foo implements [`Debug`] because `C` bounds [`Debug`].
317/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Debug`].
318/// #[derive(DebugNoBound)]
319/// struct Foo<T: Config> {
320/// 		c: T::C,
321/// }
322/// ```
323pub use frame_support_procedural::DebugNoBound;
324
325/// Derive [`Default`] but do not bound any generic.
326///
327/// This is useful for type generic over runtime:
328/// ```
329/// # use frame_support::DefaultNoBound;
330/// # use core::default::Default;
331/// trait Config {
332/// 	type C: Default;
333/// }
334///
335/// // Foo implements [`Default`] because `C` bounds [`Default`].
336/// // Otherwise compilation will fail with an output telling `c` doesn't implement [`Default`].
337/// #[derive(DefaultNoBound)]
338/// struct Foo<T: Config> {
339/// 	c: T::C,
340/// }
341///
342/// // Also works with enums, by specifying the default with #[default]:
343/// #[derive(DefaultNoBound)]
344/// enum Bar<T: Config> {
345/// 	// Bar will implement Default as long as all of the types within Baz also implement default.
346/// 	#[default]
347/// 	Baz(T::C),
348/// 	Quxx,
349/// }
350/// ```
351pub use frame_support_procedural::DefaultNoBound;
352
353/// Assert the annotated function is executed within a storage transaction.
354///
355/// The assertion is enabled for native execution and when `debug_assertions` are enabled.
356///
357/// # Example
358///
359/// ```
360/// # use frame_support::{
361/// # 	require_transactional, transactional, dispatch::DispatchResult
362/// # };
363///
364/// #[require_transactional]
365/// fn update_all(value: u32) -> DispatchResult {
366/// 	// Update multiple storages.
367/// 	// Return `Err` to indicate should revert.
368/// 	Ok(())
369/// }
370///
371/// #[transactional]
372/// fn safe_update(value: u32) -> DispatchResult {
373/// 	// This is safe
374/// 	update_all(value)
375/// }
376///
377/// fn unsafe_update(value: u32) -> DispatchResult {
378/// 	// this may panic if unsafe_update is not called within a storage transaction
379/// 	update_all(value)
380/// }
381/// ```
382pub use frame_support_procedural::require_transactional;
383
384/// Convert the current crate version into a [`CrateVersion`](crate::traits::CrateVersion).
385///
386/// It uses the `CARGO_PKG_VERSION_MAJOR`, `CARGO_PKG_VERSION_MINOR` and
387/// `CARGO_PKG_VERSION_PATCH` environment variables to fetch the crate version.
388/// This means that the [`CrateVersion`](crate::traits::CrateVersion)
389/// object will correspond to the version of the crate the macro is called in!
390///
391/// # Example
392///
393/// ```
394/// # use frame_support::{traits::CrateVersion, crate_to_crate_version};
395/// const Version: CrateVersion = crate_to_crate_version!();
396/// ```
397pub use frame_support_procedural::crate_to_crate_version;
398
399#[doc(hidden)]
400pub use serde::{Deserialize, Serialize};
401
402#[doc(hidden)]
403pub use macro_magic;
404
405pub use derive_where;
406
407/// Prelude to be used for pallet testing, for ease of use.
408#[cfg(feature = "std")]
409pub mod testing_prelude {
410	pub use super::traits::Get;
411	pub use crate::{
412		assert_err, assert_err_ignore_postinfo, assert_err_with_weight, assert_noop, assert_ok,
413		assert_storage_noop, parameter_types,
414	};
415	pub use sp_arithmetic::assert_eq_error_rate;
416	pub use sp_runtime::{bounded_btree_map, bounded_vec};
417}
418
419/// Prelude to be used alongside pallet macro, for ease of use.
420pub mod pallet_prelude {
421	pub use crate::{
422		defensive, defensive_assert,
423		dispatch::{DispatchClass, DispatchResult, DispatchResultWithPostInfo, Parameter, Pays},
424		ensure,
425		inherent::{InherentData, InherentIdentifier, ProvideInherent},
426		storage,
427		storage::{
428			bounded_btree_map::BoundedBTreeMap,
429			bounded_btree_set::BoundedBTreeSet,
430			bounded_vec::BoundedVec,
431			types::{
432				CountedStorageMap, CountedStorageNMap, Key as NMapKey, OptionQuery, ResultQuery,
433				StorageDoubleMap, StorageMap, StorageNMap, StorageValue, ValueQuery,
434			},
435			weak_bounded_vec::WeakBoundedVec,
436			StorageList,
437		},
438		traits::{
439			Authorize, BuildGenesisConfig, ConstU32, ConstUint, EnsureOrigin, Get, GetDefault,
440			GetStorageVersion, Hooks, IsType, OriginTrait, PalletInfoAccess, StorageInfoTrait,
441			StorageVersion, Task, TypedGet,
442		},
443		Blake2_128, Blake2_128Concat, Blake2_256, CloneNoBound, DebugNoBound, EqNoBound, Identity,
444		PartialEqNoBound, Twox128, Twox256, Twox64Concat,
445	};
446	pub use codec::{Decode, DecodeWithMemTracking, Encode, MaxEncodedLen};
447	pub use core::marker::PhantomData;
448	pub use frame_support::pallet_macros::*;
449	pub use frame_support_procedural::{inject_runtime_type, register_default_impl};
450	pub use scale_info::TypeInfo;
451	pub use sp_inherents::MakeFatalError;
452	pub use sp_runtime::{
453		traits::{
454			CheckedAdd, CheckedConversion, CheckedDiv, CheckedMul, CheckedShl, CheckedShr,
455			CheckedSub, MaybeSerializeDeserialize, Member, One, ValidateResult, Zero,
456		},
457		transaction_validity::{
458			InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource,
459			TransactionTag, TransactionValidity, TransactionValidityError,
460			TransactionValidityWithRefund, UnknownTransaction, ValidTransaction,
461		},
462		Debug, DispatchError, MAX_MODULE_ERROR_ENCODED_SIZE,
463	};
464	pub use sp_weights::Weight;
465
466	#[allow(deprecated)]
467	pub use sp_runtime::traits::ValidateUnsigned;
468}
469
470/// The pallet macro has 2 purposes:
471///
472/// * [For declaring a pallet as a rust module](#1---pallet-module-declaration)
473/// * [For declaring the `struct` placeholder of a
474///   pallet](#2---pallet-struct-placeholder-declaration)
475///
476/// # 1 - Pallet module declaration
477///
478/// The module to declare a pallet is organized as follows:
479/// ```
480/// #[frame_support::pallet]    // <- the macro
481/// mod pallet {
482/// 	#[pallet::pallet]
483/// 	pub struct Pallet<T>(_);
484///
485/// 	#[pallet::config]
486/// 	pub trait Config: frame_system::Config {}
487///
488/// 	#[pallet::call]
489/// 	impl<T: Config> Pallet<T> {
490/// 	}
491///
492/// 	/* ... */
493/// }
494/// ```
495///
496/// The documentation for each individual part can be found at [frame_support::pallet_macros]
497///
498/// ## Dev Mode (`#[pallet(dev_mode)]`)
499///
500/// Syntax:
501///
502/// ```
503/// #[frame_support::pallet(dev_mode)]
504/// mod pallet {
505/// # 	 #[pallet::pallet]
506/// # 	 pub struct Pallet<T>(_);
507/// # 	 #[pallet::config]
508/// # 	 pub trait Config: frame_system::Config {}
509/// 	/* ... */
510/// }
511/// ```
512///
513/// Specifying the argument `dev_mode` will allow you to enable dev mode for a pallet. The
514/// aim of dev mode is to loosen some of the restrictions and requirements placed on
515/// production pallets for easy tinkering and development. Dev mode pallets should not be
516/// used in production. Enabling dev mode has the following effects:
517///
518/// * Weights no longer need to be specified on every `#[pallet::call]` declaration. By
519///   default, dev mode pallets will assume a weight of zero (`0`) if a weight is not
520///   specified. This is equivalent to specifying `#[weight(0)]` on all calls that do not
521///   specify a weight.
522/// * Call indices no longer need to be specified on every `#[pallet::call]` declaration. By
523///   default, dev mode pallets will assume a call index based on the order of the call.
524/// * All storages are marked as unbounded, meaning you do not need to implement
525///   [`MaxEncodedLen`](frame_support::pallet_prelude::MaxEncodedLen) on storage types. This is
526///   equivalent to specifying `#[pallet::unbounded]` on all storage type definitions.
527/// * Storage hashers no longer need to be specified and can be replaced by `_`. In dev mode,
528///   these will be replaced by `Blake2_128Concat`. In case of explicit key-binding, `Hasher`
529///   can simply be ignored when in `dev_mode`.
530///
531/// Note that the `dev_mode` argument can only be supplied to the `#[pallet]` or
532/// `#[frame_support::pallet]` attribute macro that encloses your pallet module. This
533/// argument cannot be specified anywhere else, including but not limited to the
534/// `#[pallet::pallet]` attribute macro.
535///
536/// <div class="example-wrap" style="display:inline-block"><pre class="compile_fail"
537/// style="white-space:normal;font:inherit;">
538/// <strong>WARNING</strong>:
539/// You should never deploy or use dev mode pallets in production. Doing so can break your
540/// chain. Once you are done tinkering, you should
541/// remove the 'dev_mode' argument from your #[pallet] declaration and fix any compile
542/// errors before attempting to use your pallet in a production scenario.
543/// </pre></div>
544///
545/// # 2 - Pallet struct placeholder declaration
546///
547/// The pallet struct placeholder `#[pallet::pallet]` is mandatory and allows you to
548/// specify pallet information.
549///
550/// The struct must be defined as follows:
551/// ```
552/// #[frame_support::pallet]
553/// mod pallet {
554/// 	#[pallet::pallet]         // <- the macro
555/// 	pub struct Pallet<T>(_);  // <- the struct definition
556///
557/// 	#[pallet::config]
558/// 	pub trait Config: frame_system::Config {}
559/// }
560/// ```
561//
562/// I.e. a regular struct definition named `Pallet`, with generic T and no where clause.
563///
564/// ## Macro expansion:
565///
566/// The macro adds this attribute to the Pallet struct definition:
567/// ```ignore
568/// #[derive(
569/// 	frame_support::CloneNoBound,
570/// 	frame_support::EqNoBound,
571/// 	frame_support::PartialEqNoBound,
572/// 	frame_support::DebugNoBound,
573/// )]
574/// ```
575/// and replaces the type `_` with `PhantomData<T>`.
576///
577/// It also implements on the pallet:
578///
579/// * [`GetStorageVersion`](frame_support::traits::GetStorageVersion)
580/// * [`OnGenesis`](frame_support::traits::OnGenesis): contains some logic to write the pallet
581///   version into storage.
582/// * [`PalletInfoAccess`](frame_support::traits::PalletInfoAccess) to ease access to pallet
583///   information given by [`frame_support::traits::PalletInfo`]. (The implementation uses the
584///   associated type [`frame_support::traits::PalletInfo`]).
585/// * [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) to give information about
586///   storages.
587///
588/// If the attribute `set_storage_max_encoded_len` is set then the macro calls
589/// [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) for each storage in the
590/// implementation of [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) for the
591/// pallet. Otherwise, it implements
592/// [`StorageInfoTrait`](frame_support::traits::StorageInfoTrait) for the pallet using the
593/// [`PartialStorageInfoTrait`](frame_support::traits::PartialStorageInfoTrait)
594/// implementation of storages.
595///
596/// ## Note on deprecation.
597///
598/// - Usage of `deprecated` attribute will propagate deprecation information to the pallet
599///   metadata.
600/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
601/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the generated
602///   code.
603/// - If the item is annotated with `deprecated` attribute then the generated code will be
604///   automatically annotated with `allow(deprecated)`
605pub use frame_support_procedural::pallet;
606
607/// Contains macro stubs for all of the `pallet::` macros
608pub mod pallet_macros {
609	/// Declare the storage as whitelisted from benchmarking.
610	///
611	/// Doing so will exclude reads of that value's storage key from counting towards weight
612	/// calculations during benchmarking.
613	///
614	/// This attribute should only be attached to storages that are known to be
615	/// read/used in every block. This will result in a more accurate benchmarking weight.
616	///
617	/// ### Example
618	/// ```
619	/// #[frame_support::pallet]
620	/// mod pallet {
621	/// # 	use frame_support::pallet_prelude::*;
622	/// #
623	/// 	#[pallet::pallet]
624	/// 	pub struct Pallet<T>(_);
625	///
626	/// 	#[pallet::storage]
627	/// 	#[pallet::whitelist_storage]
628	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
629	/// #
630	/// # 	#[pallet::config]
631	/// # 	pub trait Config: frame_system::Config {}
632	/// }
633	/// ```
634	pub use frame_support_procedural::whitelist_storage;
635
636	/// Allows specifying the weight of a call.
637	///
638	/// Each dispatchable needs to define a weight.
639	/// This attribute allows to define a weight using the expression:
640	/// `#[pallet::weight($expr)]` Note that argument of the call are available inside the
641	/// expression.
642	///
643	/// If not defined explicitly, the weight can be implicitly inferred from the weight info
644	/// defined in the attribute `pallet::call`: `#[pallet::call(weight = $WeightInfo)]`.
645	/// Or it can be simply ignored when the pallet is in `dev_mode`.
646	///
647	/// ## Example
648	///
649	/// ```
650	/// #[frame_support::pallet]
651	/// mod pallet {
652	///  	use frame_support::pallet_prelude::*;
653	///  	use frame_system::pallet_prelude::*;
654	///
655	/// 	#[pallet::pallet]
656	/// 	pub struct Pallet<T>(_);
657	///
658	///  	#[pallet::config]
659	///  	pub trait Config: frame_system::Config {
660	///         /// Type for specifying dispatchable weights.
661	///         type WeightInfo: WeightInfo;
662	///     }
663	///
664	/// 	#[pallet::call(weight = <T as Config>::WeightInfo)]
665	/// 	impl<T: Config> Pallet<T> {
666	/// 		// Explicit weight definition
667	/// 		#[pallet::weight(<T as Config>::WeightInfo::do_something())]
668	/// 		#[pallet::call_index(0)]
669	/// 		pub fn do_something(
670	/// 			origin: OriginFor<T>,
671	/// 			foo: u32,
672	/// 		) -> DispatchResult {
673	/// 			Ok(())
674	/// 		}
675	///
676	///             // Implicit weight definition, the macro looks up to the weight info defined in
677	///             // `#[pallet::call(weight = $WeightInfo)]` attribute. Then use
678	///             // `$WeightInfo::do_something_else` as the weight function.
679	///             #[pallet::call_index(1)]
680	///             pub fn do_something_else(
681	///                 origin: OriginFor<T>,
682	///                 bar: u64,
683	///             ) -> DispatchResult {
684	///                 Ok(())
685	///             }
686	///     }
687	///
688	///     /// The `WeightInfo` trait defines weight functions for dispatchable calls.
689	///     pub trait WeightInfo {
690	///         fn do_something() -> Weight;
691	///         fn do_something_else() -> Weight;
692	///     }
693	/// }
694	/// ```
695	pub use frame_support_procedural::weight;
696
697	/// Allows whitelisting a storage item from decoding during try-runtime checks.
698	///
699	/// The optional attribute `#[pallet::disable_try_decode_storage]` will declare the
700	/// storage as whitelisted from decoding during try-runtime checks. This should only be
701	/// attached to transient storage which cannot be migrated during runtime upgrades.
702	///
703	/// ### Example
704	/// ```
705	/// #[frame_support::pallet]
706	/// mod pallet {
707	/// # 	use frame_support::pallet_prelude::*;
708	/// #
709	/// 	#[pallet::pallet]
710	/// 	pub struct Pallet<T>(_);
711	///
712	/// 	#[pallet::storage]
713	/// 	#[pallet::disable_try_decode_storage]
714	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
715	/// #
716	/// # 	#[pallet::config]
717	/// # 	pub trait Config: frame_system::Config {}
718	/// }
719	/// ```
720	pub use frame_support_procedural::disable_try_decode_storage;
721
722	/// Declares a storage as unbounded in potential size.
723	///
724	/// When implementing the storage info (when `#[pallet::generate_storage_info]` is
725	/// specified on the pallet struct placeholder), the size of the storage will be declared
726	/// as unbounded. This can be useful for storage which can never go into PoV (Proof of
727	/// Validity).
728	///
729	/// ## Example
730	///
731	/// ```
732	/// #[frame_support::pallet]
733	/// mod pallet {
734	/// # 	use frame_support::pallet_prelude::*;
735	/// #
736	/// 	#[pallet::pallet]
737	/// 	pub struct Pallet<T>(_);
738	///
739	/// 	#[pallet::storage]
740	/// 	#[pallet::unbounded]
741	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
742	/// #
743	/// # 	#[pallet::config]
744	/// # 	pub trait Config: frame_system::Config {}
745	/// }
746	/// ```
747	pub use frame_support_procedural::unbounded;
748
749	/// Defines what storage prefix to use for a storage item when building the trie.
750	///
751	/// This is helpful if you wish to rename the storage field but don't want to perform a
752	/// migration.
753	///
754	/// ## Example
755	///
756	/// ```
757	/// #[frame_support::pallet]
758	/// mod pallet {
759	/// # 	use frame_support::pallet_prelude::*;
760	/// #
761	/// 	#[pallet::pallet]
762	/// 	pub struct Pallet<T>(_);
763	///
764	/// 	#[pallet::storage]
765	/// 	#[pallet::storage_prefix = "foo"]
766	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
767	/// #
768	/// # 	#[pallet::config]
769	/// # 	pub trait Config: frame_system::Config {}
770	/// }
771	/// ```
772	pub use frame_support_procedural::storage_prefix;
773
774	/// Ensures the generated `DefaultConfig` will not have any bounds for
775	/// that trait item.
776	///
777	/// Attaching this attribute to a trait item ensures that the generated trait
778	/// `DefaultConfig` will not have any bounds for this trait item.
779	///
780	/// As an example, if you have a trait item `type AccountId: SomeTrait;` in your `Config`
781	/// trait, the generated `DefaultConfig` will only have `type AccountId;` with no trait
782	/// bound.
783	pub use frame_support_procedural::no_default_bounds;
784
785	/// Ensures the trait item will not be used as a default with the
786	/// `#[derive_impl(..)]` attribute macro.
787	///
788	/// The optional attribute `#[pallet::no_default]` can be attached to trait items within a
789	/// `Config` trait impl that has [`#[pallet::config(with_default)]`](`config`)
790	/// attached.
791	pub use frame_support_procedural::no_default;
792
793	/// Declares a module as importable into a pallet via
794	/// [`#[import_section]`](`import_section`).
795	///
796	/// Note that sections are imported by their module name/ident, and should be referred to
797	/// by their _full path_ from the perspective of the target pallet. Do not attempt to make
798	/// use of `use` statements to bring pallet sections into scope, as this will not work
799	/// (unless you do so as part of a wildcard import, in which case it will work).
800	///
801	/// ## Naming Logistics
802	///
803	/// Also note that because of how `#[pallet_section]` works, pallet section names must be
804	/// globally unique _within the crate in which they are defined_. For more information on
805	/// why this must be the case, see macro_magic's
806	/// [`#[export_tokens]`](https://docs.rs/macro_magic/latest/macro_magic/attr.export_tokens.html) macro.
807	///
808	/// Optionally, you may provide an argument to `#[pallet_section]` such as
809	/// `#[pallet_section(some_ident)]`, in the event that there is another pallet section in
810	/// same crate with the same ident/name. The ident you specify can then be used instead of
811	/// the module's ident name when you go to import it via
812	/// [`#[import_section]`](`import_section`).
813	pub use frame_support_procedural::pallet_section;
814
815	/// The `#[pallet::inherent]` attribute allows the pallet to provide
816	/// [inherents](https://docs.substrate.io/fundamentals/transaction-types/#inherent-transactions).
817	///
818	/// An inherent is some piece of data that is inserted by a block authoring node at block
819	/// creation time and can either be accepted or rejected by validators based on whether the
820	/// data falls within an acceptable range.
821	///
822	/// The most common inherent is the `timestamp` that is inserted into every block. Since
823	/// there is no way to validate timestamps, validators simply check that the timestamp
824	/// reported by the block authoring node falls within an acceptable range.
825	///
826	/// Example usage:
827	///
828	/// ```
829	/// #[frame_support::pallet]
830	/// mod pallet {
831	/// # 	use frame_support::pallet_prelude::*;
832	/// # 	use frame_support::inherent::IsFatalError;
833	/// # 	use sp_timestamp::InherentError;
834	/// # 	use core::result;
835	/// #
836	/// 	// Example inherent identifier
837	/// 	pub const INHERENT_IDENTIFIER: InherentIdentifier = *b"timstap0";
838	///
839	/// 	#[pallet::pallet]
840	/// 	pub struct Pallet<T>(_);
841	///
842	/// 	#[pallet::inherent]
843	/// 	impl<T: Config> ProvideInherent for Pallet<T> {
844	/// 		type Call = Call<T>;
845	/// 		type Error = InherentError;
846	/// 		const INHERENT_IDENTIFIER: InherentIdentifier = INHERENT_IDENTIFIER;
847	///
848	/// 		fn create_inherent(data: &InherentData) -> Option<Self::Call> {
849	/// 			unimplemented!()
850	/// 		}
851	///
852	/// 		fn check_inherent(
853	/// 			call: &Self::Call,
854	/// 			data: &InherentData,
855	/// 		) -> result::Result<(), Self::Error> {
856	/// 			unimplemented!()
857	/// 		}
858	///
859	/// 		fn is_inherent(call: &Self::Call) -> bool {
860	/// 			unimplemented!()
861	/// 		}
862	/// 	}
863	/// #
864	/// # 	#[pallet::config]
865	/// # 	pub trait Config: frame_system::Config {}
866	/// }
867	/// ```
868	///
869	/// I.e. a trait implementation with bound `T: Config`, of trait `ProvideInherent` for type
870	/// `Pallet<T>`, and some optional where clause.
871	///
872	/// ## Macro expansion
873	///
874	/// The macro currently makes no use of this information, but it might use this information
875	/// in the future to give information directly to `construct_runtime`.
876	pub use frame_support_procedural::inherent;
877
878	/// Splits a pallet declaration into multiple parts.
879	///
880	/// An attribute macro that can be attached to a module declaration. Doing so will
881	/// import the contents of the specified external pallet section that is defined
882	/// elsewhere using [`#[pallet_section]`](`pallet_section`).
883	///
884	/// ## Example
885	/// ```
886	/// # use frame_support::pallet_macros::pallet_section;
887	/// # use frame_support::pallet_macros::import_section;
888	/// #
889	/// /// A [`pallet_section`] that defines the events for a pallet.
890	/// /// This can later be imported into the pallet using [`import_section`].
891	/// #[pallet_section]
892	/// mod events {
893	/// 	#[pallet::event]
894	/// 	#[pallet::generate_deposit(pub(super) fn deposit_event)]
895	/// 	pub enum Event<T: Config> {
896	/// 		/// Event documentation should end with an array that provides descriptive names for event
897	/// 		/// parameters. [something, who]
898	/// 		SomethingStored { something: u32, who: T::AccountId },
899	/// 	}
900	/// }
901	///
902	/// #[import_section(events)]
903	/// #[frame_support::pallet]
904	/// mod pallet {
905	/// # 	use frame_support::pallet_prelude::*;
906	/// #
907	/// 	#[pallet::pallet]
908	/// 	pub struct Pallet<T>(_);
909	/// #
910	/// # 	#[pallet::config]
911	/// # 	pub trait Config: frame_system::Config<RuntimeEvent: From<Event<Self>>> {
912	/// # 	}
913	/// }
914	/// ```
915	///
916	/// This will result in the contents of `some_section` being _verbatim_ imported into
917	/// the pallet above. Note that since the tokens for `some_section` are essentially
918	/// copy-pasted into the target pallet, you cannot refer to imports that don't also
919	/// exist in the target pallet, but this is easily resolved by including all relevant
920	/// `use` statements within your pallet section, so they are imported as well, or by
921	/// otherwise ensuring that you have the same imports on the target pallet.
922	///
923	/// It is perfectly permissible to import multiple pallet sections into the same pallet,
924	/// which can be done by having multiple `#[import_section(something)]` attributes
925	/// attached to the pallet.
926	///
927	/// Note that sections are imported by their module name/ident, and should be referred to
928	/// by their _full path_ from the perspective of the target pallet.
929	pub use frame_support_procedural::import_section;
930
931	/// Allows defining getter functions on `Pallet` storage.
932	///
933	/// ## Example
934	///
935	/// ```
936	/// #[frame_support::pallet]
937	/// mod pallet {
938	/// # 	use frame_support::pallet_prelude::*;
939	/// #
940	/// 	#[pallet::pallet]
941	/// 	pub struct Pallet<T>(_);
942	///
943	/// 	#[pallet::storage]
944	/// 	#[pallet::getter(fn my_getter_fn_name)]
945	/// 	pub type MyStorage<T> = StorageValue<_, u32>;
946	/// #
947	/// # 	#[pallet::config]
948	/// # 	pub trait Config: frame_system::Config {}
949	/// }
950	/// ```
951	///
952	/// See [`pallet::storage`](`frame_support::pallet_macros::storage`) for more info.
953	pub use frame_support_procedural::getter;
954
955	/// Defines constants that are added to the constant field of
956	/// [`PalletMetadata`](frame_metadata::v15::PalletMetadata) struct for this pallet.
957	///
958	/// Must be defined like:
959	///
960	/// ```
961	/// #[frame_support::pallet]
962	/// mod pallet {
963	/// # 	use frame_support::pallet_prelude::*;
964	/// #
965	/// 	#[pallet::pallet]
966	/// 	pub struct Pallet<T>(_);
967	///
968	/// # 	#[pallet::config]
969	/// # 	pub trait Config: frame_system::Config {}
970	/// #
971	/// 	#[pallet::extra_constants]
972	/// 	impl<T: Config> Pallet<T> // $optional_where_clause
973	/// 	{
974	/// 	#[pallet::constant_name(SomeU32ConstantName)]
975	/// 		/// Some doc
976	/// 		fn some_u32_constant() -> u32 {
977	/// 			100u32
978	/// 		}
979	/// 	}
980	/// }
981	/// ```
982	///
983	/// I.e. a regular rust `impl` block with some optional where clause and functions with 0
984	/// args, 0 generics, and some return type.
985	pub use frame_support_procedural::extra_constants;
986
987	#[rustfmt::skip]
988	/// Allows bypassing the `frame_system::Config` supertrait check.
989	///
990	/// To bypass the syntactic `frame_system::Config` supertrait check, use the attribute
991	/// `pallet::disable_frame_system_supertrait_check`.
992	///
993	/// Note this bypass is purely syntactic, and does not actually remove the requirement that your
994	/// pallet implements `frame_system::Config`. When using this check, your config is still required to implement
995	/// `frame_system::Config` either via
996	/// - Implementing a trait that itself implements `frame_system::Config`
997	/// - Tightly coupling it with another pallet which itself implements `frame_system::Config`
998	///
999	/// e.g.
1000	///
1001	/// ```
1002	/// #[frame_support::pallet]
1003	/// mod pallet {
1004	/// # 	use frame_support::pallet_prelude::*;
1005	/// # 	use frame_system::pallet_prelude::*;
1006	/// 	trait OtherTrait: frame_system::Config {}
1007	///
1008	/// 	#[pallet::pallet]
1009	/// 	pub struct Pallet<T>(_);
1010	///
1011	/// 	#[pallet::config]
1012	/// 	#[pallet::disable_frame_system_supertrait_check]
1013	/// 	pub trait Config: OtherTrait {}
1014	/// }
1015	/// ```
1016	///
1017	/// To learn more about supertraits, see the
1018	/// [trait_based_programming](../../polkadot_sdk_docs/reference_docs/trait_based_programming/index.html)
1019	/// reference doc.
1020	pub use frame_support_procedural::disable_frame_system_supertrait_check;
1021
1022	/// The mandatory attribute allowing definition of configurable types for the pallet.
1023	///
1024	/// Item must be defined as:
1025	///
1026	/// ```
1027	/// #[frame_support::pallet]
1028	/// mod pallet {
1029	/// # 	use frame_support::pallet_prelude::*;
1030	/// #
1031	/// 	#[pallet::pallet]
1032	/// 	pub struct Pallet<T>(_);
1033	///
1034	/// 	#[pallet::config]
1035	/// 	pub trait Config: frame_system::Config // + $optionally_some_other_supertraits
1036	/// 	// $optional_where_clause
1037	/// 	{
1038	/// 		// config items here
1039	/// 	}
1040	/// }
1041	/// ```
1042	///
1043	/// I.e. a regular trait definition named `Config`, with the supertrait
1044	/// [`frame_system::pallet::Config`](../../frame_system/pallet/trait.Config.html), and
1045	/// optionally other supertraits and a where clause. (Specifying other supertraits here is
1046	/// known as [tight coupling](https://docs.substrate.io/reference/how-to-guides/pallet-design/use-tight-coupling/))
1047	///
1048	/// ## Optional: `with_default`
1049	///
1050	/// An optional `with_default` argument may also be specified. Doing so will automatically
1051	/// generate a `DefaultConfig` trait inside your pallet which is suitable for use with
1052	/// [`#[derive_impl(..)`](`frame_support::derive_impl`) to derive a default testing
1053	/// config:
1054	///
1055	/// ```
1056	/// #[frame_support::pallet]
1057	/// mod pallet {
1058	/// # 	use frame_support::pallet_prelude::*;
1059	/// # 	use frame_system::pallet_prelude::*;
1060	/// # 	use core::fmt::Debug;
1061	/// # 	use frame_support::traits::Contains;
1062	/// #
1063	/// # 	pub trait SomeMoreComplexBound {}
1064	/// #
1065	/// 	#[pallet::pallet]
1066	/// 	pub struct Pallet<T>(_);
1067	///
1068	/// 	#[pallet::config(with_default)] // <- with_default is optional
1069	/// 	pub trait Config: frame_system::Config {
1070	/// 		/// A more complex type.
1071	/// 		#[pallet::no_default] // Example of type where no default should be provided
1072	/// 		type MoreComplexType: SomeMoreComplexBound;
1073	///
1074	/// 		/// A simple type.
1075	/// 		// Default with bounds is supported for simple types
1076	/// 		type SimpleType: From<u32>;
1077	/// 	}
1078	///
1079	/// 	#[pallet::event]
1080	/// 	pub enum Event<T: Config> {
1081	/// 		SomeEvent(u16, u32),
1082	/// 	}
1083	/// }
1084	/// ```
1085	///
1086	/// As shown above:
1087	/// * you may attach the [`#[pallet::no_default]`](`no_default`)
1088	/// attribute to specify that a particular trait item _cannot_ be used as a default when a
1089	/// test `Config` is derived using the [`#[derive_impl(..)]`](`frame_support::derive_impl`)
1090	/// attribute macro. This will cause that particular trait item to simply not appear in
1091	/// default testing configs based on this config (the trait item will not be included in
1092	/// `DefaultConfig`).
1093	/// * you may attach the [`#[pallet::no_default_bounds]`](`no_default_bounds`)
1094	/// attribute to specify that a particular trait item can be used as a default when a
1095	/// test `Config` is derived using the [`#[derive_impl(..)]`](`frame_support::derive_impl`)
1096	/// attribute macro. But its bounds cannot be enforced at this point and should be
1097	/// discarded when generating the default config trait.
1098	/// * you may not specify any attribute to generate a trait item in the default config
1099	///   trait.
1100	///
1101	/// In case origin of error is not clear it is recommended to disable all default with
1102	/// [`#[pallet::no_default]`](`no_default`) and enable them one by one.
1103	///
1104	/// ### `DefaultConfig` Caveats
1105	///
1106	/// The auto-generated `DefaultConfig` trait:
1107	/// - is always a _subset_ of your pallet's `Config` trait.
1108	/// - can only contain items that don't rely on externalities, such as
1109	///   `frame_system::Config`.
1110	///
1111	/// Trait items that _do_ rely on externalities should be marked with
1112	/// [`#[pallet::no_default]`](`no_default`)
1113	///
1114	/// Consequently:
1115	/// - Any items that rely on externalities _must_ be marked with
1116	///   [`#[pallet::no_default]`](`no_default`) or your trait will fail to compile when used
1117	///   with [`derive_impl`](`frame_support::derive_impl`).
1118	/// - Items marked with [`#[pallet::no_default]`](`no_default`) are entirely excluded from
1119	///   the `DefaultConfig` trait, and therefore any impl of `DefaultConfig` doesn't need to
1120	///   implement such items.
1121	///
1122	/// For more information, see:
1123	/// * [`frame_support::derive_impl`].
1124	/// * [`#[pallet::no_default]`](`no_default`)
1125	/// * [`#[pallet::no_default_bounds]`](`no_default_bounds`)
1126	///
1127	/// ## Optional: `without_automatic_metadata`
1128	///
1129	/// By default, the associated types of the `Config` trait that require the `TypeInfo` or
1130	/// `Parameter` bounds are included in the metadata of the pallet.
1131	///
1132	/// The optional `without_automatic_metadata` argument can be used to exclude these
1133	/// associated types from the metadata collection.
1134	///
1135	/// Furthermore, the `without_automatic_metadata` argument can be used in combination with
1136	/// the [`#[pallet::include_metadata]`](`include_metadata`) attribute to selectively
1137	/// include only certain associated types in the metadata collection.
1138	/// ```
1139	/// #[frame_support::pallet]
1140	/// mod pallet {
1141	/// # 	use frame_support::pallet_prelude::*;
1142	/// # 	use frame_system::pallet_prelude::*;
1143	/// # 	use core::fmt::Debug;
1144	/// # 	use frame_support::traits::{Contains, VariantCount};
1145	/// #
1146	/// # 	pub trait SomeMoreComplexBound {}
1147	/// #
1148	/// 	#[pallet::pallet]
1149	/// 	pub struct Pallet<T>(_);
1150	///
1151	/// 	#[pallet::config(with_default, without_automatic_metadata)] // <- with_default and without_automatic_metadata are optional
1152	/// 	pub trait Config: frame_system::Config {
1153	/// 		/// The overarching freeze reason.
1154	/// 		#[pallet::no_default_bounds] // Default with bounds is not supported for RuntimeFreezeReason
1155	/// 		type RuntimeFreezeReason: Parameter + Member + MaxEncodedLen + Copy + VariantCount;
1156	/// 		/// A simple type.
1157	/// 		// Type that would have been included in metadata, but is now excluded.
1158	/// 		type SimpleType: From<u32> + TypeInfo;
1159	///
1160	/// 		// The `pallet::include_metadata` is used to selectively include this type in metadata.
1161	/// 		#[pallet::include_metadata]
1162	/// 		type SelectivelyInclude: From<u32> + TypeInfo;
1163	/// 	}
1164	///
1165	/// 	#[pallet::event]
1166	/// 	pub enum Event<T: Config> {
1167	/// 		SomeEvent(u16, u32),
1168	/// 	}
1169	/// }
1170	/// ```
1171	pub use frame_support_procedural::config;
1172
1173	/// Allows defining an enum that gets composed as an aggregate enum by `construct_runtime`.
1174	///
1175	/// The `#[pallet::composite_enum]` attribute allows you to define an enum that gets
1176	/// composed as an aggregate enum by `construct_runtime`. This is similar in principle with
1177	/// [frame_support_procedural::event] and [frame_support_procedural::error].
1178	///
1179	/// The attribute currently only supports enum definitions, and identifiers that are named
1180	/// `FreezeReason`, `HoldReason`, `LockId` or `SlashReason`. Arbitrary identifiers for the
1181	/// enum are not supported. The aggregate enum generated by
1182	/// [`frame_support::construct_runtime`] will have the name of `RuntimeFreezeReason`,
1183	/// `RuntimeHoldReason`, `RuntimeLockId` and `RuntimeSlashReason` respectively.
1184	///
1185	/// NOTE: The aggregate enum generated by `construct_runtime` generates a conversion
1186	/// function from the pallet enum to the aggregate enum, and automatically derives the
1187	/// following traits:
1188	///
1189	/// ```ignore
1190	/// Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Encode, Decode, MaxEncodedLen, TypeInfo,
1191	/// Debug
1192	/// ```
1193	///
1194	/// For ease of usage, when no `#[derive]` attributes are found for the enum under
1195	/// [`#[pallet::composite_enum]`](composite_enum), the aforementioned traits are
1196	/// automatically derived for it. The inverse is also true: if there are any `#[derive]`
1197	/// attributes found for the enum, then no traits will automatically be derived for it.
1198	///
1199	/// e.g, defining `HoldReason` in a pallet
1200	///
1201	/// ```
1202	/// #[frame_support::pallet]
1203	/// mod pallet {
1204	/// # 	use frame_support::pallet_prelude::*;
1205	/// #
1206	/// 	#[pallet::pallet]
1207	/// 	pub struct Pallet<T>(_);
1208	///
1209	/// 	#[pallet::composite_enum]
1210	/// 	pub enum HoldReason {
1211	/// 		/// The NIS Pallet has reserved it for a non-fungible receipt.
1212	/// 		#[codec(index = 0)]
1213	/// 		SomeHoldReason,
1214	/// 		#[codec(index = 1)]
1215	/// 		SomeOtherHoldReason,
1216	/// 	}
1217	/// #
1218	/// # 	#[pallet::config]
1219	/// # 	pub trait Config: frame_system::Config {}
1220	/// }
1221	pub use frame_support_procedural::composite_enum;
1222
1223	/// Deprecation Notice
1224	///
1225	/// The `#[pallet::validate_unsigned]` attribute has been deprecated and will be removed in
1226	/// a future release. Use [`sp_runtime::traits::TransactionExtension`] instead.
1227	///
1228	/// For more information, see: <https://github.com/paritytech/polkadot-sdk/issues/2415>
1229	/// ---
1230	/// Allows the pallet to validate unsigned transactions.
1231	///
1232	/// Item must be defined as:
1233	///
1234	/// ```
1235	/// #[frame_support::pallet]
1236	/// mod pallet {
1237	/// # 	use frame_support::pallet_prelude::*;
1238	/// #
1239	/// 	#[pallet::pallet]
1240	/// 	pub struct Pallet<T>(_);
1241	///
1242	/// 	#[pallet::validate_unsigned]
1243	/// 	impl<T: Config> sp_runtime::traits::ValidateUnsigned for Pallet<T> {
1244	/// 		type Call = Call<T>;
1245	///
1246	/// 		fn validate_unsigned(_source: TransactionSource, _call: &Self::Call) -> TransactionValidity {
1247	/// 			// Your implementation details here
1248	/// 			unimplemented!()
1249	/// 		}
1250	/// 	}
1251	/// #
1252	/// # 	#[pallet::config]
1253	/// # 	pub trait Config: frame_system::Config {}
1254	/// }
1255	/// ```
1256	///
1257	/// I.e. a trait implementation with bound `T: Config`, of trait
1258	/// [`ValidateUnsigned`](frame_support::pallet_prelude::ValidateUnsigned) for
1259	/// type `Pallet<T>`, and some optional where clause.
1260	///
1261	/// NOTE: There is also the [`sp_runtime::traits::TransactionExtension`] trait that can be
1262	/// used to add some specific logic for transaction validation.
1263	///
1264	/// ## Macro expansion
1265	///
1266	/// The macro currently makes no use of this information, but it might use this information
1267	/// in the future to give information directly to [`frame_support::construct_runtime`].
1268	pub use frame_support_procedural::validate_unsigned;
1269
1270	/// Allows defining	view functions on a pallet.
1271	///
1272	/// A pallet view function is a read-only function providing access to the state of the
1273	/// pallet from both outside and inside the runtime. It should provide a _stable_ interface
1274	/// for querying the state of the pallet, avoiding direct storage access and upgrading
1275	/// along with the runtime.
1276	///
1277	/// ## Syntax
1278	/// View functions methods must be read-only and always return some output. A
1279	/// `view_functions` impl block only allows methods to be defined inside of
1280	/// it.
1281	///
1282	/// ## Example
1283	/// ```
1284	/// #[frame_support::pallet]
1285	/// pub mod pallet {
1286	/// 	use frame_support::pallet_prelude::*;
1287	///
1288	///  	#[pallet::config]
1289	///  	pub trait Config: frame_system::Config {}
1290	///
1291	///  	#[pallet::pallet]
1292	///  	pub struct Pallet<T>(_);
1293	///
1294	///     #[pallet::storage]
1295	/// 	pub type SomeMap<T: Config> = StorageMap<_, Twox64Concat, u32, u32, OptionQuery>;
1296	///
1297	///     #[pallet::view_functions]
1298	///     impl<T: Config> Pallet<T> {
1299	/// 		/// Retrieve a map storage value by key.
1300	///         pub fn get_value_with_arg(key: u32) -> Option<u32> {
1301	/// 			SomeMap::<T>::get(key)
1302	/// 		}
1303	///     }
1304	/// }
1305	/// ```
1306	///
1307	///
1308	/// ## Usage and implementation details
1309	/// To allow outside access to pallet view functions, you need to add a runtime API that
1310	/// accepts view function queries and dispatches them to the right pallet. You can do that
1311	/// by implementing the
1312	/// [`RuntimeViewFunction`](frame_support::view_functions::runtime_api::RuntimeViewFunction)
1313	/// trait for the runtime inside an [`impl_runtime_apis!`](sp_api::impl_runtime_apis)
1314	/// block.
1315	///
1316	/// The `RuntimeViewFunction` trait implements a hashing-based dispatching mechanism to
1317	/// dispatch view functions to the right method in the right pallet based on their IDs. A
1318	/// view function ID depends both on its pallet and on its method signature, so it remains
1319	/// stable as long as those two elements are not modified. In general, pallet view
1320	/// functions should expose a _stable_ interface and changes to the method signature are
1321	/// strongly discouraged. For more details on the dispatching mechanism, see the
1322	/// [`DispatchViewFunction`](frame_support::view_functions::DispatchViewFunction) trait.
1323	pub use frame_support_procedural::view_functions;
1324
1325	/// Allows defining a struct implementing the [`Get`](frame_support::traits::Get) trait to
1326	/// ease the use of storage types.
1327	///
1328	/// This attribute is meant to be used alongside [`#[pallet::storage]`](`storage`) to
1329	/// define a storage's default value. This attribute can be used multiple times.
1330	///
1331	/// Item must be defined as:
1332	///
1333	/// ```
1334	/// #[frame_support::pallet]
1335	/// mod pallet {
1336	/// # 	use sp_runtime::FixedU128;
1337	/// # 	use frame_support::pallet_prelude::*;
1338	/// #
1339	/// 	#[pallet::pallet]
1340	/// 	pub struct Pallet<T>(_);
1341	///
1342	/// 	#[pallet::storage]
1343	/// 	pub(super) type SomeStorage<T: Config> =
1344	/// 		StorageValue<_, FixedU128, ValueQuery, DefaultForSomeValue>;
1345	///
1346	/// 	// Define default for ParachainId
1347	/// 	#[pallet::type_value]
1348	/// 	pub fn DefaultForSomeValue() -> FixedU128 {
1349	/// 		FixedU128::from_u32(1)
1350	/// 	}
1351	/// #
1352	/// # 	#[pallet::config]
1353	/// # 	pub trait Config: frame_system::Config {}
1354	/// }
1355	/// ```
1356	///
1357	/// ## Macro expansion
1358	///
1359	/// The macro renames the function to some internal name, generates a struct with the
1360	/// original name of the function and its generic, and implements `Get<$ReturnType>` by
1361	/// calling the user defined function.
1362	pub use frame_support_procedural::type_value;
1363
1364	/// Allows defining a storage version for the pallet.
1365	///
1366	/// Because the `pallet::pallet` macro implements
1367	/// [`GetStorageVersion`](frame_support::traits::GetStorageVersion), the current storage
1368	/// version needs to be communicated to the macro. This can be done by using the
1369	/// `pallet::storage_version` attribute:
1370	///
1371	/// ```
1372	/// #[frame_support::pallet]
1373	/// mod pallet {
1374	/// # 	use frame_support::pallet_prelude::StorageVersion;
1375	/// # 	use frame_support::traits::GetStorageVersion;
1376	/// #
1377	/// 	const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
1378	///
1379	/// 	#[pallet::pallet]
1380	/// 	#[pallet::storage_version(STORAGE_VERSION)]
1381	/// 	pub struct Pallet<T>(_);
1382	/// #
1383	/// # 	#[pallet::config]
1384	/// # 	pub trait Config: frame_system::Config {}
1385	/// }
1386	/// ```
1387	///
1388	/// If not present, the current storage version is set to the default value.
1389	pub use frame_support_procedural::storage_version;
1390
1391	/// The `#[pallet::hooks]` attribute allows you to specify a
1392	/// [`frame_support::traits::Hooks`] implementation for `Pallet` that specifies
1393	/// pallet-specific logic.
1394	///
1395	/// The item the attribute attaches to must be defined as follows:
1396	///
1397	/// ```
1398	/// #[frame_support::pallet]
1399	/// mod pallet {
1400	/// # 	use frame_support::pallet_prelude::*;
1401	/// # 	use frame_system::pallet_prelude::*;
1402	/// #
1403	/// 	#[pallet::pallet]
1404	/// 	pub struct Pallet<T>(_);
1405	///
1406	/// 	#[pallet::hooks]
1407	/// 	impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {
1408	/// 		// Implement hooks here
1409	/// 	}
1410	/// #
1411	/// # 	#[pallet::config]
1412	/// # 	pub trait Config: frame_system::Config {}
1413	/// }
1414	/// ```
1415	/// I.e. a regular trait implementation with generic bound: `T: Config`, for the trait
1416	/// `Hooks<BlockNumberFor<T>>` (they are defined in preludes), for the type `Pallet<T>`.
1417	///
1418	/// Optionally, you could add a where clause.
1419	///
1420	/// ## Macro expansion
1421	///
1422	/// The macro implements the traits
1423	/// [`OnInitialize`](frame_support::traits::OnInitialize),
1424	/// [`OnIdle`](frame_support::traits::OnIdle),
1425	/// [`OnFinalize`](frame_support::traits::OnFinalize),
1426	/// [`OnRuntimeUpgrade`](frame_support::traits::OnRuntimeUpgrade),
1427	/// [`OffchainWorker`](frame_support::traits::OffchainWorker), and
1428	/// [`IntegrityTest`](frame_support::traits::IntegrityTest) using
1429	/// the provided [`Hooks`](frame_support::traits::Hooks) implementation.
1430	///
1431	/// NOTE: `OnRuntimeUpgrade` is implemented with `Hooks::on_runtime_upgrade` and some
1432	/// additional logic. E.g. logic to write the pallet version into storage.
1433	///
1434	/// NOTE: The macro also adds some tracing logic when implementing the above traits. The
1435	/// following hooks emit traces: `on_initialize`, `on_finalize` and `on_runtime_upgrade`.
1436	pub use frame_support_procedural::hooks;
1437
1438	/// Generates a helper function on `Pallet` that handles deposit events.
1439	///
1440	/// NOTE: For instantiable pallets, the event must be generic over `T` and `I`.
1441	///
1442	/// ## Macro expansion
1443	///
1444	/// The macro will add on enum `Event` the attributes:
1445	/// * `#[derive(`[`frame_support::CloneNoBound`]`)]`
1446	/// * `#[derive(`[`frame_support::EqNoBound`]`)]`
1447	/// * `#[derive(`[`frame_support::PartialEqNoBound`]`)]`
1448	/// * `#[derive(`[`frame_support::DebugNoBound`]`)]`
1449	/// * `#[derive(`[`codec::Encode`]`)]`
1450	/// * `#[derive(`[`codec::Decode`]`)]`
1451	///
1452	/// The macro implements `From<Event<..>>` for ().
1453	///
1454	/// The macro implements a metadata function on `Event` returning the `EventMetadata`.
1455	///
1456	/// If `#[pallet::generate_deposit]` is present then the macro implements `fn
1457	/// deposit_event` on `Pallet`.
1458	pub use frame_support_procedural::generate_deposit;
1459
1460	/// Allows defining logic to make an extrinsic call feeless.
1461	///
1462	/// Each dispatchable may be annotated with the `#[pallet::feeless_if($closure)]`
1463	/// attribute, which explicitly defines the condition for the dispatchable to be feeless.
1464	///
1465	/// The arguments for the closure must be the referenced arguments of the dispatchable
1466	/// function.
1467	///
1468	/// The closure must return `bool`.
1469	///
1470	/// ### Example
1471	///
1472	/// ```
1473	/// #[frame_support::pallet(dev_mode)]
1474	/// mod pallet {
1475	/// # 	use frame_support::pallet_prelude::*;
1476	/// # 	use frame_system::pallet_prelude::*;
1477	/// #
1478	/// 	#[pallet::pallet]
1479	/// 	pub struct Pallet<T>(_);
1480	///
1481	/// 	#[pallet::call]
1482	/// 	impl<T: Config> Pallet<T> {
1483	/// 		#[pallet::call_index(0)]
1484	/// 		/// Marks this call as feeless if `foo` is zero.
1485	/// 		#[pallet::feeless_if(|_origin: &OriginFor<T>, foo: &u32| -> bool {
1486	/// 			*foo == 0
1487	/// 		})]
1488	/// 		pub fn something(
1489	/// 			_: OriginFor<T>,
1490	/// 			foo: u32,
1491	/// 		) -> DispatchResult {
1492	/// 			unimplemented!()
1493	/// 		}
1494	/// 	}
1495	/// #
1496	/// # 	#[pallet::config]
1497	/// # 	pub trait Config: frame_system::Config {}
1498	/// }
1499	/// ```
1500	///
1501	/// Please note that this only works for signed dispatchables and requires a transaction
1502	/// extension such as [`pallet_skip_feeless_payment::SkipCheckIfFeeless`] to wrap the
1503	/// existing payment extension. Else, this is completely ignored and the dispatchable is
1504	/// still charged.
1505	///
1506	/// Also this will not allow accountless caller to send a transaction if some transaction
1507	/// extension such as `frame_system::CheckNonce` is used.
1508	/// Extensions such as `frame_system::CheckNonce` require a funded account to validate
1509	/// the transaction.
1510	///
1511	/// ### Macro expansion
1512	///
1513	/// The macro implements the [`pallet_skip_feeless_payment::CheckIfFeeless`] trait on the
1514	/// dispatchable and calls the corresponding closure in the implementation.
1515	///
1516	/// [`pallet_skip_feeless_payment::SkipCheckIfFeeless`]: ../../pallet_skip_feeless_payment/struct.SkipCheckIfFeeless.html
1517	/// [`pallet_skip_feeless_payment::CheckIfFeeless`]: ../../pallet_skip_feeless_payment/struct.SkipCheckIfFeeless.html
1518	pub use frame_support_procedural::feeless_if;
1519
1520	/// Allows defining an error enum that will be returned from the dispatchable when an error
1521	/// occurs.
1522	///
1523	/// The information for this error type is then stored in runtime metadata.
1524	///
1525	/// Item must be defined as so:
1526	///
1527	/// ```
1528	/// #[frame_support::pallet(dev_mode)]
1529	/// mod pallet {
1530	/// 	#[pallet::pallet]
1531	/// 	pub struct Pallet<T>(_);
1532	///
1533	/// 	#[pallet::error]
1534	/// 	pub enum Error<T> {
1535	/// 		/// SomeFieldLessVariant doc
1536	/// 		SomeFieldLessVariant,
1537	/// 		/// SomeVariantWithOneField doc
1538	/// 		SomeVariantWithOneField(u32),
1539	/// 	}
1540	/// #
1541	/// # 	#[pallet::config]
1542	/// # 	pub trait Config: frame_system::Config {}
1543	/// }
1544	/// ```
1545	/// I.e. a regular enum named `Error`, with generic `T` and fieldless or multiple-field
1546	/// variants.
1547	///
1548	/// Any field type in the enum variants must implement [`scale_info::TypeInfo`] in order to
1549	/// be properly used in the metadata, and its encoded size should be as small as possible,
1550	/// preferably 1 byte in size in order to reduce storage size. The error enum itself has an
1551	/// absolute maximum encoded size specified by
1552	/// [`frame_support::MAX_MODULE_ERROR_ENCODED_SIZE`].
1553	///
1554	/// (1 byte can still be 256 different errors. The more specific the error, the easier it
1555	/// is to diagnose problems and give a better experience to the user. Don't skimp on having
1556	/// lots of individual error conditions.)
1557	///
1558	/// Field types in enum variants must also implement [`frame_support::PalletError`],
1559	/// otherwise the pallet will fail to compile. Rust primitive types have already
1560	/// implemented the [`frame_support::PalletError`] trait along with some commonly used
1561	/// stdlib types such as [`Option`] and [`core::marker::PhantomData`], and hence
1562	/// in most use cases, a manual implementation is not necessary and is discouraged.
1563	///
1564	/// The generic `T` must not bound anything and a `where` clause is not allowed. That said,
1565	/// bounds and/or a where clause should not needed for any use-case.
1566	///
1567	/// ## Macro expansion
1568	///
1569	/// The macro implements the [`Debug`] trait and functions `as_u8` using variant position,
1570	/// and `as_str` using variant doc.
1571	///
1572	/// The macro also implements `From<Error<T>>` for `&'static str` and `From<Error<T>>` for
1573	/// `DispatchError`.
1574	///
1575	/// ## Note on deprecation of Errors
1576	///
1577	/// - Usage of `deprecated` attribute will propagate deprecation information to the pallet
1578	///   metadata where the item was declared.
1579	/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
1580	/// - It's possible to deprecated either certain variants inside the `Error` or the whole
1581	///   `Error` itself. If both the `Error` and its variants are deprecated a compile error
1582	///   will be returned.
1583	/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
1584	///   generated code.
1585	/// - If the item is annotated with `deprecated` attribute then the generated code will be
1586	///   automatically annotated with `allow(deprecated)`
1587	pub use frame_support_procedural::error;
1588
1589	/// Allows defining pallet events.
1590	///
1591	/// Pallet events are stored under the `system` / `events` key when the block is applied
1592	/// (and then replaced when the next block writes it's events).
1593	///
1594	/// The Event enum can be defined as follows:
1595	///
1596	/// ```
1597	/// #[frame_support::pallet(dev_mode)]
1598	/// mod pallet {
1599	/// #     use frame_support::pallet_prelude::IsType;
1600	/// #
1601	/// 	#[pallet::pallet]
1602	/// 	pub struct Pallet<T>(_);
1603	///
1604	/// 	#[pallet::config]
1605	/// 	pub trait Config: frame_system::Config {}
1606	///
1607	/// 	#[pallet::event]
1608	/// 	#[pallet::generate_deposit(fn deposit_event)] // Optional
1609	/// 	pub enum Event<T> {
1610	/// 		/// SomeEvent doc
1611	/// 		SomeEvent(u16, u32), // SomeEvent with two fields
1612	/// 	}
1613	/// }
1614	/// ```
1615	///
1616	/// I.e. an enum (with named or unnamed fields variant), named `Event`, with generic: none
1617	/// or `T` or `T: Config`, and optional w here clause.
1618	///
1619	/// Macro expansion automatically appends `From<Event<Self>>` bound to
1620	/// system supertrait's `RuntimeEvent `associated type, i.e:
1621	///
1622	/// ```rs
1623	/// 	#[pallet::config]
1624	/// 	pub trait Config: frame_system::Config<RuntimeEvent: From<Event<Self>>> {}
1625	/// ```
1626	///
1627	/// Each field must implement [`Clone`], [`Eq`], [`PartialEq`], [`codec::Encode`],
1628	/// [`codec::Decode`], and [`Debug`] (on std only). For ease of use, bound by the trait
1629	/// `Member`, available in [`frame_support::pallet_prelude`].
1630	///
1631	/// ## Note on deprecation of Events
1632	///
1633	/// - Usage of `deprecated` attribute will propagate deprecation information to the pallet
1634	///   metadata where the item was declared.
1635	/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
1636	/// - It's possible to deprecated either certain variants inside the `Event` or the whole
1637	///   `Event` itself. If both the `Event` and its variants are deprecated a compile error
1638	///   will be returned.
1639	/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
1640	///   generated code.
1641	/// - If the item is annotated with `deprecated` attribute then the generated code will be
1642	///   automatically annotated with `allow(deprecated)`
1643	pub use frame_support_procedural::event;
1644
1645	/// Selectively includes associated types in the metadata.
1646	///
1647	/// The optional attribute allows you to selectively include associated types in the
1648	/// metadata. This can be attached to trait items that implement `TypeInfo`.
1649	///
1650	/// By default all collectable associated types are included in the metadata.
1651	///
1652	/// This attribute can be used in combination with the
1653	/// [`#[pallet::config(without_automatic_metadata)]`](`config`).
1654	pub use frame_support_procedural::include_metadata;
1655
1656	/// Allows a pallet to declare a set of functions as a *dispatchable extrinsic*.
1657	///
1658	/// In slightly simplified terms, this macro declares the set of "transactions" of a
1659	/// pallet.
1660	///
1661	/// > The exact definition of **extrinsic** can be found in
1662	/// > [`sp_runtime::generic::UncheckedExtrinsic`].
1663	///
1664	/// A **dispatchable** is a common term in FRAME, referring to process of constructing a
1665	/// function, and dispatching it with the correct inputs. This is commonly used with
1666	/// extrinsics, for example "an extrinsic has been dispatched". See
1667	/// [`sp_runtime::traits::Dispatchable`] and [`crate::traits::UnfilteredDispatchable`].
1668	///
1669	/// ## Call Enum
1670	///
1671	/// The macro is called `call` (rather than `#[pallet::extrinsics]`) because of the
1672	/// generation of a `enum Call`. This enum contains only the encoding of the function
1673	/// arguments of the dispatchable, alongside the information needed to route it to the
1674	/// correct function.
1675	///
1676	/// The macro also ensures that the extrinsic when invoked will be wrapped via
1677	/// [`frame_support::storage::with_storage_layer`] to make it transactional. Thus if the
1678	/// extrinsic returns with an error any state changes that had already occurred will be
1679	/// rolled back.
1680	///
1681	/// ```
1682	/// #[frame_support::pallet(dev_mode)]
1683	/// pub mod custom_pallet {
1684	/// #   use frame_support::pallet_prelude::*;
1685	/// #   use frame_system::pallet_prelude::*;
1686	/// #   #[pallet::config]
1687	/// #   pub trait Config: frame_system::Config {}
1688	/// #   #[pallet::pallet]
1689	/// #   pub struct Pallet<T>(_);
1690	/// #   use frame_support::traits::BuildGenesisConfig;
1691	///     #[pallet::call]
1692	///     impl<T: Config> Pallet<T> {
1693	///         pub fn some_dispatchable(_origin: OriginFor<T>, _input: u32) -> DispatchResult {
1694	///             Ok(())
1695	///         }
1696	///         pub fn other(_origin: OriginFor<T>, _input: u64) -> DispatchResult {
1697	///             Ok(())
1698	///         }
1699	///     }
1700	///
1701	///     // generates something like:
1702	///     // enum Call<T: Config> {
1703	///     //  some_dispatchable { input: u32 }
1704	///     //  other { input: u64 }
1705	///     // }
1706	/// }
1707	///
1708	/// fn main() {
1709	/// #   use frame_support::{derive_impl, construct_runtime};
1710	/// #   use frame_support::__private::codec::Encode;
1711	/// #   use frame_support::__private::TestExternalities;
1712	/// #   use frame_support::traits::UnfilteredDispatchable;
1713	/// #    impl custom_pallet::Config for Runtime {}
1714	/// #    #[derive_impl(frame_system::config_preludes::TestDefaultConfig)]
1715	/// #    impl frame_system::Config for Runtime {
1716	/// #        type Block = frame_system::mocking::MockBlock<Self>;
1717	/// #    }
1718	///     construct_runtime! {
1719	///         pub enum Runtime {
1720	///             System: frame_system,
1721	///             Custom: custom_pallet
1722	///         }
1723	///     }
1724	///
1725	/// #    TestExternalities::new_empty().execute_with(|| {
1726	///     let origin: RuntimeOrigin = frame_system::RawOrigin::Signed(10).into();
1727	///     // calling into a dispatchable from within the runtime is simply a function call.
1728	///         let _ = custom_pallet::Pallet::<Runtime>::some_dispatchable(origin.clone(), 10);
1729	///
1730	///     // calling into a dispatchable from the outer world involves constructing the bytes of
1731	///     let call = custom_pallet::Call::<Runtime>::some_dispatchable { input: 10 };
1732	///     let _ = call.clone().dispatch_bypass_filter(origin);
1733	///
1734	///     // the routing of a dispatchable is simply done through encoding of the `Call` enum,
1735	///     // which is the index of the variant, followed by the arguments.
1736	///     assert_eq!(call.encode(), vec![0u8, 10, 0, 0, 0]);
1737	///
1738	///     // notice how in the encoding of the second function, the first byte is different and
1739	///     // referring to the second variant of `enum Call`.
1740	///     let call = custom_pallet::Call::<Runtime>::other { input: 10 };
1741	///     assert_eq!(call.encode(), vec![1u8, 10, 0, 0, 0, 0, 0, 0, 0]);
1742	///     #    });
1743	/// }
1744	/// ```
1745	///
1746	/// Further properties of dispatchable functions are as follows:
1747	///
1748	/// - Unless if annotated by `dev_mode`, it must contain [`weight`] to denote the
1749	///   pre-dispatch weight consumed.
1750	/// - The dispatchable must declare its index via [`call_index`], which can override the
1751	///   position of a function in `enum Call`.
1752	/// - The first argument is always an `OriginFor` (or `T::RuntimeOrigin`).
1753	/// - The return type is always [`crate::dispatch::DispatchResult`] (or
1754	///   [`crate::dispatch::DispatchResultWithPostInfo`]).
1755	///
1756	/// **WARNING**: modifying dispatchables, changing their order (i.e. using [`call_index`]),
1757	/// removing some, etc., must be done with care. This will change the encoding of the call,
1758	/// and the call can be stored on-chain (e.g. in `pallet-scheduler`). Thus, migration
1759	/// might be needed. This is why the use of `call_index` is mandatory by default in FRAME.
1760	///
1761	/// ## Weight info
1762	///
1763	/// Each call needs to define a weight.
1764	/// * The weight can be defined explicitly using the attribute `#[pallet::weight($expr)]`
1765	///   (Note that argument of the call are available inside the expression).
1766	/// * Or it can be defined implicitly, the weight info for the calls needs to be specified
1767	///   in the call attribute: `#[pallet::call(weight = $WeightInfo)]`, then each call that
1768	///   doesn't have explicit weight will use `$WeightInfo::$call_name` as the weight.
1769	///
1770	/// * Or it can be simply ignored when the pallet is in `dev_mode`.
1771	///
1772	/// ```
1773	/// #[frame_support::pallet]
1774	/// mod pallet {
1775	///     use frame_support::pallet_prelude::*;
1776	///     use frame_system::pallet_prelude::*;
1777	///
1778	///     #[pallet::pallet]
1779	///     pub struct Pallet<T>(_);
1780	///
1781	///     #[pallet::config]
1782	///     pub trait Config: frame_system::Config {
1783	///         /// Type for specifying dispatchable weights.
1784	///         type WeightInfo: WeightInfo;
1785	///     }
1786	///
1787	///     /// The `WeightInfo` trait defines weight functions for dispatchable calls.
1788	///     pub trait WeightInfo {
1789	///         fn do_something() -> Weight;
1790	///         fn do_something_else() -> Weight;
1791	///     }
1792	///
1793	///     #[pallet::call(weight = <T as Config>::WeightInfo)]
1794	///     impl<T: Config> Pallet<T> {
1795	///         // Explicit weight definition using `#[pallet::weight(...)]`
1796	///         #[pallet::weight(<T as Config>::WeightInfo::do_something())]
1797	///         #[pallet::call_index(0)]
1798	///         pub fn do_something(
1799	///             origin: OriginFor<T>,
1800	///             foo: u32,
1801	///         ) -> DispatchResult {
1802	///             // Function logic here
1803	///             Ok(())
1804	///         }
1805	///
1806	///         // Implicit weight definition, the macro looks up to the weight info defined in
1807	///         // `#[pallet::call(weight = $WeightInfo)]` attribute. Then use
1808	///         // `$WeightInfo::do_something_else` as the weight function.
1809	///         #[pallet::call_index(1)]
1810	///         pub fn do_something_else(
1811	///             origin: OriginFor<T>,
1812	///             bar: u64,
1813	///         ) -> DispatchResult {
1814	///             // Function logic here
1815	///             Ok(())
1816	///         }
1817	///     }
1818	/// }
1819	/// ```
1820	///
1821	/// ## Default Behavior
1822	///
1823	/// If no `#[pallet::call]` exists, then a default implementation corresponding to the
1824	/// following code is automatically generated:
1825	///
1826	/// ```
1827	/// #[frame_support::pallet(dev_mode)]
1828	/// mod pallet {
1829	/// 	#[pallet::pallet]
1830	/// 	pub struct Pallet<T>(_);
1831	///
1832	/// 	#[pallet::call] // <- automatically generated
1833	/// 	impl<T: Config> Pallet<T> {} // <- automatically generated
1834	///
1835	/// 	#[pallet::config]
1836	/// 	pub trait Config: frame_system::Config {}
1837	/// }
1838	/// ```
1839	///
1840	/// ## Note on deprecation of Calls
1841	///
1842	/// - Usage of `deprecated` attribute will propagate deprecation information to the pallet
1843	///   metadata where the item was declared.
1844	/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
1845	/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
1846	///   generated code.
1847	/// - If the item is annotated with `deprecated` attribute then the generated code will be
1848	///   automatically annotated with `allow(deprecated)`
1849	pub use frame_support_procedural::call;
1850
1851	/// Enforce the index of a variant in the generated `enum Call`.
1852	///
1853	/// See [`call`] for more information.
1854	///
1855	/// All call indexes start from 0, until it encounters a dispatchable function with a
1856	/// defined call index. The dispatchable function that lexically follows the function with
1857	/// a defined call index will have that call index, but incremented by 1, e.g. if there are
1858	/// 3 dispatchable functions `fn foo`, `fn bar` and `fn qux` in that order, and only `fn
1859	/// bar` has a call index of 10, then `fn qux` will have an index of 11, instead of 1.
1860	pub use frame_support_procedural::call_index;
1861
1862	/// Declares the arguments of a [`call`] function to be encoded using
1863	/// [`codec::Compact`].
1864	///
1865	/// This will results in smaller extrinsic encoding.
1866	///
1867	/// A common example of `compact` is for numeric values that are often times far far away
1868	/// from their theoretical maximum. For example, in the context of a crypto-currency, the
1869	/// balance of an individual account is oftentimes way less than what the numeric type
1870	/// allows. In all such cases, using `compact` is sensible.
1871	///
1872	/// ```
1873	/// #[frame_support::pallet(dev_mode)]
1874	/// pub mod custom_pallet {
1875	/// #   use frame_support::pallet_prelude::*;
1876	/// #   use frame_system::pallet_prelude::*;
1877	/// #   #[pallet::config]
1878	/// #   pub trait Config: frame_system::Config {}
1879	/// #   #[pallet::pallet]
1880	/// #   pub struct Pallet<T>(_);
1881	/// #   use frame_support::traits::BuildGenesisConfig;
1882	///     #[pallet::call]
1883	///     impl<T: Config> Pallet<T> {
1884	///         pub fn some_dispatchable(_origin: OriginFor<T>, #[pallet::compact] _input: u32) -> DispatchResult {
1885	///             Ok(())
1886	///         }
1887	///     }
1888	/// }
1889	pub use frame_support_procedural::compact;
1890
1891	/// Allows you to define the genesis configuration for the pallet.
1892	///
1893	/// Item is defined as either an enum or a struct. It needs to be public and implement the
1894	/// trait [`frame_support::traits::BuildGenesisConfig`].
1895	///
1896	/// See [`genesis_build`] for an example.
1897	pub use frame_support_procedural::genesis_config;
1898
1899	/// Allows you to define how the state of your pallet at genesis is built. This
1900	/// takes as input the `GenesisConfig` type (as `self`) and constructs the pallet's initial
1901	/// state.
1902	///
1903	/// The fields of the `GenesisConfig` can in turn be populated by the chain-spec.
1904	///
1905	/// ## Example
1906	///
1907	/// ```
1908	/// #[frame_support::pallet]
1909	/// pub mod pallet {
1910	/// # 	#[pallet::config]
1911	/// # 	pub trait Config: frame_system::Config {}
1912	/// # 	#[pallet::pallet]
1913	/// # 	pub struct Pallet<T>(_);
1914	/// # 	use frame_support::traits::BuildGenesisConfig;
1915	///     #[pallet::genesis_config]
1916	///     #[derive(frame_support::DefaultNoBound)]
1917	///     pub struct GenesisConfig<T: Config> {
1918	///         foo: Vec<T::AccountId>
1919	///     }
1920	///
1921	///     #[pallet::genesis_build]
1922	///     impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
1923	///         fn build(&self) {
1924	///             // use &self to access fields.
1925	///             let foo = &self.foo;
1926	///             todo!()
1927	///         }
1928	///     }
1929	/// }
1930	/// ```
1931	///
1932	/// ## Former Usage
1933	///
1934	/// Prior to <https://github.com/paritytech/substrate/pull/14306>, the following syntax was used.
1935	/// This is deprecated and will soon be removed.
1936	///
1937	/// ```
1938	/// #[frame_support::pallet]
1939	/// pub mod pallet {
1940	/// #     #[pallet::config]
1941	/// #     pub trait Config: frame_system::Config {}
1942	/// #     #[pallet::pallet]
1943	/// #     pub struct Pallet<T>(_);
1944	/// #     use frame_support::traits::GenesisBuild;
1945	///     #[pallet::genesis_config]
1946	///     #[derive(frame_support::DefaultNoBound)]
1947	///     pub struct GenesisConfig<T: Config> {
1948	/// 		foo: Vec<T::AccountId>
1949	/// 	}
1950	///
1951	///     #[pallet::genesis_build]
1952	///     impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
1953	///         fn build(&self) {
1954	///             todo!()
1955	///         }
1956	///     }
1957	/// }
1958	/// ```
1959	pub use frame_support_procedural::genesis_build;
1960
1961	/// Allows adding an associated type trait bounded by
1962	/// [`Get`](frame_support::pallet_prelude::Get) from [`pallet::config`](`macro@config`)
1963	/// into metadata.
1964	///
1965	/// ## Example
1966	///
1967	/// ```
1968	/// #[frame_support::pallet]
1969	/// mod pallet {
1970	///     use frame_support::pallet_prelude::*;
1971	///     # #[pallet::pallet]
1972	///     # pub struct Pallet<T>(_);
1973	///     #[pallet::config]
1974	///     pub trait Config: frame_system::Config {
1975	/// 		/// This is like a normal `Get` trait, but it will be added into metadata.
1976	/// 		#[pallet::constant]
1977	/// 		type Foo: Get<u32>;
1978	/// 	}
1979	/// }
1980	/// ```
1981	///
1982	/// ## Note on deprecation of constants
1983	///
1984	/// - Usage of `deprecated` attribute will propagate deprecation information to the pallet
1985	///   metadata where the item was declared.
1986	/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
1987	/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
1988	///   generated code.
1989	/// - If the item is annotated with `deprecated` attribute then the generated code will be
1990	///   automatically annotated with `allow(deprecated)`
1991	pub use frame_support_procedural::constant;
1992
1993	/// Declares a type alias as a storage item.
1994	///
1995	/// Storage items are pointers to data stored on-chain (the *blockchain state*), under a
1996	/// specific key. The exact key is dependent on the type of the storage.
1997	///
1998	/// > From the perspective of this pallet, the entire blockchain state is abstracted behind
1999	/// > a key-value api, namely [`sp_io::storage`].
2000	///
2001	/// ## Storage Types
2002	///
2003	/// The following storage types are supported by the `#[storage]` macro. For specific
2004	/// information about each storage type, refer to the documentation of the respective type.
2005	///
2006	/// * [`StorageValue`](crate::storage::types::StorageValue)
2007	/// * [`StorageMap`](crate::storage::types::StorageMap)
2008	/// * [`CountedStorageMap`](crate::storage::types::CountedStorageMap)
2009	/// * [`StorageDoubleMap`](crate::storage::types::StorageDoubleMap)
2010	/// * [`StorageNMap`](crate::storage::types::StorageNMap)
2011	/// * [`CountedStorageNMap`](crate::storage::types::CountedStorageNMap)
2012	///
2013	/// ## Storage Type Usage
2014	///
2015	/// The following details are relevant to all of the aforementioned storage types.
2016	/// Depending on the exact storage type, it may require the following generic parameters:
2017	///
2018	/// * [`Prefix`](#prefixes) - Used to give the storage item a unique key in the underlying
2019	///   storage.
2020	/// * `Key` - Type of the keys used to store the values,
2021	/// * `Value` - Type of the value being stored,
2022	/// * [`Hasher`](#hashers) - Used to ensure the keys of a map are uniformly distributed,
2023	/// * [`QueryKind`](#querykind) - Used to configure how to handle queries to the underlying
2024	///   storage,
2025	/// * `OnEmpty` - Used to handle missing values when querying the underlying storage,
2026	/// * `MaxValues` - _not currently used_.
2027	///
2028	/// Each `Key` type requires its own designated `Hasher` declaration, so that
2029	/// [`StorageDoubleMap`](frame_support::storage::types::StorageDoubleMap) needs two of
2030	/// each, and [`StorageNMap`](frame_support::storage::types::StorageNMap) needs `N` such
2031	/// pairs. Since [`StorageValue`](frame_support::storage::types::StorageValue) only stores
2032	/// a single element, no configuration of hashers is needed.
2033	///
2034	/// ### Syntax
2035	///
2036	/// Two general syntaxes are supported, as demonstrated below:
2037	///
2038	/// 1. Named type parameters, e.g., `type Foo<T> = StorageValue<Value = u32>`.
2039	/// 2. Positional type parameters, e.g., `type Foo<T> = StorageValue<_, u32>`.
2040	///
2041	/// In both instances, declaring the generic parameter `<T>` is mandatory. Optionally, it
2042	/// can also be explicitly declared as `<T: Config>`. In the compiled code, `T` will
2043	/// automatically include the trait bound `Config`.
2044	///
2045	/// Note that in positional syntax, the first generic type parameter must be `_`.
2046	///
2047	/// #### Example
2048	///
2049	/// ```
2050	/// #[frame_support::pallet]
2051	/// mod pallet {
2052	///     # use frame_support::pallet_prelude::*;
2053	///     # #[pallet::config]
2054	///     # pub trait Config: frame_system::Config {}
2055	///     # #[pallet::pallet]
2056	///     # pub struct Pallet<T>(_);
2057	///     /// Positional syntax, without bounding `T`.
2058	///     #[pallet::storage]
2059	///     pub type Foo<T> = StorageValue<_, u32>;
2060	///
2061	///     /// Positional syntax, with bounding `T`.
2062	///     #[pallet::storage]
2063	///     pub type Bar<T: Config> = StorageValue<_, u32>;
2064	///
2065	///     /// Named syntax.
2066	///     #[pallet::storage]
2067	///     pub type Baz<T> = StorageMap<Hasher = Blake2_128Concat, Key = u32, Value = u32>;
2068	/// }
2069	/// ```
2070	///
2071	/// ### Value Trait Bounds
2072	///
2073	/// To use a type as the value of a storage type, be it `StorageValue`, `StorageMap` or
2074	/// anything else, you need to meet a number of trait bound constraints.
2075	///
2076	/// See: <https://paritytech.github.io/polkadot-sdk/master/polkadot_sdk_docs/reference_docs/frame_storage_derives/index.html>.
2077	///
2078	/// Notably, all value types need to implement `Encode`, `Decode`, `MaxEncodedLen` and
2079	/// `TypeInfo`, and possibly `Default`, if
2080	/// [`ValueQuery`](frame_support::storage::types::ValueQuery) is used, explained in the
2081	/// next section.
2082	///
2083	/// ### QueryKind
2084	///
2085	/// Every storage type mentioned above has a generic type called
2086	/// [`QueryKind`](frame_support::storage::types::QueryKindTrait) that determines its
2087	/// "query" type. This refers to the kind of value returned when querying the storage, for
2088	/// instance, through a `::get()` method.
2089	///
2090	/// There are three types of queries:
2091	///
2092	/// 1. [`OptionQuery`](frame_support::storage::types::OptionQuery): The default query type.
2093	///    It returns `Some(V)` if the value is present, or `None` if it isn't, where `V` is
2094	///    the value type.
2095	/// 2. [`ValueQuery`](frame_support::storage::types::ValueQuery): Returns the value itself
2096	///    if present; otherwise, it returns `Default::default()`. This behavior can be
2097	///    adjusted with the `OnEmpty` generic parameter, which defaults to `OnEmpty =
2098	///    GetDefault`.
2099	/// 3. [`ResultQuery`](frame_support::storage::types::ResultQuery): Returns `Result<V, E>`,
2100	///    where `V` is the value type.
2101	///
2102	/// See [`QueryKind`](frame_support::storage::types::QueryKindTrait) for further examples.
2103	///
2104	/// ### Optimized Appending
2105	///
2106	/// All storage items — such as
2107	/// [`StorageValue`](frame_support::storage::types::StorageValue),
2108	/// [`StorageMap`](frame_support::storage::types::StorageMap), and their variants—offer an
2109	/// `::append()` method optimized for collections. Using this method avoids the
2110	/// inefficiency of decoding and re-encoding entire collections when adding items. For
2111	/// instance, consider the storage declaration `type MyVal<T> = StorageValue<_, Vec<u8>,
2112	/// ValueQuery>`. With `MyVal` storing a large list of bytes, `::append()` lets you
2113	/// directly add bytes to the end in storage without processing the full list. Depending on
2114	/// the storage type, additional key specifications may be needed.
2115	///
2116	/// #### Example
2117	#[doc = docify::embed!("src/lib.rs", example_storage_value_append)]
2118	/// Similarly, there also exists a `::try_append()` method, which can be used when handling
2119	/// types where an append operation might fail, such as a
2120	/// [`BoundedVec`](frame_support::BoundedVec).
2121	///
2122	/// #### Example
2123	#[doc = docify::embed!("src/lib.rs", example_storage_value_try_append)]
2124	/// ### Optimized Length Decoding
2125	///
2126	/// All storage items — such as
2127	/// [`StorageValue`](frame_support::storage::types::StorageValue),
2128	/// [`StorageMap`](frame_support::storage::types::StorageMap), and their counterparts —
2129	/// incorporate the `::decode_len()` method. This method allows for efficient retrieval of
2130	/// a collection's length without the necessity of decoding the entire dataset.
2131	/// #### Example
2132	#[doc = docify::embed!("src/lib.rs", example_storage_value_decode_len)]
2133	/// ### Hashers
2134	///
2135	/// For all storage types, except
2136	/// [`StorageValue`](frame_support::storage::types::StorageValue), a set of hashers needs
2137	/// to be specified. The choice of hashers is crucial, especially in production chains. The
2138	/// purpose of storage hashers in maps is to ensure the keys of a map are
2139	/// uniformly distributed. An unbalanced map/trie can lead to inefficient performance.
2140	///
2141	/// In general, hashers are categorized as either cryptographically secure or not. The
2142	/// former is slower than the latter. `Blake2` and `Twox` serve as examples of each,
2143	/// respectively.
2144	///
2145	/// As a rule of thumb:
2146	///
2147	/// 1. If the map keys are not controlled by end users, or are cryptographically secure by
2148	/// definition (e.g., `AccountId`), then the use of cryptographically secure hashers is NOT
2149	/// required.
2150	/// 2. If the map keys are controllable by the end users, cryptographically secure hashers
2151	/// should be used.
2152	///
2153	/// For more information, look at the types that implement
2154	/// [`frame_support::StorageHasher`](frame_support::StorageHasher).
2155	///
2156	/// Lastly, it's recommended for hashers with "concat" to have reversible hashes. Refer to
2157	/// the implementors section of
2158	/// [`hash::ReversibleStorageHasher`](frame_support::hash::ReversibleStorageHasher).
2159	///
2160	/// ### Prefixes
2161	///
2162	/// Internally, every storage type generates a "prefix". This prefix serves as the initial
2163	/// segment of the key utilized to store values in the on-chain state (i.e., the final key
2164	/// used in [`sp_io::storage`](sp_io::storage)). For all storage types, the following rule
2165	/// applies:
2166	///
2167	/// > The storage prefix begins with `twox128(pallet_prefix) ++ twox128(STORAGE_PREFIX)`,
2168	/// > where
2169	/// > `pallet_prefix` is the name assigned to the pallet instance in
2170	/// > [`frame_support::construct_runtime`](frame_support::construct_runtime), and
2171	/// > `STORAGE_PREFIX` is the name of the `type` aliased to a particular storage type, such
2172	/// > as
2173	/// > `Foo` in `type Foo<T> = StorageValue<..>`.
2174	///
2175	/// For [`StorageValue`](frame_support::storage::types::StorageValue), no additional key is
2176	/// required. For map types, the prefix is extended with one or more keys defined by the
2177	/// map.
2178	///
2179	/// #### Example
2180	#[doc = docify::embed!("src/lib.rs", example_storage_value_map_prefixes)]
2181	/// ## Related Macros
2182	///
2183	/// The following attribute macros can be used in conjunction with the `#[storage]` macro:
2184	///
2185	/// * [`macro@getter`]: Creates a custom getter function.
2186	/// * [`macro@storage_prefix`]: Overrides the default prefix of the storage item.
2187	/// * [`macro@unbounded`]: Declares the storage item as unbounded.
2188	/// * [`macro@disable_try_decode_storage`]: Declares that try-runtime checks should not
2189	///   attempt to decode the storage item.
2190	///
2191	/// #### Example
2192	/// ```
2193	/// #[frame_support::pallet]
2194	/// mod pallet {
2195	///     # use frame_support::pallet_prelude::*;
2196	///     # #[pallet::config]
2197	///     # pub trait Config: frame_system::Config {}
2198	///     # #[pallet::pallet]
2199	///     # pub struct Pallet<T>(_);
2200	/// 	/// A kitchen-sink StorageValue, with all possible additional attributes.
2201	///     #[pallet::storage]
2202	/// 	#[pallet::getter(fn foo)]
2203	/// 	#[pallet::storage_prefix = "OtherFoo"]
2204	/// 	#[pallet::unbounded]
2205	/// 	#[pallet::disable_try_decode_storage]
2206	///     pub type Foo<T> = StorageValue<_, u32, ValueQuery>;
2207	/// }
2208	/// ```
2209	///
2210	/// ## Note on deprecation of storage items
2211	///
2212	/// - Usage of `deprecated` attribute will propagate deprecation information to the pallet
2213	///   metadata where the storage item was declared.
2214	/// - For general usage examples of `deprecated` attribute please refer to <https://doc.rust-lang.org/nightly/reference/attributes/diagnostics.html#the-deprecated-attribute>
2215	/// - Usage of `allow(deprecated)` on the item will propagate this attribute to the
2216	///   generated code.
2217	/// - If the item is annotated with `deprecated` attribute then the generated code will be
2218	///   automatically annotated with `allow(deprecated)`
2219	pub use frame_support_procedural::storage;
2220
2221	pub use frame_support_procedural::{
2222		authorize, task_condition, task_index, task_list, task_weight, tasks_experimental,
2223		weight_of_authorize,
2224	};
2225
2226	/// Allows a pallet to declare a type as an origin.
2227	///
2228	/// If defined as such, this type will be amalgamated at the runtime level into
2229	/// `RuntimeOrigin`, very similar to [`call`], [`error`] and [`event`]. See
2230	/// [`composite_enum`] for similar cases.
2231	///
2232	/// Origin is a complex FRAME topics and is further explained in `polkadot_sdk_docs`.
2233	///
2234	/// ## Syntax Variants
2235	///
2236	/// ```
2237	/// #[frame_support::pallet]
2238	/// mod pallet {
2239	///     # use frame_support::pallet_prelude::*;
2240	///     # #[pallet::config]
2241	///     # pub trait Config: frame_system::Config {}
2242	///     # #[pallet::pallet]
2243	///     # pub struct Pallet<T>(_);
2244	/// 	/// On the spot declaration.
2245	///     #[pallet::origin]
2246	/// 	#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
2247	/// 	pub enum Origin {
2248	/// 		Foo,
2249	/// 		Bar,
2250	/// 	}
2251	/// }
2252	/// ```
2253	///
2254	/// Or, more commonly used:
2255	///
2256	/// ```
2257	/// #[frame_support::pallet]
2258	/// mod pallet {
2259	///     # use frame_support::pallet_prelude::*;
2260	///     # #[pallet::config]
2261	///     # pub trait Config: frame_system::Config {}
2262	///     # #[pallet::pallet]
2263	///     # pub struct Pallet<T>(_);
2264	/// 	#[derive(PartialEq, Eq, Clone, Debug, Encode, Decode, TypeInfo, MaxEncodedLen)]
2265	/// 	pub enum RawOrigin {
2266	/// 		Foo,
2267	/// 		Bar,
2268	/// 	}
2269	///
2270	/// 	#[pallet::origin]
2271	/// 	pub type Origin = RawOrigin;
2272	/// }
2273	/// ```
2274	///
2275	/// ## Warning
2276	///
2277	/// Modifying any pallet's origin type will cause the runtime level origin type to also
2278	/// change in encoding. If stored anywhere on-chain, this will require a data migration.
2279	///
2280	/// Read more about origins at the [Origin Reference
2281	/// Docs](../../polkadot_sdk_docs/reference_docs/frame_origin/index.html).
2282	pub use frame_support_procedural::origin;
2283}
2284
2285#[deprecated(note = "Will be removed after July 2023; Use `sp_runtime::traits` directly instead.")]
2286pub mod error {
2287	#[doc(hidden)]
2288	pub use sp_runtime::traits::{BadOrigin, LookupError};
2289}
2290
2291#[doc(inline)]
2292pub use frame_support_procedural::register_default_impl;
2293
2294// Generate a macro that will enable/disable code based on `std` feature being active.
2295sp_core::generate_feature_enabled_macro!(std_enabled, feature = "std", $);
2296// Generate a macro that will enable/disable code based on `try-runtime` feature being active.
2297sp_core::generate_feature_enabled_macro!(try_runtime_enabled, feature = "try-runtime", $);
2298sp_core::generate_feature_enabled_macro!(try_runtime_or_std_enabled, any(feature = "try-runtime", feature = "std"), $);
2299sp_core::generate_feature_enabled_macro!(try_runtime_and_std_not_enabled, all(not(feature = "try-runtime"), not(feature = "std")), $);
2300
2301/// Helper for implementing GenesisBuilder runtime API
2302pub mod genesis_builder_helper;
2303
2304/// Helper for generating the `RuntimeGenesisConfig` instance for presets.
2305pub mod generate_genesis_config;
2306
2307#[cfg(test)]
2308mod test {
2309	// use super::*;
2310	use crate::{
2311		hash::*,
2312		storage::types::{StorageMap, StorageValue, ValueQuery},
2313		traits::{ConstU32, StorageInstance},
2314		BoundedVec,
2315	};
2316	use sp_io::{hashing::twox_128, TestExternalities};
2317
2318	struct Prefix;
2319	impl StorageInstance for Prefix {
2320		fn pallet_prefix() -> &'static str {
2321			"test"
2322		}
2323		const STORAGE_PREFIX: &'static str = "foo";
2324	}
2325
2326	struct Prefix1;
2327	impl StorageInstance for Prefix1 {
2328		fn pallet_prefix() -> &'static str {
2329			"test"
2330		}
2331		const STORAGE_PREFIX: &'static str = "MyVal";
2332	}
2333	struct Prefix2;
2334	impl StorageInstance for Prefix2 {
2335		fn pallet_prefix() -> &'static str {
2336			"test"
2337		}
2338		const STORAGE_PREFIX: &'static str = "MyMap";
2339	}
2340
2341	#[docify::export]
2342	#[test]
2343	pub fn example_storage_value_try_append() {
2344		type MyVal = StorageValue<Prefix, BoundedVec<u8, ConstU32<10>>, ValueQuery>;
2345
2346		TestExternalities::default().execute_with(|| {
2347			MyVal::set(BoundedVec::try_from(vec![42, 43]).unwrap());
2348			assert_eq!(MyVal::get(), vec![42, 43]);
2349			// Try to append a single u32 to BoundedVec stored in `MyVal`
2350			crate::assert_ok!(MyVal::try_append(40));
2351			assert_eq!(MyVal::get(), vec![42, 43, 40]);
2352		});
2353	}
2354
2355	#[docify::export]
2356	#[test]
2357	pub fn example_storage_value_append() {
2358		type MyVal = StorageValue<Prefix, Vec<u8>, ValueQuery>;
2359
2360		TestExternalities::default().execute_with(|| {
2361			MyVal::set(vec![42, 43]);
2362			assert_eq!(MyVal::get(), vec![42, 43]);
2363			// Append a single u32 to Vec stored in `MyVal`
2364			MyVal::append(40);
2365			assert_eq!(MyVal::get(), vec![42, 43, 40]);
2366		});
2367	}
2368
2369	#[docify::export]
2370	#[test]
2371	pub fn example_storage_value_decode_len() {
2372		type MyVal = StorageValue<Prefix, BoundedVec<u8, ConstU32<10>>, ValueQuery>;
2373
2374		TestExternalities::default().execute_with(|| {
2375			MyVal::set(BoundedVec::try_from(vec![42, 43]).unwrap());
2376			assert_eq!(MyVal::decode_len().unwrap(), 2);
2377		});
2378	}
2379
2380	#[docify::export]
2381	#[test]
2382	pub fn example_storage_value_map_prefixes() {
2383		type MyVal = StorageValue<Prefix1, u32, ValueQuery>;
2384		type MyMap = StorageMap<Prefix2, Blake2_128Concat, u16, u32, ValueQuery>;
2385		TestExternalities::default().execute_with(|| {
2386			// This example assumes `pallet_prefix` to be "test"
2387			// Get storage key for `MyVal` StorageValue
2388			assert_eq!(
2389				MyVal::hashed_key().to_vec(),
2390				[twox_128(b"test"), twox_128(b"MyVal")].concat()
2391			);
2392			// Get storage key for `MyMap` StorageMap and `key` = 1
2393			let mut k: Vec<u8> = vec![];
2394			k.extend(&twox_128(b"test"));
2395			k.extend(&twox_128(b"MyMap"));
2396			k.extend(&1u16.blake2_128_concat());
2397			assert_eq!(MyMap::hashed_key_for(1).to_vec(), k);
2398		});
2399	}
2400}