Skip to content
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
8 changes: 7 additions & 1 deletion pallets/rmrk-market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub use pallet::*;
pub mod pallet {
use super::*;
use crate::types::ListInfo;
use frame_support::pallet_prelude::*;
use frame_support::{pallet_prelude::*, traits::tokens::nonfungibles::Inspect};
use frame_system::pallet_prelude::*;
use sp_runtime::Permill;

Expand Down Expand Up @@ -254,6 +254,12 @@ pub mod pallet {
// Check NFT is transferable
pallet_rmrk_core::Pallet::<T>::check_is_transferable(&nft)?;

// Check if NFT is frozen
ensure!(
pallet_uniques::Pallet::<T>::can_transfer(&collection_id, &nft_id),
pallet_uniques::Error::<T>::Frozen
);

// Lock NFT to prevent transfers or interactions with the NFT
pallet_rmrk_core::Pallet::<T>::set_lock((collection_id, nft_id), true);

Expand Down
32 changes: 31 additions & 1 deletion pallets/rmrk-market/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use super::*;
use crate::mock::*;
use frame_support::{assert_noop, assert_ok};
use mock::{Event as MockEvent};
use mock::Event as MockEvent;

use sp_runtime::Permill;
use sp_std::convert::TryInto;
Expand Down Expand Up @@ -130,6 +130,36 @@ fn list_non_transferable_fail() {
});
}

#[test]
fn list_frozen_fail() {
new_test_ext().execute_with(|| {
// Create a basic collection
assert_ok!(basic_collection());
// Mint non-transferable NFT
assert_ok!(RmrkCore::mint_nft(
Origin::signed(ALICE),
Some(ALICE),
NFT_ID_0,
COLLECTION_ID_0,
Some(ALICE),
Some(Permill::from_float(1.525)),
bvec![0u8; 20],
true, // transferable
None,
));
// freeze NFT
assert_ok!(pallet_uniques::Pallet::<Test>::freeze(
Origin::signed(ALICE),
COLLECTION_ID_0,
NFT_ID_0
));
assert_noop!(
RmrkMarket::list(Origin::signed(ALICE), COLLECTION_ID_0, 0, 10u128, None,),
pallet_uniques::Error::<Test>::Frozen
);
});
}

#[test]
fn buy_works() {
new_test_ext().execute_with(|| {
Expand Down