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

Commit e526f80

Browse files
authored
Make owned_item in MintWitness optional (#14800)
Co-authored-by: parity-processbot <>
1 parent 51695bb commit e526f80

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

frame/nfts/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ pub mod pallet {
662662
///
663663
/// The origin must be Signed and the sender must have sufficient funds free.
664664
///
665-
/// `ItemDeposit` funds of sender are reserved.
665+
/// `CollectionDeposit` funds of sender are reserved.
666666
///
667667
/// Parameters:
668668
/// - `admin`: The admin of this collection. The admin is the initial address of each
@@ -844,6 +844,7 @@ pub mod pallet {
844844
MintType::HolderOf(collection_id) => {
845845
let MintWitness { owned_item, .. } =
846846
witness_data.clone().ok_or(Error::<T, I>::WitnessRequired)?;
847+
let owned_item = owned_item.ok_or(Error::<T, I>::BadWitness)?;
847848

848849
let owns_item = Account::<T, I>::contains_key((
849850
&caller,

frame/nfts/src/tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ fn mint_should_work() {
427427
1,
428428
42,
429429
account(2),
430-
Some(MintWitness { owned_item: 42, ..Default::default() })
430+
Some(MintWitness { owned_item: Some(42), ..Default::default() })
431431
),
432432
Error::<Test>::BadWitness
433433
);
@@ -436,7 +436,7 @@ fn mint_should_work() {
436436
1,
437437
42,
438438
account(2),
439-
Some(MintWitness { owned_item: 43, ..Default::default() })
439+
Some(MintWitness { owned_item: Some(43), ..Default::default() })
440440
));
441441

442442
// can't mint twice
@@ -446,7 +446,7 @@ fn mint_should_work() {
446446
1,
447447
46,
448448
account(2),
449-
Some(MintWitness { owned_item: 43, ..Default::default() })
449+
Some(MintWitness { owned_item: Some(43), ..Default::default() })
450450
),
451451
Error::<Test>::AlreadyClaimed
452452
);

frame/nfts/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ impl<AccountId, DepositBalance> CollectionDetails<AccountId, DepositBalance> {
133133
#[derive(Clone, Encode, Decode, Default, Eq, PartialEq, RuntimeDebug, TypeInfo)]
134134
pub struct MintWitness<ItemId, Balance> {
135135
/// Provide the id of the item in a required collection.
136-
pub owned_item: ItemId,
136+
pub owned_item: Option<ItemId>,
137137
/// The price specified in mint settings.
138138
pub mint_price: Option<Balance>,
139139
}

0 commit comments

Comments
 (0)