Skip to content

Commit c7de5ab

Browse files
jsidorenkonathanwhit
authored andcommitted
Nfts: minor fixes (paritytech#13576)
* Rename owner_of_item to owned_item * Move AttributeNamespace into the types file
1 parent 7dd18f0 commit c7de5ab

5 files changed

Lines changed: 25 additions & 28 deletions

File tree

frame/nfts/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ pub mod weights;
4545

4646
use codec::{Decode, Encode};
4747
use frame_support::traits::{
48-
tokens::{AttributeNamespace, Locker},
49-
BalanceStatus::Reserved,
50-
Currency, EnsureOriginWithArg, ReservableCurrency,
48+
tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency,
5149
};
5250
use frame_system::Config as SystemConfig;
5351
use sp_runtime::{
@@ -809,13 +807,13 @@ pub mod pallet {
809807
match mint_settings.mint_type {
810808
MintType::Issuer => return Err(Error::<T, I>::NoPermission.into()),
811809
MintType::HolderOf(collection_id) => {
812-
let MintWitness { owner_of_item } =
810+
let MintWitness { owned_item } =
813811
witness_data.ok_or(Error::<T, I>::BadWitness)?;
814812

815813
let owns_item = Account::<T, I>::contains_key((
816814
&caller,
817815
&collection_id,
818-
&owner_of_item,
816+
&owned_item,
819817
));
820818
ensure!(owns_item, Error::<T, I>::BadWitness);
821819

@@ -824,7 +822,7 @@ pub mod pallet {
824822

825823
let key = (
826824
&collection_id,
827-
Some(owner_of_item),
825+
Some(owned_item),
828826
AttributeNamespace::Pallet,
829827
&Self::construct_attribute_key(pallet_attribute.encode())?,
830828
);

frame/nfts/src/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ fn mint_should_work() {
335335
1,
336336
42,
337337
account(2),
338-
Some(MintWitness { owner_of_item: 42 })
338+
Some(MintWitness { owned_item: 42 })
339339
),
340340
Error::<Test>::BadWitness
341341
);
@@ -344,7 +344,7 @@ fn mint_should_work() {
344344
1,
345345
42,
346346
account(2),
347-
Some(MintWitness { owner_of_item: 43 })
347+
Some(MintWitness { owned_item: 43 })
348348
));
349349

350350
// can't mint twice
@@ -354,7 +354,7 @@ fn mint_should_work() {
354354
1,
355355
46,
356356
account(2),
357-
Some(MintWitness { owner_of_item: 43 })
357+
Some(MintWitness { owned_item: 43 })
358358
),
359359
Error::<Test>::AlreadyClaimed
360360
);

frame/nfts/src/types.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl<AccountId, DepositBalance> CollectionDetails<AccountId, DepositBalance> {
124124
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
125125
pub struct MintWitness<ItemId> {
126126
/// Provide the id of the item in a required collection.
127-
pub owner_of_item: ItemId,
127+
pub owned_item: ItemId,
128128
}
129129

130130
/// Information concerning the ownership of a single unique item.
@@ -317,6 +317,21 @@ impl<Price, BlockNumber, CollectionId> Default for MintSettings<Price, BlockNumb
317317
}
318318
}
319319

320+
/// Attribute namespaces for non-fungible tokens.
321+
#[derive(
322+
Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen,
323+
)]
324+
pub enum AttributeNamespace<AccountId> {
325+
/// An attribute was set by the pallet.
326+
Pallet,
327+
/// An attribute was set by collection's owner.
328+
CollectionOwner,
329+
/// An attribute was set by item's owner.
330+
ItemOwner,
331+
/// An attribute was set by pre-approved account.
332+
Account(AccountId),
333+
}
334+
320335
/// A witness data to cancel attributes approval operation.
321336
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
322337
pub struct CancelAttributesApprovalWitness {

frame/support/src/traits/tokens.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub mod nonfungibles;
2828
pub mod nonfungibles_v2;
2929
pub use imbalance::Imbalance;
3030
pub use misc::{
31-
AssetId, AttributeNamespace, Balance, BalanceConversion, BalanceStatus, ConvertRank,
32-
DepositConsequence, ExistenceRequirement, GetSalary, Locker, WithdrawConsequence,
33-
WithdrawReasons,
31+
AssetId, Balance, BalanceConversion, BalanceStatus, ConvertRank, DepositConsequence,
32+
ExistenceRequirement, GetSalary, Locker, WithdrawConsequence, WithdrawReasons,
3433
};

frame/support/src/traits/tokens/misc.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,6 @@ pub enum BalanceStatus {
126126
Reserved,
127127
}
128128

129-
/// Attribute namespaces for non-fungible tokens.
130-
#[derive(
131-
Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, scale_info::TypeInfo, MaxEncodedLen,
132-
)]
133-
pub enum AttributeNamespace<AccountId> {
134-
/// An attribute was set by the pallet.
135-
Pallet,
136-
/// An attribute was set by collection's owner.
137-
CollectionOwner,
138-
/// An attribute was set by item's owner.
139-
ItemOwner,
140-
/// An attribute was set by pre-approved account.
141-
Account(AccountId),
142-
}
143-
144129
bitflags::bitflags! {
145130
/// Reasons for moving funds out of an account.
146131
#[derive(Encode, Decode, MaxEncodedLen)]

0 commit comments

Comments
 (0)