Rewrap all comments to 100 line width (#9490)

* reformat everything again

* manual formatting

* last manual fix

* Fix build
This commit is contained in:
Kian Paimani
2021-08-11 16:56:55 +02:00
committed by GitHub
parent 8180c58700
commit abd08e29ce
258 changed files with 1776 additions and 1447 deletions
+107 -95
View File
@@ -271,10 +271,10 @@ macro_rules! generate_storage_alias {
///
/// `twox_128(":" ++ NAME ++ ":")` where `NAME` is the name that is passed as type name.
///
/// - Using `static` to create a static parameter type. Its value is
/// being provided by a static variable with the equivalent name in `UPPER_SNAKE_CASE`. An
/// additional `set` function is provided in this case to alter the static variable.
/// **This is intended for testing ONLY and is ONLY available when `std` is enabled.**
/// - Using `static` to create a static parameter type. Its value is being provided by a static
/// variable with the equivalent name in `UPPER_SNAKE_CASE`. An additional `set` function is
/// provided in this case to alter the static variable. **This is intended for testing ONLY and is
/// ONLY available when `std` is enabled.**
///
/// # Examples
///
@@ -1314,11 +1314,11 @@ pub mod pallet_prelude {
/// }
/// ```
///
/// Inside the module the macro will parse item with the attribute: `#[pallet::*]`, some attributes
/// are mandatory, some other optional.
/// Inside the module the macro will parse item with the attribute: `#[pallet::*]`, some
/// attributes are mandatory, some other optional.
///
/// The attribute are explained with the syntax of non instantiable pallets, to see how pallet with
/// instance work see below example.
/// The attribute are explained with the syntax of non instantiable pallets, to see how pallet
/// with instance work see below example.
///
/// Note various type can be automatically imported using pallet_prelude in frame_support and
/// frame_system:
@@ -1348,7 +1348,8 @@ pub mod pallet_prelude {
/// optionally other supertrait and where clause.
///
/// The associated type `Event` is reserved, if defined it must bounds `From<Event>` and
/// `IsType<<Self as frame_system::Config>::Event>`, see `#[pallet::event]` for more information.
/// `IsType<<Self as frame_system::Config>::Event>`, see `#[pallet::event]` for more
/// information.
///
/// To put `Get` associated type into metadatas, use the attribute `#[pallet::constant]`, e.g.:
/// ```ignore
@@ -1369,7 +1370,8 @@ pub mod pallet_prelude {
///
/// ### Macro expansion:
///
/// The macro expand pallet constant metadata with the information given by `#[pallet::constant]`.
/// The macro expand pallet constant metadata with the information given by
/// `#[pallet::constant]`.
///
/// # Pallet struct placeholder: `#[pallet::pallet]` mandatory
///
@@ -1389,8 +1391,8 @@ pub mod pallet_prelude {
/// #[pallet::generate_store(pub(super) trait Store)]
/// pub struct Pallet<T>(_);
/// ```
/// More precisely the store trait contains an associated type for each storage. It is implemented
/// for `Pallet` allowing to access the storage from pallet struct.
/// More precisely the store trait contains an associated type for each storage. It is
/// implemented for `Pallet` allowing to access the storage from pallet struct.
///
/// Thus when defining a storage named `Foo`, it can later be accessed from `Pallet` using
/// `<Pallet as Store>::Foo`.
@@ -1406,8 +1408,8 @@ pub mod pallet_prelude {
/// This require all storage to implement the trait [`traits::StorageInfoTrait`], thus all keys
/// and value types must bound [`pallet_prelude::MaxEncodedLen`].
///
/// As the macro implements [`traits::GetStorageVersion`], the current storage version needs to be
/// communicated to the macro. This can be done by using the `storage_version` attribute:
/// As the macro implements [`traits::GetStorageVersion`], the current storage version needs to
/// be communicated to the macro. This can be done by using the `storage_version` attribute:
///
/// ```ignore
/// const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);
@@ -1439,14 +1441,15 @@ pub mod pallet_prelude {
///
/// It declare `type Module` type alias for `Pallet`, used by [`construct_runtime`].
///
/// It implements [`traits::PalletInfoAccess`] on `Pallet` to ease access to pallet informations
/// given by [`frame_support::traits::PalletInfo`].
/// It implements [`traits::PalletInfoAccess`] on `Pallet` to ease access to pallet
/// informations given by [`frame_support::traits::PalletInfo`].
/// (The implementation use the associated type `frame_system::Config::PalletInfo`).
///
/// It implements [`traits::StorageInfoTrait`] on `Pallet` which give information about all storages.
/// It implements [`traits::StorageInfoTrait`] on `Pallet` which give information about all
/// storages.
///
/// If the attribute generate_store is set then the macro creates the trait `Store` and implements
/// it on `Pallet`.
/// If the attribute generate_store is set then the macro creates the trait `Store` and
/// implements it on `Pallet`.
///
/// If the attribute set_storage_max_encoded_len is set then the macro call
/// [`traits::StorageInfoTrait`] for each storage in the implementation of
@@ -1468,8 +1471,8 @@ pub mod pallet_prelude {
/// `Hooks<BlockNumberFor<T>>` (they are defined in preludes), for the type `Pallet<T>`
/// and with an optional where clause.
///
/// If no `#[pallet::hooks]` exists, then a default implementation corresponding to the following
/// code is automatically generated:
/// If no `#[pallet::hooks]` exists, then a default implementation corresponding to the
/// following code is automatically generated:
/// ```ignore
/// #[pallet::hooks]
/// impl<T: Config> Hooks<BlockNumberFor<T>> for Pallet<T> {}
@@ -1483,8 +1486,8 @@ pub mod pallet_prelude {
/// NOTE: OnRuntimeUpgrade is implemented with `Hooks::on_runtime_upgrade` and some additional
/// logic. E.g. logic to write pallet version into storage.
///
/// NOTE: The macro also adds some tracing logic when implementing the above traits. The following
/// hooks emit traces: `on_initialize`, `on_finalize` and `on_runtime_upgrade`.
/// NOTE: The macro also adds some tracing logic when implementing the above traits. The
/// following hooks emit traces: `on_initialize`, `on_finalize` and `on_runtime_upgrade`.
///
/// # Call: `#[pallet::call]` optional
///
@@ -1511,30 +1514,30 @@ pub mod pallet_prelude {
/// optional where clause.
///
/// Each dispatchable needs to define a weight with `#[pallet::weight($expr)]` attribute,
/// the first argument must be `origin: OriginFor<T>`, compact encoding for argument can be used
/// using `#[pallet::compact]`, function must return `DispatchResultWithPostInfo` or
/// the first argument must be `origin: OriginFor<T>`, compact encoding for argument can be
/// used using `#[pallet::compact]`, function must return `DispatchResultWithPostInfo` or
/// `DispatchResult`.
///
/// All arguments must implement `Debug`, `PartialEq`, `Eq`, `Decode`, `Encode`, `Clone`. For ease
/// of use, bound the trait `Member` available in frame_support::pallet_prelude.
/// All arguments must implement `Debug`, `PartialEq`, `Eq`, `Decode`, `Encode`, `Clone`. For
/// ease of use, bound the trait `Member` available in frame_support::pallet_prelude.
///
/// If no `#[pallet::call]` exists, then a default implementation corresponding to the following
/// code is automatically generated:
/// If no `#[pallet::call]` exists, then a default implementation corresponding to the
/// following code is automatically generated:
/// ```ignore
/// #[pallet::call]
/// impl<T: Config> Pallet<T> {}
/// ```
///
/// **WARNING**: modifying dispatchables, changing their order, removing some must be done with
/// care. Indeed this will change the outer runtime call type (which is an enum with one variant
/// per pallet), this outer runtime call can be stored on-chain (e.g. in pallet-scheduler).
/// Thus migration might be needed.
/// care. Indeed this will change the outer runtime call type (which is an enum with one
/// variant per pallet), this outer runtime call can be stored on-chain (e.g. in
/// pallet-scheduler). Thus migration might be needed.
///
/// ### Macro expansion
///
/// The macro create an enum `Call` with one variant per dispatchable. This enum implements:
/// `Clone`, `Eq`, `PartialEq`, `Debug` (with stripped implementation in `not("std")`), `Encode`,
/// `Decode`, `GetDispatchInfo`, `GetCallName`, `UnfilteredDispatchable`.
/// `Clone`, `Eq`, `PartialEq`, `Debug` (with stripped implementation in `not("std")`),
/// `Encode`, `Decode`, `GetDispatchInfo`, `GetCallName`, `UnfilteredDispatchable`.
///
/// The macro implement on `Pallet`, the `Callable` trait and a function `call_functions` which
/// returns the dispatchable metadatas.
@@ -1554,8 +1557,8 @@ pub mod pallet_prelude {
/// ...
/// }
/// ```
/// I.e. a regular rust implement block with some optional where clause and functions with 0 args,
/// 0 generics, and some return type.
/// I.e. a regular rust implement block with some optional where clause and functions with 0
/// args, 0 generics, and some return type.
///
/// ### Macro expansion
///
@@ -1576,13 +1579,13 @@ pub mod pallet_prelude {
/// }
/// ```
/// I.e. a regular rust enum named `Error`, with generic `T` and fieldless variants.
/// The generic `T` mustn't bound anything and where clause is not allowed. But bounds and where
/// clause shouldn't be needed for any usecase.
/// The generic `T` mustn't bound anything and where clause is not allowed. But bounds and
/// where clause shouldn't be needed for any usecase.
///
/// ### Macro expansion
///
/// The macro implements `Debug` trait and functions `as_u8` using variant position, and `as_str`
/// using variant doc.
/// The macro implements `Debug` trait and functions `as_u8` using variant position, and
/// `as_str` using variant doc.
///
/// The macro implements `From<Error<T>>` for `&'static str`.
/// The macro implements `From<Error<T>>` for `DispatchError`.
@@ -1592,8 +1595,8 @@ pub mod pallet_prelude {
///
/// # Event: `#[pallet::event]` optional
///
/// Allow to define pallet events, pallet events are stored in the block when they deposited (and
/// removed in next block).
/// Allow to define pallet events, pallet events are stored in the block when they deposited
/// (and removed in next block).
///
/// Item is defined as:
/// ```ignore
@@ -1606,15 +1609,16 @@ pub mod pallet_prelude {
/// ...
/// }
/// ```
/// I.e. an enum (with named or unnamed fields variant), named Event, with generic: none or `T` or
/// `T: Config`, and optional where clause.
/// I.e. an enum (with named or unnamed fields variant), named Event, with generic: none or `T`
/// or `T: Config`, and optional where clause.
///
/// Each field must implement `Clone`, `Eq`, `PartialEq`, `Encode`, `Decode`, and `Debug` (on std
/// only).
/// Each field must implement `Clone`, `Eq`, `PartialEq`, `Encode`, `Decode`, and `Debug` (on
/// std only).
/// For ease of use, bound the trait `Member` available in frame_support::pallet_prelude.
///
/// Variant documentations and field types are put into metadata.
/// The attribute `#[pallet::metadata(..)]` allows to specify the metadata to put for some types.
/// The attribute `#[pallet::metadata(..)]` allows to specify the metadata to put for some
/// types.
///
/// The metadata of a type is defined by:
/// * if matching a type in `#[pallet::metadata(..)]`, then the corresponding metadata.
@@ -1676,16 +1680,16 @@ pub mod pallet_prelude {
/// For named generic argument: the name for each argument is the one as define on the storage
/// struct:
/// * [`pallet_prelude::StorageValue`] expect `Value` and optionally `QueryKind` and `OnEmpty`,
/// * [`pallet_prelude::StorageMap`] expect `Hasher`, `Key`, `Value` and optionally `QueryKind` and
/// `OnEmpty`,
/// * [`pallet_prelude::StorageDoubleMap`] expect `Hasher1`, `Key1`, `Hasher2`, `Key2`, `Value` and
/// optionally `QueryKind` and `OnEmpty`.
/// * [`pallet_prelude::StorageMap`] expect `Hasher`, `Key`, `Value` and optionally `QueryKind`
/// and `OnEmpty`,
/// * [`pallet_prelude::StorageDoubleMap`] expect `Hasher1`, `Key1`, `Hasher2`, `Key2`, `Value`
/// and optionally `QueryKind` and `OnEmpty`.
///
/// For unnamed generic argument: Their first generic must be `_` as it is replaced by the macro
/// and other generic must declared as a normal declaration of type generic in rust.
/// For unnamed generic argument: Their first generic must be `_` as it is replaced by the
/// macro and other generic must declared as a normal declaration of type generic in rust.
///
/// The Prefix generic written by the macro is generated using `PalletInfo::name::<Pallet<..>>()`
/// and the name of the storage type.
/// The Prefix generic written by the macro is generated using
/// `PalletInfo::name::<Pallet<..>>()` and the name of the storage type.
/// E.g. if runtime names the pallet "MyExample" then the storage `type Foo<T> = ...` use the
/// prefix: `Twox128(b"MyExample") ++ Twox128(b"Foo")`.
///
@@ -1714,12 +1718,12 @@ pub mod pallet_prelude {
/// pub(super) type MyStorage<T> = StorageValue<Value = u32>;
/// ```
///
/// All the `cfg` attributes are automatically copied to the items generated for the storage, i.e. the
/// getter, storage prefix, and the metadata element etc.
/// All the `cfg` attributes are automatically copied to the items generated for the storage,
/// i.e. the getter, storage prefix, and the metadata element etc.
///
/// NOTE: If the `QueryKind` generic parameter is still generic at this stage or is using some type
/// alias then the generation of the getter might fail. In this case the getter can be implemented
/// manually.
/// NOTE: If the `QueryKind` generic parameter is still generic at this stage or is using some
/// type alias then the generation of the getter might fail. In this case the getter can be
/// implemented manually.
///
/// NOTE: The generic `Hasher` must implement the [`StorageHasher`] trait (or the type is not
/// usable at all). We use [`StorageHasher::METADATA`] for the metadata of the hasher of the
@@ -1729,17 +1733,17 @@ pub mod pallet_prelude {
///
/// For each storage item the macro generates a struct named
/// `_GeneratedPrefixForStorage$NameOfStorage`, and implements
/// [`StorageInstance`](traits::StorageInstance) on it using the pallet and storage name. It then
/// uses it as the first generic of the aliased type.
/// [`StorageInstance`](traits::StorageInstance) on it using the pallet and storage name. It
/// then uses it as the first generic of the aliased type.
///
/// For named generic, the macro will reorder the generics, and remove the names.
///
/// The macro implements the function `storage_metadata` on `Pallet` implementing the metadata for
/// all storage items based on their kind:
/// The macro implements the function `storage_metadata` on `Pallet` implementing the metadata
/// for all storage items based on their kind:
/// * for a storage value, the type of the value is copied into the metadata
/// * for a storage map, the type of the values and the key's type is copied into the metadata
/// * for a storage double map, the type of the values, and the types of key1 and key2 are copied into
/// the metadata.
/// * for a storage double map, the type of the values, and the types of key1 and key2 are
/// copied into the metadata.
///
/// # Type value: `#[pallet::type_value]` optional
///
@@ -1764,9 +1768,9 @@ pub mod pallet_prelude {
///
/// ### Macro expansion
///
/// Macro renames the function to some internal name, generate a struct with the original name of
/// the function and its generic, and implement `Get<$ReturnType>` by calling the user defined
/// function.
/// Macro renames the function to some internal name, generate a struct with the original name
/// of the function and its generic, and implement `Get<$ReturnType>` by calling the user
/// defined function.
///
/// # Genesis config: `#[pallet::genesis_config]` optional
///
@@ -1805,8 +1809,8 @@ pub mod pallet_prelude {
/// fn build(&self) { $expr }
/// }
/// ```
/// I.e. a rust trait implementation with generic `T: Config`, of trait `GenesisBuild<T>` on type
/// `GenesisConfig` with generics none or `T`.
/// I.e. a rust trait implementation with generic `T: Config`, of trait `GenesisBuild<T>` on
/// type `GenesisConfig` with generics none or `T`.
///
/// E.g.:
/// ```ignore
@@ -1821,8 +1825,8 @@ pub mod pallet_prelude {
/// Macro will add the following attribute on it:
/// * `#[cfg(feature = "std")]`
///
/// Macro will implement `sp_runtime::BuildModuleGenesisStorage` using `()` as second generic for
/// non-instantiable pallets.
/// Macro will implement `sp_runtime::BuildModuleGenesisStorage` using `()` as second generic
/// for non-instantiable pallets.
///
/// # Inherent: `#[pallet::inherent]` optional
///
@@ -1857,8 +1861,8 @@ pub mod pallet_prelude {
/// I.e. a trait implementation with bound `T: Config`, of trait `ValidateUnsigned` for type
/// `Pallet<T>`, and some optional where clause.
///
/// NOTE: There is also `sp_runtime::traits::SignedExtension` that can be used to add some specific
/// logic for transaction validation.
/// NOTE: There is also `sp_runtime::traits::SignedExtension` that can be used to add some
/// specific logic for transaction validation.
///
/// ### Macro expansion
///
@@ -1877,19 +1881,19 @@ pub mod pallet_prelude {
/// pub struct Origin<T>(PhantomData<(T)>);
/// ```
///
/// **WARNING**: modifying origin changes the outer runtime origin. This outer runtime origin can
/// be stored on-chain (e.g. in pallet-scheduler), thus any change must be done with care as it
/// might require some migration.
/// **WARNING**: modifying origin changes the outer runtime origin. This outer runtime origin
/// can be stored on-chain (e.g. in pallet-scheduler), thus any change must be done with care
/// as it might require some migration.
///
/// NOTE: for instantiable pallet, origin must be generic over T and I.
///
/// # General notes on instantiable pallet
///
/// An instantiable pallet is one where Config is generic, i.e. `Config<I>`. This allow runtime to
/// implement multiple instance of the pallet, by using different type for the generic.
/// An instantiable pallet is one where Config is generic, i.e. `Config<I>`. This allow runtime
/// to implement multiple instance of the pallet, by using different type for the generic.
/// This is the sole purpose of the generic `I`.
/// But because `PalletInfo` requires `Pallet` placeholder to be static it is important to bound
/// `'static` whenever `PalletInfo` can be used.
/// But because `PalletInfo` requires `Pallet` placeholder to be static it is important to
/// bound `'static` whenever `PalletInfo` can be used.
/// And in order to have instantiable pallet usable as a regular pallet without instance, it is
/// important to bound `= ()` on every types.
///
@@ -2226,8 +2230,8 @@ pub mod pallet_prelude {
///
/// 1. Export the metadata of the pallet for later checks
/// - run your node with the pallet active
/// - query the metadata using the `state_getMetadata` RPC and curl, or use
/// `subsee -p <PALLET_NAME> > meta.json`
/// - query the metadata using the `state_getMetadata` RPC and curl, or use `subsee -p
/// <PALLET_NAME> > meta.json`
/// 2. generate the template upgrade for the pallet provided by decl_storage
/// with environment variable `PRINT_PALLET_UPGRADE`:
/// `PRINT_PALLET_UPGRADE=1 cargo check -p my_pallet` This template can be
@@ -2271,7 +2275,8 @@ pub mod pallet_prelude {
/// impl<T: Config> Hooks for Pallet<T> {
/// }
/// ```
/// and write inside on_initialize/on_finalize/on_runtime_upgrade/offchain_worker/integrity_test
/// and write inside
/// `on_initialize`, `on_finalize`, `on_runtime_upgrade`, `offchain_worker`, `integrity_test`.
///
/// then write:
/// ```ignore
@@ -2281,7 +2286,8 @@ pub mod pallet_prelude {
/// ```
/// and write inside all the calls in decl_module with a few changes in the signature:
/// - origin must now be written completely, e.g. `origin: OriginFor<T>`
/// - result type must be `DispatchResultWithPostInfo`, you need to write it and also you might
/// - result type must be `DispatchResultWithPostInfo`, you need to write it and also you
/// might
/// need to put `Ok(().into())` at the end or the function.
/// - `#[compact]` must now be written `#[pallet::compact]`
/// - `#[weight = ..]` must now be written `#[pallet::weight(..)]`
@@ -2289,8 +2295,8 @@ pub mod pallet_prelude {
/// 7. **migrate event**:
/// rewrite as a simple enum under with the attribute `#[pallet::event]`,
/// use `#[pallet::generate_deposit($vis fn deposit_event)]` to generate deposit_event,
/// use `#[pallet::metadata(...)]` to configure the metadata for types in order not to break them.
/// 8. **migrate error**: rewrite it with attribute `#[pallet::error]`.
/// use `#[pallet::metadata(...)]` to configure the metadata for types in order not to break
/// them. 8. **migrate error**: rewrite it with attribute `#[pallet::error]`.
/// 9. **migrate storage**:
/// decl_storage provide an upgrade template (see 3.). All storages, genesis config, genesis
/// build and default implementation of genesis config can be taken from it directly.
@@ -2308,7 +2314,8 @@ pub mod pallet_prelude {
/// }
/// #[pallet::genesis_build]
/// impl<T: Config> GenesisBuild<T> for GenesisConfig {
/// // impl<T: Config, I: 'static> GenesisBuild<T, I> for GenesisConfig { for instantiable pallet
/// // for instantiable pallet:
/// // `impl<T: Config, I: 'static> GenesisBuild<T, I> for GenesisConfig {
/// fn build() {
/// // The add_extra_genesis build logic
/// }
@@ -2325,10 +2332,12 @@ pub mod pallet_prelude {
/// Once this is done you can migrate storage individually, a few notes:
/// - for private storage use `pub(crate) type ` or `pub(super) type` or nothing,
/// - for storage with `get(fn ..)` use `#[pallet::getter(fn ...)]`
/// - for storage with value being `Option<$something>` make generic `Value` being `$something`
/// - for storage with value being `Option<$something>` make generic `Value` being
/// `$something`
/// and generic `QueryKind` being `OptionQuery` (note: this is default). Otherwise make
/// `Value` the complete value type and `QueryKind` being `ValueQuery`.
/// - for storage with default value: `= $expr;` provide some specific OnEmpty generic. To do so
/// - for storage with default value: `= $expr;` provide some specific OnEmpty generic. To do
/// so
/// use of `#[pallet::type_value]` to generate the wanted struct to put.
/// example: `MyStorage: u32 = 3u32` would be written:
/// ```ignore
@@ -2361,9 +2370,11 @@ pub mod pallet_prelude {
/// * error , error, constant,
/// * manually check that:
/// * `Origin` is moved inside the macro under `#[pallet::origin]` if it exists
/// * `ValidateUnsigned` is moved inside the macro under `#[pallet::validate_unsigned)]` if it exists
/// * `ValidateUnsigned` is moved inside the macro under `#[pallet::validate_unsigned)]` if it
/// exists
/// * `ProvideInherent` is moved inside macro under `#[pallet::inherent)]` if it exists
/// * `on_initialize`/`on_finalize`/`on_runtime_upgrade`/`offchain_worker` are moved to `Hooks`
/// * `on_initialize`/`on_finalize`/`on_runtime_upgrade`/`offchain_worker` are moved to
/// `Hooks`
/// implementation
/// * storages with `config(..)` are converted to `GenesisConfig` field, and their default is
/// `= $expr;` if the storage have default value
@@ -2380,8 +2391,9 @@ pub mod pallet_prelude {
/// as the name the pallet was giving to `decl_storage`,
/// * or do a storage migration from the old prefix used to the new prefix used.
///
/// NOTE: The prefixes used by storage items are in the metadata. Thus, ensuring the metadata hasn't
/// changed does ensure that the `pallet_prefix`s used by the storage items haven't changed.
/// NOTE: The prefixes used by storage items are in the metadata. Thus, ensuring the metadata
/// hasn't changed does ensure that the `pallet_prefix`s used by the storage items haven't
/// changed.
///
/// # Notes when macro fails to show proper error message spans:
///
@@ -125,7 +125,8 @@ where
}
}
/// Remove a key from the map, returning the value at the key if the key was previously in the map.
/// Remove a key from the map, returning the value at the key if the key was previously in the
/// map.
///
/// The key may be any borrowed form of the map's key type, but the ordering on the borrowed
/// form _must_ match the ordering on the key type.
@@ -137,7 +138,8 @@ where
self.0.remove(key)
}
/// Remove a key from the map, returning the value at the key if the key was previously in the map.
/// Remove a key from the map, returning the value at the key if the key was previously in the
/// map.
///
/// The key may be any borrowed form of the map's key type, but the ordering on the borrowed
/// form _must_ match the ordering on the key type.
+6 -4
View File
@@ -160,8 +160,8 @@ pub trait StorageValue<T: FullCodec> {
/// # Usage
///
/// This would typically be called inside the module implementation of on_runtime_upgrade, while
/// ensuring **no usage of this storage are made before the call to `on_runtime_upgrade`**. (More
/// precisely prior initialized modules doesn't make use of this storage).
/// ensuring **no usage of this storage are made before the call to `on_runtime_upgrade`**.
/// (More precisely prior initialized modules doesn't make use of this storage).
fn translate<O: Decode, F: FnOnce(Option<O>) -> Option<T>>(f: F) -> Result<Option<T>, ()>;
/// Store a value under this key into the provided storage instance.
@@ -989,7 +989,8 @@ impl<T> ChildTriePrefixIterator<T> {
}
impl<T: Decode + Sized> ChildTriePrefixIterator<(Vec<u8>, T)> {
/// Construct iterator to iterate over child trie items in `child_info` with the prefix `prefix`.
/// Construct iterator to iterate over child trie items in `child_info` with the prefix
/// `prefix`.
///
/// NOTE: Iterator with [`Self::drain`] will remove any value who failed to decode
pub fn with_prefix(child_info: &ChildInfo, prefix: &[u8]) -> Self {
@@ -1012,7 +1013,8 @@ impl<T: Decode + Sized> ChildTriePrefixIterator<(Vec<u8>, T)> {
}
impl<K: Decode + Sized, T: Decode + Sized> ChildTriePrefixIterator<(K, T)> {
/// Construct iterator to iterate over child trie items in `child_info` with the prefix `prefix`.
/// Construct iterator to iterate over child trie items in `child_info` with the prefix
/// `prefix`.
///
/// NOTE: Iterator with [`Self::drain`] will remove any key or value who failed to decode
pub fn with_prefix_over_key<H: ReversibleStorageHasher>(
@@ -58,7 +58,8 @@ pub trait KeyGeneratorMaxEncodedLen: KeyGenerator {
fn key_max_encoded_len() -> usize;
}
/// A trait containing methods that are only implemented on the Key struct instead of the entire tuple.
/// A trait containing methods that are only implemented on the Key struct instead of the entire
/// tuple.
pub trait KeyGeneratorInner: KeyGenerator {
type Hasher: StorageHasher;
@@ -39,10 +39,10 @@ pub use value::{StorageValue, StorageValueMetadata};
/// Trait implementing how the storage optional value is converted into the queried type.
///
/// It is implemented by:
/// * `OptionQuery` which convert an optional value to an optional value, user when querying
/// storage will get an optional value.
/// * `ValueQuery` which convert an optional value to a value, user when querying storage will get
/// a value.
/// * `OptionQuery` which convert an optional value to an optional value, user when querying storage
/// will get an optional value.
/// * `ValueQuery` which convert an optional value to a value, user when querying storage will get a
/// value.
pub trait QueryKindTrait<Value, OnEmpty> {
/// Metadata for the storage kind.
const METADATA: StorageEntryModifier;
@@ -270,8 +270,8 @@ impl<T, S> codec::DecodeLength for WeakBoundedVec<T, S> {
}
// NOTE: we could also implement this as:
// impl<T: Value, S1: Get<u32>, S2: Get<u32>> PartialEq<WeakBoundedVec<T, S2>> for WeakBoundedVec<T, S1>
// to allow comparison of bounded vectors with different bounds.
// impl<T: Value, S1: Get<u32>, S2: Get<u32>> PartialEq<WeakBoundedVec<T, S2>> for WeakBoundedVec<T,
// S1> to allow comparison of bounded vectors with different bounds.
impl<T, S> PartialEq for WeakBoundedVec<T, S>
where
T: PartialEq,
@@ -185,8 +185,8 @@ pub trait ChangeMembers<AccountId: Clone + Ord> {
sorted_new: &[AccountId],
);
/// Set the new members; they **must already be sorted**. This will compute the diff and use it to
/// call `change_members_sorted`.
/// Set the new members; they **must already be sorted**. This will compute the diff and use it
/// to call `change_members_sorted`.
///
/// This resets any previous value of prime.
fn set_members_sorted(new_members: &[AccountId], old_members: &[AccountId]) {
+2 -1
View File
@@ -277,7 +277,8 @@ pub trait IsSubType<T> {
pub trait ExecuteBlock<Block: BlockT> {
/// Execute the given `block`.
///
/// This will execute all extrinsics in the block and check that the resulting header is correct.
/// This will execute all extrinsics in the block and check that the resulting header is
/// correct.
///
/// # Panic
///
@@ -42,8 +42,8 @@ pub enum DispatchTime<BlockNumber> {
/// The highest priority. We invert the value so that normal sorting will place the highest
/// priority at the beginning of the list.
pub const HIGHEST_PRIORITY: Priority = 0;
/// Anything of this value or lower will definitely be scheduled on the block that they ask for, even
/// if it breaches the `MaximumWeight` limitation.
/// Anything of this value or lower will definitely be scheduled on the block that they ask for,
/// even if it breaches the `MaximumWeight` limitation.
pub const HARD_DEADLINE: Priority = 63;
/// The lowest priority. Most stuff should be around here.
pub const LOWEST_PRIORITY: Priority = 255;
@@ -21,7 +21,8 @@ use sp_std::prelude::*;
/// An instance of a pallet in the storage.
///
/// It is required that these instances are unique, to support multiple instances per pallet in the same runtime!
/// It is required that these instances are unique, to support multiple instances per pallet in the
/// same runtime!
///
/// E.g. for module MyModule default instance will have prefix "MyModule" and other instances
/// "InstanceNMyModule".
@@ -56,8 +56,8 @@ pub trait Currency<AccountId> {
/// The total amount of issuance in the system.
fn total_issuance() -> Self::Balance;
/// The minimum balance any single account may have. This is equivalent to the `Balances` module's
/// `ExistentialDeposit`.
/// The minimum balance any single account may have. This is equivalent to the `Balances`
/// module's `ExistentialDeposit`.
fn minimum_balance() -> Self::Balance;
/// Reduce the total issuance by `amount` and return the according imbalance. The imbalance will
@@ -192,8 +192,8 @@ pub trait Currency<AccountId> {
/// Ensure an account's free balance equals some value; this will create the account
/// if needed.
///
/// Returns a signed imbalance and status to indicate if the account was successfully updated or update
/// has led to killing of the account.
/// Returns a signed imbalance and status to indicate if the account was successfully updated or
/// update has led to killing of the account.
fn make_free_balance_be(
who: &AccountId,
balance: Self::Balance,
@@ -193,8 +193,8 @@ pub trait NamedReservableCurrency<AccountId>: ReservableCurrency<AccountId> {
Self::slash_reserved_named(id, who, value).0
}
/// Move all the named reserved balance of one account into the balance of another, according to `status`.
/// If `status` is `Reserved`, the balance will be reserved with given `id`.
/// Move all the named reserved balance of one account into the balance of another, according to
/// `status`. If `status` is `Reserved`, the balance will be reserved with given `id`.
///
/// Is a no-op if:
/// - the value to be moved is zero; or
@@ -198,7 +198,8 @@ pub trait Unbalanced<AccountId>: Inspect<AccountId> {
}
let mut r = Self::set_balance(who, new_balance);
if r.is_err() {
// Some error, probably because we tried to destroy an account which cannot be destroyed.
// Some error, probably because we tried to destroy an account which cannot be
// destroyed.
if new_balance.is_zero() && amount >= minimum_balance {
new_balance = minimum_balance;
amount -= minimum_balance;
@@ -142,7 +142,8 @@ pub type DebtOf<AccountId, B> = Imbalance<
<B as Balanced<AccountId>>::OnDropCredit,
>;
/// Imbalance implying that the total_issuance value is greater than the sum of all account balances.
/// Imbalance implying that the total_issuance value is greater than the sum of all account
/// balances.
pub type CreditOf<AccountId, B> = Imbalance<
<B as Inspect<AccountId>>::Balance,
// This will generally be implemented by decreasing the total_issuance value.
@@ -223,7 +223,8 @@ pub trait Unbalanced<AccountId>: Inspect<AccountId> {
}
let mut r = Self::set_balance(asset, who, new_balance);
if r.is_err() {
// Some error, probably because we tried to destroy an account which cannot be destroyed.
// Some error, probably because we tried to destroy an account which cannot be
// destroyed.
if new_balance.is_zero() && amount >= minimum_balance {
new_balance = minimum_balance;
amount -= minimum_balance;
@@ -168,7 +168,8 @@ pub type DebtOf<AccountId, B> = Imbalance<
<B as Balanced<AccountId>>::OnDropCredit,
>;
/// Imbalance implying that the total_issuance value is greater than the sum of all account balances.
/// Imbalance implying that the total_issuance value is greater than the sum of all account
/// balances.
pub type CreditOf<AccountId, B> = Imbalance<
<B as Inspect<AccountId>>::AssetId,
<B as Inspect<AccountId>>::Balance,
@@ -51,8 +51,8 @@ pub enum WithdrawConsequence<Balance> {
}
impl<Balance: Zero> WithdrawConsequence<Balance> {
/// Convert the type into a `Result` with `DispatchError` as the error or the additional `Balance`
/// by which the account will be reduced.
/// Convert the type into a `Result` with `DispatchError` as the error or the additional
/// `Balance` by which the account will be reduced.
pub fn into_result(self) -> Result<Balance, DispatchError> {
use WithdrawConsequence::*;
match self {
@@ -238,7 +238,8 @@ impl<N: Zero> Lateness<N> for () {
}
/// Implementors of this trait provide information about whether or not some validator has
/// been registered with them. The [Session module](../../pallet_session/index.html) is an implementor.
/// been registered with them. The [Session module](../../pallet_session/index.html) is an
/// implementor.
pub trait ValidatorRegistration<ValidatorId> {
/// Returns true if the provided validator ID has been registered with the implementing runtime
/// module
+8 -7
View File
@@ -229,8 +229,9 @@ pub enum DispatchClass {
Operational,
/// A mandatory dispatch. These kinds of dispatch are always included regardless of their
/// weight, therefore it is critical that they are separately validated to ensure that a
/// malicious validator cannot craft a valid but impossibly heavy block. Usually this just means
/// ensuring that the extrinsic can only be included once and that it is always very light.
/// malicious validator cannot craft a valid but impossibly heavy block. Usually this just
/// means ensuring that the extrinsic can only be included once and that it is always very
/// light.
///
/// Do *NOT* use it for extrinsics that can be heavy.
///
@@ -528,12 +529,12 @@ impl<T> PaysFee<T> for (Weight, Pays) {
/// A struct to represent a weight which is a function of the input arguments. The given items have
/// the following types:
///
/// - `WD`: a raw `Weight` value or a closure that returns a `Weight` with the same
/// - `WD`: a raw `Weight` value or a closure that returns a `Weight` with the same argument list as
/// the dispatched, wrapped in a tuple.
/// - `CD`: a raw `DispatchClass` value or a closure that returns a `DispatchClass` with the same
/// argument list as the dispatched, wrapped in a tuple.
/// - `CD`: a raw `DispatchClass` value or a closure that returns a `DispatchClass`
/// with the same argument list as the dispatched, wrapped in a tuple.
/// - `PF`: a `Pays` variant for whether this dispatch pays fee or not or a closure that
/// returns a `Pays` variant with the same argument list as the dispatched, wrapped in a tuple.
/// - `PF`: a `Pays` variant for whether this dispatch pays fee or not or a closure that returns a
/// `Pays` variant with the same argument list as the dispatched, wrapped in a tuple.
#[deprecated = "Function arguments are available directly inside the annotation now."]
pub struct FunctionOf<WD, CD, PF>(pub WD, pub CD, pub PF);