changes to nfts pallet for xcm integration (#14395)

* Use Incrementable from frame_support::traits

* Chore

* make incremental fallible and new nfts function for custom collection ids

* fmt

* fix benchmark tests nfts

* add test

* fmt

* add safety comment to CollectionId

* fmt

* add comments to Incrementable

* line wrapping

* rewrap comments

* address feedback

* fmt

* change unwrap for expect

---------

Co-authored-by: Jegor Sidorenko <jegor@parity.io>
Co-authored-by: parity-processbot <>
This commit is contained in:
Just van Stam
2023-07-25 10:02:39 +02:00
committed by GitHub
parent 5e6bbfa0a6
commit ae018a01a4
9 changed files with 145 additions and 29 deletions
+39 -1
View File
@@ -23,7 +23,7 @@ use frame_support::{
assert_noop, assert_ok,
dispatch::Dispatchable,
traits::{
tokens::nonfungibles_v2::{Destroy, Mutate},
tokens::nonfungibles_v2::{Create, Destroy, Mutate},
Currency, Get,
},
};
@@ -3678,3 +3678,41 @@ fn pre_signed_attributes_should_work() {
);
})
}
#[test]
fn basic_create_collection_with_id_should_work() {
new_test_ext().execute_with(|| {
assert_noop!(
Nfts::create_collection_with_id(
0u32,
&account(1),
&account(1),
&default_collection_config(),
),
Error::<Test>::WrongSetting
);
Balances::make_free_balance_be(&account(1), 100);
Balances::make_free_balance_be(&account(2), 100);
assert_ok!(Nfts::create_collection_with_id(
0u32,
&account(1),
&account(1),
&collection_config_with_all_settings_enabled(),
));
assert_eq!(collections(), vec![(account(1), 0)]);
// CollectionId already taken.
assert_noop!(
Nfts::create_collection_with_id(
0u32,
&account(2),
&account(2),
&collection_config_with_all_settings_enabled(),
),
Error::<Test>::CollectionIdInUse
);
});
}