mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-17 13:35:41 +00:00
[fix lint warnings: NFTs pallet] fix clippy::missing_docs_in_private_items warnings (#14610)
* add docs for impl_codec_bitflags * add missing docs for type aliases * add docs to transfer module * add docs for settings module * add docs to roles module * add docs to metadata module * add docs to migration module * add missing docs to feature library * methods not functions * add docs to lock module * add docs to attributes module * add docs to create_delete_item module * add docs for create_delete_collection module * add docs to buy_sell module * add missing doc for buy_sell module * add docs to atomic_swap module * add docs to atomic_swap module * add docs for approvals module * run cargo fmt * Fix issues with multi-line comments * Apply suggestions from code review Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> * update from review * fmt * update from review * remove bitflag example * ".git/.scripts/commands/fmt/fmt.sh" * Apply suggestions from code review Co-authored-by: Squirrel <gilescope@gmail.com> * add note about pallet features --------- Co-authored-by: Jegor Sidorenko <jegor@parity.io> Co-authored-by: Jegor Sidorenko <5252494+jsidorenko@users.noreply.github.com> Co-authored-by: parity-processbot <> Co-authored-by: Squirrel <gilescope@gmail.com>
This commit is contained in:
@@ -15,10 +15,19 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//! This module provides helper methods to configure collection settings for the NFTs pallet.
|
||||
|
||||
use crate::*;
|
||||
use frame_support::pallet_prelude::*;
|
||||
|
||||
impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
/// Forcefully change the configuration of a collection.
|
||||
///
|
||||
/// - `collection`: The ID of the collection for which to update the configuration.
|
||||
/// - `config`: The new collection configuration to set.
|
||||
///
|
||||
/// This function allows for changing the configuration of a collection without any checks.
|
||||
/// It updates the collection configuration and emits a `CollectionConfigChanged` event.
|
||||
pub(crate) fn do_force_collection_config(
|
||||
collection: T::CollectionId,
|
||||
config: CollectionConfigFor<T, I>,
|
||||
@@ -29,6 +38,22 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set the maximum supply for a collection.
|
||||
///
|
||||
/// - `maybe_check_owner`: An optional account ID used to check permissions.
|
||||
/// - `collection`: The ID of the collection for which to set the maximum supply.
|
||||
/// - `max_supply`: The new maximum supply to set for the collection.
|
||||
///
|
||||
/// This function checks if the setting `UnlockedMaxSupply` is enabled in the collection
|
||||
/// configuration. If it is not enabled, it returns an `Error::MaxSupplyLocked`. If
|
||||
/// `maybe_check_owner` is `Some(owner)`, it checks if the caller of the function is the
|
||||
/// owner of the collection. If the caller is not the owner and the `maybe_check_owner`
|
||||
/// parameter is provided, it returns an `Error::NoPermission`.
|
||||
///
|
||||
/// It also checks if the new maximum supply is greater than the current number of items in
|
||||
/// the collection, and if not, it returns an `Error::MaxSupplyTooSmall`. If all checks pass,
|
||||
/// it updates the collection configuration with the new maximum supply and emits a
|
||||
/// `CollectionMaxSupplySet` event.
|
||||
pub(crate) fn do_set_collection_max_supply(
|
||||
maybe_check_owner: Option<T::AccountId>,
|
||||
collection: T::CollectionId,
|
||||
@@ -56,6 +81,18 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Update the mint settings for a collection.
|
||||
///
|
||||
/// - `maybe_check_origin`: An optional account ID used to check issuer permissions.
|
||||
/// - `collection`: The ID of the collection for which to update the mint settings.
|
||||
/// - `mint_settings`: The new mint settings to set for the collection.
|
||||
///
|
||||
/// This function updates the mint settings for a collection. If `maybe_check_origin` is
|
||||
/// `Some(origin)`, it checks if the caller of the function has the `CollectionRole::Issuer`
|
||||
/// for the given collection. If the caller doesn't have the required permission and
|
||||
/// `maybe_check_origin` is provided, it returns an `Error::NoPermission`. If all checks
|
||||
/// pass, it updates the collection configuration with the new mint settings and emits a
|
||||
/// `CollectionMintSettingsUpdated` event.
|
||||
pub(crate) fn do_update_mint_settings(
|
||||
maybe_check_origin: Option<T::AccountId>,
|
||||
collection: T::CollectionId,
|
||||
@@ -80,6 +117,13 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the configuration for a specific collection.
|
||||
///
|
||||
/// - `collection_id`: The ID of the collection for which to retrieve the configuration.
|
||||
///
|
||||
/// This function attempts to fetch the configuration (`CollectionConfigFor`) associated
|
||||
/// with the given `collection_id`. If the configuration exists, it returns `Ok(config)`,
|
||||
/// otherwise, it returns a `DispatchError` with `Error::NoConfig`.
|
||||
pub(crate) fn get_collection_config(
|
||||
collection_id: &T::CollectionId,
|
||||
) -> Result<CollectionConfigFor<T, I>, DispatchError> {
|
||||
@@ -88,6 +132,14 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
/// Get the configuration for a specific item within a collection.
|
||||
///
|
||||
/// - `collection_id`: The ID of the collection to which the item belongs.
|
||||
/// - `item_id`: The ID of the item for which to retrieve the configuration.
|
||||
///
|
||||
/// This function attempts to fetch the configuration (`ItemConfig`) associated with the given
|
||||
/// `collection_id` and `item_id`. If the configuration exists, it returns `Ok(config)`,
|
||||
/// otherwise, it returns a `DispatchError` with `Error::UnknownItem`.
|
||||
pub(crate) fn get_item_config(
|
||||
collection_id: &T::CollectionId,
|
||||
item_id: &T::ItemId,
|
||||
@@ -97,6 +149,14 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
/// Get the default item settings for a specific collection.
|
||||
///
|
||||
/// - `collection_id`: The ID of the collection for which to retrieve the default item settings.
|
||||
///
|
||||
/// This function fetches the `default_item_settings` from the collection configuration
|
||||
/// associated with the given `collection_id`. If the collection configuration exists, it
|
||||
/// returns `Ok(default_item_settings)`, otherwise, it returns a `DispatchError` with
|
||||
/// `Error::NoConfig`.
|
||||
pub(crate) fn get_default_item_settings(
|
||||
collection_id: &T::CollectionId,
|
||||
) -> Result<ItemSettings, DispatchError> {
|
||||
@@ -104,6 +164,13 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(collection_config.mint_settings.default_item_settings)
|
||||
}
|
||||
|
||||
/// Check if a specified pallet feature is enabled.
|
||||
///
|
||||
/// - `feature`: The feature to check.
|
||||
///
|
||||
/// This function checks if the given `feature` is enabled in the runtime using the
|
||||
/// pallet's `T::Features::get()` function. It returns `true` if the feature is enabled,
|
||||
/// otherwise it returns `false`.
|
||||
pub(crate) fn is_pallet_feature_enabled(feature: PalletFeature) -> bool {
|
||||
let features = T::Features::get();
|
||||
return features.is_enabled(feature)
|
||||
|
||||
Reference in New Issue
Block a user