diff --git a/pallets/rmrk-core/src/lib.rs b/pallets/rmrk-core/src/lib.rs index d04cb07a..5f7ba906 100644 --- a/pallets/rmrk-core/src/lib.rs +++ b/pallets/rmrk-core/src/lib.rs @@ -246,6 +246,11 @@ pub mod pallet { metadata: BoundedVec, ) -> DispatchResult { let sender = ensure_signed(origin.clone())?; + if let Some(collection_issuer) = pallet_uniques::Pallet::::class_owner(&collection_id) { + ensure!(collection_issuer == sender, Error::::NoPermission); + } else { + Err(Error::::CollectionUnknown)?; + } let (collection_id, nft_id) = Self::nft_mint(sender.clone(), owner, collection_id, recipient, royalty, metadata)?; diff --git a/pallets/rmrk-core/src/tests.rs b/pallets/rmrk-core/src/tests.rs index 10f6dcf8..a1497949 100644 --- a/pallets/rmrk-core/src/tests.rs +++ b/pallets/rmrk-core/src/tests.rs @@ -179,16 +179,18 @@ fn mint_nft_works() { Some(Permill::from_float(20.525)), bvec![0u8; 20] )); - //TODO BOB shouldn't be able to mint in ALICE's collection?! - assert_ok!(RMRKCore::mint_nft( + // BOB shouldn't be able to mint in ALICE's collection + assert_noop!(RMRKCore::mint_nft( Origin::signed(BOB), BOB, COLLECTION_ID_0, Some(CHARLIE), Some(Permill::from_float(20.525)), bvec![0u8; 20] - )); - assert_eq!(RMRKCore::collections(COLLECTION_ID_0).unwrap().nfts_count, 3); + ), + Error::::NoPermission + ); + assert_eq!(RMRKCore::collections(COLLECTION_ID_0).unwrap().nfts_count, 2); assert_noop!( RMRKCore::mint_nft( Origin::signed(ALICE),