Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

[NFTs] Make owned_item in MintWitness optional #14800

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frame/nfts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ pub mod pallet {
///
/// The origin must be Signed and the sender must have sufficient funds free.
///
/// `ItemDeposit` funds of sender are reserved.
/// `CollectionDeposit` funds of sender are reserved.
///
/// Parameters:
/// - `admin`: The admin of this collection. The admin is the initial address of each
Expand Down Expand Up @@ -844,6 +844,7 @@ pub mod pallet {
MintType::HolderOf(collection_id) => {
let MintWitness { owned_item, .. } =
witness_data.clone().ok_or(Error::<T, I>::WitnessRequired)?;
let owned_item = owned_item.ok_or(Error::<T, I>::BadWitness)?;

let owns_item = Account::<T, I>::contains_key((
&caller,
Expand Down
6 changes: 3 additions & 3 deletions frame/nfts/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ fn mint_should_work() {
1,
42,
account(2),
Some(MintWitness { owned_item: 42, ..Default::default() })
Some(MintWitness { owned_item: Some(42), ..Default::default() })
),
Error::<Test>::BadWitness
);
Expand All @@ -436,7 +436,7 @@ fn mint_should_work() {
1,
42,
account(2),
Some(MintWitness { owned_item: 43, ..Default::default() })
Some(MintWitness { owned_item: Some(43), ..Default::default() })
));

// can't mint twice
Expand All @@ -446,7 +446,7 @@ fn mint_should_work() {
1,
46,
account(2),
Some(MintWitness { owned_item: 43, ..Default::default() })
Some(MintWitness { owned_item: Some(43), ..Default::default() })
),
Error::<Test>::AlreadyClaimed
);
Expand Down
2 changes: 1 addition & 1 deletion frame/nfts/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl<AccountId, DepositBalance> CollectionDetails<AccountId, DepositBalance> {
#[derive(Clone, Encode, Decode, Default, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct MintWitness<ItemId, Balance> {
/// Provide the id of the item in a required collection.
pub owned_item: ItemId,
pub owned_item: Option<ItemId>,
/// The price specified in mint settings.
pub mint_price: Option<Balance>,
}
Expand Down