mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 19:11:04 +00:00
Nfts: minor fixes (#13576)
* Rename owner_of_item to owned_item * Move AttributeNamespace into the types file
This commit is contained in:
@@ -45,9 +45,7 @@ pub mod weights;
|
|||||||
|
|
||||||
use codec::{Decode, Encode};
|
use codec::{Decode, Encode};
|
||||||
use frame_support::traits::{
|
use frame_support::traits::{
|
||||||
tokens::{AttributeNamespace, Locker},
|
tokens::Locker, BalanceStatus::Reserved, Currency, EnsureOriginWithArg, ReservableCurrency,
|
||||||
BalanceStatus::Reserved,
|
|
||||||
Currency, EnsureOriginWithArg, ReservableCurrency,
|
|
||||||
};
|
};
|
||||||
use frame_system::Config as SystemConfig;
|
use frame_system::Config as SystemConfig;
|
||||||
use sp_runtime::{
|
use sp_runtime::{
|
||||||
@@ -809,13 +807,13 @@ pub mod pallet {
|
|||||||
match mint_settings.mint_type {
|
match mint_settings.mint_type {
|
||||||
MintType::Issuer => return Err(Error::<T, I>::NoPermission.into()),
|
MintType::Issuer => return Err(Error::<T, I>::NoPermission.into()),
|
||||||
MintType::HolderOf(collection_id) => {
|
MintType::HolderOf(collection_id) => {
|
||||||
let MintWitness { owner_of_item } =
|
let MintWitness { owned_item } =
|
||||||
witness_data.ok_or(Error::<T, I>::BadWitness)?;
|
witness_data.ok_or(Error::<T, I>::BadWitness)?;
|
||||||
|
|
||||||
let owns_item = Account::<T, I>::contains_key((
|
let owns_item = Account::<T, I>::contains_key((
|
||||||
&caller,
|
&caller,
|
||||||
&collection_id,
|
&collection_id,
|
||||||
&owner_of_item,
|
&owned_item,
|
||||||
));
|
));
|
||||||
ensure!(owns_item, Error::<T, I>::BadWitness);
|
ensure!(owns_item, Error::<T, I>::BadWitness);
|
||||||
|
|
||||||
@@ -824,7 +822,7 @@ pub mod pallet {
|
|||||||
|
|
||||||
let key = (
|
let key = (
|
||||||
&collection_id,
|
&collection_id,
|
||||||
Some(owner_of_item),
|
Some(owned_item),
|
||||||
AttributeNamespace::Pallet,
|
AttributeNamespace::Pallet,
|
||||||
&Self::construct_attribute_key(pallet_attribute.encode())?,
|
&Self::construct_attribute_key(pallet_attribute.encode())?,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ fn mint_should_work() {
|
|||||||
1,
|
1,
|
||||||
42,
|
42,
|
||||||
account(2),
|
account(2),
|
||||||
Some(MintWitness { owner_of_item: 42 })
|
Some(MintWitness { owned_item: 42 })
|
||||||
),
|
),
|
||||||
Error::<Test>::BadWitness
|
Error::<Test>::BadWitness
|
||||||
);
|
);
|
||||||
@@ -344,7 +344,7 @@ fn mint_should_work() {
|
|||||||
1,
|
1,
|
||||||
42,
|
42,
|
||||||
account(2),
|
account(2),
|
||||||
Some(MintWitness { owner_of_item: 43 })
|
Some(MintWitness { owned_item: 43 })
|
||||||
));
|
));
|
||||||
|
|
||||||
// can't mint twice
|
// can't mint twice
|
||||||
@@ -354,7 +354,7 @@ fn mint_should_work() {
|
|||||||
1,
|
1,
|
||||||
46,
|
46,
|
||||||
account(2),
|
account(2),
|
||||||
Some(MintWitness { owner_of_item: 43 })
|
Some(MintWitness { owned_item: 43 })
|
||||||
),
|
),
|
||||||
Error::<Test>::AlreadyClaimed
|
Error::<Test>::AlreadyClaimed
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ impl<AccountId, DepositBalance> CollectionDetails<AccountId, DepositBalance> {
|
|||||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
|
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
|
||||||
pub struct MintWitness<ItemId> {
|
pub struct MintWitness<ItemId> {
|
||||||
/// Provide the id of the item in a required collection.
|
/// 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.
|
/// 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.
|
/// A witness data to cancel attributes approval operation.
|
||||||
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
|
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
|
||||||
pub struct CancelAttributesApprovalWitness {
|
pub struct CancelAttributesApprovalWitness {
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ pub mod nonfungibles;
|
|||||||
pub mod nonfungibles_v2;
|
pub mod nonfungibles_v2;
|
||||||
pub use imbalance::Imbalance;
|
pub use imbalance::Imbalance;
|
||||||
pub use misc::{
|
pub use misc::{
|
||||||
AssetId, AttributeNamespace, Balance, BalanceConversion, BalanceStatus, ConvertRank,
|
AssetId, Balance, BalanceConversion, BalanceStatus, ConvertRank, DepositConsequence,
|
||||||
DepositConsequence, ExistenceRequirement, GetSalary, Locker, WithdrawConsequence,
|
ExistenceRequirement, GetSalary, Locker, WithdrawConsequence, WithdrawReasons,
|
||||||
WithdrawReasons,
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -126,21 +126,6 @@ pub enum BalanceStatus {
|
|||||||
Reserved,
|
Reserved,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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),
|
|
||||||
}
|
|
||||||
|
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
/// Reasons for moving funds out of an account.
|
/// Reasons for moving funds out of an account.
|
||||||
#[derive(Encode, Decode, MaxEncodedLen)]
|
#[derive(Encode, Decode, MaxEncodedLen)]
|
||||||
|
|||||||
Reference in New Issue
Block a user