diff --git a/pallets/api/src/nonfungibles/benchmarking.rs b/pallets/api/src/nonfungibles/benchmarking.rs new file mode 100644 index 00000000..45d9d5bd --- /dev/null +++ b/pallets/api/src/nonfungibles/benchmarking.rs @@ -0,0 +1,110 @@ +//! Benchmarking setup for pallet_api::nonfungibles + +use frame_benchmarking::{account, v2::*}; +use frame_support::{traits::nonfungibles_v2::Inspect, BoundedVec}; +use sp_runtime::traits::Zero; + +use super::{AttributeNamespace, CollectionIdOf, Config, ItemIdOf, NftsInstanceOf, Pallet, Read}; +use crate::Read as _; + +const SEED: u32 = 1; + +#[benchmarks( + where + > as Inspect<::AccountId>>::ItemId: Zero, + > as Inspect<::AccountId>>::CollectionId: Zero, +)] +mod benchmarks { + use super::*; + + #[benchmark] + // Storage: `Collection` + fn total_supply() { + #[block] + { + Pallet::::read(Read::TotalSupply(CollectionIdOf::::zero())); + } + } + + #[benchmark] + // Storage: `AccountBalance` + fn balance_of() { + #[block] + { + Pallet::::read(Read::BalanceOf { + collection: CollectionIdOf::::zero(), + owner: account("Alice", 0, SEED), + }); + } + } + + #[benchmark] + // Storage: `Allowances`, `Item` + fn allowance() { + #[block] + { + Pallet::::read(Read::Allowance { + collection: CollectionIdOf::::zero(), + owner: account("Alice", 0, SEED), + operator: account("Bob", 0, SEED), + item: Some(ItemIdOf::::zero()), + }); + } + } + + #[benchmark] + // Storage: `Item` + fn owner_of() { + #[block] + { + Pallet::::read(Read::OwnerOf { + collection: CollectionIdOf::::zero(), + item: ItemIdOf::::zero(), + }); + } + } + + #[benchmark] + // Storage: `Attribute` + fn get_attribute() { + #[block] + { + Pallet::::read(Read::GetAttribute { + key: BoundedVec::default(), + collection: CollectionIdOf::::zero(), + item: ItemIdOf::::zero(), + namespace: AttributeNamespace::CollectionOwner, + }); + } + } + + #[benchmark] + // Storage: `Collection` + fn collection() { + #[block] + { + Pallet::::read(Read::Collection(CollectionIdOf::::zero())); + } + } + + #[benchmark] + // Storage: `NextCollectionId` + fn next_collection_id() { + #[block] + { + Pallet::::read(Read::NextCollectionId); + } + } + + #[benchmark] + // Storage: `ItemMetadata` + fn item_metadata() { + #[block] + { + Pallet::::read(Read::ItemMetadata { + collection: CollectionIdOf::::zero(), + item: ItemIdOf::::zero(), + }); + } + } +} diff --git a/pallets/api/src/nonfungibles/mod.rs b/pallets/api/src/nonfungibles/mod.rs index b3370a84..6da7de5f 100644 --- a/pallets/api/src/nonfungibles/mod.rs +++ b/pallets/api/src/nonfungibles/mod.rs @@ -5,15 +5,20 @@ use frame_support::traits::{nonfungibles_v2::Inspect, Currency}; use frame_system::pallet_prelude::BlockNumberFor; pub use pallet::*; -use pallet_nfts::WeightInfo; +use pallet_nfts::WeightInfo as NftsWeightInfoTrait; pub use pallet_nfts::{ - AttributeNamespace, CollectionConfig, CollectionDetails, CollectionSetting, CollectionSettings, - DestroyWitness, ItemDeposit, ItemDetails, ItemSetting, MintSettings, MintType, MintWitness, + AttributeNamespace, CancelAttributesApprovalWitness, CollectionConfig, CollectionDetails, + CollectionSetting, CollectionSettings, DestroyWitness, ItemDeposit, ItemDetails, ItemMetadata, + ItemSetting, MintSettings, MintType, MintWitness, }; use sp_runtime::traits::StaticLookup; +use weights::WeightInfo; +#[cfg(feature = "runtime-benchmarks")] +mod benchmarking; #[cfg(test)] mod tests; +pub mod weights; type AccountIdOf = ::AccountId; type NftsOf = pallet_nfts::Pallet>; @@ -31,15 +36,19 @@ type CollectionDetailsFor = CollectionDetails, BalanceOf>; type AttributeNamespaceOf = AttributeNamespace>; type CollectionConfigFor = CollectionConfig, BlockNumberFor, CollectionIdOf>; -// Type aliases for storage items. -pub(super) type NextCollectionIdOf = pallet_nfts::NextCollectionId>; +// Type aliases for pallet-nfts storage items. pub(super) type AccountBalanceOf = pallet_nfts::AccountBalance>; pub(super) type AttributeOf = pallet_nfts::Attribute>; +pub(super) type NextCollectionIdOf = pallet_nfts::NextCollectionId>; pub(super) type CollectionOf = pallet_nfts::Collection>; #[frame_support::pallet] pub mod pallet { - use frame_support::{dispatch::DispatchResult, pallet_prelude::*, traits::Incrementable}; + use frame_support::{ + dispatch::{DispatchResult, DispatchResultWithPostInfo, WithPostDispatchInfo}, + pallet_prelude::*, + traits::Incrementable, + }; use frame_system::pallet_prelude::*; use pallet_nfts::{CancelAttributesApprovalWitness, DestroyWitness, MintWitness}; use sp_runtime::BoundedVec; @@ -59,42 +68,42 @@ pub mod pallet { /// Account balance for a specified collection. #[codec(index = 1)] BalanceOf { - // The collection. + /// The collection. collection: CollectionIdOf, - // The owner of the collection . + /// The owner of the collection . owner: AccountIdOf, }, /// Allowance for an operator approved by an owner, for a specified collection or item. #[codec(index = 2)] Allowance { - // The collection. + /// The collection. collection: CollectionIdOf, - // The collection item. + /// The collection item. item: Option>, - // The owner of the collection item. + /// The owner of the collection item. owner: AccountIdOf, - // The delegated operator of collection item. + /// The delegated operator of collection item. operator: AccountIdOf, }, /// Owner of a specified collection item. #[codec(index = 5)] OwnerOf { - // The collection. + /// The collection. collection: CollectionIdOf, - // The collection item. + /// The collection item. item: ItemIdOf, }, /// Attribute value of a specified collection item. (Error: bounded collection is not /// partial) #[codec(index = 6)] GetAttribute { - // The collection. + /// The collection. collection: CollectionIdOf, - // The collection item. + /// The collection item. item: ItemIdOf, - // The namespace of the attribute. + /// The namespace of the attribute. namespace: AttributeNamespaceOf, - // The key of the attribute. + /// The key of the attribute. key: BoundedVec, }, /// Details of a specified collection. @@ -106,9 +115,9 @@ pub mod pallet { /// Metadata of a specified collection item. #[codec(index = 11)] ItemMetadata { - // The collection. + /// The collection. collection: CollectionIdOf, - // The collection item. + /// The collection item. item: ItemIdOf, }, } @@ -213,8 +222,8 @@ pub mod pallet { /// Transfers the collection item from the caller's account to account `to`. /// /// # Parameters - /// - `collection` - The collection of the item to be transferred. - /// - `item` - The item to be transferred. + /// - `collection` - The collection of the item to transfer. + /// - `item` - The item to transfer. /// - `to` - The recipient account. #[pallet::call_index(3)] #[pallet::weight(NftsWeightInfoOf::::transfer())] @@ -239,38 +248,49 @@ pub mod pallet { /// Approves `operator` to spend the collection item on behalf of the caller. /// /// # Parameters - /// - `collection` - The collection of the item to be approved for delegated transfer. - /// - `item` - The item to be approved for delegated transfer. + /// - `collection` - The collection of the item to approve for a delegated transfer. + /// - `item` - The item to approve for a delegated transfer. /// - `operator` - The account that is allowed to spend the collection item. /// - `approved` - The approval status of the collection item. #[pallet::call_index(4)] - #[pallet::weight(NftsWeightInfoOf::::approve_transfer() + NftsWeightInfoOf::::cancel_approval())] + #[pallet::weight( + NftsWeightInfoOf::::approve_transfer(item.is_some() as u32) + + NftsWeightInfoOf::::cancel_approval(item.is_some() as u32) + )] pub fn approve( origin: OriginFor, collection: CollectionIdOf, item: Option>, operator: AccountIdOf, approved: bool, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let owner = ensure_signed(origin.clone())?; - if approved { + let weight = if approved { NftsOf::::approve_transfer( origin, collection, item, T::Lookup::unlookup(operator.clone()), None, - )?; + ) + .map_err(|e| { + e.with_weight(NftsWeightInfoOf::::approve_transfer(item.is_some() as u32)) + })?; + NftsWeightInfoOf::::approve_transfer(item.is_some() as u32) } else { NftsOf::::cancel_approval( origin, collection, item, T::Lookup::unlookup(operator.clone()), - )?; - } + ) + .map_err(|e| { + e.with_weight(NftsWeightInfoOf::::cancel_approval(item.is_some() as u32)) + })?; + NftsWeightInfoOf::::cancel_approval(item.is_some() as u32) + }; Self::deposit_event(Event::Approval { collection, item, operator, owner, approved }); - Ok(()) + Ok(Some(weight).into()) } /// Issue a new collection of non-fungible items from a public origin. @@ -286,21 +306,21 @@ pub mod pallet { admin: AccountIdOf, config: CollectionConfigFor, ) -> DispatchResult { + let creator = ensure_signed(origin.clone())?; // TODO: re-evaluate next collection id in nfts pallet. The `Incrementable` trait causes // issues for setting it to xcm's `Location`. This can easily be done differently. let id = NextCollectionIdOf::::get() .or(T::CollectionId::initial_value()) .ok_or(NftsErrorOf::::UnknownCollection)?; - let creator = ensure_signed(origin.clone())?; NftsOf::::create(origin, T::Lookup::unlookup(admin.clone()), config)?; - Self::deposit_event(Event::Created { id, admin, creator }); + Self::deposit_event(Event::Created { id, creator, admin }); Ok(()) } /// Destroy a collection of fungible items. /// /// # Parameters - /// - `collection` - The identifier of the collection to be destroyed. + /// - `collection` - The collection to destroy. /// - `witness` - Information on the items minted in the collection. This must be /// correct. #[pallet::call_index(8)] @@ -308,6 +328,8 @@ pub mod pallet { witness.item_metadatas, witness.item_configs, witness.attributes, + witness.item_holders, + witness.allowances, ))] pub fn destroy( origin: OriginFor, @@ -410,7 +432,7 @@ pub mod pallet { /// All the previously set attributes by the `delegate` will be removed. /// /// # Parameters - /// - `collection` - Collection that the item is contained within. + /// - `collection` - The collection that the item is contained within. /// - `item` - The item that holds attributes. /// - `delegate` - The previously approved account to remove. /// - `witness` - A witness data to cancel attributes approval operation. @@ -450,9 +472,9 @@ pub mod pallet { /// Mint an item of a particular collection. /// /// # Parameters - /// - `collection` - The collection of the item to be minted. + /// - `to` - Account into which the item will be minted. + /// - `collection` - The collection of the item to mint. /// - `item` - An identifier of the new item. - /// - `mint_to` - Account into which the item will be minted. /// - `witness_data` - When the mint type is `HolderOf(collection_id)`, then the owned /// item_id from that collection needs to be provided within the witness data object. If /// the mint price is set, then it should be additionally confirmed in the `witness_data`. @@ -487,8 +509,8 @@ pub mod pallet { /// Destroy a single collection item. /// /// # Parameters - /// - `collection` - The collection of the item to be burned. - /// - `item` - The item to be burned. + /// - `collection` - The collection of the item to burn. + /// - `item` - The item to burn. #[pallet::call_index(20)] #[pallet::weight(NftsWeightInfoOf::::burn())] pub fn burn( @@ -520,8 +542,18 @@ pub mod pallet { /// /// # Parameters /// - `request` - The read request. - fn weight(_request: &Self::Read) -> Weight { - Default::default() + fn weight(request: &Self::Read) -> Weight { + use Read::*; + match request { + TotalSupply(_) => ::WeightInfo::total_supply(), + BalanceOf { .. } => ::WeightInfo::balance_of(), + Allowance { .. } => ::WeightInfo::allowance(), + OwnerOf { .. } => ::WeightInfo::owner_of(), + GetAttribute { .. } => ::WeightInfo::get_attribute(), + Collection(_) => ::WeightInfo::collection(), + ItemMetadata { .. } => ::WeightInfo::item_metadata(), + NextCollectionId => ::WeightInfo::next_collection_id(), + } } /// Performs the requested read and returns the result. diff --git a/pallets/api/src/nonfungibles/tests.rs b/pallets/api/src/nonfungibles/tests.rs index 290f49f2..e7866b03 100644 --- a/pallets/api/src/nonfungibles/tests.rs +++ b/pallets/api/src/nonfungibles/tests.rs @@ -2,19 +2,21 @@ use codec::Encode; use frame_support::{ assert_noop, assert_ok, sp_runtime::{BoundedVec, DispatchError::BadOrigin}, - traits::Incrementable, }; +use pallet_nfts::WeightInfo as NftsWeightInfoTrait; use crate::{ mock::*, nonfungibles::{ - AccountBalanceOf, BlockNumberFor, CollectionConfig, CollectionDetails, CollectionIdOf, + AccountBalanceOf, AttributeNamespace, AttributeOf, BlockNumberFor, + CancelAttributesApprovalWitness, CollectionConfig, CollectionDetails, CollectionIdOf, CollectionOf, CollectionSettings, DestroyWitness, ItemIdOf, MintSettings, MintWitness, - NextCollectionIdOf, NftsInstanceOf, Read::*, ReadResult, + NextCollectionIdOf, NftsInstanceOf, NftsWeightInfoOf, Read::*, ReadResult, }, Read, }; +const COLLECTION: u32 = 0; const ITEM: u32 = 1; type NftsError = pallet_nfts::Error>; @@ -71,7 +73,9 @@ mod encoding_read_result { items: 0, item_metadatas: 0, item_configs: 0, + item_holders: 0, attributes: 0, + allowances: 0, }); assert_eq!( ReadResult::Collection::(collection_details.clone()).encode(), @@ -160,9 +164,14 @@ fn burn_works() { new_test_ext().execute_with(|| { let owner = ALICE; + // "UnknownItem" error is returned if collection item is not created. + assert_noop!(NonFungibles::burn(signed(owner), COLLECTION, ITEM), NftsError::UnknownItem); // Successfully burn an existing new collection item. let (collection, item) = nfts::create_collection_mint(owner, ITEM); + let balance_before_burn = AccountBalanceOf::::get(collection, owner); assert_ok!(NonFungibles::burn(signed(owner), collection, ITEM)); + let balance_after_burn = AccountBalanceOf::::get(collection, owner); + assert_eq!(balance_after_burn, balance_before_burn - 1); System::assert_last_event( Event::Transfer { collection, item, from: Some(owner), to: None, price: None }.into(), ); @@ -175,8 +184,12 @@ fn approve_works() { let owner = ALICE; let operator = BOB; let (collection, item) = nfts::create_collection_mint(owner, ITEM); - // Successfully approve `oeprator` to transfer the collection item. - assert_ok!(NonFungibles::approve(signed(owner), collection, Some(item), operator, true)); + // Successfully approve `operator` to transfer the collection item. + assert_eq!( + NonFungibles::approve(signed(owner), collection, Some(item), operator, true), + Ok(Some(NftsWeightInfoOf::::approve_transfer()).into()) + ); + assert_ok!(Nfts::check_allowance(&collection, &Some(item), &owner, &operator)); System::assert_last_event( Event::Approval { collection, item: Some(item), owner, operator, approved: true } .into(), @@ -186,6 +199,26 @@ fn approve_works() { }); } +#[test] +fn approve_collection_works() { + new_test_ext().execute_with(|| { + let owner = ALICE; + let operator = BOB; + let (collection, item) = nfts::create_collection_mint(owner, ITEM); + // Successfully approve `operator` to transfer all items within the collection. + assert_eq!( + NonFungibles::approve(signed(owner), collection, None, operator, true), + Ok(Some(NftsWeightInfoOf::::approve_transfer()).into()) + ); + assert_ok!(Nfts::check_allowance(&collection, &None, &owner, &operator)); + System::assert_last_event( + Event::Approval { collection, item: None, owner, operator, approved: true }.into(), + ); + // Successfully transfer the item by the delegated account `operator`. + assert_ok!(Nfts::transfer(signed(operator), collection, item, operator)); + }); +} + #[test] fn cancel_approval_works() { new_test_ext().execute_with(|| { @@ -193,7 +226,38 @@ fn cancel_approval_works() { let operator = BOB; let (collection, item) = nfts::create_collection_mint_and_approve(owner, ITEM, operator); // Successfully cancel the transfer approval of `operator` by `owner`. - assert_ok!(NonFungibles::approve(signed(owner), collection, Some(item), operator, false)); + assert_eq!( + NonFungibles::approve(signed(owner), collection, Some(item), operator, false), + Ok(Some(NftsWeightInfoOf::::cancel_approval()).into()) + ); + assert_eq!( + Nfts::check_allowance(&collection, &Some(item), &owner, &operator), + Err(NftsError::NoPermission.into()) + ); + // Failed to transfer the item by `operator` without permission. + assert_noop!( + Nfts::transfer(signed(operator), collection, item, operator), + NftsError::NoPermission + ); + }); +} + +#[test] +fn cancel_collection_approval_works() { + new_test_ext().execute_with(|| { + let owner = ALICE; + let operator = BOB; + let (collection, item) = nfts::create_collection_mint(owner, ITEM); + // Successfully cancel the transfer collection approval of `operator` by `owner`. + assert_ok!(Nfts::approve_transfer(signed(owner), collection, None, operator, None)); + assert_eq!( + NonFungibles::approve(signed(owner), collection, None, operator, false), + Ok(Some(NftsWeightInfoOf::::cancel_approval()).into()) + ); + assert_eq!( + Nfts::check_allowance(&collection, &None, &owner, &operator), + Err(NftsError::NoPermission.into()) + ); // Failed to transfer the item by `operator` without permission. assert_noop!( Nfts::transfer(signed(operator), collection, item, operator), @@ -218,60 +282,6 @@ fn set_max_supply_works() { }); } -#[test] -fn owner_of_works() { - new_test_ext().execute_with(|| { - let (collection, item) = nfts::create_collection_mint(ALICE, ITEM); - assert_eq!( - NonFungibles::read(OwnerOf { collection, item }).encode(), - Nfts::owner(collection, item).encode() - ); - }); -} - -#[test] -fn get_attribute_works() { - new_test_ext().execute_with(|| { - let (collection, item) = nfts::create_collection_mint(ALICE, ITEM); - let attribute = BoundedVec::truncate_from("some attribute".as_bytes().to_vec()); - let value = BoundedVec::truncate_from("some value".as_bytes().to_vec()); - let mut result: Option< - BoundedVec>>::ValueLimit>, - > = None; - // No attribute set. - assert_eq!( - NonFungibles::read(GetAttribute { - collection, - item, - namespace: pallet_nfts::AttributeNamespace::CollectionOwner, - key: attribute.clone() - }) - .encode(), - result.encode() - ); - // Successfully get an existing attribute. - result = Some(value.clone()); - assert_ok!(Nfts::set_attribute( - signed(ALICE), - collection, - Some(item), - pallet_nfts::AttributeNamespace::CollectionOwner, - attribute.clone(), - value, - )); - assert_eq!( - NonFungibles::read(GetAttribute { - collection, - item, - namespace: pallet_nfts::AttributeNamespace::CollectionOwner, - key: attribute - }) - .encode(), - result.encode() - ); - }); -} - #[test] fn set_metadata_works() { new_test_ext().execute_with(|| { @@ -316,7 +326,7 @@ fn clear_attribute_works() { signed(ALICE), collection, Some(item), - pallet_nfts::AttributeNamespace::CollectionOwner, + AttributeNamespace::CollectionOwner, attribute.clone(), BoundedVec::truncate_from("some value".as_bytes().to_vec()) )); @@ -325,14 +335,14 @@ fn clear_attribute_works() { signed(ALICE), collection, Some(item), - pallet_nfts::AttributeNamespace::CollectionOwner, + AttributeNamespace::CollectionOwner, attribute.clone(), )); assert_eq!( NonFungibles::read(GetAttribute { collection, item, - namespace: pallet_nfts::AttributeNamespace::CollectionOwner, + namespace: AttributeNamespace::CollectionOwner, key: attribute }) .encode(), @@ -354,7 +364,7 @@ fn approve_item_attribute_works() { signed(BOB), collection, Some(item), - pallet_nfts::AttributeNamespace::Account(BOB), + AttributeNamespace::Account(BOB), attribute.clone(), value.clone() )); @@ -365,7 +375,7 @@ fn approve_item_attribute_works() { NonFungibles::read(GetAttribute { collection, item, - namespace: pallet_nfts::AttributeNamespace::Account(BOB), + namespace: AttributeNamespace::Account(BOB), key: attribute }) .encode(), @@ -387,7 +397,7 @@ fn cancel_item_attribute_approval_works() { signed(BOB), collection, Some(item), - pallet_nfts::AttributeNamespace::Account(BOB), + AttributeNamespace::Account(BOB), attribute.clone(), value.clone() )); @@ -396,14 +406,14 @@ fn cancel_item_attribute_approval_works() { collection, item, BOB, - pallet_nfts::CancelAttributesApprovalWitness { account_attributes: 1 } + CancelAttributesApprovalWitness { account_attributes: 1 } )); assert_noop!( Nfts::set_attribute( signed(BOB), collection, Some(item), - pallet_nfts::AttributeNamespace::Account(BOB), + AttributeNamespace::Account(BOB), attribute.clone(), value.clone() ), @@ -412,78 +422,79 @@ fn cancel_item_attribute_approval_works() { }); } -#[test] -fn next_collection_id_works() { - new_test_ext().execute_with(|| { - let _ = nfts::create_collection_mint(ALICE, ITEM); - assert_eq!(NonFungibles::read(NextCollectionId).encode(), Some(1).encode()); - assert_eq!( - NonFungibles::read(NextCollectionId).encode(), - NextCollectionIdOf::::get() - .or(CollectionIdOf::::initial_value()) - .encode(), - ); - }); -} - -#[test] -fn total_supply_works() { - new_test_ext().execute_with(|| { - let owner = ALICE; - let collection = nfts::create_collection(owner); - (0..10).into_iter().for_each(|i| { - assert_ok!(Nfts::mint(signed(owner), collection, i, owner, None)); - assert_eq!( - NonFungibles::read(TotalSupply(collection)).encode(), - ((i + 1) as u128).encode() - ); - assert_eq!( - NonFungibles::read(TotalSupply(collection)).encode(), - (Nfts::collection_items(collection).unwrap_or_default() as u128).encode() - ); - }); - }); -} - #[test] fn create_works() { new_test_ext().execute_with(|| { - let owner = ALICE; + let creator = ALICE; + let admin = ALICE; let next_collection_id = NextCollectionIdOf::::get().unwrap_or_default(); + for origin in vec![root(), none()] { + assert_noop!( + NonFungibles::create( + origin, + admin, + CollectionConfig { + max_supply: None, + mint_settings: MintSettings::default(), + settings: CollectionSettings::all_enabled() + }, + ), + BadOrigin + ); + } assert_ok!(NonFungibles::create( - signed(owner), - owner, + signed(creator), + admin, CollectionConfig { max_supply: None, mint_settings: MintSettings::default(), settings: CollectionSettings::all_enabled() }, )); - assert_eq!(Nfts::collection_owner(next_collection_id), Some(owner)); + assert_eq!(Nfts::collection_owner(next_collection_id), Some(creator)); + System::assert_last_event(Event::Created { id: next_collection_id, creator, admin }.into()); }); } #[test] fn destroy_works() { new_test_ext().execute_with(|| { - let collection = nfts::create_collection(ALICE); - assert_ok!(NonFungibles::destroy( - signed(ALICE), - collection, - DestroyWitness { item_metadatas: 0, item_configs: 0, attributes: 0 } - )); + let collection = COLLECTION; + let witness = DestroyWitness { + item_metadatas: 0, + item_configs: 0, + item_holders: 0, + attributes: 0, + allowances: 0, + }; + // Check error works for `Nfts::destroy()`. + assert_noop!( + NonFungibles::destroy(signed(ALICE), collection, witness), + NftsError::UnknownCollection + ); + nfts::create_collection(ALICE); + assert_ok!(NonFungibles::destroy(signed(ALICE), collection, witness)); assert_eq!(Nfts::collection_owner(collection), None); }); } #[test] -fn collection_works() { +fn total_supply_works() { new_test_ext().execute_with(|| { - let (collection, _) = nfts::create_collection_mint(ALICE, ITEM); - assert_eq!( - NonFungibles::read(Collection(collection)).encode(), - CollectionOf::::get(&collection).encode(), - ); + let owner = ALICE; + let collection = nfts::create_collection(owner); + assert_eq!(NonFungibles::read(TotalSupply(collection)), ReadResult::TotalSupply(0)); + (0..10).into_iter().for_each(|i| { + assert_ok!(Nfts::mint(signed(owner), collection, i, owner, None)); + assert_eq!( + NonFungibles::read(TotalSupply(collection)), + ReadResult::TotalSupply((i + 1).into()) + ); + assert_eq!( + NonFungibles::read(TotalSupply(collection)).encode(), + (Nfts::collection_items(collection).unwrap_or_default() as u128).encode() + ); + }); }); } @@ -492,11 +503,15 @@ fn balance_of_works() { new_test_ext().execute_with(|| { let owner = ALICE; let collection = nfts::create_collection(owner); + assert_eq!( + NonFungibles::read(BalanceOf { collection, owner }), + ReadResult::BalanceOf(Default::default()) + ); (0..10).into_iter().for_each(|i| { assert_ok!(Nfts::mint(signed(owner), collection, i, owner, None)); assert_eq!( - NonFungibles::read(BalanceOf { collection, owner }).encode(), - (i + 1).encode() + NonFungibles::read(BalanceOf { collection, owner }), + ReadResult::BalanceOf(i + 1) ); assert_eq!( NonFungibles::read(BalanceOf { collection, owner }).encode(), @@ -513,9 +528,8 @@ fn allowance_works() { let operator = BOB; let (collection, item) = nfts::create_collection_mint_and_approve(owner, ITEM, operator); assert_eq!( - NonFungibles::read(Allowance { collection, item: Some(item), owner, operator }) - .encode(), - true.encode() + NonFungibles::read(Allowance { collection, item: Some(item), owner, operator }), + ReadResult::Allowance(true) ); assert_eq!( NonFungibles::read(Allowance { collection, item: Some(item), owner, operator }) @@ -527,6 +541,131 @@ fn allowance_works() { }); } +#[test] +fn owner_of_works() { + new_test_ext().execute_with(|| { + assert_eq!( + NonFungibles::read(OwnerOf { collection: COLLECTION, item: ITEM }), + ReadResult::OwnerOf(None) + ); + nfts::create_collection_mint(ALICE, ITEM); + assert_eq!( + NonFungibles::read(OwnerOf { collection: COLLECTION, item: ITEM }), + ReadResult::OwnerOf(Some(ALICE)) + ); + assert_eq!( + NonFungibles::read(OwnerOf { collection: COLLECTION, item: ITEM }).encode(), + Nfts::owner(COLLECTION, ITEM).encode() + ); + }); +} + +#[test] +fn get_attribute_works() { + new_test_ext().execute_with(|| { + let (collection, item) = nfts::create_collection_mint(ALICE, ITEM); + let attribute = BoundedVec::truncate_from("some attribute".as_bytes().to_vec()); + let raw_value = "some value".as_bytes().to_vec(); + let value = BoundedVec::truncate_from(raw_value.clone()); + let namespace = AttributeNamespace::CollectionOwner; + // No attribute set. + assert_eq!( + NonFungibles::read(GetAttribute { + collection, + item, + namespace: namespace.clone(), + key: attribute.clone() + }), + ReadResult::GetAttribute(None) + ); + // Successfully get an existing attribute. + assert_ok!(Nfts::set_attribute( + signed(ALICE), + collection, + Some(item), + namespace.clone(), + attribute.clone(), + value, + )); + assert_eq!( + NonFungibles::read(GetAttribute { + collection, + item, + namespace: namespace.clone(), + key: attribute.clone() + }), + ReadResult::GetAttribute(Some(raw_value)) + ); + assert_eq!( + NonFungibles::read(GetAttribute { + collection, + item, + namespace: namespace.clone(), + key: attribute.clone() + }) + .encode(), + AttributeOf::::get((collection, Some(item), namespace, attribute)) + .map(|result| result.0) + .encode() + ); + }); +} + +#[test] +fn collection_works() { + new_test_ext().execute_with(|| { + assert_eq!(NonFungibles::read(Collection(COLLECTION)), ReadResult::Collection(None),); + nfts::create_collection_mint(ALICE, ITEM); + assert_eq!( + NonFungibles::read(Collection(COLLECTION)), + ReadResult::Collection(CollectionOf::::get(COLLECTION)), + ); + assert_eq!( + NonFungibles::read(Collection(COLLECTION)).encode(), + CollectionOf::::get(COLLECTION).encode(), + ); + }); +} + +#[test] +fn item_metadata_works() { + new_test_ext().execute_with(|| { + assert_eq!( + NonFungibles::read(ItemMetadata { collection: COLLECTION, item: ITEM }), + ReadResult::ItemMetadata(None) + ); + nfts::create_collection_mint(ALICE, ITEM); + let value = "some metadata".as_bytes().to_vec(); + assert_ok!(NonFungibles::set_metadata( + signed(ALICE), + COLLECTION, + ITEM, + BoundedVec::truncate_from(value.clone()) + )); + assert_eq!( + NonFungibles::read(ItemMetadata { collection: COLLECTION, item: ITEM }), + ReadResult::ItemMetadata(Some(value)) + ); + assert_eq!( + NonFungibles::read(ItemMetadata { collection: COLLECTION, item: ITEM }).encode(), + Nfts::item_metadata(COLLECTION, ITEM).encode() + ); + }); +} + +#[test] +fn next_collection_id_works() { + new_test_ext().execute_with(|| { + assert_eq!(NonFungibles::read(NextCollectionId), ReadResult::NextCollectionId(Some(0))); + nfts::create_collection_mint(ALICE, ITEM); + assert_eq!(NonFungibles::read(NextCollectionId), ReadResult::NextCollectionId(Some(1))); + assert_eq!( + NonFungibles::read(NextCollectionId).encode(), + Some(NextCollectionIdOf::::get().unwrap_or_default()).encode(), + ); + }); +} + fn signed(account_id: AccountId) -> RuntimeOrigin { RuntimeOrigin::signed(account_id) } @@ -539,6 +678,7 @@ fn none() -> RuntimeOrigin { RuntimeOrigin::none() } +// Helper functions for interacting with pallet-nfts. mod nfts { use super::*; @@ -559,7 +699,7 @@ mod nfts { } pub(super) fn create_collection(owner: AccountId) -> u32 { - let next_id = next_collection_id(); + let next_id = NextCollectionIdOf::::get().unwrap_or_default(); assert_ok!(Nfts::create( signed(owner), owner, @@ -568,10 +708,6 @@ mod nfts { next_id } - pub(super) fn next_collection_id() -> u32 { - NextCollectionIdOf::::get().unwrap_or_default() - } - pub(super) fn collection_config_with_all_settings_enabled( ) -> CollectionConfig, CollectionIdOf> { CollectionConfig { @@ -581,3 +717,287 @@ mod nfts { } } } + +mod read_weights { + use frame_support::weights::Weight; + + use super::*; + use crate::nonfungibles::{weights::WeightInfo, Config}; + + struct ReadWeightInfo { + total_supply: Weight, + balance_of: Weight, + allowance: Weight, + owner_of: Weight, + get_attribute: Weight, + collection: Weight, + next_collection_id: Weight, + item_metadata: Weight, + } + + impl ReadWeightInfo { + fn new() -> Self { + Self { + total_supply: NonFungibles::weight(&TotalSupply(COLLECTION)), + balance_of: NonFungibles::weight(&BalanceOf { + collection: COLLECTION, + owner: ALICE, + }), + allowance: NonFungibles::weight(&Allowance { + collection: COLLECTION, + item: Some(ITEM), + owner: ALICE, + operator: BOB, + }), + owner_of: NonFungibles::weight(&OwnerOf { collection: COLLECTION, item: ITEM }), + get_attribute: NonFungibles::weight(&GetAttribute { + collection: COLLECTION, + item: ITEM, + namespace: AttributeNamespace::CollectionOwner, + key: BoundedVec::default(), + }), + collection: NonFungibles::weight(&Collection(COLLECTION)), + next_collection_id: NonFungibles::weight(&NextCollectionId), + item_metadata: NonFungibles::weight(&ItemMetadata { + collection: COLLECTION, + item: ITEM, + }), + } + } + } + + #[test] + fn ensure_read_matches_benchmarks() { + let ReadWeightInfo { + allowance, + balance_of, + collection, + get_attribute, + item_metadata, + next_collection_id, + owner_of, + total_supply, + } = ReadWeightInfo::new(); + + assert_eq!(total_supply, ::WeightInfo::total_supply()); + assert_eq!(balance_of, ::WeightInfo::balance_of()); + assert_eq!(allowance, ::WeightInfo::allowance()); + assert_eq!(owner_of, ::WeightInfo::owner_of()); + assert_eq!(get_attribute, ::WeightInfo::get_attribute()); + assert_eq!(collection, ::WeightInfo::collection()); + assert_eq!(next_collection_id, ::WeightInfo::next_collection_id()); + assert_eq!(item_metadata, ::WeightInfo::item_metadata()); + } + + // These types read from the `Collection` storage. + #[test] + fn ensure_collection_variants_match() { + let ReadWeightInfo { total_supply, collection, .. } = ReadWeightInfo::new(); + + assert_eq!(total_supply, collection); + } + + // Proof size is based on `MaxEncodedLen`, not hardware. + // This test ensures that the data structure sizes do not change with upgrades. + #[test] + fn ensure_expected_proof_size_does_not_change() { + let ReadWeightInfo { + allowance, + balance_of, + collection, + get_attribute, + item_metadata, + next_collection_id, + owner_of, + total_supply, + } = ReadWeightInfo::new(); + + // These values come from `weights.rs`. + assert_eq!(total_supply.proof_size(), 3557); + assert_eq!(balance_of.proof_size(), 3529); + assert_eq!(allowance.proof_size(), 4326); + assert_eq!(owner_of.proof_size(), 4326); + assert_eq!(get_attribute.proof_size(), 3944); + assert_eq!(collection.proof_size(), 3557); + assert_eq!(next_collection_id.proof_size(), 1489); + assert_eq!(item_metadata.proof_size(), 3812); + } +} + +mod ensure_codec_indexes { + use super::{Encode, *}; + use crate::{mock::RuntimeCall::NonFungibles, nonfungibles}; + + #[test] + fn ensure_read_variant_indexes() { + [ + (TotalSupply::(Default::default()), 0u8, "TotalSupply"), + ( + BalanceOf:: { collection: Default::default(), owner: Default::default() }, + 1, + "BalanceOf", + ), + ( + Allowance:: { + collection: Default::default(), + item: Default::default(), + owner: Default::default(), + operator: Default::default(), + }, + 2, + "Allowance", + ), + ( + OwnerOf:: { collection: Default::default(), item: Default::default() }, + 5, + "OwnerOf", + ), + ( + GetAttribute:: { + collection: Default::default(), + item: Default::default(), + namespace: AttributeNamespace::CollectionOwner, + key: Default::default(), + }, + 6, + "GetAttribute", + ), + (Collection::(Default::default()), 9, "Collection"), + (NextCollectionId, 10, "NextCollectionId"), + ( + ItemMetadata { collection: Default::default(), item: Default::default() }, + 11, + "ItemMetadata", + ), + ] + .iter() + .for_each(|(variant, expected_index, name)| { + assert_eq!(variant.encode()[0], *expected_index, "{name} variant index changed"); + }) + } + + #[test] + fn ensure_dispatchable_indexes() { + use nonfungibles::Call::*; + + [ + ( + transfer { + collection: Default::default(), + item: Default::default(), + to: Default::default(), + }, + 3u8, + "transfer", + ), + ( + approve { + collection: Default::default(), + item: Default::default(), + operator: Default::default(), + approved: Default::default(), + }, + 4, + "approve", + ), + (create { admin: Default::default(), config: Default::default() }, 7, "create"), + ( + destroy { + collection: Default::default(), + witness: DestroyWitness { + item_metadatas: Default::default(), + item_configs: Default::default(), + item_holders: Default::default(), + attributes: Default::default(), + allowances: Default::default(), + }, + }, + 8, + "destroy", + ), + ( + set_attribute { + collection: Default::default(), + item: Default::default(), + namespace: AttributeNamespace::CollectionOwner, + key: Default::default(), + value: Default::default(), + }, + 12, + "set_attribute", + ), + ( + clear_attribute { + collection: Default::default(), + item: Default::default(), + namespace: AttributeNamespace::CollectionOwner, + key: Default::default(), + }, + 13, + "clear_attribute", + ), + ( + set_metadata { + collection: Default::default(), + item: Default::default(), + data: Default::default(), + }, + 14, + "set_metadata", + ), + ( + clear_metadata { collection: Default::default(), item: Default::default() }, + 15, + "clear_metadata", + ), + ( + approve_item_attributes { + collection: Default::default(), + item: Default::default(), + delegate: Default::default(), + }, + 16, + "approve_item_attributes", + ), + ( + cancel_item_attributes_approval { + collection: Default::default(), + item: Default::default(), + delegate: Default::default(), + witness: CancelAttributesApprovalWitness { + account_attributes: Default::default(), + }, + }, + 17, + "cancel_item_attributes_approval", + ), + ( + set_max_supply { collection: Default::default(), max_supply: Default::default() }, + 18, + "set_max_supply", + ), + ( + mint { + to: Default::default(), + collection: Default::default(), + item: Default::default(), + witness: MintWitness { + owned_item: Default::default(), + mint_price: Default::default(), + }, + }, + 19, + "mint", + ), + (burn { collection: Default::default(), item: Default::default() }, 20, "burn"), + ] + .iter() + .for_each(|(variant, expected_index, name)| { + assert_eq!( + NonFungibles(variant.to_owned()).encode()[1], + *expected_index, + "{name} dispatchable index changed" + ); + }) + } +} diff --git a/pallets/api/src/nonfungibles/weights.rs b/pallets/api/src/nonfungibles/weights.rs new file mode 100644 index 00000000..f0b8fa83 --- /dev/null +++ b/pallets/api/src/nonfungibles/weights.rs @@ -0,0 +1,217 @@ + +//! Autogenerated weights for `nonfungibles` +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 40.0.0 +//! DATE: 2024-11-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! WORST CASE MAP SIZE: `1000000` +//! HOSTNAME: `R0GUE`, CPU: `` +//! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` + +// Executed Command: +// ./target/release/pop-node +// benchmark +// pallet +// --chain=dev +// --wasm-execution=compiled +// --pallet=nonfungibles +// --steps=50 +// --repeat=20 +// --json +// --template +// ./scripts/pallet-weights-template.hbs +// --output=./pallets/api/src/nonfungibles/weights.rs +// --extrinsic= + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] +#![allow(missing_docs)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use core::marker::PhantomData; + +/// Weight functions needed for `nonfungibles`. +pub trait WeightInfo { + fn total_supply() -> Weight; + fn balance_of() -> Weight; + fn allowance() -> Weight; + fn owner_of() -> Weight; + fn get_attribute() -> Weight; + fn collection() -> Weight; + fn next_collection_id() -> Weight; + fn item_metadata() -> Weight; +} + +/// Weights for `nonfungibles` using the Substrate node and recommended hardware. +pub struct SubstrateWeight(PhantomData); +impl WeightInfo for SubstrateWeight { + /// Storage: `Nfts::Collection` (r:1 w:0) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn total_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3557` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(2_000_000, 3557) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::AccountBalance` (r:1 w:0) + /// Proof: `Nfts::AccountBalance` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + fn balance_of() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3529` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(3_000_000, 3529) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::Allowances` (r:1 w:0) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Item` (r:1 w:0) + /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) + fn allowance() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `4326` + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(7_000_000, 4326) + .saturating_add(T::DbWeight::get().reads(2_u64)) + } + /// Storage: `Nfts::Item` (r:1 w:0) + /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) + fn owner_of() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `4326` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(2_000_000, 4326) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::Attribute` (r:1 w:0) + /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) + fn get_attribute() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3944` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(5_000_000, 3944) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::Collection` (r:1 w:0) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn collection() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3557` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(2_000_000, 3557) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::NextCollectionId` (r:1 w:0) + /// Proof: `Nfts::NextCollectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn next_collection_id() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `1489` + // Minimum execution time: 1_000_000 picoseconds. + Weight::from_parts(1_000_000, 1489) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::ItemMetadataOf` (r:1 w:0) + /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) + fn item_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3812` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(3_000_000, 3812) + .saturating_add(T::DbWeight::get().reads(1_u64)) + } +} + +// For backwards compatibility and tests. +impl WeightInfo for () { + /// Storage: `Nfts::Collection` (r:1 w:0) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn total_supply() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3557` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(2_000_000, 3557) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::AccountBalance` (r:1 w:0) + /// Proof: `Nfts::AccountBalance` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + fn balance_of() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3529` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(3_000_000, 3529) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::Allowances` (r:1 w:0) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Item` (r:1 w:0) + /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) + fn allowance() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `4326` + // Minimum execution time: 7_000_000 picoseconds. + Weight::from_parts(7_000_000, 4326) + .saturating_add(RocksDbWeight::get().reads(2_u64)) + } + /// Storage: `Nfts::Item` (r:1 w:0) + /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) + fn owner_of() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `4326` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(2_000_000, 4326) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::Attribute` (r:1 w:0) + /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) + fn get_attribute() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3944` + // Minimum execution time: 5_000_000 picoseconds. + Weight::from_parts(5_000_000, 3944) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::Collection` (r:1 w:0) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + fn collection() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3557` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(2_000_000, 3557) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::NextCollectionId` (r:1 w:0) + /// Proof: `Nfts::NextCollectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) + fn next_collection_id() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `1489` + // Minimum execution time: 1_000_000 picoseconds. + Weight::from_parts(1_000_000, 1489) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } + /// Storage: `Nfts::ItemMetadataOf` (r:1 w:0) + /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) + fn item_metadata() -> Weight { + // Proof Size summary in bytes: + // Measured: `3` + // Estimated: `3812` + // Minimum execution time: 2_000_000 picoseconds. + Weight::from_parts(3_000_000, 3812) + .saturating_add(RocksDbWeight::get().reads(1_u64)) + } +} + diff --git a/pallets/nfts/src/benchmarking.rs b/pallets/nfts/src/benchmarking.rs index ab66da26..58209b8b 100644 --- a/pallets/nfts/src/benchmarking.rs +++ b/pallets/nfts/src/benchmarking.rs @@ -64,6 +64,27 @@ fn add_collection_metadata, I: 'static>() -> (T::AccountId, Account (caller, caller_lookup) } +fn approve_collection, I: 'static>( + index: u32, +) -> (T::AccountId, AccountIdLookupOf) { + let caller = Collection::::get(T::Helper::collection(0)).unwrap().owner; + if caller != whitelisted_caller() { + whitelist_account!(caller); + } + let caller_lookup = T::Lookup::unlookup(caller.clone()); + let delegate: T::AccountId = account("delegate", 0, SEED + index); + let delegate_lookup = T::Lookup::unlookup(delegate.clone()); + let deadline = BlockNumberFor::::max_value(); + assert_ok!(Nfts::::approve_transfer( + SystemOrigin::Signed(caller.clone()).into(), + T::Helper::collection(0), + None, + delegate_lookup.clone(), + Some(deadline), + )); + (caller, caller_lookup) +} + fn mint_item, I: 'static>( index: u16, ) -> (T::ItemId, T::AccountId, AccountIdLookupOf) { @@ -77,7 +98,7 @@ fn mint_item, I: 'static>( let item_exists = Item::::contains_key(&collection, &item); let item_config = ItemConfigOf::::get(&collection, &item); if item_exists { - return (item, caller, caller_lookup) + return (item, caller, caller_lookup); } else if let Some(item_config) = item_config { assert_ok!(Nfts::::force_mint( SystemOrigin::Signed(caller.clone()).into(), @@ -250,6 +271,8 @@ benchmarks_instance_pallet! { let m in 0 .. 1_000; let c in 0 .. 1_000; let a in 0 .. 1_000; + let h in 0 .. 1_000; + let l in 0 .. 1_000; let (collection, caller, _) = create_collection::(); add_collection_metadata::(); @@ -267,6 +290,13 @@ benchmarks_instance_pallet! { for i in 0..a { add_collection_attribute::(i as u16); } + for i in 0..h { + mint_item::(i as u16); + burn_item::(i as u16); + } + for i in 0..l { + approve_collection::(i as u32); + } let witness = Collection::::get(collection).unwrap().destroy_witness(); }: _(SystemOrigin::Signed(caller), collection, witness) verify { @@ -573,27 +603,45 @@ benchmarks_instance_pallet! { } approve_transfer { + let i in 0..1; + let (collection, caller, _) = create_collection::(); let (item, ..) = mint_item::(0); let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); - let deadline = BlockNumberFor::::max_value(); - }: _(SystemOrigin::Signed(caller.clone()), collection, Some(item), delegate_lookup, Some(deadline)) + let maybe_deadline = if i == 0 { + None + } else { + Some(BlockNumberFor::::max_value()) + }; + let maybe_item = if i == 0 { + None + } else { + Some(item) + }; + }: _(SystemOrigin::Signed(caller.clone()), collection, maybe_item, delegate_lookup, maybe_deadline) verify { - assert_last_event::(Event::TransferApproved { collection, item: Some(item), owner: caller, delegate, deadline: Some(deadline) }.into()); + assert_last_event::(Event::TransferApproved { collection, item: maybe_item, owner: caller, delegate, deadline: maybe_deadline }.into()); } cancel_approval { + let i in 0..1; + let (collection, caller, _) = create_collection::(); let (item, ..) = mint_item::(0); let delegate: T::AccountId = account("delegate", 0, SEED); let delegate_lookup = T::Lookup::unlookup(delegate.clone()); let origin = SystemOrigin::Signed(caller.clone()).into(); let deadline = BlockNumberFor::::max_value(); - Nfts::::approve_transfer(origin, collection, Some(item), delegate_lookup.clone(), Some(deadline))?; - }: _(SystemOrigin::Signed(caller.clone()), collection, Some(item), delegate_lookup) + let maybe_item = if i == 0 { + None + } else { + Some(item) + }; + Nfts::::approve_transfer(origin, collection, maybe_item, delegate_lookup.clone(), Some(deadline))?; + }: _(SystemOrigin::Signed(caller.clone()), collection, maybe_item, delegate_lookup) verify { - assert_last_event::(Event::ApprovalCancelled { collection, item: Some(item), owner: caller, delegate }.into()); + assert_last_event::(Event::ApprovalCancelled { collection, item: maybe_item, owner: caller, delegate }.into()); } clear_all_transfer_approvals { diff --git a/pallets/nfts/src/common_functions.rs b/pallets/nfts/src/common_functions.rs index 89de1f05..abd8b61d 100644 --- a/pallets/nfts/src/common_functions.rs +++ b/pallets/nfts/src/common_functions.rs @@ -39,6 +39,11 @@ impl, I: 'static> Pallet { Collection::::get(collection).map(|i| i.items) } + /// Get the allowances to spend items within the collection. + pub fn collection_allowances(collection: T::CollectionId) -> Option { + Collection::::get(collection).map(|i| i.allowances) + } + /// Get the metadata of the collection item. pub fn item_metadata( collection: T::CollectionId, diff --git a/pallets/nfts/src/features/approvals.rs b/pallets/nfts/src/features/approvals.rs index e1e79ef4..2647492c 100644 --- a/pallets/nfts/src/features/approvals.rs +++ b/pallets/nfts/src/features/approvals.rs @@ -195,6 +195,15 @@ impl, I: 'static> Pallet { Allowances::::mutate((&collection, &owner, &delegate), |allowance| { *allowance = true; }); + Collection::::try_mutate( + &collection, + |maybe_collection_details| -> Result<(), DispatchError> { + let collection_details = + maybe_collection_details.as_mut().ok_or(Error::::UnknownCollection)?; + collection_details.allowances.saturating_inc(); + Ok(()) + }, + )?; Self::deposit_event(Event::TransferApproved { collection, @@ -217,6 +226,15 @@ impl, I: 'static> Pallet { ensure!(check_origin == owner, Error::::NoPermission); } Allowances::::remove((&collection, &owner, &delegate)); + Collection::::try_mutate( + &collection, + |maybe_collection_details| -> Result<(), DispatchError> { + let collection_details = + maybe_collection_details.as_mut().ok_or(Error::::UnknownCollection)?; + collection_details.allowances.saturating_dec(); + Ok(()) + }, + )?; Self::deposit_event(Event::ApprovalCancelled { collection, owner, item: None, delegate }); diff --git a/pallets/nfts/src/features/create_delete_collection.rs b/pallets/nfts/src/features/create_delete_collection.rs index b7efd03a..1d08cd1b 100644 --- a/pallets/nfts/src/features/create_delete_collection.rs +++ b/pallets/nfts/src/features/create_delete_collection.rs @@ -54,7 +54,9 @@ impl, I: 'static> Pallet { items: 0, item_metadatas: 0, item_configs: 0, + item_holders: 0, attributes: 0, + allowances: 0, }, ); CollectionRoleOf::::insert( @@ -119,6 +121,11 @@ impl, I: 'static> Pallet { collection_details.item_configs == witness.item_configs, Error::::BadWitness ); + ensure!( + collection_details.item_holders == witness.item_holders, + Error::::BadWitness + ); + ensure!(collection_details.allowances == witness.allowances, Error::::BadWitness); for (_, metadata) in ItemMetadataOf::::drain_prefix(&collection) { if let Some(depositor) = metadata.deposit.account { @@ -137,8 +144,6 @@ impl, I: 'static> Pallet { } } - // TODO: Do we need another storage item to keep track of number of holders of a - // collection let _ = AccountBalance::::clear_prefix(collection, collection_details.items, None); let _ = Allowances::::clear_prefix((collection,), collection_details.items, None); @@ -152,7 +157,9 @@ impl, I: 'static> Pallet { Ok(DestroyWitness { item_metadatas: collection_details.item_metadatas, item_configs: collection_details.item_configs, + item_holders: collection_details.item_holders, attributes: collection_details.attributes, + allowances: collection_details.allowances, }) }) } diff --git a/pallets/nfts/src/features/create_delete_item.rs b/pallets/nfts/src/features/create_delete_item.rs index cc29f8da..a7b7ddf3 100644 --- a/pallets/nfts/src/features/create_delete_item.rs +++ b/pallets/nfts/src/features/create_delete_item.rs @@ -69,9 +69,15 @@ impl, I: 'static> Pallet { } collection_details.items.saturating_inc(); - AccountBalance::::mutate(collection, &mint_to, |balance| { - balance.saturating_inc(); - }); + + let account_balance = + AccountBalance::::mutate(collection, &mint_to, |balance| -> u32 { + balance.saturating_inc(); + balance.clone() + }); + if account_balance == 1 { + collection_details.item_holders.saturating_inc(); + } let collection_config = Self::get_collection_config(&collection)?; let deposit_amount = match collection_config @@ -257,6 +263,10 @@ impl, I: 'static> Pallet { } } + if AccountBalance::::get(collection, &details.owner) == 1 { + collection_details.item_holders.saturating_dec(); + } + Ok(details.owner) }, )?; diff --git a/pallets/nfts/src/features/transfer.rs b/pallets/nfts/src/features/transfer.rs index 3b25b014..dbe6f3b0 100644 --- a/pallets/nfts/src/features/transfer.rs +++ b/pallets/nfts/src/features/transfer.rs @@ -54,7 +54,7 @@ impl, I: 'static> Pallet { ) -> DispatchResult, ) -> DispatchResult { // Retrieve collection details. - let collection_details = + let mut collection_details = Collection::::get(&collection).ok_or(Error::::UnknownCollection)?; // Ensure the item is not locked. @@ -87,13 +87,23 @@ impl, I: 'static> Pallet { // Perform the transfer with custom details using the provided closure. with_details(&collection_details, &mut details)?; - // Update account balances. - AccountBalance::::mutate(collection, &details.owner, |balance| { - balance.saturating_dec(); - }); - AccountBalance::::mutate(collection, &dest, |balance| { + // Update account balance of the owner. + let owner_balance = + AccountBalance::::mutate(collection, &details.owner, |balance| -> u32 { + balance.saturating_dec(); + balance.clone() + }); + if owner_balance == 0 { + collection_details.item_holders.saturating_dec(); + } + // Update account balance of the destination account. + let dest_balance = AccountBalance::::mutate(collection, &dest, |balance| -> u32 { balance.saturating_inc(); + balance.clone() }); + if dest_balance == 1 { + collection_details.item_holders.saturating_inc(); + } // Update account ownership information. Account::::remove((&details.owner, &collection, &item)); @@ -108,6 +118,7 @@ impl, I: 'static> Pallet { // Update item details. Item::::insert(&collection, &item, &details); + Collection::::insert(&collection, &collection_details); ItemPriceOf::::remove(&collection, &item); PendingSwapOf::::remove(&collection, &item); diff --git a/pallets/nfts/src/lib.rs b/pallets/nfts/src/lib.rs index bc8b67b6..37e8b29c 100644 --- a/pallets/nfts/src/lib.rs +++ b/pallets/nfts/src/lib.rs @@ -30,7 +30,6 @@ #[cfg(feature = "runtime-benchmarks")] mod benchmarking; -pub mod migration; #[cfg(test)] pub mod mock; #[cfg(test)] @@ -832,6 +831,8 @@ pub mod pallet { witness.item_metadatas, witness.item_configs, witness.attributes, + witness.item_holders, + witness.allowances, ))] pub fn destroy( origin: OriginFor, @@ -847,6 +848,8 @@ pub mod pallet { details.item_metadatas, details.item_configs, details.attributes, + details.item_holders, + details.allowances, )) .into()) } @@ -1311,7 +1314,7 @@ pub mod pallet { /// /// Weight: `O(1)` #[pallet::call_index(15)] - #[pallet::weight(T::WeightInfo::approve_transfer())] + #[pallet::weight(T::WeightInfo::approve_transfer(maybe_item.is_some() as u32))] pub fn approve_transfer( origin: OriginFor, collection: T::CollectionId, @@ -1350,7 +1353,7 @@ pub mod pallet { /// /// Weight: `O(1)` #[pallet::call_index(16)] - #[pallet::weight(T::WeightInfo::cancel_approval())] + #[pallet::weight(T::WeightInfo::cancel_approval(maybe_item.is_some() as u32))] pub fn cancel_approval( origin: OriginFor, collection: T::CollectionId, diff --git a/pallets/nfts/src/migration.rs b/pallets/nfts/src/migration.rs deleted file mode 100644 index af611bf1..00000000 --- a/pallets/nfts/src/migration.rs +++ /dev/null @@ -1,120 +0,0 @@ -// This file is part of Substrate. - -// Copyright (C) Parity Technologies (UK) Ltd. -// SPDX-License-Identifier: Apache-2.0 - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -use frame_support::traits::OnRuntimeUpgrade; -use log; -#[cfg(feature = "try-runtime")] -use sp_runtime::TryRuntimeError; - -use super::*; - -pub mod v1 { - use frame_support::{pallet_prelude::*, weights::Weight}; - - use super::*; - - #[derive(Decode)] - pub struct OldCollectionDetails { - pub owner: AccountId, - pub owner_deposit: DepositBalance, - pub items: u32, - pub item_metadatas: u32, - pub attributes: u32, - } - - impl OldCollectionDetails { - /// Migrates the old collection details to the new v1 format. - fn migrate_to_v1(self, item_configs: u32) -> CollectionDetails { - CollectionDetails { - owner: self.owner, - owner_deposit: self.owner_deposit, - items: self.items, - item_metadatas: self.item_metadatas, - item_configs, - attributes: self.attributes, - } - } - } - - /// A migration utility to update the storage version from v0 to v1 for the pallet. - pub struct MigrateToV1(core::marker::PhantomData); - impl OnRuntimeUpgrade for MigrateToV1 { - fn on_runtime_upgrade() -> Weight { - let in_code_version = Pallet::::in_code_storage_version(); - let on_chain_version = Pallet::::on_chain_storage_version(); - - log::info!( - target: LOG_TARGET, - "Running migration with in-code storage version {:?} / onchain {:?}", - in_code_version, - on_chain_version - ); - - if on_chain_version == 0 && in_code_version == 1 { - let mut translated = 0u64; - let mut configs_iterated = 0u64; - Collection::::translate::< - OldCollectionDetails>, - _, - >(|key, old_value| { - let item_configs = ItemConfigOf::::iter_prefix(&key).count() as u32; - configs_iterated += item_configs as u64; - translated.saturating_inc(); - Some(old_value.migrate_to_v1(item_configs)) - }); - - in_code_version.put::>(); - - log::info!( - target: LOG_TARGET, - "Upgraded {} records, storage to version {:?}", - translated, - in_code_version - ); - T::DbWeight::get().reads_writes(translated + configs_iterated + 1, translated + 1) - } else { - log::info!( - target: LOG_TARGET, - "Migration did not execute. This probably should be removed" - ); - T::DbWeight::get().reads(1) - } - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { - let prev_count = Collection::::iter().count(); - Ok((prev_count as u32).encode()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(prev_count: Vec) -> Result<(), TryRuntimeError> { - let prev_count: u32 = Decode::decode(&mut prev_count.as_slice()).expect( - "the state parameter should be something that was generated by pre_upgrade", - ); - let post_count = Collection::::iter().count() as u32; - ensure!( - prev_count == post_count, - "the records count before and after the migration should be the same" - ); - - ensure!(Pallet::::on_chain_storage_version() >= 1, "wrong storage version"); - - Ok(()) - } - } -} diff --git a/pallets/nfts/src/tests.rs b/pallets/nfts/src/tests.rs index 4d0f08c9..6d0c894a 100644 --- a/pallets/nfts/src/tests.rs +++ b/pallets/nfts/src/tests.rs @@ -165,6 +165,7 @@ fn basic_minting_should_work() { assert_eq!(collections(), vec![(account(1), 0)]); assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 42, account(1), None)); assert_eq!(AccountBalance::::get(0, account(1)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_eq!(items(), vec![(account(1), 0, 42)]); assert_ok!(Nfts::force_create( @@ -175,10 +176,37 @@ fn basic_minting_should_work() { assert_eq!(collections(), vec![(account(1), 0), (account(2), 1)]); assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(2)), 1, 69, account(1), None)); assert_eq!(AccountBalance::::get(1, account(1)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_eq!(items(), vec![(account(1), 0, 42), (account(1), 1, 69)]); }); } +#[test] +fn collection_item_holders_should_works() { + new_test_ext().execute_with(|| { + assert_ok!(Nfts::force_create( + RuntimeOrigin::root(), + account(1), + default_collection_config() + )); + assert_eq!(collections(), vec![(account(1), 0)]); + let total = 5; + for i in 0..total { + assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, i, account(1), None)); + } + assert_eq!(AccountBalance::::get(0, account(1)), total); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); + + assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, total, account(2), None)); + assert_eq!(AccountBalance::::get(0, account(2)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 2); + + assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(2)), 0, total)); + assert_eq!(AccountBalance::::get(0, account(2)), 0); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); + }); +} + #[test] fn lifecycle_should_work() { new_test_ext().execute_with(|| { @@ -223,6 +251,7 @@ fn lifecycle_should_work() { assert_eq!(Collection::::get(0).unwrap().items, 3); assert_eq!(Collection::::get(0).unwrap().item_metadatas, 0); assert_eq!(Collection::::get(0).unwrap().item_configs, 3); + assert_eq!(Collection::::get(0).unwrap().item_holders, 3); assert_eq!(Balances::reserved_balance(&account(1)), 8); assert_ok!(Nfts::transfer(RuntimeOrigin::signed(account(1)), 0, 70, account(2))); @@ -317,6 +346,7 @@ fn destroy_should_work() { assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 42, account(2), None)); assert_eq!(AccountBalance::::get(0, account(2)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_ok!(Nfts::approve_transfer( RuntimeOrigin::signed(account(1)), 0, @@ -360,6 +390,7 @@ fn mint_should_work() { assert_ok!(Nfts::mint(RuntimeOrigin::signed(account(1)), 0, 42, account(1), None)); assert_eq!(AccountBalance::::get(0, account(1)), 1); assert_eq!(Nfts::owner(0, 42).unwrap(), account(1)); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_eq!(collections(), vec![(account(1), 0)]); assert_eq!(items(), vec![(account(1), 0, 42)]); @@ -425,6 +456,7 @@ fn mint_should_work() { Some(MintWitness { mint_price: Some(1), ..Default::default() }) )); assert_eq!(AccountBalance::::get(0, account(2)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 2); assert_eq!(Balances::total_balance(&account(2)), 99); // validate types @@ -464,6 +496,7 @@ fn mint_should_work() { Some(MintWitness { owned_item: Some(43), ..Default::default() }) )); assert_eq!(AccountBalance::::get(1, account(2)), 1); + assert_eq!(Collection::::get(1).unwrap().item_holders, 1); assert!(events().contains(&Event::::PalletAttributeSet { collection: 0, item: Some(43), @@ -500,10 +533,11 @@ fn transfer_should_work() { account(2), default_item_config() )); - + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_ok!(Nfts::transfer(RuntimeOrigin::signed(account(2)), 0, 42, account(3))); assert_eq!(AccountBalance::::get(0, account(2)), 0); assert_eq!(AccountBalance::::get(0, account(3)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_eq!(items(), vec![(account(3), 0, 42)]); assert_noop!( Nfts::transfer(RuntimeOrigin::signed(account(2)), 0, 42, account(4)), @@ -521,6 +555,7 @@ fn transfer_should_work() { assert_eq!(AccountBalance::::get(0, account(2)), 0); assert_eq!(AccountBalance::::get(0, account(3)), 0); assert_eq!(AccountBalance::::get(0, account(4)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); // validate we can't transfer non-transferable items let collection_id = 1; assert_ok!(Nfts::force_create( @@ -1775,6 +1810,7 @@ fn burn_works() { default_item_config() )); assert_eq!(AccountBalance::::get(0, account(5)), 2); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_eq!(Balances::reserved_balance(account(1)), 2); assert_noop!( @@ -1783,8 +1819,10 @@ fn burn_works() { ); assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 42)); assert_eq!(AccountBalance::::get(0, account(5)), 1); + assert_eq!(Collection::::get(0).unwrap().item_holders, 1); assert_ok!(Nfts::burn(RuntimeOrigin::signed(account(5)), 0, 69)); assert_eq!(AccountBalance::::get(0, account(5)), 0); + assert_eq!(Collection::::get(0).unwrap().item_holders, 0); assert_eq!(Balances::reserved_balance(account(1)), 0); }); } @@ -2036,6 +2074,7 @@ fn cancel_approval_collection_works_with_admin() { delegate: account(3) })); assert_eq!(Allowances::::get((0, account(2), account(3))), false); + assert_eq!(Nfts::collection_allowances(0).unwrap(), 0); assert_noop!( Nfts::transfer(RuntimeOrigin::signed(account(3)), 0, 42, account(4)), @@ -2192,6 +2231,7 @@ fn approval_collection_works_with_admin() { deadline: None })); assert_eq!(Allowances::::get((0, account(1), account(3))), true); + assert_eq!(Nfts::collection_allowances(0).unwrap(), 1); assert_ok!(Nfts::transfer(RuntimeOrigin::signed(account(3)), 0, 42, account(4))); }); } @@ -4114,7 +4154,13 @@ fn clear_collection_metadata_works() { assert_ok!(Nfts::destroy( RuntimeOrigin::signed(account(1)), 0, - DestroyWitness { item_configs: 0, item_metadatas: 0, attributes: 0 } + DestroyWitness { + item_configs: 0, + item_metadatas: 0, + attributes: 0, + allowances: 0, + item_holders: 0 + } )); assert_eq!(Collection::::get(0), None); assert_eq!(Balances::reserved_balance(&account(1)), 10); diff --git a/pallets/nfts/src/types.rs b/pallets/nfts/src/types.rs index 941da6ca..46148d63 100644 --- a/pallets/nfts/src/types.rs +++ b/pallets/nfts/src/types.rs @@ -104,8 +104,12 @@ pub struct CollectionDetails { pub item_metadatas: u32, /// The total number of outstanding item configs of this collection. pub item_configs: u32, + /// The total number of accounts that hold items of the collection. + pub item_holders: u32, /// The total number of attributes for this collection. pub attributes: u32, + /// The total number of allowances to spend all items within collections. + pub allowances: u32, } /// Witness data for the destroy transactions. @@ -117,9 +121,15 @@ pub struct DestroyWitness { /// The total number of outstanding item configs of this collection. #[codec(compact)] pub item_configs: u32, + /// The total number of accounts that hold items of the collection. + #[codec(compact)] + pub item_holders: u32, /// The total number of attributes for this collection. #[codec(compact)] pub attributes: u32, + /// The total number of allowances to spend all items within collections. + #[codec(compact)] + pub allowances: u32, } impl CollectionDetails { @@ -127,7 +137,9 @@ impl CollectionDetails { DestroyWitness { item_metadatas: self.item_metadatas, item_configs: self.item_configs, + item_holders: self.item_holders, attributes: self.attributes, + allowances: self.allowances, } } } diff --git a/pallets/nfts/src/weights.rs b/pallets/nfts/src/weights.rs index c374d6db..b3307503 100644 --- a/pallets/nfts/src/weights.rs +++ b/pallets/nfts/src/weights.rs @@ -2,7 +2,7 @@ //! Autogenerated weights for `pallet_nfts` //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 40.0.0 -//! DATE: 2024-10-24, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2024-11-16, STEPS: `50`, REPEAT: `20`, LOW RANGE: `[]`, HIGH RANGE: `[]` //! WORST CASE MAP SIZE: `1000000` //! HOSTNAME: `R0GUE`, CPU: `` //! WASM-EXECUTION: `Compiled`, CHAIN: `Some("dev")`, DB CACHE: `1024` @@ -36,7 +36,7 @@ use core::marker::PhantomData; pub trait WeightInfo { fn create() -> Weight; fn force_create() -> Weight; - fn destroy(m: u32, c: u32, a: u32, ) -> Weight; + fn destroy(m: u32, c: u32, a: u32, h: u32, l: u32, ) -> Weight; fn mint() -> Weight; fn force_mint() -> Weight; fn burn() -> Weight; @@ -59,8 +59,8 @@ pub trait WeightInfo { fn clear_metadata() -> Weight; fn set_collection_metadata() -> Weight; fn clear_collection_metadata() -> Weight; - fn approve_transfer() -> Weight; - fn cancel_approval() -> Weight; + fn approve_transfer(i: u32, ) -> Weight; + fn cancel_approval(i: u32, ) -> Weight; fn clear_all_transfer_approvals() -> Weight; fn set_accept_ownership() -> Weight; fn set_collection_max_supply() -> Weight; @@ -81,7 +81,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::NextCollectionId` (r:1 w:1) /// Proof: `Nfts::NextCollectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:0 w:1) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:0 w:1) @@ -91,16 +91,16 @@ impl WeightInfo for SubstrateWeight { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `105` - // Estimated: `3549` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(27_000_000, 3549) + // Estimated: `3557` + // Minimum execution time: 28_000_000 picoseconds. + Weight::from_parts(29_000_000, 3557) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `Nfts::NextCollectionId` (r:1 w:1) /// Proof: `Nfts::NextCollectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:0 w:1) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:0 w:1) @@ -110,14 +110,14 @@ impl WeightInfo for SubstrateWeight { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `3` - // Estimated: `3549` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(15_000_000, 3549) + // Estimated: `3557` + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(15_000_000, 3557) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemMetadataOf` (r:1 w:0) /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:1 w:1) @@ -126,6 +126,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:0) /// Proof: `Nfts::AccountBalance` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Allowances` (r:1 w:0) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1000 w:1000) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionMetadataOf` (r:0 w:1) @@ -137,19 +139,17 @@ impl WeightInfo for SubstrateWeight { /// The range of component `m` is `[0, 1000]`. /// The range of component `c` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(m: u32, c: u32, a: u32, ) -> Weight { + /// The range of component `h` is `[0, 1000]`. + /// The range of component `l` is `[0, 1000]`. + fn destroy(_m: u32, _c: u32, a: u32, _h: u32, _l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `32216 + a * (366 ±0)` + // Measured: `32875 + a * (366 ±0)` // Estimated: `2523990 + a * (2954 ±0)` // Minimum execution time: 982_000_000 picoseconds. - Weight::from_parts(937_587_516, 2523990) - // Standard Error: 12_288 - .saturating_add(Weight::from_parts(34_348, 0).saturating_mul(m.into())) - // Standard Error: 12_288 - .saturating_add(Weight::from_parts(23_800, 0).saturating_mul(c.into())) - // Standard Error: 12_288 - .saturating_add(Weight::from_parts(5_095_505, 0).saturating_mul(a.into())) - .saturating_add(T::DbWeight::get().reads(1005_u64)) + Weight::from_parts(4_613_129_128, 2523990) + // Standard Error: 125_087 + .saturating_add(Weight::from_parts(5_072_767, 0).saturating_mul(a.into())) + .saturating_add(T::DbWeight::get().reads(1006_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(T::DbWeight::get().writes(1005_u64)) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(a.into()))) @@ -160,7 +160,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:1) @@ -171,10 +171,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Account` (`max_values`: None, `max_size`: Some(88), added: 2563, mode: `MaxEncodedLen`) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `382` + // Measured: `390` // Estimated: `4326` - // Minimum execution time: 41_000_000 picoseconds. - Weight::from_parts(42_000_000, 4326) + // Minimum execution time: 40_000_000 picoseconds. + Weight::from_parts(41_000_000, 4326) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -183,7 +183,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:1) @@ -194,10 +194,10 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Account` (`max_values`: None, `max_size`: Some(88), added: 2563, mode: `MaxEncodedLen`) fn force_mint() -> Weight { // Proof Size summary in bytes: - // Measured: `382` + // Measured: `390` // Estimated: `4326` // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(40_000_000, 4326) + Weight::from_parts(39_000_000, 4326) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(5_u64)) } @@ -206,7 +206,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::ItemConfigOf` (r:1 w:1) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemMetadataOf` (r:1 w:0) @@ -223,15 +223,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `576` + // Measured: `584` // Estimated: `4326` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(59_000_000, 4326) + // Minimum execution time: 45_000_000 picoseconds. + Weight::from_parts(46_000_000, 4326) .saturating_add(T::DbWeight::get().reads(6_u64)) .saturating_add(T::DbWeight::get().writes(8_u64)) } - /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:1 w:0) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -250,15 +250,15 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `605` + // Measured: `613` // Estimated: `6068` // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(83_000_000, 6068) + Weight::from_parts(38_000_000, 6068) .saturating_add(T::DbWeight::get().reads(7_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Item` (r:5000 w:5000) @@ -266,12 +266,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `690 + i * (108 ±0)` - // Estimated: `3549 + i * (3336 ±0)` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(11_000_000, 3549) - // Standard Error: 20_022 - .saturating_add(Weight::from_parts(16_005_327, 0).saturating_mul(i.into())) + // Measured: `698 + i * (108 ±0)` + // Estimated: `3557 + i * (3336 ±0)` + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 3557) + // Standard Error: 30_743 + .saturating_add(Weight::from_parts(15_569_470, 0).saturating_mul(i.into())) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -285,7 +285,7 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `395` // Estimated: `3534` - // Minimum execution time: 13_000_000 picoseconds. + // Minimum execution time: 14_000_000 picoseconds. Weight::from_parts(14_000_000, 3534) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -298,35 +298,35 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `395` // Estimated: `3534` - // Minimum execution time: 14_000_000 picoseconds. + // Minimum execution time: 13_000_000 picoseconds. Weight::from_parts(14_000_000, 3534) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:1) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) fn lock_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `267` - // Estimated: `3549` + // Measured: `275` + // Estimated: `3557` // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(11_000_000, 3549) + Weight::from_parts(11_000_000, 3557) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Nfts::OwnershipAcceptance` (r:1 w:1) /// Proof: `Nfts::OwnershipAcceptance` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionAccount` (r:0 w:2) /// Proof: `Nfts::CollectionAccount` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `425` // Estimated: `3593` // Minimum execution time: 18_000_000 picoseconds. Weight::from_parts(19_000_000, 3593) @@ -334,12 +334,12 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:2 w:4) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `296` + // Measured: `304` // Estimated: `6078` // Minimum execution time: 30_000_000 picoseconds. Weight::from_parts(31_000_000, 6078) @@ -347,28 +347,28 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(5_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionAccount` (r:0 w:2) /// Proof: `Nfts::CollectionAccount` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) fn force_collection_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `238` - // Estimated: `3549` + // Measured: `246` + // Estimated: `3557` // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_000_000, 3549) + Weight::from_parts(12_000_000, 3557) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(3_u64)) } /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:0 w:1) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) fn force_collection_config() -> Weight { // Proof Size summary in bytes: // Measured: `203` - // Estimated: `3549` + // Estimated: `3557` // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(9_000_000, 3549) + Weight::from_parts(9_000_000, 3557) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -386,7 +386,7 @@ impl WeightInfo for SubstrateWeight { .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -397,20 +397,20 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `499` + // Measured: `507` // Estimated: `3944` - // Minimum execution time: 37_000_000 picoseconds. - Weight::from_parts(38_000_000, 3944) + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(39_000_000, 3944) .saturating_add(T::DbWeight::get().reads(5_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:1 w:1) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) fn force_set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `271` + // Measured: `279` // Estimated: `3944` // Minimum execution time: 19_000_000 picoseconds. Weight::from_parts(19_000_000, 3944) @@ -424,13 +424,13 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::ItemConfigOf` (r:1 w:0) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `943` + // Measured: `951` // Estimated: `3944` // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(36_000_000, 3944) + Weight::from_parts(37_000_000, 3944) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -462,8 +462,8 @@ impl WeightInfo for SubstrateWeight { // Estimated: `4466 + n * (2954 ±0)` // Minimum execution time: 18_000_000 picoseconds. Weight::from_parts(19_000_000, 4466) - // Standard Error: 6_379 - .saturating_add(Weight::from_parts(5_018_740, 0).saturating_mul(n.into())) + // Standard Error: 10_431 + .saturating_add(Weight::from_parts(4_776_454, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -473,7 +473,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1 w:0) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -482,7 +482,7 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `499` + // Measured: `507` // Estimated: `3812` // Minimum execution time: 30_000_000 picoseconds. Weight::from_parts(31_000_000, 3812) @@ -494,15 +494,15 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::ItemMetadataOf` (r:1 w:1) /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1 w:0) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `809` + // Measured: `817` // Estimated: `3812` - // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(29_000_000, 3812) + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 3812) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -511,32 +511,32 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionMetadataOf` (r:1 w:1) /// Proof: `Nfts::CollectionMetadataOf` (`max_values`: None, `max_size`: Some(294), added: 2769, mode: `MaxEncodedLen`) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `325` + // Measured: `333` // Estimated: `3759` // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(30_000_000, 3759) + Weight::from_parts(28_000_000, 3759) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionMetadataOf` (r:1 w:1) /// Proof: `Nfts::CollectionMetadataOf` (`max_values`: None, `max_size`: Some(294), added: 2769, mode: `MaxEncodedLen`) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `643` + // Measured: `651` // Estimated: `3759` // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(29_000_000, 3759) + Weight::from_parts(28_000_000, 3759) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().writes(2_u64)) } @@ -544,25 +544,37 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) - fn approve_transfer() -> Weight { - // Proof Size summary in bytes: - // Measured: `337` - // Estimated: `4326` - // Minimum execution time: 13_000_000 picoseconds. - Weight::from_parts(14_000_000, 4326) - .saturating_add(T::DbWeight::get().reads(2_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Allowances` (r:1 w:1) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 1]`. + fn approve_transfer(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `308 + i * (29 ±0)` + // Estimated: `3574 + i * (2163 ±0)` + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(16_969_387, 3574) + .saturating_add(T::DbWeight::get().reads(3_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2163).saturating_mul(i.into())) } /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) - fn cancel_approval() -> Weight { - // Proof Size summary in bytes: - // Measured: `345` - // Estimated: `4326` + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Allowances` (r:0 w:1) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 1]`. + fn cancel_approval(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `312 + i * (33 ±0)` + // Estimated: `3557 + i * (2163 ±0)` // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_000_000, 4326) + Weight::from_parts(14_000_000, 3557) .saturating_add(T::DbWeight::get().reads(1_u64)) - .saturating_add(T::DbWeight::get().writes(1_u64)) + .saturating_add(T::DbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2163).saturating_mul(i.into())) } /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) @@ -582,20 +594,20 @@ impl WeightInfo for SubstrateWeight { // Measured: `3` // Estimated: `3517` // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(10_000_000, 3517) + Weight::from_parts(9_000_000, 3517) .saturating_add(T::DbWeight::get().reads(1_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } /// Storage: `Nfts::CollectionConfigOf` (r:1 w:1) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `267` - // Estimated: `3549` + // Measured: `275` + // Estimated: `3557` // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 3549) + Weight::from_parts(13_000_000, 3557) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -608,7 +620,7 @@ impl WeightInfo for SubstrateWeight { // Measured: `250` // Estimated: `3538` // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 3538) + Weight::from_parts(12_000_000, 3538) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -624,8 +636,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `478` // Estimated: `4326` - // Minimum execution time: 16_000_000 picoseconds. - Weight::from_parts(17_000_000, 4326) + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(16_000_000, 4326) .saturating_add(T::DbWeight::get().reads(3_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -633,8 +645,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemPriceOf` (r:1 w:1) /// Proof: `Nfts::ItemPriceOf` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`) - /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:1 w:0) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -649,12 +661,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `717` + // Measured: `725` // Estimated: `6068` - // Minimum execution time: 42_000_000 picoseconds. - Weight::from_parts(45_000_000, 6068) + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(44_000_000, 6068) .saturating_add(T::DbWeight::get().reads(8_u64)) - .saturating_add(T::DbWeight::get().writes(7_u64)) + .saturating_add(T::DbWeight::get().writes(8_u64)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { @@ -662,9 +674,9 @@ impl WeightInfo for SubstrateWeight { // Measured: `0` // Estimated: `0` // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(390_532, 0) - // Standard Error: 84_277 - .saturating_add(Weight::from_parts(3_087_492, 0).saturating_mul(n.into())) + Weight::from_parts(2_101_372, 0) + // Standard Error: 5_552 + .saturating_add(Weight::from_parts(1_704_563, 0).saturating_mul(n.into())) } /// Storage: `Nfts::Item` (r:2 w:0) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) @@ -674,8 +686,8 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `421` // Estimated: `7662` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(15_000_000, 7662) + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_000_000, 7662) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) } @@ -687,7 +699,7 @@ impl WeightInfo for SubstrateWeight { // Proof Size summary in bytes: // Measured: `440` // Estimated: `4326` - // Minimum execution time: 14_000_000 picoseconds. + // Minimum execution time: 13_000_000 picoseconds. Weight::from_parts(14_000_000, 4326) .saturating_add(T::DbWeight::get().reads(2_u64)) .saturating_add(T::DbWeight::get().writes(1_u64)) @@ -696,8 +708,8 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::PendingSwapOf` (r:1 w:2) /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) - /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:2 w:0) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -712,12 +724,12 @@ impl WeightInfo for SubstrateWeight { /// Proof: `Nfts::ItemPriceOf` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`) fn claim_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `907` + // Measured: `915` // Estimated: `7662` - // Minimum execution time: 75_000_000 picoseconds. - Weight::from_parts(77_000_000, 7662) + // Minimum execution time: 78_000_000 picoseconds. + Weight::from_parts(79_000_000, 7662) .saturating_add(T::DbWeight::get().reads(11_u64)) - .saturating_add(T::DbWeight::get().writes(12_u64)) + .saturating_add(T::DbWeight::get().writes(13_u64)) } /// Storage: `Nfts::CollectionRoleOf` (r:2 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) @@ -726,7 +738,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:1) /// Proof: `Nfts::AccountBalance` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1 w:1) @@ -742,12 +754,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 10]`. fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `485` + // Measured: `493` // Estimated: `6078 + n * (2954 ±0)` - // Minimum execution time: 100_000_000 picoseconds. - Weight::from_parts(107_476_765, 6078) - // Standard Error: 61_259 - .saturating_add(Weight::from_parts(27_610_007, 0).saturating_mul(n.into())) + // Minimum execution time: 101_000_000 picoseconds. + Weight::from_parts(102_689_064, 6078) + // Standard Error: 25_175 + .saturating_add(Weight::from_parts(27_553_304, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(9_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(7_u64)) @@ -761,7 +773,7 @@ impl WeightInfo for SubstrateWeight { /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:10 w:10) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) @@ -769,12 +781,12 @@ impl WeightInfo for SubstrateWeight { /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `514` + // Measured: `522` // Estimated: `4466 + n * (2954 ±0)` - // Minimum execution time: 51_000_000 picoseconds. - Weight::from_parts(57_358_180, 4466) - // Standard Error: 54_968 - .saturating_add(Weight::from_parts(27_429_606, 0).saturating_mul(n.into())) + // Minimum execution time: 50_000_000 picoseconds. + Weight::from_parts(55_735_551, 4466) + // Standard Error: 34_490 + .saturating_add(Weight::from_parts(26_799_214, 0).saturating_mul(n.into())) .saturating_add(T::DbWeight::get().reads(4_u64)) .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(T::DbWeight::get().writes(2_u64)) @@ -788,7 +800,7 @@ impl WeightInfo for () { /// Storage: `Nfts::NextCollectionId` (r:1 w:1) /// Proof: `Nfts::NextCollectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:0 w:1) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:0 w:1) @@ -798,16 +810,16 @@ impl WeightInfo for () { fn create() -> Weight { // Proof Size summary in bytes: // Measured: `105` - // Estimated: `3549` - // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(27_000_000, 3549) + // Estimated: `3557` + // Minimum execution time: 28_000_000 picoseconds. + Weight::from_parts(29_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: `Nfts::NextCollectionId` (r:1 w:1) /// Proof: `Nfts::NextCollectionId` (`max_values`: Some(1), `max_size`: Some(4), added: 499, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:0 w:1) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:0 w:1) @@ -817,14 +829,14 @@ impl WeightInfo for () { fn force_create() -> Weight { // Proof Size summary in bytes: // Measured: `3` - // Estimated: `3549` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(15_000_000, 3549) + // Estimated: `3557` + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(15_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemMetadataOf` (r:1 w:0) /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:1 w:1) @@ -833,6 +845,8 @@ impl WeightInfo for () { /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:0) /// Proof: `Nfts::AccountBalance` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Allowances` (r:1 w:0) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1000 w:1000) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionMetadataOf` (r:0 w:1) @@ -844,19 +858,17 @@ impl WeightInfo for () { /// The range of component `m` is `[0, 1000]`. /// The range of component `c` is `[0, 1000]`. /// The range of component `a` is `[0, 1000]`. - fn destroy(m: u32, c: u32, a: u32, ) -> Weight { + /// The range of component `h` is `[0, 1000]`. + /// The range of component `l` is `[0, 1000]`. + fn destroy(_m: u32, _c: u32, a: u32, _h: u32, _l: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `32216 + a * (366 ±0)` + // Measured: `32875 + a * (366 ±0)` // Estimated: `2523990 + a * (2954 ±0)` // Minimum execution time: 982_000_000 picoseconds. - Weight::from_parts(937_587_516, 2523990) - // Standard Error: 12_288 - .saturating_add(Weight::from_parts(34_348, 0).saturating_mul(m.into())) - // Standard Error: 12_288 - .saturating_add(Weight::from_parts(23_800, 0).saturating_mul(c.into())) - // Standard Error: 12_288 - .saturating_add(Weight::from_parts(5_095_505, 0).saturating_mul(a.into())) - .saturating_add(RocksDbWeight::get().reads(1005_u64)) + Weight::from_parts(4_613_129_128, 2523990) + // Standard Error: 125_087 + .saturating_add(Weight::from_parts(5_072_767, 0).saturating_mul(a.into())) + .saturating_add(RocksDbWeight::get().reads(1006_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(a.into()))) .saturating_add(RocksDbWeight::get().writes(1005_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(a.into()))) @@ -867,7 +879,7 @@ impl WeightInfo for () { /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:1) @@ -878,10 +890,10 @@ impl WeightInfo for () { /// Proof: `Nfts::Account` (`max_values`: None, `max_size`: Some(88), added: 2563, mode: `MaxEncodedLen`) fn mint() -> Weight { // Proof Size summary in bytes: - // Measured: `382` + // Measured: `390` // Estimated: `4326` - // Minimum execution time: 41_000_000 picoseconds. - Weight::from_parts(42_000_000, 4326) + // Minimum execution time: 40_000_000 picoseconds. + Weight::from_parts(41_000_000, 4326) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -890,7 +902,7 @@ impl WeightInfo for () { /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:1) @@ -901,10 +913,10 @@ impl WeightInfo for () { /// Proof: `Nfts::Account` (`max_values`: None, `max_size`: Some(88), added: 2563, mode: `MaxEncodedLen`) fn force_mint() -> Weight { // Proof Size summary in bytes: - // Measured: `382` + // Measured: `390` // Estimated: `4326` // Minimum execution time: 39_000_000 picoseconds. - Weight::from_parts(40_000_000, 4326) + Weight::from_parts(39_000_000, 4326) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(5_u64)) } @@ -913,7 +925,7 @@ impl WeightInfo for () { /// Storage: `Nfts::ItemConfigOf` (r:1 w:1) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemMetadataOf` (r:1 w:0) @@ -930,15 +942,15 @@ impl WeightInfo for () { /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) fn burn() -> Weight { // Proof Size summary in bytes: - // Measured: `576` + // Measured: `584` // Estimated: `4326` - // Minimum execution time: 46_000_000 picoseconds. - Weight::from_parts(59_000_000, 4326) + // Minimum execution time: 45_000_000 picoseconds. + Weight::from_parts(46_000_000, 4326) .saturating_add(RocksDbWeight::get().reads(6_u64)) .saturating_add(RocksDbWeight::get().writes(8_u64)) } - /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:1 w:0) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -957,15 +969,15 @@ impl WeightInfo for () { /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) fn transfer() -> Weight { // Proof Size summary in bytes: - // Measured: `605` + // Measured: `613` // Estimated: `6068` // Minimum execution time: 38_000_000 picoseconds. - Weight::from_parts(83_000_000, 6068) + Weight::from_parts(38_000_000, 6068) .saturating_add(RocksDbWeight::get().reads(7_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) } /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Item` (r:5000 w:5000) @@ -973,12 +985,12 @@ impl WeightInfo for () { /// The range of component `i` is `[0, 5000]`. fn redeposit(i: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `690 + i * (108 ±0)` - // Estimated: `3549 + i * (3336 ±0)` - // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(11_000_000, 3549) - // Standard Error: 20_022 - .saturating_add(Weight::from_parts(16_005_327, 0).saturating_mul(i.into())) + // Measured: `698 + i * (108 ±0)` + // Estimated: `3557 + i * (3336 ±0)` + // Minimum execution time: 10_000_000 picoseconds. + Weight::from_parts(11_000_000, 3557) + // Standard Error: 30_743 + .saturating_add(Weight::from_parts(15_569_470, 0).saturating_mul(i.into())) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(i.into()))) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(i.into()))) @@ -992,7 +1004,7 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `395` // Estimated: `3534` - // Minimum execution time: 13_000_000 picoseconds. + // Minimum execution time: 14_000_000 picoseconds. Weight::from_parts(14_000_000, 3534) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -1005,35 +1017,35 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `395` // Estimated: `3534` - // Minimum execution time: 14_000_000 picoseconds. + // Minimum execution time: 13_000_000 picoseconds. Weight::from_parts(14_000_000, 3534) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:1) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) fn lock_collection() -> Weight { // Proof Size summary in bytes: - // Measured: `267` - // Estimated: `3549` + // Measured: `275` + // Estimated: `3557` // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(11_000_000, 3549) + Weight::from_parts(11_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Nfts::OwnershipAcceptance` (r:1 w:1) /// Proof: `Nfts::OwnershipAcceptance` (`max_values`: None, `max_size`: Some(52), added: 2527, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) /// Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionAccount` (r:0 w:2) /// Proof: `Nfts::CollectionAccount` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) fn transfer_ownership() -> Weight { // Proof Size summary in bytes: - // Measured: `417` + // Measured: `425` // Estimated: `3593` // Minimum execution time: 18_000_000 picoseconds. Weight::from_parts(19_000_000, 3593) @@ -1041,12 +1053,12 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:2 w:4) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) fn set_team() -> Weight { // Proof Size summary in bytes: - // Measured: `296` + // Measured: `304` // Estimated: `6078` // Minimum execution time: 30_000_000 picoseconds. Weight::from_parts(31_000_000, 6078) @@ -1054,28 +1066,28 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(5_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionAccount` (r:0 w:2) /// Proof: `Nfts::CollectionAccount` (`max_values`: None, `max_size`: Some(68), added: 2543, mode: `MaxEncodedLen`) fn force_collection_owner() -> Weight { // Proof Size summary in bytes: - // Measured: `238` - // Estimated: `3549` + // Measured: `246` + // Estimated: `3557` // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_000_000, 3549) + Weight::from_parts(12_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(3_u64)) } /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:0 w:1) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) fn force_collection_config() -> Weight { // Proof Size summary in bytes: // Measured: `203` - // Estimated: `3549` + // Estimated: `3557` // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(9_000_000, 3549) + Weight::from_parts(9_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1093,7 +1105,7 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -1104,20 +1116,20 @@ impl WeightInfo for () { /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) fn set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `499` + // Measured: `507` // Estimated: `3944` - // Minimum execution time: 37_000_000 picoseconds. - Weight::from_parts(38_000_000, 3944) + // Minimum execution time: 38_000_000 picoseconds. + Weight::from_parts(39_000_000, 3944) .saturating_add(RocksDbWeight::get().reads(5_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:1 w:1) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) fn force_set_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `271` + // Measured: `279` // Estimated: `3944` // Minimum execution time: 19_000_000 picoseconds. Weight::from_parts(19_000_000, 3944) @@ -1131,13 +1143,13 @@ impl WeightInfo for () { /// Storage: `Nfts::ItemConfigOf` (r:1 w:0) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) fn clear_attribute() -> Weight { // Proof Size summary in bytes: - // Measured: `943` + // Measured: `951` // Estimated: `3944` // Minimum execution time: 35_000_000 picoseconds. - Weight::from_parts(36_000_000, 3944) + Weight::from_parts(37_000_000, 3944) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1169,8 +1181,8 @@ impl WeightInfo for () { // Estimated: `4466 + n * (2954 ±0)` // Minimum execution time: 18_000_000 picoseconds. Weight::from_parts(19_000_000, 4466) - // Standard Error: 6_379 - .saturating_add(Weight::from_parts(5_018_740, 0).saturating_mul(n.into())) + // Standard Error: 10_431 + .saturating_add(Weight::from_parts(4_776_454, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) @@ -1180,7 +1192,7 @@ impl WeightInfo for () { /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1 w:0) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -1189,7 +1201,7 @@ impl WeightInfo for () { /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) fn set_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `499` + // Measured: `507` // Estimated: `3812` // Minimum execution time: 30_000_000 picoseconds. Weight::from_parts(31_000_000, 3812) @@ -1201,15 +1213,15 @@ impl WeightInfo for () { /// Storage: `Nfts::ItemMetadataOf` (r:1 w:1) /// Proof: `Nfts::ItemMetadataOf` (`max_values`: None, `max_size`: Some(347), added: 2822, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1 w:0) /// Proof: `Nfts::ItemConfigOf` (`max_values`: None, `max_size`: Some(48), added: 2523, mode: `MaxEncodedLen`) fn clear_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `809` + // Measured: `817` // Estimated: `3812` - // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(29_000_000, 3812) + // Minimum execution time: 29_000_000 picoseconds. + Weight::from_parts(30_000_000, 3812) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1218,32 +1230,32 @@ impl WeightInfo for () { /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionMetadataOf` (r:1 w:1) /// Proof: `Nfts::CollectionMetadataOf` (`max_values`: None, `max_size`: Some(294), added: 2769, mode: `MaxEncodedLen`) fn set_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `325` + // Measured: `333` // Estimated: `3759` // Minimum execution time: 28_000_000 picoseconds. - Weight::from_parts(30_000_000, 3759) + Weight::from_parts(28_000_000, 3759) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } /// Storage: `Nfts::CollectionRoleOf` (r:1 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionMetadataOf` (r:1 w:1) /// Proof: `Nfts::CollectionMetadataOf` (`max_values`: None, `max_size`: Some(294), added: 2769, mode: `MaxEncodedLen`) fn clear_collection_metadata() -> Weight { // Proof Size summary in bytes: - // Measured: `643` + // Measured: `651` // Estimated: `3759` // Minimum execution time: 27_000_000 picoseconds. - Weight::from_parts(29_000_000, 3759) + Weight::from_parts(28_000_000, 3759) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(2_u64)) } @@ -1251,25 +1263,37 @@ impl WeightInfo for () { /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) - fn approve_transfer() -> Weight { - // Proof Size summary in bytes: - // Measured: `337` - // Estimated: `4326` - // Minimum execution time: 13_000_000 picoseconds. - Weight::from_parts(14_000_000, 4326) - .saturating_add(RocksDbWeight::get().reads(2_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Allowances` (r:1 w:1) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 1]`. + fn approve_transfer(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `308 + i * (29 ±0)` + // Estimated: `3574 + i * (2163 ±0)` + // Minimum execution time: 14_000_000 picoseconds. + Weight::from_parts(16_969_387, 3574) + .saturating_add(RocksDbWeight::get().reads(3_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2163).saturating_mul(i.into())) } /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) - fn cancel_approval() -> Weight { - // Proof Size summary in bytes: - // Measured: `345` - // Estimated: `4326` + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Allowances` (r:0 w:1) + /// Proof: `Nfts::Allowances` (`max_values`: None, `max_size`: Some(109), added: 2584, mode: `MaxEncodedLen`) + /// The range of component `i` is `[0, 1]`. + fn cancel_approval(i: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `312 + i * (33 ±0)` + // Estimated: `3557 + i * (2163 ±0)` // Minimum execution time: 11_000_000 picoseconds. - Weight::from_parts(12_000_000, 4326) + Weight::from_parts(14_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(1_u64)) - .saturating_add(RocksDbWeight::get().writes(1_u64)) + .saturating_add(RocksDbWeight::get().writes(2_u64)) + .saturating_add(Weight::from_parts(0, 2163).saturating_mul(i.into())) } /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) @@ -1289,20 +1313,20 @@ impl WeightInfo for () { // Measured: `3` // Estimated: `3517` // Minimum execution time: 9_000_000 picoseconds. - Weight::from_parts(10_000_000, 3517) + Weight::from_parts(9_000_000, 3517) .saturating_add(RocksDbWeight::get().reads(1_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } /// Storage: `Nfts::CollectionConfigOf` (r:1 w:1) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) fn set_collection_max_supply() -> Weight { // Proof Size summary in bytes: - // Measured: `267` - // Estimated: `3549` + // Measured: `275` + // Estimated: `3557` // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 3549) + Weight::from_parts(13_000_000, 3557) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1315,7 +1339,7 @@ impl WeightInfo for () { // Measured: `250` // Estimated: `3538` // Minimum execution time: 12_000_000 picoseconds. - Weight::from_parts(13_000_000, 3538) + Weight::from_parts(12_000_000, 3538) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1331,8 +1355,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `478` // Estimated: `4326` - // Minimum execution time: 16_000_000 picoseconds. - Weight::from_parts(17_000_000, 4326) + // Minimum execution time: 15_000_000 picoseconds. + Weight::from_parts(16_000_000, 4326) .saturating_add(RocksDbWeight::get().reads(3_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1340,8 +1364,8 @@ impl WeightInfo for () { /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemPriceOf` (r:1 w:1) /// Proof: `Nfts::ItemPriceOf` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`) - /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:1 w:0) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -1356,12 +1380,12 @@ impl WeightInfo for () { /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) fn buy_item() -> Weight { // Proof Size summary in bytes: - // Measured: `717` + // Measured: `725` // Estimated: `6068` - // Minimum execution time: 42_000_000 picoseconds. - Weight::from_parts(45_000_000, 6068) + // Minimum execution time: 43_000_000 picoseconds. + Weight::from_parts(44_000_000, 6068) .saturating_add(RocksDbWeight::get().reads(8_u64)) - .saturating_add(RocksDbWeight::get().writes(7_u64)) + .saturating_add(RocksDbWeight::get().writes(8_u64)) } /// The range of component `n` is `[0, 10]`. fn pay_tips(n: u32, ) -> Weight { @@ -1369,9 +1393,9 @@ impl WeightInfo for () { // Measured: `0` // Estimated: `0` // Minimum execution time: 1_000_000 picoseconds. - Weight::from_parts(390_532, 0) - // Standard Error: 84_277 - .saturating_add(Weight::from_parts(3_087_492, 0).saturating_mul(n.into())) + Weight::from_parts(2_101_372, 0) + // Standard Error: 5_552 + .saturating_add(Weight::from_parts(1_704_563, 0).saturating_mul(n.into())) } /// Storage: `Nfts::Item` (r:2 w:0) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) @@ -1381,8 +1405,8 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `421` // Estimated: `7662` - // Minimum execution time: 14_000_000 picoseconds. - Weight::from_parts(15_000_000, 7662) + // Minimum execution time: 13_000_000 picoseconds. + Weight::from_parts(14_000_000, 7662) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } @@ -1394,7 +1418,7 @@ impl WeightInfo for () { // Proof Size summary in bytes: // Measured: `440` // Estimated: `4326` - // Minimum execution time: 14_000_000 picoseconds. + // Minimum execution time: 13_000_000 picoseconds. Weight::from_parts(14_000_000, 4326) .saturating_add(RocksDbWeight::get().reads(2_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) @@ -1403,8 +1427,8 @@ impl WeightInfo for () { /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::PendingSwapOf` (r:1 w:2) /// Proof: `Nfts::PendingSwapOf` (`max_values`: None, `max_size`: Some(71), added: 2546, mode: `MaxEncodedLen`) - /// Storage: `Nfts::Collection` (r:1 w:0) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Storage: `Nfts::Collection` (r:1 w:1) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:2 w:0) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) @@ -1419,12 +1443,12 @@ impl WeightInfo for () { /// Proof: `Nfts::ItemPriceOf` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`) fn claim_swap() -> Weight { // Proof Size summary in bytes: - // Measured: `907` + // Measured: `915` // Estimated: `7662` - // Minimum execution time: 75_000_000 picoseconds. - Weight::from_parts(77_000_000, 7662) + // Minimum execution time: 78_000_000 picoseconds. + Weight::from_parts(79_000_000, 7662) .saturating_add(RocksDbWeight::get().reads(11_u64)) - .saturating_add(RocksDbWeight::get().writes(12_u64)) + .saturating_add(RocksDbWeight::get().writes(13_u64)) } /// Storage: `Nfts::CollectionRoleOf` (r:2 w:0) /// Proof: `Nfts::CollectionRoleOf` (`max_values`: None, `max_size`: Some(69), added: 2544, mode: `MaxEncodedLen`) @@ -1433,7 +1457,7 @@ impl WeightInfo for () { /// Storage: `Nfts::Item` (r:1 w:1) /// Proof: `Nfts::Item` (`max_values`: None, `max_size`: Some(861), added: 3336, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::AccountBalance` (r:1 w:1) /// Proof: `Nfts::AccountBalance` (`max_values`: None, `max_size`: Some(64), added: 2539, mode: `MaxEncodedLen`) /// Storage: `Nfts::ItemConfigOf` (r:1 w:1) @@ -1449,12 +1473,12 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 10]`. fn mint_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `485` + // Measured: `493` // Estimated: `6078 + n * (2954 ±0)` - // Minimum execution time: 100_000_000 picoseconds. - Weight::from_parts(107_476_765, 6078) - // Standard Error: 61_259 - .saturating_add(Weight::from_parts(27_610_007, 0).saturating_mul(n.into())) + // Minimum execution time: 101_000_000 picoseconds. + Weight::from_parts(102_689_064, 6078) + // Standard Error: 25_175 + .saturating_add(Weight::from_parts(27_553_304, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(9_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(7_u64)) @@ -1468,7 +1492,7 @@ impl WeightInfo for () { /// Storage: `Nfts::CollectionConfigOf` (r:1 w:0) /// Proof: `Nfts::CollectionConfigOf` (`max_values`: None, `max_size`: Some(73), added: 2548, mode: `MaxEncodedLen`) /// Storage: `Nfts::Collection` (r:1 w:1) - /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(84), added: 2559, mode: `MaxEncodedLen`) + /// Proof: `Nfts::Collection` (`max_values`: None, `max_size`: Some(92), added: 2567, mode: `MaxEncodedLen`) /// Storage: `Nfts::Attribute` (r:10 w:10) /// Proof: `Nfts::Attribute` (`max_values`: None, `max_size`: Some(479), added: 2954, mode: `MaxEncodedLen`) /// Storage: `System::Account` (r:1 w:1) @@ -1476,16 +1500,16 @@ impl WeightInfo for () { /// The range of component `n` is `[0, 10]`. fn set_attributes_pre_signed(n: u32, ) -> Weight { // Proof Size summary in bytes: - // Measured: `514` + // Measured: `522` // Estimated: `4466 + n * (2954 ±0)` - // Minimum execution time: 51_000_000 picoseconds. - Weight::from_parts(57_358_180, 4466) - // Standard Error: 54_968 - .saturating_add(Weight::from_parts(27_429_606, 0).saturating_mul(n.into())) + // Minimum execution time: 50_000_000 picoseconds. + Weight::from_parts(55_735_551, 4466) + // Standard Error: 34_490 + .saturating_add(Weight::from_parts(26_799_214, 0).saturating_mul(n.into())) .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(n.into()))) .saturating_add(RocksDbWeight::get().writes(2_u64)) .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(n.into()))) .saturating_add(Weight::from_parts(0, 2954).saturating_mul(n.into())) } -} \ No newline at end of file +} diff --git a/runtime/devnet/src/config/api/mod.rs b/runtime/devnet/src/config/api/mod.rs index 5ea1d923..d96fd85b 100644 --- a/runtime/devnet/src/config/api/mod.rs +++ b/runtime/devnet/src/config/api/mod.rs @@ -11,7 +11,7 @@ use sp_std::vec::Vec; use versioning::*; use crate::{ - config::assets::{NftsInstance, TrustBackedAssetsInstance}, + config::assets::{TrustBackedAssetsInstance, TrustBackedNftsInstance}, fungibles, nonfungibles, Runtime, RuntimeCall, RuntimeEvent, }; @@ -88,7 +88,7 @@ impl fungibles::Config for Runtime { } impl nonfungibles::Config for Runtime { - type NftsInstance = NftsInstance; + type NftsInstance = TrustBackedNftsInstance; type RuntimeEvent = RuntimeEvent; type WeightInfo = (); } @@ -311,7 +311,13 @@ mod tests { }), NonFungibles(destroy { collection: 0, - witness: DestroyWitness { attributes: 0, item_configs: 0, item_metadatas: 0 }, + witness: DestroyWitness { + attributes: 0, + item_configs: 0, + item_metadatas: 0, + item_holders: 0, + allowances: 0, + }, }), NonFungibles(set_attribute { collection: 0, diff --git a/runtime/devnet/src/config/assets.rs b/runtime/devnet/src/config/assets.rs index 97c2a9e7..43f88990 100644 --- a/runtime/devnet/src/config/assets.rs +++ b/runtime/devnet/src/config/assets.rs @@ -46,9 +46,9 @@ impl Get for KeyLimit { } } -pub(crate) type NftsInstance = pallet_nfts::Instance1; -pub type NftsCall = pallet_nfts::Call; -impl pallet_nfts::Config for Runtime { +pub(crate) type TrustBackedNftsInstance = pallet_nfts::Instance1; +pub type NftsCall = pallet_nfts::Call; +impl pallet_nfts::Config for Runtime { // TODO: source from primitives type ApprovalsLimit = ConstU32<20>; type AttributeDepositBase = NftsAttributeDepositBase; @@ -97,8 +97,8 @@ impl pallet_nft_fractionalization::Config for Runtime { type Deposit = AssetDeposit; type NewAssetName = NewAssetName; type NewAssetSymbol = NewAssetSymbol; - type NftCollectionId = >::CollectionId; - type NftId = >::ItemId; + type NftCollectionId = >::CollectionId; + type NftId = >::ItemId; type Nfts = Nfts; type PalletId = NftFractionalizationPalletId; type RuntimeEvent = RuntimeEvent; diff --git a/runtime/devnet/src/lib.rs b/runtime/devnet/src/lib.rs index 839f819d..736f0be7 100644 --- a/runtime/devnet/src/lib.rs +++ b/runtime/devnet/src/lib.rs @@ -646,6 +646,7 @@ mod benches { frame_benchmarking::define_benchmarks!( [frame_system, SystemBench::] [fungibles, Fungibles] + [nonfungibles, NonFungibles] [pallet_balances, Balances] [pallet_session, SessionBench::] [pallet_timestamp, Timestamp]