mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 20:27:58 +00:00
This reverts commit 658b179686.
Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
committed by
GitHub
parent
9d75f3e3e7
commit
b0ff805740
@@ -51,7 +51,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::Config as SystemConfig;
|
||||
use sp_runtime::{
|
||||
traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero},
|
||||
traits::{Saturating, StaticLookup, Zero},
|
||||
ArithmeticError, RuntimeDebug,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
@@ -94,12 +94,7 @@ pub mod pallet {
|
||||
type Event: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Identifier for the collection of item.
|
||||
type CollectionId: Member
|
||||
+ Parameter
|
||||
+ MaxEncodedLen
|
||||
+ Copy
|
||||
+ Default
|
||||
+ AtLeast32BitUnsigned;
|
||||
type CollectionId: Member + Parameter + MaxEncodedLen + Copy;
|
||||
|
||||
/// The type used to identify a unique item within a collection.
|
||||
type ItemId: Member + Parameter + MaxEncodedLen + Copy;
|
||||
@@ -273,12 +268,6 @@ pub mod pallet {
|
||||
pub(super) type CollectionMaxSupply<T: Config<I>, I: 'static = ()> =
|
||||
StorageMap<_, Blake2_128Concat, T::CollectionId, u32, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
/// Stores the `CollectionId` that is going to be used for the next collection.
|
||||
/// This gets incremented by 1 whenever a new collection is created.
|
||||
pub(super) type NextCollectionId<T: Config<I>, I: 'static = ()> =
|
||||
StorageValue<_, T::CollectionId, ValueQuery>;
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||
@@ -370,8 +359,6 @@ pub mod pallet {
|
||||
OwnershipAcceptanceChanged { who: T::AccountId, maybe_collection: Option<T::CollectionId> },
|
||||
/// Max supply has been set for a collection.
|
||||
CollectionMaxSupplySet { collection: T::CollectionId, max_supply: u32 },
|
||||
/// Event gets emmited when the `NextCollectionId` gets incremented.
|
||||
NextCollectionIdIncremented { next_id: T::CollectionId },
|
||||
/// The price was set for the instance.
|
||||
ItemPriceSet {
|
||||
collection: T::CollectionId,
|
||||
@@ -423,10 +410,6 @@ pub mod pallet {
|
||||
MaxSupplyAlreadySet,
|
||||
/// The provided max supply is less to the amount of items a collection already has.
|
||||
MaxSupplyTooSmall,
|
||||
/// The `CollectionId` in `NextCollectionId` is not being used.
|
||||
///
|
||||
/// This means that you can directly proceed to call `create`.
|
||||
NextIdNotUsed,
|
||||
/// The given item ID is unknown.
|
||||
UnknownItem,
|
||||
/// Item is not for sale.
|
||||
@@ -458,6 +441,7 @@ pub mod pallet {
|
||||
/// `ItemDeposit` funds of sender are reserved.
|
||||
///
|
||||
/// Parameters:
|
||||
/// - `collection`: The identifier of the new collection. This must not be currently in use.
|
||||
/// - `admin`: The admin of this collection. The admin is the initial address of each
|
||||
/// member of the collection's admin team.
|
||||
///
|
||||
@@ -465,9 +449,11 @@ pub mod pallet {
|
||||
///
|
||||
/// Weight: `O(1)`
|
||||
#[pallet::weight(T::WeightInfo::create())]
|
||||
pub fn create(origin: OriginFor<T>, admin: AccountIdLookupOf<T>) -> DispatchResult {
|
||||
let collection = NextCollectionId::<T, I>::get();
|
||||
|
||||
pub fn create(
|
||||
origin: OriginFor<T>,
|
||||
collection: T::CollectionId,
|
||||
admin: AccountIdLookupOf<T>,
|
||||
) -> DispatchResult {
|
||||
let owner = T::CreateOrigin::ensure_origin(origin, &collection)?;
|
||||
let admin = T::Lookup::lookup(admin)?;
|
||||
|
||||
@@ -489,6 +475,7 @@ pub mod pallet {
|
||||
///
|
||||
/// Unlike `create`, no funds are reserved.
|
||||
///
|
||||
/// - `collection`: The identifier of the new item. This must not be currently in use.
|
||||
/// - `owner`: The owner of this collection of items. The owner has full superuser
|
||||
/// permissions
|
||||
/// over this item, but may later change and configure the permissions using
|
||||
@@ -500,14 +487,13 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::force_create())]
|
||||
pub fn force_create(
|
||||
origin: OriginFor<T>,
|
||||
collection: T::CollectionId,
|
||||
owner: AccountIdLookupOf<T>,
|
||||
free_holding: bool,
|
||||
) -> DispatchResult {
|
||||
T::ForceOrigin::ensure_origin(origin)?;
|
||||
let owner = T::Lookup::lookup(owner)?;
|
||||
|
||||
let collection = NextCollectionId::<T, I>::get();
|
||||
|
||||
Self::do_create_collection(
|
||||
collection,
|
||||
owner.clone(),
|
||||
@@ -518,31 +504,6 @@ pub mod pallet {
|
||||
)
|
||||
}
|
||||
|
||||
/// Increments the `CollectionId` stored in `NextCollectionId`.
|
||||
///
|
||||
/// This is only callable when the next `CollectionId` is already being
|
||||
/// used for some other collection.
|
||||
///
|
||||
/// The origin must be Signed and the sender must have sufficient funds
|
||||
/// free.
|
||||
///
|
||||
/// Emits `NextCollectionIdIncremented` event when successful.
|
||||
///
|
||||
/// Weight: `O(1)`
|
||||
#[pallet::weight(T::WeightInfo::try_increment_id())]
|
||||
pub fn try_increment_id(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_signed(origin)?;
|
||||
ensure!(
|
||||
Collection::<T, I>::contains_key(NextCollectionId::<T, I>::get()),
|
||||
Error::<T, I>::NextIdNotUsed
|
||||
);
|
||||
|
||||
let next_id = NextCollectionId::<T, I>::get().saturating_add(1u32.into());
|
||||
NextCollectionId::<T, I>::set(next_id);
|
||||
Self::deposit_event(Event::NextCollectionIdIncremented { next_id });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Destroy a collection of fungible items.
|
||||
///
|
||||
/// The origin must conform to `ForceOrigin` or must be `Signed` and the sender must be the
|
||||
|
||||
Reference in New Issue
Block a user