Auto-incremental CollectionId (#11796)

* autoincrementing CollectionId

* fix

* benchmarking fix

* fmt

* fix

* update before checking

* fmt

* fix

* fmt

* commit

* tests & fix

* fix

* commit

* docs

* safe math

* unexpose function

* benchmark

* fmt

* better naming

* fix?

* merge fixes

* fmt

* ".git/.scripts/bench-bot.sh" pallet dev pallet_uniques

* wrong weight

* Update frame/uniques/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* Update frame/uniques/src/lib.rs

Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>

* using substrate trait instead of num-traits

* remove unnecessary trait

* emit NextCollectionIdIncremented in do_create_collection

* fix in benchmarks

* check for event & group import

* docs

Co-authored-by: Sergej Sakač <sergejsakac@Sergejs-MacBook-Air.local>
Co-authored-by: command-bot <>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
This commit is contained in:
Sergej Sakac
2022-07-30 16:09:25 +02:00
committed by GitHub
parent e82da9d499
commit 658b179686
6 changed files with 233 additions and 117 deletions
+16 -9
View File
@@ -42,13 +42,10 @@ fn create_collection<T: Config<I>, I: 'static>(
let caller_lookup = T::Lookup::unlookup(caller.clone());
let collection = T::Helper::collection(0);
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
assert!(Uniques::<T, I>::force_create(
SystemOrigin::Root.into(),
collection,
caller_lookup.clone(),
false,
)
.is_ok());
assert!(
Uniques::<T, I>::force_create(SystemOrigin::Root.into(), caller_lookup.clone(), false,)
.is_ok()
);
(collection, caller, caller_lookup)
}
@@ -143,7 +140,7 @@ benchmarks_instance_pallet! {
whitelist_account!(caller);
let admin = T::Lookup::unlookup(caller.clone());
T::Currency::make_free_balance_be(&caller, DepositBalanceOf::<T, I>::max_value());
let call = Call::<T, I>::create { collection, admin };
let call = Call::<T, I>::create { admin };
}: { call.dispatch_bypass_filter(origin)? }
verify {
assert_last_event::<T, I>(Event::Created { collection: T::Helper::collection(0), creator: caller.clone(), owner: caller }.into());
@@ -152,7 +149,7 @@ benchmarks_instance_pallet! {
force_create {
let caller: T::AccountId = whitelisted_caller();
let caller_lookup = T::Lookup::unlookup(caller.clone());
}: _(SystemOrigin::Root, T::Helper::collection(0), caller_lookup, true)
}: _(SystemOrigin::Root, caller_lookup, true)
verify {
assert_last_event::<T, I>(Event::ForceCreated { collection: T::Helper::collection(0), owner: caller }.into());
}
@@ -408,6 +405,16 @@ benchmarks_instance_pallet! {
}.into());
}
try_increment_id {
let (_, caller, _) = create_collection::<T, I>();
Uniques::<T, I>::set_next_id(0);
}: _(SystemOrigin::Signed(caller.clone()))
verify {
assert_last_event::<T, I>(Event::NextCollectionIdIncremented {
next_id: 1u32.into()
}.into());
}
set_price {
let (collection, caller, _) = create_collection::<T, I>();
let (item, ..) = mint_item::<T, I>(0);