mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 10:31:03 +00:00
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:
@@ -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);
|
||||
|
||||
@@ -88,7 +88,12 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
},
|
||||
);
|
||||
|
||||
let next_id = collection.saturating_add(1u32.into());
|
||||
|
||||
CollectionAccount::<T, I>::insert(&owner, &collection, ());
|
||||
NextCollectionId::<T, I>::set(next_id);
|
||||
|
||||
Self::deposit_event(Event::NextCollectionIdIncremented { next_id });
|
||||
Self::deposit_event(event);
|
||||
Ok(())
|
||||
}
|
||||
@@ -208,6 +213,16 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(any(test, feature = "runtime-benchmarks"))]
|
||||
pub fn set_next_id(count: u32) {
|
||||
NextCollectionId::<T, I>::set(count.into());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub fn get_next_id() -> T::CollectionId {
|
||||
NextCollectionId::<T, I>::get()
|
||||
}
|
||||
|
||||
pub fn do_set_price(
|
||||
collection: T::CollectionId,
|
||||
item: T::ItemId,
|
||||
|
||||
@@ -51,7 +51,7 @@ use frame_support::{
|
||||
};
|
||||
use frame_system::Config as SystemConfig;
|
||||
use sp_runtime::{
|
||||
traits::{Saturating, StaticLookup, Zero},
|
||||
traits::{AtLeast32BitUnsigned, Saturating, StaticLookup, Zero},
|
||||
ArithmeticError, RuntimeDebug,
|
||||
};
|
||||
use sp_std::prelude::*;
|
||||
@@ -92,7 +92,12 @@ pub mod pallet {
|
||||
type Event: From<Event<Self, I>> + IsType<<Self as frame_system::Config>::Event>;
|
||||
|
||||
/// Identifier for the collection of item.
|
||||
type CollectionId: Member + Parameter + MaxEncodedLen + Copy;
|
||||
type CollectionId: Member
|
||||
+ Parameter
|
||||
+ MaxEncodedLen
|
||||
+ Copy
|
||||
+ Default
|
||||
+ AtLeast32BitUnsigned;
|
||||
|
||||
/// The type used to identify a unique item within a collection.
|
||||
type ItemId: Member + Parameter + MaxEncodedLen + Copy;
|
||||
@@ -266,6 +271,12 @@ pub mod pallet {
|
||||
pub(super) type CollectionMaxSupply<T: Config<I>, I: 'static = ()> =
|
||||
StorageMap<_, Blake2_128Concat, T::CollectionId, u32, OptionQuery>;
|
||||
|
||||
#[pallet::storage]
|
||||
/// Stores the `CollectionId` that is going to be used for the next collection.
|
||||
/// This gets incremented by 1 whenever a new collection is created.
|
||||
pub(super) type NextCollectionId<T: Config<I>, I: 'static = ()> =
|
||||
StorageValue<_, T::CollectionId, ValueQuery>;
|
||||
|
||||
#[pallet::event]
|
||||
#[pallet::generate_deposit(pub(super) fn deposit_event)]
|
||||
pub enum Event<T: Config<I>, I: 'static = ()> {
|
||||
@@ -357,6 +368,8 @@ pub mod pallet {
|
||||
OwnershipAcceptanceChanged { who: T::AccountId, maybe_collection: Option<T::CollectionId> },
|
||||
/// Max supply has been set for a collection.
|
||||
CollectionMaxSupplySet { collection: T::CollectionId, max_supply: u32 },
|
||||
/// Event gets emmited when the `NextCollectionId` gets incremented.
|
||||
NextCollectionIdIncremented { next_id: T::CollectionId },
|
||||
/// The price was set for the instance.
|
||||
ItemPriceSet {
|
||||
collection: T::CollectionId,
|
||||
@@ -408,6 +421,10 @@ pub mod pallet {
|
||||
MaxSupplyAlreadySet,
|
||||
/// The provided max supply is less to the amount of items a collection already has.
|
||||
MaxSupplyTooSmall,
|
||||
/// The `CollectionId` in `NextCollectionId` is not being used.
|
||||
///
|
||||
/// This means that you can directly proceed to call `create`.
|
||||
NextIdNotUsed,
|
||||
/// The given item ID is unknown.
|
||||
UnknownItem,
|
||||
/// Item is not for sale.
|
||||
@@ -439,7 +456,6 @@ pub mod pallet {
|
||||
/// `ItemDeposit` funds of sender are reserved.
|
||||
///
|
||||
/// Parameters:
|
||||
/// - `collection`: The identifier of the new collection. This must not be currently in use.
|
||||
/// - `admin`: The admin of this collection. The admin is the initial address of each
|
||||
/// member of the collection's admin team.
|
||||
///
|
||||
@@ -449,9 +465,10 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::create())]
|
||||
pub fn create(
|
||||
origin: OriginFor<T>,
|
||||
collection: T::CollectionId,
|
||||
admin: <T::Lookup as StaticLookup>::Source,
|
||||
) -> DispatchResult {
|
||||
let collection = NextCollectionId::<T, I>::get();
|
||||
|
||||
let owner = T::CreateOrigin::ensure_origin(origin, &collection)?;
|
||||
let admin = T::Lookup::lookup(admin)?;
|
||||
|
||||
@@ -473,7 +490,6 @@ pub mod pallet {
|
||||
///
|
||||
/// Unlike `create`, no funds are reserved.
|
||||
///
|
||||
/// - `collection`: The identifier of the new item. This must not be currently in use.
|
||||
/// - `owner`: The owner of this collection of items. The owner has full superuser
|
||||
/// permissions
|
||||
/// over this item, but may later change and configure the permissions using
|
||||
@@ -485,13 +501,14 @@ pub mod pallet {
|
||||
#[pallet::weight(T::WeightInfo::force_create())]
|
||||
pub fn force_create(
|
||||
origin: OriginFor<T>,
|
||||
collection: T::CollectionId,
|
||||
owner: <T::Lookup as StaticLookup>::Source,
|
||||
free_holding: bool,
|
||||
) -> DispatchResult {
|
||||
T::ForceOrigin::ensure_origin(origin)?;
|
||||
let owner = T::Lookup::lookup(owner)?;
|
||||
|
||||
let collection = NextCollectionId::<T, I>::get();
|
||||
|
||||
Self::do_create_collection(
|
||||
collection,
|
||||
owner.clone(),
|
||||
@@ -502,6 +519,31 @@ pub mod pallet {
|
||||
)
|
||||
}
|
||||
|
||||
/// Increments the `CollectionId` stored in `NextCollectionId`.
|
||||
///
|
||||
/// This is only callable when the next `CollectionId` is already being
|
||||
/// used for some other collection.
|
||||
///
|
||||
/// The origin must be Signed and the sender must have sufficient funds
|
||||
/// free.
|
||||
///
|
||||
/// Emits `NextCollectionIdIncremented` event when successful.
|
||||
///
|
||||
/// Weight: `O(1)`
|
||||
#[pallet::weight(T::WeightInfo::try_increment_id())]
|
||||
pub fn try_increment_id(origin: OriginFor<T>) -> DispatchResult {
|
||||
ensure_signed(origin)?;
|
||||
ensure!(
|
||||
Collection::<T, I>::contains_key(NextCollectionId::<T, I>::get()),
|
||||
Error::<T, I>::NextIdNotUsed
|
||||
);
|
||||
|
||||
let next_id = NextCollectionId::<T, I>::get().saturating_add(1u32.into());
|
||||
NextCollectionId::<T, I>::set(next_id);
|
||||
Self::deposit_event(Event::NextCollectionIdIncremented { next_id });
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Destroy a collection of fungible items.
|
||||
///
|
||||
/// The origin must conform to `ForceOrigin` or must be `Signed` and the sender must be the
|
||||
|
||||
@@ -92,12 +92,12 @@ fn basic_setup_works() {
|
||||
#[test]
|
||||
fn basic_minting_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_eq!(items(), vec![(1, 0, 42)]);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, 2, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 2, true));
|
||||
assert_eq!(collections(), vec![(1, 0), (2, 1)]);
|
||||
assert_ok!(Uniques::mint(Origin::signed(2), 1, 69, 1));
|
||||
assert_eq!(items(), vec![(1, 0, 42), (1, 1, 69)]);
|
||||
@@ -108,7 +108,7 @@ fn basic_minting_should_work() {
|
||||
fn lifecycle_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 0, 1));
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 1));
|
||||
assert_eq!(Balances::reserved_balance(&1), 2);
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0, 0], false));
|
||||
@@ -151,7 +151,7 @@ fn lifecycle_should_work() {
|
||||
fn destroy_with_bad_witness_should_not_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 0, 1));
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 1));
|
||||
|
||||
let w = Collection::<Test>::get(0).unwrap().destroy_witness();
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
@@ -162,7 +162,7 @@ fn destroy_with_bad_witness_should_not_work() {
|
||||
#[test]
|
||||
fn mint_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_eq!(Uniques::owner(0, 42).unwrap(), 1);
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
@@ -173,7 +173,7 @@ fn mint_should_work() {
|
||||
#[test]
|
||||
fn transfer_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 2));
|
||||
|
||||
assert_ok!(Uniques::transfer(Origin::signed(2), 0, 42, 3));
|
||||
@@ -188,7 +188,7 @@ fn transfer_should_work() {
|
||||
#[test]
|
||||
fn freezing_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_ok!(Uniques::freeze(Origin::signed(1), 0, 42));
|
||||
assert_noop!(Uniques::transfer(Origin::signed(1), 0, 42, 2), Error::<Test>::Frozen);
|
||||
@@ -205,7 +205,7 @@ fn freezing_should_work() {
|
||||
#[test]
|
||||
fn origin_guards_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
|
||||
Balances::make_free_balance_be(&2, 100);
|
||||
@@ -230,7 +230,7 @@ fn transfer_owner_should_work() {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
Balances::make_free_balance_be(&2, 100);
|
||||
Balances::make_free_balance_be(&3, 100);
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 0, 1));
|
||||
assert_ok!(Uniques::create(Origin::signed(1), 1));
|
||||
assert_eq!(collections(), vec![(1, 0)]);
|
||||
assert_noop!(
|
||||
Uniques::transfer_ownership(Origin::signed(1), 0, 2),
|
||||
@@ -275,7 +275,7 @@ fn transfer_owner_should_work() {
|
||||
#[test]
|
||||
fn set_team_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::set_team(Origin::signed(1), 0, 2, 3, 4));
|
||||
|
||||
assert_ok!(Uniques::mint(Origin::signed(2), 0, 42, 2));
|
||||
@@ -294,7 +294,7 @@ fn set_collection_metadata_should_work() {
|
||||
Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0u8; 20], false),
|
||||
Error::<Test>::UnknownCollection,
|
||||
);
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, false));
|
||||
// Cannot add metadata to unowned item
|
||||
assert_noop!(
|
||||
Uniques::set_collection_metadata(Origin::signed(2), 0, bvec![0u8; 20], false),
|
||||
@@ -354,7 +354,7 @@ fn set_item_metadata_should_work() {
|
||||
Balances::make_free_balance_be(&1, 30);
|
||||
|
||||
// Cannot add metadata to unknown item
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, false));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
// Cannot add metadata to unowned item
|
||||
assert_noop!(
|
||||
@@ -410,7 +410,7 @@ fn set_attribute_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, false));
|
||||
|
||||
assert_ok!(Uniques::set_attribute(Origin::signed(1), 0, None, bvec![0], bvec![0]));
|
||||
assert_ok!(Uniques::set_attribute(Origin::signed(1), 0, Some(0), bvec![0], bvec![0]));
|
||||
@@ -455,7 +455,7 @@ fn set_attribute_should_respect_freeze() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, false));
|
||||
|
||||
assert_ok!(Uniques::set_attribute(Origin::signed(1), 0, None, bvec![0], bvec![0]));
|
||||
assert_ok!(Uniques::set_attribute(Origin::signed(1), 0, Some(0), bvec![0], bvec![0]));
|
||||
@@ -487,7 +487,7 @@ fn force_item_status_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, false));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 1));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 69, 2));
|
||||
assert_ok!(Uniques::set_collection_metadata(Origin::signed(1), 0, bvec![0; 20], false));
|
||||
@@ -521,7 +521,7 @@ fn force_item_status_should_work() {
|
||||
fn burn_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
Balances::make_free_balance_be(&1, 100);
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, false));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, false));
|
||||
assert_ok!(Uniques::set_team(Origin::signed(1), 0, 2, 3, 4));
|
||||
|
||||
assert_noop!(
|
||||
@@ -545,7 +545,7 @@ fn burn_works() {
|
||||
#[test]
|
||||
fn approval_lifecycle_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 2));
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
assert_ok!(Uniques::transfer(Origin::signed(3), 0, 42, 4));
|
||||
@@ -560,7 +560,7 @@ fn approval_lifecycle_works() {
|
||||
#[test]
|
||||
fn cancel_approval_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 2));
|
||||
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
@@ -592,7 +592,7 @@ fn cancel_approval_works() {
|
||||
#[test]
|
||||
fn cancel_approval_works_with_admin() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 2));
|
||||
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
@@ -620,7 +620,7 @@ fn cancel_approval_works_with_admin() {
|
||||
#[test]
|
||||
fn cancel_approval_works_with_force() {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 0, 1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert_ok!(Uniques::mint(Origin::signed(1), 0, 42, 2));
|
||||
|
||||
assert_ok!(Uniques::approve_transfer(Origin::signed(2), 0, 42, 3));
|
||||
@@ -653,7 +653,7 @@ fn max_supply_should_work() {
|
||||
let max_supply = 2;
|
||||
|
||||
// validate set_collection_max_supply
|
||||
assert_ok!(Uniques::force_create(Origin::root(), collection_id, user_id, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), user_id, true));
|
||||
assert!(!CollectionMaxSupply::<Test>::contains_key(collection_id));
|
||||
|
||||
assert_ok!(Uniques::set_collection_max_supply(
|
||||
@@ -695,15 +695,48 @@ fn max_supply_should_work() {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn try_increment_id_works() {
|
||||
new_test_ext().execute_with(|| {
|
||||
// should fail because the next `CollectionId` is not being used.
|
||||
assert_noop!(Uniques::try_increment_id(Origin::signed(2)), Error::<Test>::NextIdNotUsed);
|
||||
|
||||
// create two collections & check for events.
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert!(events().contains(&Event::<Test>::NextCollectionIdIncremented { next_id: 1 }));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), 1, true));
|
||||
assert!(events().contains(&Event::<Test>::NextCollectionIdIncremented { next_id: 2 }));
|
||||
|
||||
// there are now two collections.
|
||||
assert_eq!(Uniques::get_next_id(), 2);
|
||||
|
||||
// reset the collections counter to test if the `try_increment_id`
|
||||
// works.
|
||||
Uniques::set_next_id(0);
|
||||
assert_ok!(Uniques::try_increment_id(Origin::signed(2)));
|
||||
|
||||
// `try_increment_id` should emit an event when successful.
|
||||
assert!(events().contains(&Event::<Test>::NextCollectionIdIncremented { next_id: 1 }));
|
||||
|
||||
// because reset, the collections count should be now 1
|
||||
assert_eq!(Uniques::get_next_id(), 1);
|
||||
|
||||
// increment the collections count again.
|
||||
assert_ok!(Uniques::try_increment_id(Origin::signed(2)));
|
||||
// should fail because the next `CollectionId` is not being used.
|
||||
assert_noop!(Uniques::try_increment_id(Origin::signed(2)), Error::<Test>::NextIdNotUsed);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_price_should_work() {
|
||||
new_test_ext().execute_with(|| {
|
||||
let user_id = 1;
|
||||
let collection_id = 0;
|
||||
let collection_id: u32 = 0;
|
||||
let item_1 = 1;
|
||||
let item_2 = 2;
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), collection_id, user_id, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), user_id, true));
|
||||
|
||||
assert_ok!(Uniques::mint(Origin::signed(user_id), collection_id, item_1, user_id));
|
||||
assert_ok!(Uniques::mint(Origin::signed(user_id), collection_id, item_2, user_id));
|
||||
@@ -755,7 +788,7 @@ fn buy_item_should_work() {
|
||||
let user_1 = 1;
|
||||
let user_2 = 2;
|
||||
let user_3 = 3;
|
||||
let collection_id = 0;
|
||||
let collection_id: u32 = 0;
|
||||
let item_1 = 1;
|
||||
let item_2 = 2;
|
||||
let item_3 = 3;
|
||||
@@ -767,7 +800,7 @@ fn buy_item_should_work() {
|
||||
Balances::make_free_balance_be(&user_2, initial_balance);
|
||||
Balances::make_free_balance_be(&user_3, initial_balance);
|
||||
|
||||
assert_ok!(Uniques::force_create(Origin::root(), collection_id, user_1, true));
|
||||
assert_ok!(Uniques::force_create(Origin::root(), user_1, true));
|
||||
|
||||
assert_ok!(Uniques::mint(Origin::signed(user_1), collection_id, item_1, user_1));
|
||||
assert_ok!(Uniques::mint(Origin::signed(user_1), collection_id, item_2, user_1));
|
||||
|
||||
@@ -18,12 +18,12 @@
|
||||
//! Autogenerated weights for pallet_uniques
|
||||
//!
|
||||
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
|
||||
//! DATE: 2022-07-13, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `test-bench-bot`, CPU: `Intel(R) Xeon(R) CPU @ 3.10GHz`
|
||||
//! DATE: 2022-07-15, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]`
|
||||
//! HOSTNAME: `bm3`, CPU: `Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz`
|
||||
//! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024
|
||||
|
||||
// Executed Command:
|
||||
// target/production/substrate
|
||||
// /home/benchbot/cargo_target_dir/production/substrate
|
||||
// benchmark
|
||||
// pallet
|
||||
// --steps=50
|
||||
@@ -70,6 +70,7 @@ pub trait WeightInfo {
|
||||
fn cancel_approval() -> Weight;
|
||||
fn set_accept_ownership() -> Weight;
|
||||
fn set_collection_max_supply() -> Weight;
|
||||
fn try_increment_id() -> Weight;
|
||||
fn set_price() -> Weight;
|
||||
fn buy_item() -> Weight;
|
||||
}
|
||||
@@ -77,19 +78,21 @@ pub trait WeightInfo {
|
||||
/// Weights for pallet_uniques using the Substrate node and recommended hardware.
|
||||
pub struct SubstrateWeight<T>(PhantomData<T>);
|
||||
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques NextCollectionId (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn create() -> Weight {
|
||||
(33_075_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
(30_481_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
// Storage: Uniques NextCollectionId (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_create() -> Weight {
|
||||
(19_528_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
(19_811_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques Asset (r:1 w:0)
|
||||
@@ -104,12 +107,12 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// The range of component `a` is `[0, 1000]`.
|
||||
fn destroy(n: u32, m: u32, a: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 25_000
|
||||
.saturating_add((13_639_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 25_000
|
||||
.saturating_add((2_393_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 25_000
|
||||
.saturating_add((2_217_000 as Weight).saturating_mul(a as Weight))
|
||||
// Standard Error: 17_000
|
||||
.saturating_add((10_950_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 17_000
|
||||
.saturating_add((1_657_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 17_000
|
||||
.saturating_add((1_512_000 as Weight).saturating_mul(a as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
@@ -122,7 +125,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques CollectionMaxSupply (r:1 w:0)
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
fn mint() -> Weight {
|
||||
(42_146_000 as Weight)
|
||||
(36_980_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -131,7 +134,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
// Storage: Uniques ItemPriceOf (r:0 w:1)
|
||||
fn burn() -> Weight {
|
||||
(42_960_000 as Weight)
|
||||
(38_771_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
@@ -140,7 +143,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Account (r:0 w:2)
|
||||
// Storage: Uniques ItemPriceOf (r:0 w:1)
|
||||
fn transfer() -> Weight {
|
||||
(33_025_000 as Weight)
|
||||
(29_914_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
@@ -149,8 +152,8 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
/// The range of component `i` is `[0, 5000]`.
|
||||
fn redeposit(i: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 24_000
|
||||
.saturating_add((15_540_000 as Weight).saturating_mul(i as Weight))
|
||||
// Standard Error: 16_000
|
||||
.saturating_add((12_759_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
@@ -159,26 +162,26 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn freeze() -> Weight {
|
||||
(25_194_000 as Weight)
|
||||
(22_425_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn thaw() -> Weight {
|
||||
(25_397_000 as Weight)
|
||||
(23_011_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn freeze_collection() -> Weight {
|
||||
(19_278_000 as Weight)
|
||||
(17_718_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn thaw_collection() -> Weight {
|
||||
(19_304_000 as Weight)
|
||||
(17_619_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
@@ -186,20 +189,20 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:2)
|
||||
fn transfer_ownership() -> Weight {
|
||||
(28_615_000 as Weight)
|
||||
(25_869_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn set_team() -> Weight {
|
||||
(19_943_000 as Weight)
|
||||
(18_058_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_item_status() -> Weight {
|
||||
(22_583_000 as Weight)
|
||||
(20_720_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -207,7 +210,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn set_attribute() -> Weight {
|
||||
(47_520_000 as Weight)
|
||||
(41_808_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -215,69 +218,76 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn clear_attribute() -> Weight {
|
||||
(45_316_000 as Weight)
|
||||
(39_866_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn set_metadata() -> Weight {
|
||||
(38_391_000 as Weight)
|
||||
(34_767_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn clear_metadata() -> Weight {
|
||||
(38_023_000 as Weight)
|
||||
(33_910_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn set_collection_metadata() -> Weight {
|
||||
(37_398_000 as Weight)
|
||||
(33_827_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn clear_collection_metadata() -> Weight {
|
||||
(35_621_000 as Weight)
|
||||
(31_998_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn approve_transfer() -> Weight {
|
||||
(25_856_000 as Weight)
|
||||
(23_607_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn cancel_approval() -> Weight {
|
||||
(26_098_000 as Weight)
|
||||
(23_341_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques OwnershipAcceptance (r:1 w:1)
|
||||
fn set_accept_ownership() -> Weight {
|
||||
(24_076_000 as Weight)
|
||||
(21_969_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques CollectionMaxSupply (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn set_collection_max_supply() -> Weight {
|
||||
(22_035_000 as Weight)
|
||||
(20_355_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques NextCollectionId (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn try_increment_id() -> Weight {
|
||||
(19_233_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Asset (r:1 w:0)
|
||||
// Storage: Uniques ItemPriceOf (r:0 w:1)
|
||||
fn set_price() -> Weight {
|
||||
(22_534_000 as Weight)
|
||||
(20_733_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
@@ -286,7 +296,7 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Account (r:0 w:2)
|
||||
fn buy_item() -> Weight {
|
||||
(45_272_000 as Weight)
|
||||
(40_798_000 as Weight)
|
||||
.saturating_add(T::DbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(T::DbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
@@ -294,19 +304,21 @@ impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
|
||||
|
||||
// For backwards compatibility and tests
|
||||
impl WeightInfo for () {
|
||||
// Storage: Uniques NextCollectionId (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn create() -> Weight {
|
||||
(33_075_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
(30_481_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
// Storage: Uniques NextCollectionId (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_create() -> Weight {
|
||||
(19_528_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
(19_811_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques Asset (r:1 w:0)
|
||||
@@ -321,12 +333,12 @@ impl WeightInfo for () {
|
||||
/// The range of component `a` is `[0, 1000]`.
|
||||
fn destroy(n: u32, m: u32, a: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 25_000
|
||||
.saturating_add((13_639_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 25_000
|
||||
.saturating_add((2_393_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 25_000
|
||||
.saturating_add((2_217_000 as Weight).saturating_mul(a as Weight))
|
||||
// Standard Error: 17_000
|
||||
.saturating_add((10_950_000 as Weight).saturating_mul(n as Weight))
|
||||
// Standard Error: 17_000
|
||||
.saturating_add((1_657_000 as Weight).saturating_mul(m as Weight))
|
||||
// Standard Error: 17_000
|
||||
.saturating_add((1_512_000 as Weight).saturating_mul(a as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(n as Weight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
@@ -339,7 +351,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques CollectionMaxSupply (r:1 w:0)
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
fn mint() -> Weight {
|
||||
(42_146_000 as Weight)
|
||||
(36_980_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(3 as Weight))
|
||||
}
|
||||
@@ -348,7 +360,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Account (r:0 w:1)
|
||||
// Storage: Uniques ItemPriceOf (r:0 w:1)
|
||||
fn burn() -> Weight {
|
||||
(42_960_000 as Weight)
|
||||
(38_771_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
@@ -357,7 +369,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Account (r:0 w:2)
|
||||
// Storage: Uniques ItemPriceOf (r:0 w:1)
|
||||
fn transfer() -> Weight {
|
||||
(33_025_000 as Weight)
|
||||
(29_914_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
@@ -366,8 +378,8 @@ impl WeightInfo for () {
|
||||
/// The range of component `i` is `[0, 5000]`.
|
||||
fn redeposit(i: u32, ) -> Weight {
|
||||
(0 as Weight)
|
||||
// Standard Error: 24_000
|
||||
.saturating_add((15_540_000 as Weight).saturating_mul(i as Weight))
|
||||
// Standard Error: 16_000
|
||||
.saturating_add((12_759_000 as Weight).saturating_mul(i as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().reads((1 as Weight).saturating_mul(i as Weight)))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
@@ -376,26 +388,26 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn freeze() -> Weight {
|
||||
(25_194_000 as Weight)
|
||||
(22_425_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn thaw() -> Weight {
|
||||
(25_397_000 as Weight)
|
||||
(23_011_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn freeze_collection() -> Weight {
|
||||
(19_278_000 as Weight)
|
||||
(17_718_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn thaw_collection() -> Weight {
|
||||
(19_304_000 as Weight)
|
||||
(17_619_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
@@ -403,20 +415,20 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:2)
|
||||
fn transfer_ownership() -> Weight {
|
||||
(28_615_000 as Weight)
|
||||
(25_869_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
fn set_team() -> Weight {
|
||||
(19_943_000 as Weight)
|
||||
(18_058_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassAccount (r:0 w:1)
|
||||
fn force_item_status() -> Weight {
|
||||
(22_583_000 as Weight)
|
||||
(20_720_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -424,7 +436,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn set_attribute() -> Weight {
|
||||
(47_520_000 as Weight)
|
||||
(41_808_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
@@ -432,69 +444,76 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:0)
|
||||
// Storage: Uniques Attribute (r:1 w:1)
|
||||
fn clear_attribute() -> Weight {
|
||||
(45_316_000 as Weight)
|
||||
(39_866_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn set_metadata() -> Weight {
|
||||
(38_391_000 as Weight)
|
||||
(34_767_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques InstanceMetadataOf (r:1 w:1)
|
||||
fn clear_metadata() -> Weight {
|
||||
(38_023_000 as Weight)
|
||||
(33_910_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:1)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn set_collection_metadata() -> Weight {
|
||||
(37_398_000 as Weight)
|
||||
(33_827_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(2 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques ClassMetadataOf (r:1 w:1)
|
||||
fn clear_collection_metadata() -> Weight {
|
||||
(35_621_000 as Weight)
|
||||
(31_998_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn approve_transfer() -> Weight {
|
||||
(25_856_000 as Weight)
|
||||
(23_607_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Asset (r:1 w:1)
|
||||
fn cancel_approval() -> Weight {
|
||||
(26_098_000 as Weight)
|
||||
(23_341_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques OwnershipAcceptance (r:1 w:1)
|
||||
fn set_accept_ownership() -> Weight {
|
||||
(24_076_000 as Weight)
|
||||
(21_969_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques CollectionMaxSupply (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn set_collection_max_supply() -> Weight {
|
||||
(22_035_000 as Weight)
|
||||
(20_355_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques NextCollectionId (r:1 w:1)
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
fn try_increment_id() -> Weight {
|
||||
(19_233_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(2 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
// Storage: Uniques Asset (r:1 w:0)
|
||||
// Storage: Uniques ItemPriceOf (r:0 w:1)
|
||||
fn set_price() -> Weight {
|
||||
(22_534_000 as Weight)
|
||||
(20_733_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(1 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(1 as Weight))
|
||||
}
|
||||
@@ -503,7 +522,7 @@ impl WeightInfo for () {
|
||||
// Storage: Uniques Class (r:1 w:0)
|
||||
// Storage: Uniques Account (r:0 w:2)
|
||||
fn buy_item() -> Weight {
|
||||
(45_272_000 as Weight)
|
||||
(40_798_000 as Weight)
|
||||
.saturating_add(RocksDbWeight::get().reads(3 as Weight))
|
||||
.saturating_add(RocksDbWeight::get().writes(4 as Weight))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user