Nfts: minor fixes (#13576)

* Rename owner_of_item to owned_item

* Move AttributeNamespace into the types file
This commit is contained in:
Jegor Sidorenko
2023-03-10 11:52:10 +02:00
committed by GitHub
parent 03b2358dd1
commit 689c2f6d4e
5 changed files with 25 additions and 28 deletions
+4 -6
View File
@@ -45,9 +45,7 @@ pub mod weights;
use codec::{Decode, Encode};
use frame_support::traits::{
tokens::{AttributeNamespace, Locker},
BalanceStatus::Reserved,
Currency, EnsureOriginWithArg, ReservableCurrency,
tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency,
};
use frame_system::Config as SystemConfig;
use sp_runtime::{
@@ -809,13 +807,13 @@ pub mod pallet {
match mint_settings.mint_type {
MintType::Issuer => return Err(Error::<T, I>::NoPermission.into()),
MintType::HolderOf(collection_id) => {
let MintWitness { owner_of_item } =
let MintWitness { owned_item } =
witness_data.ok_or(Error::<T, I>::BadWitness)?;
let owns_item = Account::<T, I>::contains_key((
&caller,
&collection_id,
&owner_of_item,
&owned_item,
));
ensure!(owns_item, Error::<T, I>::BadWitness);
@@ -824,7 +822,7 @@ pub mod pallet {
let key = (
&collection_id,
Some(owner_of_item),
Some(owned_item),
AttributeNamespace::Pallet,
&Self::construct_attribute_key(pallet_attribute.encode())?,
);
+3 -3
View File
@@ -335,7 +335,7 @@ fn mint_should_work() {
1,
42,
account(2),
Some(MintWitness { owner_of_item: 42 })
Some(MintWitness { owned_item: 42 })
),
Error::<Test>::BadWitness
);
@@ -344,7 +344,7 @@ fn mint_should_work() {
1,
42,
account(2),
Some(MintWitness { owner_of_item: 43 })
Some(MintWitness { owned_item: 43 })
));
// can't mint twice
@@ -354,7 +354,7 @@ fn mint_should_work() {
1,
46,
account(2),
Some(MintWitness { owner_of_item: 43 })
Some(MintWitness { owned_item: 43 })
),
Error::<Test>::AlreadyClaimed
);
+16 -1
View File
@@ -124,7 +124,7 @@ impl<AccountId, DepositBalance> CollectionDetails<AccountId, DepositBalance> {
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct MintWitness<ItemId> {
/// Provide the id of the item in a required collection.
pub owner_of_item: ItemId,
pub owned_item: ItemId,
}
/// Information concerning the ownership of a single unique item.
@@ -317,6 +317,21 @@ impl<Price, BlockNumber, CollectionId> Default for MintSettings<Price, BlockNumb
}
}
/// Attribute namespaces for non-fungible tokens.
#[derive(
Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen,
)]
pub enum AttributeNamespace<AccountId> {
/// An attribute was set by the pallet.
Pallet,
/// An attribute was set by collection's owner.
CollectionOwner,
/// An attribute was set by item's owner.
ItemOwner,
/// An attribute was set by pre-approved account.
Account(AccountId),
}
/// A witness data to cancel attributes approval operation.
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct CancelAttributesApprovalWitness {