difftreelog
Merge pull request #1007 from UniqueNetwork/fix/token-properties-benchmarks
in: master
Fix token properties and nesting weights
32 files changed
pallets/balances-adapter/src/common.rsdiffbeforeafterboth--- a/pallets/balances-adapter/src/common.rs
+++ b/pallets/balances-adapter/src/common.rs
@@ -30,15 +30,7 @@
Weight::default()
}
- fn delete_collection_properties(_amount: u32) -> Weight {
- Weight::default()
- }
-
fn set_token_properties(_amount: u32) -> Weight {
- Weight::default()
- }
-
- fn delete_token_properties(_amount: u32) -> Weight {
Weight::default()
}
@@ -63,18 +55,6 @@
}
fn burn_from() -> Weight {
- Weight::default()
- }
-
- fn burn_recursively_self_raw() -> Weight {
- Weight::default()
- }
-
- fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
- Weight::default()
- }
-
- fn token_owner() -> Weight {
Weight::default()
}
@@ -124,16 +104,6 @@
_sender: <T>::CrossAccountId,
_token: TokenId,
_amount: u128,
- ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {
- fail!(<pallet_common::Error<T>>::UnsupportedOperation);
- }
-
- fn burn_item_recursively(
- &self,
- _sender: <T>::CrossAccountId,
- _token: TokenId,
- _self_budget: &dyn up_data_structs::budget::Budget,
- _breadth_budget: &dyn up_data_structs::budget::Budget,
) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {
fail!(<pallet_common::Error<T>>::UnsupportedOperation);
}
pallets/common/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -29,12 +29,11 @@
use sp_std::{vec, vec::Vec};
use up_data_structs::{
AccessMode, CollectionId, CollectionMode, CollectionPermissions, CreateCollectionData,
- NestingPermissions, PropertiesPermissionMap, Property, PropertyKey, PropertyValue,
- MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_PROPERTIES_PER_ITEM,
- MAX_TOKEN_PREFIX_LENGTH,
+ NestingPermissions, Property, PropertyKey, PropertyValue, MAX_COLLECTION_DESCRIPTION_LENGTH,
+ MAX_COLLECTION_NAME_LENGTH, MAX_PROPERTIES_PER_ITEM, MAX_TOKEN_PREFIX_LENGTH,
};
-use crate::{CollectionHandle, Config, Pallet};
+use crate::{BenchmarkPropertyWriter, CollectionHandle, Config, Pallet};
const SEED: u32 = 1;
@@ -126,16 +125,6 @@
)
}
-pub fn load_is_admin_and_property_permissions<T: Config>(
- collection: &CollectionHandle<T>,
- sender: &T::CrossAccountId,
-) -> (bool, PropertiesPermissionMap) {
- (
- collection.is_owner_or_admin(sender),
- <Pallet<T>>::property_permissions(collection.id),
- )
-}
-
/// Helper macros, which handles all benchmarking preparation in semi-declarative way
///
/// `name` is a substrate account
@@ -200,31 +189,6 @@
#[block]
{
<Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
- }
-
- Ok(())
- }
-
- #[benchmark]
- fn delete_collection_properties(
- b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
- ) -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- owner: cross_from_sub;
- };
- let props = (0..b)
- .map(|p| Property {
- key: property_key(p as usize),
- value: property_value(),
- })
- .collect::<Vec<_>>();
- <Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
- let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();
-
- #[block]
- {
- <Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete.into_iter())?;
}
Ok(())
@@ -263,7 +227,7 @@
}
#[benchmark]
- fn init_token_properties_common() -> Result<(), BenchmarkError> {
+ fn property_writer_load_collection_info() -> Result<(), BenchmarkError> {
bench_init! {
owner: sub; collection: collection(owner);
sender: sub;
@@ -272,7 +236,7 @@
#[block]
{
- load_is_admin_and_property_permissions(&collection, &sender);
+ <BenchmarkPropertyWriter<T>>::load_collection_info(&&collection, &sender);
}
Ok(())
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -126,7 +126,7 @@
///
/// @param key Property key.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]
+ #[weight(<SelfWeightOf<T>>::set_collection_properties(1))]
fn delete_collection_property(&mut self, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let key = <Vec<u8>>::from(key)
@@ -139,7 +139,7 @@
/// Delete collection properties.
///
/// @param keys Properties keys.
- #[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]
+ #[weight(<SelfWeightOf<T>>::set_collection_properties(keys.len() as u32))]
fn delete_collection_properties(&mut self, caller: Caller, keys: Vec<String>) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let keys = keys
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -53,10 +53,12 @@
#![cfg_attr(not(feature = "std"), no_std)]
extern crate alloc;
+use alloc::boxed::Box;
use core::{
marker::PhantomData,
ops::{Deref, DerefMut},
slice::from_ref,
+ unreachable,
};
use evm_coder::ToLog;
@@ -871,63 +873,77 @@
>;
}
+enum LazyValueState<'a, T> {
+ Pending(Box<dyn FnOnce() -> T + 'a>),
+ InProgress,
+ Computed(T),
+}
+
/// Value representation with delayed initialization time.
-pub struct LazyValue<T, F: FnOnce() -> T> {
- value: Option<T>,
- f: Option<F>,
+pub struct LazyValue<'a, T> {
+ state: LazyValueState<'a, T>,
}
-impl<T, F: FnOnce() -> T> LazyValue<T, F> {
+impl<'a, T> LazyValue<'a, T> {
/// Create a new LazyValue.
- pub fn new(f: F) -> Self {
+ pub fn new(f: impl FnOnce() -> T + 'a) -> Self {
Self {
- value: None,
- f: Some(f),
+ state: LazyValueState::Pending(Box::new(f)),
}
}
/// Get the value. If it is called the first time, the value will be initialized.
pub fn value(&mut self) -> &T {
self.force_value();
- self.value.as_ref().unwrap()
+ self.value_mut()
}
/// Get the value. If it is called the first time, the value will be initialized.
pub fn value_mut(&mut self) -> &mut T {
self.force_value();
- self.value.as_mut().unwrap()
+
+ if let LazyValueState::Computed(value) = &mut self.state {
+ value
+ } else {
+ unreachable!()
+ }
}
fn into_inner(mut self) -> T {
self.force_value();
- self.value.unwrap()
+ if let LazyValueState::Computed(value) = self.state {
+ value
+ } else {
+ unreachable!()
+ }
}
/// Is value initialized?
pub fn has_value(&self) -> bool {
- self.value.is_some()
+ matches!(self.state, LazyValueState::Computed(_))
}
fn force_value(&mut self) {
- if self.value.is_none() {
- self.value = Some(self.f.take().unwrap()())
+ use LazyValueState::*;
+
+ if self.has_value() {
+ return;
+ }
+
+ match sp_std::mem::replace(&mut self.state, InProgress) {
+ Pending(f) => self.state = Computed(f()),
+ _ => panic!("recursion isn't supported"),
}
}
}
-fn check_token_permissions<T, FCA, FTO, FTE>(
+fn check_token_permissions<T: Config>(
collection_admin_permitted: bool,
token_owner_permitted: bool,
- is_collection_admin: &mut LazyValue<bool, FCA>,
- is_token_owner: &mut LazyValue<Result<bool, DispatchError>, FTO>,
- is_token_exist: &mut LazyValue<bool, FTE>,
-) -> DispatchResult
-where
- T: Config,
- FCA: FnOnce() -> bool,
- FTO: FnOnce() -> Result<bool, DispatchError>,
- FTE: FnOnce() -> bool,
-{
+ is_collection_admin: &mut LazyValue<bool>,
+ is_token_owner: &mut LazyValue<Result<bool, DispatchError>>,
+ is_token_exist: &mut LazyValue<bool>,
+) -> DispatchResult {
if !(collection_admin_permitted && *is_collection_admin.value()
|| token_owner_permitted && (*is_token_owner.value())?)
{
@@ -1902,7 +1918,9 @@
/// Collection property deletion weight.
///
/// * `amount`- The number of properties to set.
- fn delete_collection_properties(amount: u32) -> Weight;
+ fn delete_collection_properties(amount: u32) -> Weight {
+ Self::set_collection_properties(amount)
+ }
/// Token property setting weight.
///
@@ -1912,7 +1930,9 @@
/// Token property deletion weight.
///
/// * `amount`- The number of properties to delete.
- fn delete_token_properties(amount: u32) -> Weight;
+ fn delete_token_properties(amount: u32) -> Weight {
+ Self::set_token_properties(amount)
+ }
/// Token property permissions set weight.
///
@@ -1933,31 +1953,7 @@
/// The price of burning a token from another user.
fn burn_from() -> Weight;
-
- /// Differs from burn_item in case of Fungible and Refungible, as it should burn
- /// whole users's balance.
- ///
- /// This method shouldn't be used directly, as it doesn't count breadth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead
- fn burn_recursively_self_raw() -> Weight;
- /// Cost of iterating over `amount` children while burning, without counting child burning itself.
- ///
- /// This method shouldn't be used directly, as it doesn't count depth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead
- fn burn_recursively_breadth_raw(amount: u32) -> Weight;
-
- /// The price of recursive burning a token.
- ///
- /// `max_selfs` - The maximum burning weight of the token itself.
- /// `max_breadth` - The maximum number of nested tokens to burn.
- fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {
- Self::burn_recursively_self_raw()
- .saturating_mul(max_selfs.max(1) as u64)
- .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))
- }
-
- /// The price of retrieving token owner
- fn token_owner() -> Weight;
-
/// The price of setting approval for all
fn set_allowance_for_all() -> Weight;
@@ -2029,20 +2025,6 @@
amount: u128,
) -> DispatchResultWithPostInfo;
- /// Burn token and all nested tokens recursievly.
- ///
- /// * `sender` - The user who owns the token.
- /// * `token` - Token id that will burned.
- /// * `self_budget` - The budget that can be spent on burning tokens.
- /// * `breadth_budget` - The budget that can be spent on burning nested tokens.
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo;
-
/// Set collection properties.
///
/// * `sender` - Must be either the owner of the collection or its admin.
@@ -2374,160 +2356,33 @@
}
}
-/// A marker structure that enables the writer implementation
-/// to provide the interface to write properties to **newly created** tokens.
-pub struct NewTokenPropertyWriter;
-
-/// A marker structure that enables the writer implementation
-/// to provide the interface to write properties to **already existing** tokens.
-pub struct ExistingTokenPropertyWriter;
-
/// The type-safe interface for writing properties (setting or deleting) to tokens.
/// It has two distinct implementations for newly created tokens and existing ones.
///
/// This type utilizes the lazy evaluation to avoid repeating the computation
/// of several performance-heavy or PoV-heavy tasks,
/// such as checking the indirect ownership or reading the token property permissions.
-pub struct PropertyWriter<
- 'a,
- T,
- Handle,
- WriterVariant,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
-> where
- T: Config,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
-{
+pub struct PropertyWriter<'a, WriterVariant, T, Handle> {
collection: &'a Handle,
- is_collection_admin: LazyValue<bool, FIsAdmin>,
- property_permissions: LazyValue<PropertiesPermissionMap, FPropertyPermissions>,
- check_token_exist: FCheckTokenExist,
- get_properties: FGetProperties,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo<'a>,
_phantom: PhantomData<(T, WriterVariant)>,
}
-impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>
- PropertyWriter<
- 'a,
- T,
- Handle,
- NewTokenPropertyWriter,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- > where
- T: Config,
- Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
- FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
- FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
-{
- /// A function to write properties to a **newly created** token.
- pub fn write_token_properties(
- &mut self,
- mint_target_is_sender: bool,
- token_id: TokenId,
- properties_updates: impl Iterator<Item = Property>,
- log: evm_coder::ethereum::Log,
- ) -> DispatchResult {
- self.internal_write_token_properties(
- token_id,
- properties_updates.map(|p| (p.key, Some(p.value))),
- |_| Ok(mint_target_is_sender),
- log,
- )
- }
-}
-
-impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>
- PropertyWriter<
- 'a,
- T,
- Handle,
- ExistingTokenPropertyWriter,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- > where
+impl<'a, T, Handle, WriterVariant> PropertyWriter<'a, WriterVariant, T, Handle>
+where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
- FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
- FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
{
- /// A function to write properties to an **already existing** token.
- pub fn write_token_properties(
+ fn internal_write_token_properties(
&mut self,
- sender: &T::CrossAccountId,
token_id: TokenId,
+ mut token_lazy_info: PropertyWriterLazyTokenInfo,
properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
- nesting_budget: &dyn Budget,
log: evm_coder::ethereum::Log,
) -> DispatchResult {
- self.internal_write_token_properties(
- token_id,
- properties_updates,
- |collection| collection.check_token_indirect_owner(token_id, sender, nesting_budget),
- log,
- )
- }
-}
-
-impl<
- 'a,
- T,
- Handle,
- WriterVariant,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- >
- PropertyWriter<
- 'a,
- T,
- Handle,
- WriterVariant,
- FIsAdmin,
- FPropertyPermissions,
- FCheckTokenExist,
- FGetProperties,
- > where
- T: Config,
- Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
- FIsAdmin: FnOnce() -> bool,
- FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
- FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
- FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
-{
- fn internal_write_token_properties<FCheckTokenOwner>(
- &mut self,
- token_id: TokenId,
- properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
- check_token_owner: FCheckTokenOwner,
- log: evm_coder::ethereum::Log,
- ) -> DispatchResult
- where
- FCheckTokenOwner: FnOnce(&Handle) -> Result<bool, DispatchError>,
- {
- let get_properties = self.get_properties;
- let mut stored_properties = LazyValue::new(move || get_properties(token_id));
-
- let mut is_token_owner = LazyValue::new(|| check_token_owner(self.collection));
-
- let check_token_exist = self.check_token_exist;
- let mut is_token_exist = LazyValue::new(move || check_token_exist(token_id));
-
for (key, value) in properties_updates {
let permission = self
+ .collection_lazy_info
.property_permissions
.value()
.get(&key)
@@ -2536,7 +2391,11 @@
match permission {
PropertyPermission { mutable: false, .. }
- if stored_properties.value().get(&key).is_some() =>
+ if token_lazy_info
+ .stored_properties
+ .value()
+ .get(&key)
+ .is_some() =>
{
return Err(<Error<T>>::NoPermission.into());
}
@@ -2545,18 +2404,19 @@
collection_admin,
token_owner,
..
- } => check_token_permissions::<T, _, _, _>(
+ } => check_token_permissions::<T>(
collection_admin,
token_owner,
- &mut self.is_collection_admin,
- &mut is_token_owner,
- &mut is_token_exist,
+ &mut self.collection_lazy_info.is_collection_admin,
+ &mut token_lazy_info.is_token_owner,
+ &mut token_lazy_info.is_token_exist,
)?,
}
match value {
Some(value) => {
- stored_properties
+ token_lazy_info
+ .stored_properties
.value_mut()
.try_set(key.clone(), value)
.map_err(<Error<T>>::from)?;
@@ -2568,7 +2428,8 @@
));
}
None => {
- stored_properties
+ token_lazy_info
+ .stored_properties
.value_mut()
.remove(&key)
.map_err(<Error<T>>::from)?;
@@ -2582,142 +2443,292 @@
}
}
- let properties_changed = stored_properties.has_value();
+ let properties_changed = token_lazy_info.stored_properties.has_value();
if properties_changed {
<PalletEvm<T>>::deposit_log(log);
self.collection
- .set_token_properties_raw(token_id, stored_properties.into_inner());
+ .set_token_properties_raw(token_id, token_lazy_info.stored_properties.into_inner());
}
Ok(())
}
}
-/// Create a [`PropertyWriter`] for newly created tokens.
-pub fn property_writer_for_new_token<'a, T, Handle>(
- collection: &'a Handle,
- sender: &'a T::CrossAccountId,
-) -> PropertyWriter<
- 'a,
- T,
- Handle,
- NewTokenPropertyWriter,
- impl FnOnce() -> bool + 'a,
- impl FnOnce() -> PropertiesPermissionMap + 'a,
- impl Copy + FnOnce(TokenId) -> bool + 'a,
- impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,
->
+/// A helper structure for the [`PropertyWriter`] that holds
+/// the collection-related info. The info is loaded using lazy evaluation.
+/// This info is common for any token for which we write properties.
+pub struct PropertyWriterLazyCollectionInfo<'a> {
+ is_collection_admin: LazyValue<'a, bool>,
+ property_permissions: LazyValue<'a, PropertiesPermissionMap>,
+}
+
+/// A helper structure for the [`PropertyWriter`] that holds
+/// the token-related info. The info is loaded using lazy evaluation.
+pub struct PropertyWriterLazyTokenInfo<'a> {
+ is_token_exist: LazyValue<'a, bool>,
+ is_token_owner: LazyValue<'a, Result<bool, DispatchError>>,
+ stored_properties: LazyValue<'a, TokenProperties>,
+}
+
+impl<'a> PropertyWriterLazyTokenInfo<'a> {
+ /// Create a lazy token info.
+ pub fn new(
+ check_token_exist: impl FnOnce() -> bool + 'a,
+ check_token_owner: impl FnOnce() -> Result<bool, DispatchError> + 'a,
+ get_token_properties: impl FnOnce() -> TokenProperties + 'a,
+ ) -> Self {
+ Self {
+ is_token_exist: LazyValue::new(check_token_exist),
+ is_token_owner: LazyValue::new(check_token_owner),
+ stored_properties: LazyValue::new(get_token_properties),
+ }
+ }
+}
+
+/// A marker structure that enables the writer implementation
+/// to provide the interface to write properties to **newly created** tokens.
+pub struct NewTokenPropertyWriter<T>(PhantomData<T>);
+impl<T: Config> NewTokenPropertyWriter<T> {
+ /// Creates a [`PropertyWriter`] for **newly created** tokens.
+ pub fn new<'a, Handle>(
+ collection: &'a Handle,
+ sender: &'a T::CrossAccountId,
+ ) -> PropertyWriter<'a, Self, T, Handle>
+ where
+ T: Config,
+ Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ {
+ PropertyWriter {
+ collection,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo {
+ is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
+ property_permissions: LazyValue::new(|| {
+ <Pallet<T>>::property_permissions(collection.id)
+ }),
+ },
+ _phantom: PhantomData,
+ }
+ }
+}
+
+impl<'a, T, Handle> PropertyWriter<'a, NewTokenPropertyWriter<T>, T, Handle>
where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
{
- PropertyWriter {
- collection,
- is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
- property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),
- check_token_exist: |token_id| {
- debug_assert!(collection.token_exists(token_id));
+ /// A function to write properties to a **newly created** token.
+ pub fn write_token_properties(
+ &mut self,
+ mint_target_is_sender: bool,
+ token_id: TokenId,
+ properties_updates: impl Iterator<Item = Property>,
+ log: evm_coder::ethereum::Log,
+ ) -> DispatchResult {
+ let check_token_exist = || {
+ debug_assert!(self.collection.token_exists(token_id));
true
- },
- get_properties: |token_id| {
- debug_assert!(collection.get_token_properties_raw(token_id).is_none());
+ };
+
+ let check_token_owner = || Ok(mint_target_is_sender);
+
+ let get_token_properties = || {
+ debug_assert!(self.collection.get_token_properties_raw(token_id).is_none());
TokenProperties::new()
- },
- _phantom: PhantomData,
+ };
+
+ self.internal_write_token_properties(
+ token_id,
+ PropertyWriterLazyTokenInfo::new(
+ check_token_exist,
+ check_token_owner,
+ get_token_properties,
+ ),
+ properties_updates.map(|p| (p.key, Some(p.value))),
+ log,
+ )
}
}
-#[cfg(feature = "runtime-benchmarks")]
-/// Create a `PropertyWriter` with preloaded `is_collection_admin` and `property_permissions.
-/// Also:
-/// * it will return `true` for the token ownership check.
-/// * it will return empty stored properties without reading them from the storage.
-pub fn collection_info_loaded_property_writer<T, Handle>(
- collection: &Handle,
- is_collection_admin: bool,
- property_permissions: PropertiesPermissionMap,
-) -> PropertyWriter<
- T,
- Handle,
- NewTokenPropertyWriter,
- impl FnOnce() -> bool,
- impl FnOnce() -> PropertiesPermissionMap,
- impl Copy + FnOnce(TokenId) -> bool,
- impl Copy + FnOnce(TokenId) -> TokenProperties,
->
+/// A marker structure that enables the writer implementation
+/// to provide the interface to write properties to **already existing** tokens.
+pub struct ExistingTokenPropertyWriter<T>(PhantomData<T>);
+impl<T: Config> ExistingTokenPropertyWriter<T> {
+ /// Creates a [`PropertyWriter`] for **already existing** tokens.
+ pub fn new<'a, Handle>(
+ collection: &'a Handle,
+ sender: &'a T::CrossAccountId,
+ ) -> PropertyWriter<'a, Self, T, Handle>
+ where
+ Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ {
+ PropertyWriter {
+ collection,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo {
+ is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
+ property_permissions: LazyValue::new(|| {
+ <Pallet<T>>::property_permissions(collection.id)
+ }),
+ },
+ _phantom: PhantomData,
+ }
+ }
+}
+
+impl<'a, T, Handle> PropertyWriter<'a, ExistingTokenPropertyWriter<T>, T, Handle>
where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
{
- PropertyWriter {
- collection,
- is_collection_admin: LazyValue::new(move || is_collection_admin),
- property_permissions: LazyValue::new(move || property_permissions),
- check_token_exist: |_token_id| true,
- get_properties: |_token_id| TokenProperties::new(),
- _phantom: PhantomData,
+ /// A function to write properties to an **already existing** token.
+ pub fn write_token_properties(
+ &mut self,
+ sender: &T::CrossAccountId,
+ token_id: TokenId,
+ properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
+ nesting_budget: &dyn Budget,
+ log: evm_coder::ethereum::Log,
+ ) -> DispatchResult {
+ let check_token_exist = || self.collection.token_exists(token_id);
+ let check_token_owner = || {
+ self.collection
+ .check_token_indirect_owner(token_id, sender, nesting_budget)
+ };
+ let get_token_properties = || {
+ self.collection
+ .get_token_properties_raw(token_id)
+ .unwrap_or_default()
+ };
+
+ self.internal_write_token_properties(
+ token_id,
+ PropertyWriterLazyTokenInfo::new(
+ check_token_exist,
+ check_token_owner,
+ get_token_properties,
+ ),
+ properties_updates,
+ log,
+ )
}
}
-/// Create a [`PropertyWriter`] for already existing tokens.
-pub fn property_writer_for_existing_token<'a, T, Handle>(
- collection: &'a Handle,
- sender: &'a T::CrossAccountId,
-) -> PropertyWriter<
- 'a,
- T,
- Handle,
- ExistingTokenPropertyWriter,
- impl FnOnce() -> bool + 'a,
- impl FnOnce() -> PropertiesPermissionMap + 'a,
- impl Copy + FnOnce(TokenId) -> bool + 'a,
- impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,
->
+/// A marker structure that enables the writer implementation
+/// to benchmark the token properties writing.
+#[cfg(feature = "runtime-benchmarks")]
+pub struct BenchmarkPropertyWriter<T>(PhantomData<T>);
+
+#[cfg(feature = "runtime-benchmarks")]
+impl<T: Config> BenchmarkPropertyWriter<T> {
+ /// Creates a [`PropertyWriter`] for benchmarking tokens properties writing.
+ pub fn new<'a, Handle>(
+ collection: &'a Handle,
+ collection_lazy_info: PropertyWriterLazyCollectionInfo<'a>,
+ ) -> PropertyWriter<'a, Self, T, Handle>
+ where
+ Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
+ {
+ PropertyWriter {
+ collection,
+ collection_lazy_info,
+ _phantom: PhantomData,
+ }
+ }
+
+ /// Load the [`PropertyWriterLazyCollectionInfo`] from the storage.
+ pub fn load_collection_info<Handle>(
+ collection_handle: &Handle,
+ sender: &T::CrossAccountId,
+ ) -> PropertyWriterLazyCollectionInfo<'static>
+ where
+ Handle: Deref<Target = CollectionHandle<T>>,
+ {
+ let is_collection_admin = collection_handle.is_owner_or_admin(sender);
+ let property_permissions = <Pallet<T>>::property_permissions(collection_handle.id);
+
+ PropertyWriterLazyCollectionInfo {
+ is_collection_admin: LazyValue::new(move || is_collection_admin),
+ property_permissions: LazyValue::new(move || property_permissions),
+ }
+ }
+
+ /// Load the [`PropertyWriterLazyTokenInfo`] with token properties from the storage.
+ pub fn load_token_properties<Handle>(
+ collection: &Handle,
+ token_id: TokenId,
+ ) -> PropertyWriterLazyTokenInfo
+ where
+ Handle: CommonCollectionOperations<T>,
+ {
+ let stored_properties = collection
+ .get_token_properties_raw(token_id)
+ .unwrap_or_default();
+
+ PropertyWriterLazyTokenInfo {
+ is_token_exist: LazyValue::new(|| true),
+ is_token_owner: LazyValue::new(|| Ok(true)),
+ stored_properties: LazyValue::new(move || stored_properties),
+ }
+ }
+}
+
+#[cfg(feature = "runtime-benchmarks")]
+impl<'a, T, Handle> PropertyWriter<'a, BenchmarkPropertyWriter<T>, T, Handle>
where
T: Config,
Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
{
- PropertyWriter {
- collection,
- is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
- property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),
- check_token_exist: |token_id| collection.token_exists(token_id),
- get_properties: |token_id| {
- collection
- .get_token_properties_raw(token_id)
- .unwrap_or_default()
- },
- _phantom: PhantomData,
+ /// A function to benchmark the writing of token properties.
+ pub fn write_token_properties(
+ &mut self,
+ token_id: TokenId,
+ properties_updates: impl Iterator<Item = Property>,
+ log: evm_coder::ethereum::Log,
+ ) -> DispatchResult {
+ let check_token_exist = || true;
+ let check_token_owner = || Ok(true);
+ let get_token_properties = TokenProperties::new;
+
+ self.internal_write_token_properties(
+ token_id,
+ PropertyWriterLazyTokenInfo::new(
+ check_token_exist,
+ check_token_owner,
+ get_token_properties,
+ ),
+ properties_updates.map(|p| (p.key, Some(p.value))),
+ log,
+ )
}
}
-/// Computes the weight delta for newly created tokens with properties.
+/// Computes the weight of writing properties to tokens.
/// * `properties_nums` - The properties num of each created token.
-/// * `init_token_properties` - The function to obtain the weight from a token's properties num.
-pub fn init_token_properties_delta<T: Config, I: Fn(u32) -> Weight>(
+/// * `per_token_weight_weight` - The function to obtain the weight
+/// of writing properties from a token's properties num.
+pub fn write_token_properties_total_weight<T: Config, I: Fn(u32) -> Weight>(
properties_nums: impl Iterator<Item = u32>,
- init_token_properties: I,
+ per_token_weight: I,
) -> Weight {
- let mut delta = properties_nums
+ let mut weight = properties_nums
.filter_map(|properties_num| {
if properties_num > 0 {
- Some(init_token_properties(properties_num))
+ Some(per_token_weight(properties_num))
} else {
None
}
})
.fold(Weight::zero(), |a, b| a.saturating_add(b));
- // If at least once the `init_token_properties` was called,
- // it means at least one newly created token has properties.
- // Becuase of that, some common collection data also was loaded and we need to add this weight.
- // However, these common data was loaded only once which is guaranteed by the `PropertyWriter`.
- if !delta.is_zero() {
- delta = delta.saturating_add(<SelfWeightOf<T>>::init_token_properties_common())
+ if !weight.is_zero() {
+ // If we are here, it means the token properties were written at least once.
+ // Because of that, some common collection data was also loaded; we must add this weight.
+ // However, this common data was loaded only once, which is guaranteed by the `PropertyWriter`.
+
+ weight = weight.saturating_add(<SelfWeightOf<T>>::property_writer_load_collection_info());
}
- delta
+ weight
}
#[cfg(any(feature = "tests", test))]
@@ -2781,20 +2792,14 @@
/* 15*/ TestCase::new(1, 1, 1, 1, 0),
];
- pub fn check_token_permissions<T, FCA, FTO, FTE>(
+ pub fn check_token_permissions<T: Config>(
collection_admin_permitted: bool,
token_owner_permitted: bool,
- is_collection_admin: &mut LazyValue<bool, FCA>,
- check_token_ownership: &mut LazyValue<Result<bool, DispatchError>, FTO>,
- check_token_existence: &mut LazyValue<bool, FTE>,
- ) -> DispatchResult
- where
- T: Config,
- FCA: FnOnce() -> bool,
- FTO: FnOnce() -> Result<bool, DispatchError>,
- FTE: FnOnce() -> bool,
- {
- crate::check_token_permissions::<T, FCA, FTO, FTE>(
+ is_collection_admin: &mut LazyValue<bool>,
+ check_token_ownership: &mut LazyValue<Result<bool, DispatchError>>,
+ check_token_existence: &mut LazyValue<bool>,
+ ) -> DispatchResult {
+ crate::check_token_permissions::<T>(
collection_admin_permitted,
token_owner_permitted,
is_collection_admin,
pallets/common/src/weights.rsdiffbeforeafterboth--- a/pallets/common/src/weights.rs
+++ b/pallets/common/src/weights.rs
@@ -3,13 +3,13 @@
//! Autogenerated weights for pallet_common
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-10-13, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`
-//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
+//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
+//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
-// target/production/unique-collator
+// ./target/production/unique-collator
// benchmark
// pallet
// --pallet
@@ -20,7 +20,7 @@
// *
// --template=.maintain/frame-weight-template.hbs
// --steps=50
-// --repeat=400
+// --repeat=80
// --heap-pages=4096
// --output=./pallets/common/src/weights.rs
@@ -34,116 +34,87 @@
/// Weight functions needed for pallet_common.
pub trait WeightInfo {
fn set_collection_properties(b: u32, ) -> Weight;
- fn delete_collection_properties(b: u32, ) -> Weight;
fn check_accesslist() -> Weight;
- fn init_token_properties_common() -> Weight;
+ fn property_writer_load_collection_info() -> Weight;
}
/// Weights for pallet_common using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
- /// Storage: Common CollectionProperties (r:1 w:1)
- /// Proof: Common CollectionProperties (max_values: None, max_size: Some(40992), added: 43467, mode: MaxEncodedLen)
+ /// Storage: `Common::CollectionProperties` (r:1 w:1)
+ /// Proof: `Common::CollectionProperties` (`max_values`: None, `max_size`: Some(40992), added: 43467, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
fn set_collection_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `298`
// Estimated: `44457`
- // Minimum execution time: 4_987_000 picoseconds.
- Weight::from_parts(5_119_000, 44457)
- // Standard Error: 7_609
- .saturating_add(Weight::from_parts(5_750_459, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(1_u64))
- .saturating_add(T::DbWeight::get().writes(1_u64))
- }
- /// Storage: Common CollectionProperties (r:1 w:1)
- /// Proof: Common CollectionProperties (max_values: None, max_size: Some(40992), added: 43467, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn delete_collection_properties(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `303 + b * (33030 ±0)`
- // Estimated: `44457`
- // Minimum execution time: 4_923_000 picoseconds.
- Weight::from_parts(5_074_000, 44457)
- // Standard Error: 36_651
- .saturating_add(Weight::from_parts(23_145_677, 0).saturating_mul(b.into()))
+ // Minimum execution time: 4_560_000 picoseconds.
+ Weight::from_parts(28_643_440, 44457)
+ // Standard Error: 28_941
+ .saturating_add(Weight::from_parts(18_277_422, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Common Allowlist (r:1 w:0)
- /// Proof: Common Allowlist (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
+ /// Storage: `Common::Allowlist` (r:1 w:0)
+ /// Proof: `Common::Allowlist` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`)
fn check_accesslist() -> Weight {
// Proof Size summary in bytes:
// Measured: `373`
// Estimated: `3535`
- // Minimum execution time: 4_271_000 picoseconds.
- Weight::from_parts(4_461_000, 3535)
+ // Minimum execution time: 4_290_000 picoseconds.
+ Weight::from_parts(4_460_000, 3535)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
- /// Storage: Common IsAdmin (r:1 w:0)
- /// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- fn init_token_properties_common() -> Weight {
+ /// Storage: `Common::IsAdmin` (r:1 w:0)
+ /// Proof: `Common::IsAdmin` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`)
+ /// Storage: `Common::CollectionPropertyPermissions` (r:1 w:0)
+ /// Proof: `Common::CollectionPropertyPermissions` (`max_values`: None, `max_size`: Some(16726), added: 19201, mode: `MaxEncodedLen`)
+ fn property_writer_load_collection_info() -> Weight {
// Proof Size summary in bytes:
// Measured: `326`
// Estimated: `20191`
- // Minimum execution time: 5_889_000 picoseconds.
- Weight::from_parts(6_138_000, 20191)
+ // Minimum execution time: 6_100_000 picoseconds.
+ Weight::from_parts(6_350_000, 20191)
.saturating_add(T::DbWeight::get().reads(2_u64))
}
}
// For backwards compatibility and tests
impl WeightInfo for () {
- /// Storage: Common CollectionProperties (r:1 w:1)
- /// Proof: Common CollectionProperties (max_values: None, max_size: Some(40992), added: 43467, mode: MaxEncodedLen)
+ /// Storage: `Common::CollectionProperties` (r:1 w:1)
+ /// Proof: `Common::CollectionProperties` (`max_values`: None, `max_size`: Some(40992), added: 43467, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
fn set_collection_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `298`
// Estimated: `44457`
- // Minimum execution time: 4_987_000 picoseconds.
- Weight::from_parts(5_119_000, 44457)
- // Standard Error: 7_609
- .saturating_add(Weight::from_parts(5_750_459, 0).saturating_mul(b.into()))
+ // Minimum execution time: 4_560_000 picoseconds.
+ Weight::from_parts(28_643_440, 44457)
+ // Standard Error: 28_941
+ .saturating_add(Weight::from_parts(18_277_422, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionProperties (r:1 w:1)
- /// Proof: Common CollectionProperties (max_values: None, max_size: Some(40992), added: 43467, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn delete_collection_properties(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `303 + b * (33030 ±0)`
- // Estimated: `44457`
- // Minimum execution time: 4_923_000 picoseconds.
- Weight::from_parts(5_074_000, 44457)
- // Standard Error: 36_651
- .saturating_add(Weight::from_parts(23_145_677, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(1_u64))
- .saturating_add(RocksDbWeight::get().writes(1_u64))
- }
- /// Storage: Common Allowlist (r:1 w:0)
- /// Proof: Common Allowlist (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
+ /// Storage: `Common::Allowlist` (r:1 w:0)
+ /// Proof: `Common::Allowlist` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`)
fn check_accesslist() -> Weight {
// Proof Size summary in bytes:
// Measured: `373`
// Estimated: `3535`
- // Minimum execution time: 4_271_000 picoseconds.
- Weight::from_parts(4_461_000, 3535)
+ // Minimum execution time: 4_290_000 picoseconds.
+ Weight::from_parts(4_460_000, 3535)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
- /// Storage: Common IsAdmin (r:1 w:0)
- /// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- fn init_token_properties_common() -> Weight {
+ /// Storage: `Common::IsAdmin` (r:1 w:0)
+ /// Proof: `Common::IsAdmin` (`max_values`: None, `max_size`: Some(70), added: 2545, mode: `MaxEncodedLen`)
+ /// Storage: `Common::CollectionPropertyPermissions` (r:1 w:0)
+ /// Proof: `Common::CollectionPropertyPermissions` (`max_values`: None, `max_size`: Some(16726), added: 19201, mode: `MaxEncodedLen`)
+ fn property_writer_load_collection_info() -> Weight {
// Proof Size summary in bytes:
// Measured: `326`
// Estimated: `20191`
- // Minimum execution time: 5_889_000 picoseconds.
- Weight::from_parts(6_138_000, 20191)
+ // Minimum execution time: 6_100_000 picoseconds.
+ Weight::from_parts(6_350_000, 20191)
.saturating_add(RocksDbWeight::get().reads(2_u64))
}
}
pallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth--- a/pallets/evm-coder-substrate/src/lib.rs
+++ b/pallets/evm-coder-substrate/src/lib.rs
@@ -84,7 +84,7 @@
}
impl<T: Config> budget::Budget for GasCallsBudget<'_, T> {
fn consume_custom(&self, calls: u32) -> bool {
- let (gas, overflown) = (calls as u64).overflowing_add(self.gas_per_call);
+ let (gas, overflown) = (calls as u64).overflowing_mul(self.gas_per_call);
if overflown {
return false;
}
pallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth--- a/pallets/foreign-assets/src/impl_fungibles.rs
+++ b/pallets/foreign-assets/src/impl_fungibles.rs
@@ -23,7 +23,7 @@
use pallet_common::{CollectionHandle, CommonCollectionOperations};
use pallet_fungible::FungibleHandle;
use sp_runtime::traits::{CheckedAdd, CheckedSub};
-use up_data_structs::budget::Value;
+use up_data_structs::budget;
use super::*;
@@ -327,7 +327,7 @@
&collection,
&account,
amount_data,
- &Value::new(0),
+ &budget::Value::new(0),
)?;
Ok(amount)
@@ -440,7 +440,7 @@
&T::CrossAccountId::from_sub(source.clone()),
&T::CrossAccountId::from_sub(dest.clone()),
amount.into(),
- &Value::new(0),
+ &budget::Value::new(0),
)
.map_err(|e| e.error)?;
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -16,14 +16,11 @@
use core::marker::PhantomData;
-use frame_support::{
- dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
-};
+use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
use pallet_common::{
weights::WeightInfo as _, with_weight, CommonCollectionOperations, CommonWeightInfo,
RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
};
-use pallet_structure::Error as StructureError;
use sp_runtime::{ArithmeticError, DispatchError};
use sp_std::{vec, vec::Vec};
use up_data_structs::{
@@ -58,18 +55,9 @@
fn set_collection_properties(amount: u32) -> Weight {
<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
- }
-
- fn delete_collection_properties(amount: u32) -> Weight {
- <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
}
fn set_token_properties(_amount: u32) -> Weight {
- // Error
- Weight::zero()
- }
-
- fn delete_token_properties(_amount: u32) -> Weight {
// Error
Weight::zero()
}
@@ -80,7 +68,8 @@
}
fn transfer() -> Weight {
- <SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
+ <SelfWeightOf<T>>::transfer_raw()
+ .saturating_add(<PalletCommonWeightOf<T>>::check_accesslist().saturating_mul(2))
}
fn approve() -> Weight {
@@ -93,28 +82,14 @@
fn transfer_from() -> Weight {
Self::transfer()
- + <SelfWeightOf<T>>::check_allowed_raw()
- + <SelfWeightOf<T>>::set_allowance_unchecked_raw()
+ .saturating_add(<SelfWeightOf<T>>::check_allowed_raw())
+ .saturating_add(<SelfWeightOf<T>>::set_allowance_unchecked_raw())
}
fn burn_from() -> Weight {
<SelfWeightOf<T>>::burn_from()
}
- fn burn_recursively_self_raw() -> Weight {
- // Read to get total balance
- Self::burn_item() + T::DbWeight::get().reads(1)
- }
-
- fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
- // Fungible tokens can't have children
- Weight::zero()
- }
-
- fn token_owner() -> Weight {
- Weight::zero()
- }
-
fn set_allowance_for_all() -> Weight {
Weight::zero()
}
@@ -200,26 +175,6 @@
with_weight(
<Pallet<T>>::burn(self, &sender, amount),
<CommonWeights<T>>::burn_item(),
- )
- }
-
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- _breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- // Should not happen?
- ensure!(
- token == TokenId::default(),
- <Error<T>>::FungibleItemsHaveNoId
- );
- ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
-
- with_weight(
- <Pallet<T>>::burn(self, &sender, <Balance<T>>::get((self.id, &sender))),
- <CommonWeights<T>>::burn_recursively_self_raw(),
)
}
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -32,12 +32,12 @@
use pallet_evm_coder_substrate::{
call, dispatch_to_evm,
execution::{PreDispatch, Result},
- frontier_contract,
+ frontier_contract, SubstrateRecorder,
};
use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::{Get, U256};
use sp_std::vec::Vec;
-use up_data_structs::CollectionMode;
+use up_data_structs::{budget::Budget, CollectionMode};
use crate::{
common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, FungibleHandle, Pallet,
@@ -73,6 +73,10 @@
amount: U256,
}
+fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
+ recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
+}
+
#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]
impl<T: Config> FungibleHandle<T> {
fn name(&self) -> Result<String> {
@@ -106,11 +110,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, amount, &budget)
+ <Pallet<T>>::transfer(self, &caller, &to, amount, &nesting_budget(&self.recorder))
.map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(true)
}
@@ -127,12 +128,16 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(true)
}
#[weight(<SelfWeightOf<T>>::approve())]
@@ -164,10 +169,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::create_item(self, &caller, (to, amount), &budget)
+
+ <Pallet<T>>::create_item(self, &caller, (to, amount), &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -201,10 +204,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::create_item(self, &caller, (to, amount), &budget)
+
+ <Pallet<T>>::create_item(self, &caller, (to, amount), &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -236,12 +237,15 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -260,12 +264,15 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -274,9 +281,6 @@
#[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]
fn mint_bulk(&mut self, caller: Caller, amounts: Vec<AmountForAddress>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let amounts = amounts
.into_iter()
.map(|AmountForAddress { to, amount }| {
@@ -287,7 +291,7 @@
})
.collect::<Result<_>>()?;
- <Pallet<T>>::create_multiple_items(self, &caller, amounts, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, amounts, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -297,11 +301,9 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;
+ <Pallet<T>>::transfer(self, &caller, &to, amount, &nesting_budget(&self.recorder))
+ .map_err(|_| "transfer error")?;
Ok(true)
}
@@ -317,12 +319,16 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(true)
}
pallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -18,7 +18,6 @@
use pallet_common::{
bench_init,
benchmarking::{create_collection_raw, property_key, property_value},
- CommonCollectionOperations,
};
use sp_std::prelude::*;
use up_data_structs::{
@@ -131,49 +130,8 @@
#[block]
{
<Pallet<T>>::burn(&collection, &burner, item)?;
- }
-
- Ok(())
- }
-
- #[benchmark]
- fn burn_recursively_self_raw() -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- sender: cross_from_sub(owner); burner: cross_sub;
- };
- let item = create_max_item(&collection, &sender, burner.clone())?;
-
- #[block]
- {
- <Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?;
- }
-
- Ok(())
- }
-
- #[benchmark]
- fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(
- b: Linear<0, 200>,
- ) -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- sender: cross_from_sub(owner); burner: cross_sub;
- };
- let item = create_max_item(&collection, &sender, burner.clone())?;
- for _ in 0..b {
- create_max_item(
- &collection,
- &sender,
- T::CrossTokenAddressMapping::token_to_address(collection.id, item),
- )?;
}
- #[block]
- {
- <Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?;
- }
-
Ok(())
}
@@ -267,38 +225,29 @@
}
#[benchmark]
- fn set_token_property_permissions(
- b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
- ) -> Result<(), BenchmarkError> {
+ fn load_token_properties() -> Result<(), BenchmarkError> {
bench_init! {
owner: sub; collection: collection(owner);
owner: cross_from_sub;
};
- let perms = (0..b)
- .map(|k| PropertyKeyPermission {
- key: property_key(k as usize),
- permission: PropertyPermission {
- mutable: false,
- collection_admin: false,
- token_owner: false,
- },
- })
- .collect::<Vec<_>>();
+ let item = create_max_item(&collection, &owner, owner.clone())?;
+
#[block]
{
- <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(&collection, item);
}
Ok(())
}
#[benchmark]
- fn set_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
+ fn write_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
bench_init! {
owner: sub; collection: collection(owner);
owner: cross_from_sub;
};
+
let perms = (0..b)
.map(|k| PropertyKeyPermission {
key: property_key(k as usize),
@@ -318,71 +267,29 @@
.collect::<Vec<_>>();
let item = create_max_item(&collection, &owner, owner.clone())?;
+ let lazy_collection_info =
+ pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(&collection, &owner);
+
#[block]
{
- <Pallet<T>>::set_token_properties(
- &collection,
- &owner,
+ let mut property_writer =
+ pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+
+ property_writer.write_token_properties(
item,
props.into_iter(),
- &Unlimited,
+ crate::erc::ERC721TokenEvent::TokenChanged {
+ token_id: item.into(),
+ }
+ .to_log(T::ContractAddress::get()),
)?;
}
Ok(())
}
- // TODO:
#[benchmark]
- fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
- // bench_init! {
- // owner: sub; collection: collection(owner);
- // owner: cross_from_sub;
- // };
-
- // let perms = (0..b)
- // .map(|k| PropertyKeyPermission {
- // key: property_key(k as usize),
- // permission: PropertyPermission {
- // mutable: false,
- // collection_admin: true,
- // token_owner: true,
- // },
- // })
- // .collect::<Vec<_>>();
- // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
- #[block]
- {}
- // let props = (0..b)
- // .map(|k| Property {
- // key: property_key(k as usize),
- // value: property_value(),
- // })
- // .collect::<Vec<_>>();
- // let item = create_max_item(&collection, &owner, owner.clone())?;
-
- // let (is_collection_admin, property_permissions) =
- // load_is_admin_and_property_permissions(&collection, &owner);
- // #[block]
- // {
- // let mut property_writer =
- // pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
-
- // property_writer.write_token_properties(
- // item,
- // props.into_iter(),
- // crate::erc::ERC721TokenEvent::TokenChanged {
- // token_id: item.into(),
- // }
- // .to_log(T::ContractAddress::get()),
- // )?;
- // }
-
- Ok(())
- }
-
- #[benchmark]
- fn delete_token_properties(
+ fn set_token_property_permissions(
b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
) -> Result<(), BenchmarkError> {
bench_init! {
@@ -393,54 +300,16 @@
.map(|k| PropertyKeyPermission {
key: property_key(k as usize),
permission: PropertyPermission {
- mutable: true,
- collection_admin: true,
- token_owner: true,
+ mutable: false,
+ collection_admin: false,
+ token_owner: false,
},
})
.collect::<Vec<_>>();
- <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
- let props = (0..b)
- .map(|k| Property {
- key: property_key(k as usize),
- value: property_value(),
- })
- .collect::<Vec<_>>();
- let item = create_max_item(&collection, &owner, owner.clone())?;
- <Pallet<T>>::set_token_properties(
- &collection,
- &owner,
- item,
- props.into_iter(),
- &Unlimited,
- )?;
- let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
#[block]
{
- <Pallet<T>>::delete_token_properties(
- &collection,
- &owner,
- item,
- to_delete.into_iter(),
- &Unlimited,
- )?;
- }
-
- Ok(())
- }
-
- #[benchmark]
- fn token_owner() -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- owner: cross_from_sub;
- };
- let item = create_max_item(&collection, &owner, owner.clone())?;
-
- #[block]
- {
- collection.token_owner(item).unwrap();
+ <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
}
Ok(())
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -18,8 +18,9 @@
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
use pallet_common::{
- init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,
- CommonWeightInfo, RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
+ weights::WeightInfo as _, with_weight, write_token_properties_total_weight,
+ CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions,
+ SelfWeightOf as PalletCommonWeightOf,
};
use pallet_structure::Pallet as PalletStructure;
use sp_runtime::DispatchError;
@@ -38,24 +39,21 @@
impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
match data {
- CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)
- .saturating_add(init_token_properties_delta::<T, _>(
- t.iter().map(|t| t.properties.len() as u32),
- <SelfWeightOf<T>>::init_token_properties,
- )),
+ CreateItemExData::NFT(t) => mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32),
+ t.iter().map(|t| t.properties.len() as u32),
+ ),
_ => Weight::zero(),
}
}
fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
- <SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
- init_token_properties_delta::<T, _>(
- data.iter().map(|t| match t {
- up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,
- _ => 0,
- }),
- <SelfWeightOf<T>>::init_token_properties,
- ),
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items(data.len() as u32),
+ data.iter().map(|t| match t {
+ up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,
+ _ => 0,
+ }),
)
}
@@ -65,18 +63,17 @@
fn set_collection_properties(amount: u32) -> Weight {
<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
- }
-
- fn delete_collection_properties(amount: u32) -> Weight {
- <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
}
fn set_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::set_token_properties(amount)
+ write_token_properties_total_weight::<T, _>([amount].into_iter(), |amount| {
+ <SelfWeightOf<T>>::load_token_properties()
+ .saturating_add(<SelfWeightOf<T>>::write_token_properties(amount))
+ })
}
fn delete_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::delete_token_properties(amount)
+ Self::set_token_properties(amount)
}
fn set_token_property_permissions(amount: u32) -> Weight {
@@ -84,7 +81,8 @@
}
fn transfer() -> Weight {
- <SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
+ <SelfWeightOf<T>>::transfer_raw()
+ .saturating_add(<PalletCommonWeightOf<T>>::check_accesslist().saturating_mul(2))
}
fn approve() -> Weight {
@@ -96,24 +94,11 @@
}
fn transfer_from() -> Weight {
- Self::transfer() + <SelfWeightOf<T>>::check_allowed_raw()
+ Self::transfer().saturating_add(<SelfWeightOf<T>>::check_allowed_raw())
}
fn burn_from() -> Weight {
<SelfWeightOf<T>>::burn_from()
- }
-
- fn burn_recursively_self_raw() -> Weight {
- <SelfWeightOf<T>>::burn_recursively_self_raw()
- }
-
- fn burn_recursively_breadth_raw(amount: u32) -> Weight {
- <SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)
- .saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))
- }
-
- fn token_owner() -> Weight {
- <SelfWeightOf<T>>::token_owner()
}
fn set_allowance_for_all() -> Weight {
@@ -125,6 +110,20 @@
}
}
+/// Weight of minting tokens with properties
+/// * `create_no_data_weight` -- the weight of minting without properties
+/// * `token_properties_nums` -- number of properties of each token
+#[inline]
+pub(crate) fn mint_with_props_weight<T: Config>(
+ create_no_data_weight: Weight,
+ token_properties_nums: impl Iterator<Item = u32> + Clone,
+) -> Weight {
+ create_no_data_weight.saturating_add(write_token_properties_total_weight::<T, _>(
+ token_properties_nums,
+ <SelfWeightOf<T>>::write_token_properties,
+ ))
+}
+
fn map_create_data<T: Config>(
data: up_data_structs::CreateItemData,
to: &T::CrossAccountId,
@@ -306,16 +305,6 @@
<Pallet<T>>::check_token_immediate_ownership(self, token, &sender)?;
Ok(().into())
}
- }
-
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- <Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)
}
fn transfer(
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -38,19 +38,21 @@
use pallet_evm_coder_substrate::{
call, dispatch_to_evm,
execution::{Error, PreDispatch, Result},
- frontier_contract,
+ frontier_contract, SubstrateRecorder,
};
use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::{Get, U256};
use sp_std::{vec, vec::Vec};
use up_data_structs::{
- CollectionId, CollectionPropertiesVec, Property, PropertyKey, PropertyKeyPermission,
- PropertyPermission, TokenId,
+ budget::Budget, CollectionId, CollectionPropertiesVec, Property, PropertyKey,
+ PropertyKeyPermission, PropertyPermission, TokenId,
};
use crate::{
- common::CommonWeights, weights::WeightInfo, AccountBalance, Config, CreateItemData,
- NonfungibleHandle, Pallet, SelfWeightOf, TokenData, TokenProperties, TokensMinted,
+ common::{mint_with_props_weight, CommonWeights},
+ weights::WeightInfo,
+ AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, SelfWeightOf, TokenData,
+ TokenProperties, TokensMinted,
};
/// Nft events.
@@ -78,6 +80,10 @@
impl<T: Config> Contract for NonfungibleHandle<T> {...}
}
+fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
+ recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
+}
+
/// @title A contract that allows to set and delete token properties and change token property permissions.
#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
impl<T: Config> NonfungibleHandle<T> {
@@ -146,7 +152,7 @@
/// @param key Property key.
/// @param value Property value.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(<CommonWeights<T>>::set_token_properties(1))]
fn set_property(
&mut self,
caller: Caller,
@@ -161,16 +167,12 @@
.map_err(|_| "key too long")?;
let value = value.0.try_into().map_err(|_| "value too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
<Pallet<T>>::set_token_property(
self,
&caller,
TokenId(token_id),
Property { key, value },
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -179,7 +181,7 @@
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param properties settable properties
- #[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+ #[weight(<CommonWeights<T>>::set_token_properties(properties.len() as u32))]
fn set_properties(
&mut self,
caller: Caller,
@@ -189,10 +191,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
let properties = properties
.into_iter()
.map(eth::Property::try_into)
@@ -203,7 +201,7 @@
&caller,
TokenId(token_id),
properties.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -213,7 +211,7 @@
/// @param tokenId ID of the token.
/// @param key Property key.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::delete_token_properties(1))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(1))]
fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -221,19 +219,21 @@
.try_into()
.map_err(|_| "key too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
- <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)
- .map_err(dispatch_to_evm::<T>)
+ <Pallet<T>>::delete_token_property(
+ self,
+ &caller,
+ TokenId(token_id),
+ key,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)
}
/// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param keys Properties key.
- #[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(keys.len() as u32))]
fn delete_properties(
&mut self,
token_id: U256,
@@ -247,16 +247,12 @@
.map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
.collect::<Result<Vec<_>>>()?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
<Pallet<T>>::delete_token_properties(
self,
&caller,
TokenId(token_id),
keys.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -481,12 +477,16 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -594,9 +594,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -613,7 +610,7 @@
properties: BoundedVec::default(),
owner: to,
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
@@ -625,7 +622,7 @@
/// @param tokenUri Token URI that would be stored in the NFT properties
/// @return uint256 The id of the newly minted token
#[solidity(rename_selector = "mintWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
fn mint_with_token_uri(
&mut self,
caller: Caller,
@@ -647,7 +644,7 @@
/// @param tokenId ID of the minted NFT
/// @param tokenUri Token URI that would be stored in the NFT properties
#[solidity(hide, rename_selector = "mintWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
fn mint_with_token_uri_check_id(
&mut self,
caller: Caller,
@@ -664,9 +661,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -694,7 +688,7 @@
properties,
owner: to,
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
@@ -840,11 +834,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, token, &budget)
+ <Pallet<T>>::transfer(self, &caller, &to, token, &nesting_budget(&self.recorder))
.map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -864,11 +855,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, token, &budget)
+ <Pallet<T>>::transfer(self, &caller, &to, token, &nesting_budget(&self.recorder))
.map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -891,11 +879,16 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let token_id = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, &budget)
- .map_err(|e| dispatch_to_evm::<T>(e.error))?;
+
+ Pallet::<T>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token_id,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(|e| dispatch_to_evm::<T>(e.error))?;
Ok(())
}
@@ -911,11 +904,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, token, &budget)
+ <Pallet<T>>::burn_from(self, &caller, &from, token, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -936,11 +926,8 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, token, &budget)
+ <Pallet<T>>::burn_from(self, &caller, &from, token, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -966,9 +953,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let total_tokens = token_ids.len();
for id in token_ids.into_iter() {
@@ -985,19 +969,21 @@
})
.collect();
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
/// @notice Function to mint a token.
/// @param data Array of pairs of token owner and token's properties for minted token
- #[weight(<SelfWeightOf<T>>::create_multiple_items(data.len() as u32) + <SelfWeightOf<T>>::set_token_properties(data.len() as u32))]
+ #[weight(
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items_ex(data.len() as u32),
+ data.iter().map(|d| d.properties.len() as u32),
+ )
+ )]
fn mint_bulk_cross(&mut self, caller: Caller, data: Vec<MintTokenData>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let mut create_nft_data = Vec::with_capacity(data.len());
for MintTokenData { owner, properties } in data {
@@ -1013,8 +999,13 @@
});
}
- <Pallet<T>>::create_multiple_items(self, &caller, create_nft_data, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::create_multiple_items(
+ self,
+ &caller,
+ create_nft_data,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1024,7 +1015,12 @@
/// @param to The new owner
/// @param tokens array of pairs of token ID and token URI for minted tokens
#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]
+ #[weight(
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32),
+ tokens.iter().map(|_| 1),
+ )
+ )]
fn mint_bulk_with_token_uri(
&mut self,
caller: Caller,
@@ -1037,9 +1033,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let mut data = Vec::with_capacity(tokens.len());
for TokenUri { id, uri } in tokens {
@@ -1066,7 +1059,7 @@
});
}
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1075,7 +1068,7 @@
/// @param to The new owner crossAccountId
/// @param properties Properties of minted token
/// @return uint256 The id of the newly minted token
- #[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+ #[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [properties.len() as u32].into_iter()))]
fn mint_cross(
&mut self,
caller: Caller,
@@ -1096,10 +1089,6 @@
.map_err(|_| Error::Revert("too many properties".to_string()))?;
let caller = T::CrossAccountId::from_eth(caller);
-
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
<Pallet<T>>::create_item(
self,
@@ -1108,7 +1097,7 @@
properties,
owner: to,
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -109,7 +109,7 @@
};
use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use pallet_structure::{Error as StructureError, Pallet as PalletStructure};
+use pallet_structure::Pallet as PalletStructure;
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
use scale_info::TypeInfo;
use sp_core::{Get, H160};
@@ -502,52 +502,7 @@
));
Ok(())
}
-
- /// Same as [`burn`] but burns all the tokens that are nested in the token first
- ///
- /// - `self_budget`: Limit for searching children in depth.
- /// - `breadth_budget`: Limit of breadth of searching children.
- ///
- /// [`burn`]: struct.Pallet.html#method.burn
- #[transactional]
- pub fn burn_recursively(
- collection: &NonfungibleHandle<T>,
- sender: &T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
- let current_token_account =
- T::CrossTokenAddressMapping::token_to_address(collection.id, token);
-
- let mut weight = Weight::zero();
-
- // This method is transactional, if user in fact doesn't have permissions to remove token -
- // tokens removed here will be restored after rejected transaction
- for ((collection, token), _) in <TokenChildren<T>>::iter_prefix((collection.id, token)) {
- ensure!(breadth_budget.consume(), <StructureError<T>>::BreadthLimit,);
- let PostDispatchInfo { actual_weight, .. } =
- <PalletStructure<T>>::burn_item_recursively(
- current_token_account.clone(),
- collection,
- token,
- self_budget,
- breadth_budget,
- )?;
- if let Some(actual_weight) = actual_weight {
- weight = weight.saturating_add(actual_weight);
- }
- }
-
- Self::burn(collection, sender, token)?;
- DispatchResultWithPostInfo::Ok(PostDispatchInfo {
- actual_weight: Some(weight + <SelfWeightOf<T>>::burn_item()),
- pays_fee: Pays::Yes,
- })
- }
-
/// A batch operation to add, edit or remove properties for a token.
///
/// - `nesting_budget`: Limit for searching parents in-depth to check ownership.
@@ -568,7 +523,7 @@
nesting_budget: &dyn Budget,
) -> DispatchResult {
let mut property_writer =
- pallet_common::property_writer_for_existing_token(collection, sender);
+ pallet_common::ExistingTokenPropertyWriter::new(collection, sender);
property_writer.write_token_properties(
sender,
@@ -915,7 +870,7 @@
// =========
- let mut property_writer = pallet_common::property_writer_for_new_token(collection, sender);
+ let mut property_writer = pallet_common::NewTokenPropertyWriter::new(collection, sender);
with_transaction(|| {
for (i, data) in data.iter().enumerate() {
pallets/nonfungible/src/weights.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -3,13 +3,13 @@
//! Autogenerated weights for pallet_nonfungible
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-10-13, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`
-//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
+//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
+//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
-// target/production/unique-collator
+// ./target/production/unique-collator
// benchmark
// pallet
// --pallet
@@ -20,7 +20,7 @@
// *
// --template=.maintain/frame-weight-template.hbs
// --steps=50
-// --repeat=400
+// --repeat=80
// --heap-pages=4096
// --output=./pallets/nonfungible/src/weights.rs
@@ -37,18 +37,14 @@
fn create_multiple_items(b: u32, ) -> Weight;
fn create_multiple_items_ex(b: u32, ) -> Weight;
fn burn_item() -> Weight;
- fn burn_recursively_self_raw() -> Weight;
- fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;
fn transfer_raw() -> Weight;
fn approve() -> Weight;
fn approve_from() -> Weight;
fn check_allowed_raw() -> Weight;
fn burn_from() -> Weight;
+ fn load_token_properties() -> Weight;
+ fn write_token_properties(b: u32, ) -> Weight;
fn set_token_property_permissions(b: u32, ) -> Weight;
- fn set_token_properties(b: u32, ) -> Weight;
- fn init_token_properties(b: u32, ) -> Weight;
- fn delete_token_properties(b: u32, ) -> Weight;
- fn token_owner() -> Weight;
fn set_allowance_for_all() -> Weight;
fn allowance_for_all() -> Weight;
fn repair_item() -> Weight;
@@ -57,321 +53,231 @@
/// Weights for pallet_nonfungible using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
- /// Storage: Nonfungible TokensMinted (r:1 w:1)
- /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:0 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:1)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn create_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3530`
- // Minimum execution time: 9_726_000 picoseconds.
- Weight::from_parts(10_059_000, 3530)
+ // Minimum execution time: 15_410_000 picoseconds.
+ Weight::from_parts(15_850_000, 3530)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
- /// Storage: Nonfungible TokensMinted (r:1 w:1)
- /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:0 w:200)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:200)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:0 w:200)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:200)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3530`
- // Minimum execution time: 3_270_000 picoseconds.
- Weight::from_parts(3_693_659, 3530)
- // Standard Error: 255
- .saturating_add(Weight::from_parts(3_024_284, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_300_000 picoseconds.
+ Weight::from_parts(5_992_994, 3530)
+ // Standard Error: 4_478
+ .saturating_add(Weight::from_parts(8_002_092, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))
}
- /// Storage: Nonfungible TokensMinted (r:1 w:1)
- /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:200 w:200)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:0 w:200)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:200)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:200 w:200)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:0 w:200)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:200)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items_ex(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 3_188_000 picoseconds.
- Weight::from_parts(3_307_000, 3481)
- // Standard Error: 567
- .saturating_add(Weight::from_parts(4_320_449, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_300_000 picoseconds.
+ Weight::from_parts(3_980_000, 3481)
+ // Standard Error: 1_382
+ .saturating_add(Weight::from_parts(11_259_286, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1_u64))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))
}
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenChildren (r:1 w:0)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenChildren` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenChildren` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:0)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:1)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `380`
// Estimated: `3530`
- // Minimum execution time: 18_062_000 picoseconds.
- Weight::from_parts(18_433_000, 3530)
- .saturating_add(T::DbWeight::get().reads(5_u64))
- .saturating_add(T::DbWeight::get().writes(5_u64))
- }
- /// Storage: Nonfungible TokenChildren (r:1 w:0)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- fn burn_recursively_self_raw() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `380`
- // Estimated: `3530`
- // Minimum execution time: 22_942_000 picoseconds.
- Weight::from_parts(23_527_000, 3530)
+ // Minimum execution time: 26_360_000 picoseconds.
+ Weight::from_parts(26_850_000, 3530)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
- }
- /// Storage: Nonfungible TokenChildren (r:401 w:200)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Common CollectionById (r:1 w:0)
- /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:201 w:201)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:2 w:2)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:201 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:201)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:201)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 200]`.
- fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `1500 + b * (58 ±0)`
- // Estimated: `5874 + b * (5032 ±0)`
- // Minimum execution time: 22_709_000 picoseconds.
- Weight::from_parts(23_287_000, 5874)
- // Standard Error: 89_471
- .saturating_add(Weight::from_parts(63_285_201, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(7_u64))
- .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(b.into())))
- .saturating_add(T::DbWeight::get().writes(6_u64))
- .saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(b.into())))
- .saturating_add(Weight::from_parts(0, 5032).saturating_mul(b.into()))
}
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:2 w:2)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:2)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:2 w:2)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:0)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:2)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_raw() -> Weight {
// Proof Size summary in bytes:
// Measured: `380`
// Estimated: `6070`
- // Minimum execution time: 13_652_000 picoseconds.
- Weight::from_parts(13_981_000, 6070)
+ // Minimum execution time: 22_710_000 picoseconds.
+ Weight::from_parts(23_130_000, 6070)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:1)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:1)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
fn approve() -> Weight {
// Proof Size summary in bytes:
// Measured: `326`
// Estimated: `3522`
- // Minimum execution time: 7_837_000 picoseconds.
- Weight::from_parts(8_113_000, 3522)
+ // Minimum execution time: 11_520_000 picoseconds.
+ Weight::from_parts(12_030_000, 3522)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:1)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:1)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
fn approve_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `313`
// Estimated: `3522`
- // Minimum execution time: 7_769_000 picoseconds.
- Weight::from_parts(7_979_000, 3522)
+ // Minimum execution time: 11_570_000 picoseconds.
+ Weight::from_parts(12_139_000, 3522)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:0)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
fn check_allowed_raw() -> Weight {
// Proof Size summary in bytes:
// Measured: `362`
// Estimated: `3522`
- // Minimum execution time: 4_194_000 picoseconds.
- Weight::from_parts(4_353_000, 3522)
+ // Minimum execution time: 4_210_000 picoseconds.
+ Weight::from_parts(4_350_000, 3522)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
- /// Storage: Nonfungible Allowance (r:1 w:1)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenChildren (r:1 w:0)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:1)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenChildren` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenChildren` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:1)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `463`
// Estimated: `3530`
- // Minimum execution time: 21_978_000 picoseconds.
- Weight::from_parts(22_519_000, 3530)
+ // Minimum execution time: 32_230_000 picoseconds.
+ Weight::from_parts(33_210_000, 3530)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:1)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_property_permissions(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `314`
- // Estimated: `20191`
- // Minimum execution time: 1_457_000 picoseconds.
- Weight::from_parts(1_563_000, 20191)
- // Standard Error: 14_041
- .saturating_add(Weight::from_parts(8_452_415, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(1_u64))
- .saturating_add(T::DbWeight::get().writes(1_u64))
- }
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:1 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_properties(b: u32, ) -> Weight {
+ /// Storage: `Nonfungible::TokenProperties` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
+ fn load_token_properties() -> Weight {
// Proof Size summary in bytes:
- // Measured: `640 + b * (261 ±0)`
+ // Measured: `279`
// Estimated: `36269`
- // Minimum execution time: 963_000 picoseconds.
- Weight::from_parts(1_126_511, 36269)
- // Standard Error: 9_175
- .saturating_add(Weight::from_parts(5_096_011, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(3_u64))
- .saturating_add(T::DbWeight::get().writes(1_u64))
+ // Minimum execution time: 3_180_000 picoseconds.
+ Weight::from_parts(3_370_000, 36269)
+ .saturating_add(T::DbWeight::get().reads(1_u64))
}
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn init_token_properties(b: u32, ) -> Weight {
+ fn write_token_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 194_000 picoseconds.
- Weight::from_parts(222_000, 0)
- // Standard Error: 7_295
- .saturating_add(Weight::from_parts(4_499_463, 0).saturating_mul(b.into()))
+ // Minimum execution time: 440_000 picoseconds.
+ Weight::from_parts(3_567_990, 0)
+ // Standard Error: 24_013
+ .saturating_add(Weight::from_parts(19_386_123, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:1 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Common::CollectionPropertyPermissions` (r:1 w:1)
+ /// Proof: `Common::CollectionPropertyPermissions` (`max_values`: None, `max_size`: Some(16726), added: 19201, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn delete_token_properties(b: u32, ) -> Weight {
+ fn set_token_property_permissions(b: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `699 + b * (33291 ±0)`
- // Estimated: `36269`
- // Minimum execution time: 992_000 picoseconds.
- Weight::from_parts(1_043_000, 36269)
- // Standard Error: 37_370
- .saturating_add(Weight::from_parts(23_672_870, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(3_u64))
+ // Measured: `314`
+ // Estimated: `20191`
+ // Minimum execution time: 1_460_000 picoseconds.
+ Weight::from_parts(1_530_000, 20191)
+ // Standard Error: 124_929
+ .saturating_add(Weight::from_parts(28_397_581, 0).saturating_mul(b.into()))
+ .saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- fn token_owner() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `326`
- // Estimated: `3522`
- // Minimum execution time: 3_743_000 picoseconds.
- Weight::from_parts(3_908_000, 3522)
- .saturating_add(T::DbWeight::get().reads(1_u64))
- }
- /// Storage: Nonfungible CollectionAllowance (r:0 w:1)
- /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::CollectionAllowance` (r:0 w:1)
+ /// Proof: `Nonfungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn set_allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 4_106_000 picoseconds.
- Weight::from_parts(4_293_000, 0)
+ // Minimum execution time: 6_840_000 picoseconds.
+ Weight::from_parts(7_160_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible CollectionAllowance (r:1 w:0)
- /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::CollectionAllowance` (r:1 w:0)
+ /// Proof: `Nonfungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3576`
- // Minimum execution time: 2_775_000 picoseconds.
- Weight::from_parts(2_923_000, 3576)
+ // Minimum execution time: 3_630_000 picoseconds.
+ Weight::from_parts(3_780_000, 3576)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
- /// Storage: Nonfungible TokenProperties (r:1 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenProperties` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn repair_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `279`
// Estimated: `36269`
- // Minimum execution time: 3_033_000 picoseconds.
- Weight::from_parts(3_174_000, 36269)
+ // Minimum execution time: 3_280_000 picoseconds.
+ Weight::from_parts(3_480_000, 36269)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -379,321 +285,231 @@
// For backwards compatibility and tests
impl WeightInfo for () {
- /// Storage: Nonfungible TokensMinted (r:1 w:1)
- /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:0 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:1)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn create_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3530`
- // Minimum execution time: 9_726_000 picoseconds.
- Weight::from_parts(10_059_000, 3530)
+ // Minimum execution time: 15_410_000 picoseconds.
+ Weight::from_parts(15_850_000, 3530)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
- /// Storage: Nonfungible TokensMinted (r:1 w:1)
- /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:0 w:200)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:200)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:0 w:200)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:200)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3530`
- // Minimum execution time: 3_270_000 picoseconds.
- Weight::from_parts(3_693_659, 3530)
- // Standard Error: 255
- .saturating_add(Weight::from_parts(3_024_284, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_300_000 picoseconds.
+ Weight::from_parts(5_992_994, 3530)
+ // Standard Error: 4_478
+ .saturating_add(Weight::from_parts(8_002_092, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))
}
- /// Storage: Nonfungible TokensMinted (r:1 w:1)
- /// Proof: Nonfungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:200 w:200)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:0 w:200)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:200)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:200 w:200)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:0 w:200)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:200)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items_ex(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 3_188_000 picoseconds.
- Weight::from_parts(3_307_000, 3481)
- // Standard Error: 567
- .saturating_add(Weight::from_parts(4_320_449, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_300_000 picoseconds.
+ Weight::from_parts(3_980_000, 3481)
+ // Standard Error: 1_382
+ .saturating_add(Weight::from_parts(11_259_286, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(1_u64))
.saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))
}
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenChildren (r:1 w:0)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenChildren` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenChildren` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:0)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:1)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `380`
// Estimated: `3530`
- // Minimum execution time: 18_062_000 picoseconds.
- Weight::from_parts(18_433_000, 3530)
- .saturating_add(RocksDbWeight::get().reads(5_u64))
- .saturating_add(RocksDbWeight::get().writes(5_u64))
- }
- /// Storage: Nonfungible TokenChildren (r:1 w:0)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- fn burn_recursively_self_raw() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `380`
- // Estimated: `3530`
- // Minimum execution time: 22_942_000 picoseconds.
- Weight::from_parts(23_527_000, 3530)
+ // Minimum execution time: 26_360_000 picoseconds.
+ Weight::from_parts(26_850_000, 3530)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
- /// Storage: Nonfungible TokenChildren (r:401 w:200)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Common CollectionById (r:1 w:0)
- /// Proof: Common CollectionById (max_values: None, max_size: Some(860), added: 3335, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:201 w:201)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:2 w:2)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:201 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:201)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:201)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 200]`.
- fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `1500 + b * (58 ±0)`
- // Estimated: `5874 + b * (5032 ±0)`
- // Minimum execution time: 22_709_000 picoseconds.
- Weight::from_parts(23_287_000, 5874)
- // Standard Error: 89_471
- .saturating_add(Weight::from_parts(63_285_201, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(7_u64))
- .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(b.into())))
- .saturating_add(RocksDbWeight::get().writes(6_u64))
- .saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(b.into())))
- .saturating_add(Weight::from_parts(0, 5032).saturating_mul(b.into()))
- }
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:2 w:2)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:2)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:2 w:2)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:0)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:2)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_raw() -> Weight {
// Proof Size summary in bytes:
// Measured: `380`
// Estimated: `6070`
- // Minimum execution time: 13_652_000 picoseconds.
- Weight::from_parts(13_981_000, 6070)
+ // Minimum execution time: 22_710_000 picoseconds.
+ Weight::from_parts(23_130_000, 6070)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:1)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:1)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
fn approve() -> Weight {
// Proof Size summary in bytes:
// Measured: `326`
// Estimated: `3522`
- // Minimum execution time: 7_837_000 picoseconds.
- Weight::from_parts(8_113_000, 3522)
+ // Minimum execution time: 11_520_000 picoseconds.
+ Weight::from_parts(12_030_000, 3522)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible Allowance (r:1 w:1)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:1)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
fn approve_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `313`
// Estimated: `3522`
- // Minimum execution time: 7_769_000 picoseconds.
- Weight::from_parts(7_979_000, 3522)
+ // Minimum execution time: 11_570_000 picoseconds.
+ Weight::from_parts(12_139_000, 3522)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible Allowance (r:1 w:0)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:0)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
fn check_allowed_raw() -> Weight {
// Proof Size summary in bytes:
// Measured: `362`
// Estimated: `3522`
- // Minimum execution time: 4_194_000 picoseconds.
- Weight::from_parts(4_353_000, 3522)
+ // Minimum execution time: 4_210_000 picoseconds.
+ Weight::from_parts(4_350_000, 3522)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
- /// Storage: Nonfungible Allowance (r:1 w:1)
- /// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:1)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenChildren (r:1 w:0)
- /// Proof: Nonfungible TokenChildren (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokensBurnt (r:1 w:1)
- /// Proof: Nonfungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Nonfungible AccountBalance (r:1 w:1)
- /// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Nonfungible Owned (r:0 w:1)
- /// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::Allowance` (r:1 w:1)
+ /// Proof: `Nonfungible::Allowance` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenData` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenData` (`max_values`: None, `max_size`: Some(57), added: 2532, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenChildren` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenChildren` (`max_values`: None, `max_size`: Some(41), added: 2516, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Nonfungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Nonfungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::Owned` (r:0 w:1)
+ /// Proof: `Nonfungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Nonfungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `463`
// Estimated: `3530`
- // Minimum execution time: 21_978_000 picoseconds.
- Weight::from_parts(22_519_000, 3530)
+ // Minimum execution time: 32_230_000 picoseconds.
+ Weight::from_parts(33_210_000, 3530)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
- }
- /// Storage: Common CollectionPropertyPermissions (r:1 w:1)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_property_permissions(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `314`
- // Estimated: `20191`
- // Minimum execution time: 1_457_000 picoseconds.
- Weight::from_parts(1_563_000, 20191)
- // Standard Error: 14_041
- .saturating_add(Weight::from_parts(8_452_415, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(1_u64))
- .saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:1 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_properties(b: u32, ) -> Weight {
+ /// Storage: `Nonfungible::TokenProperties` (r:1 w:0)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
+ fn load_token_properties() -> Weight {
// Proof Size summary in bytes:
- // Measured: `640 + b * (261 ±0)`
+ // Measured: `279`
// Estimated: `36269`
- // Minimum execution time: 963_000 picoseconds.
- Weight::from_parts(1_126_511, 36269)
- // Standard Error: 9_175
- .saturating_add(Weight::from_parts(5_096_011, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(3_u64))
- .saturating_add(RocksDbWeight::get().writes(1_u64))
+ // Minimum execution time: 3_180_000 picoseconds.
+ Weight::from_parts(3_370_000, 36269)
+ .saturating_add(RocksDbWeight::get().reads(1_u64))
}
- /// Storage: Nonfungible TokenProperties (r:0 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn init_token_properties(b: u32, ) -> Weight {
+ fn write_token_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 194_000 picoseconds.
- Weight::from_parts(222_000, 0)
- // Standard Error: 7_295
- .saturating_add(Weight::from_parts(4_499_463, 0).saturating_mul(b.into()))
+ // Minimum execution time: 440_000 picoseconds.
+ Weight::from_parts(3_567_990, 0)
+ // Standard Error: 24_013
+ .saturating_add(Weight::from_parts(19_386_123, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- /// Storage: Nonfungible TokenProperties (r:1 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Common::CollectionPropertyPermissions` (r:1 w:1)
+ /// Proof: `Common::CollectionPropertyPermissions` (`max_values`: None, `max_size`: Some(16726), added: 19201, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn delete_token_properties(b: u32, ) -> Weight {
+ fn set_token_property_permissions(b: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `699 + b * (33291 ±0)`
- // Estimated: `36269`
- // Minimum execution time: 992_000 picoseconds.
- Weight::from_parts(1_043_000, 36269)
- // Standard Error: 37_370
- .saturating_add(Weight::from_parts(23_672_870, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(3_u64))
+ // Measured: `314`
+ // Estimated: `20191`
+ // Minimum execution time: 1_460_000 picoseconds.
+ Weight::from_parts(1_530_000, 20191)
+ // Standard Error: 124_929
+ .saturating_add(Weight::from_parts(28_397_581, 0).saturating_mul(b.into()))
+ .saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible TokenData (r:1 w:0)
- /// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
- fn token_owner() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `326`
- // Estimated: `3522`
- // Minimum execution time: 3_743_000 picoseconds.
- Weight::from_parts(3_908_000, 3522)
- .saturating_add(RocksDbWeight::get().reads(1_u64))
- }
- /// Storage: Nonfungible CollectionAllowance (r:0 w:1)
- /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::CollectionAllowance` (r:0 w:1)
+ /// Proof: `Nonfungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn set_allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 4_106_000 picoseconds.
- Weight::from_parts(4_293_000, 0)
+ // Minimum execution time: 6_840_000 picoseconds.
+ Weight::from_parts(7_160_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Nonfungible CollectionAllowance (r:1 w:0)
- /// Proof: Nonfungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::CollectionAllowance` (r:1 w:0)
+ /// Proof: `Nonfungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `142`
// Estimated: `3576`
- // Minimum execution time: 2_775_000 picoseconds.
- Weight::from_parts(2_923_000, 3576)
+ // Minimum execution time: 3_630_000 picoseconds.
+ Weight::from_parts(3_780_000, 3576)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
- /// Storage: Nonfungible TokenProperties (r:1 w:1)
- /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Nonfungible::TokenProperties` (r:1 w:1)
+ /// Proof: `Nonfungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn repair_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `279`
// Estimated: `36269`
- // Minimum execution time: 3_033_000 picoseconds.
- Weight::from_parts(3_174_000, 36269)
+ // Minimum execution time: 3_280_000 picoseconds.
+ Weight::from_parts(3_480_000, 36269)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
pallets/refungible/src/benchmarking.rsdiffbeforeafterboth--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -19,10 +19,7 @@
use frame_benchmarking::v2::*;
use pallet_common::{
bench_init,
- benchmarking::{
- create_collection_raw, /*load_is_admin_and_property_permissions,*/ property_key,
- property_value,
- },
+ benchmarking::{create_collection_raw, property_key, property_value},
};
use sp_std::prelude::*;
use up_data_structs::{
@@ -425,38 +422,29 @@
}
#[benchmark]
- fn set_token_property_permissions(
- b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
- ) -> Result<(), BenchmarkError> {
+ fn load_token_properties() -> Result<(), BenchmarkError> {
bench_init! {
owner: sub; collection: collection(owner);
owner: cross_from_sub;
};
- let perms = (0..b)
- .map(|k| PropertyKeyPermission {
- key: property_key(k as usize),
- permission: PropertyPermission {
- mutable: false,
- collection_admin: false,
- token_owner: false,
- },
- })
- .collect::<Vec<_>>();
+ let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
+
#[block]
{
- <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+ pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(&collection, item);
}
Ok(())
}
#[benchmark]
- fn set_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
+ fn write_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
bench_init! {
owner: sub; collection: collection(owner);
owner: cross_from_sub;
};
+
let perms = (0..b)
.map(|k| PropertyKeyPermission {
key: property_key(k as usize),
@@ -476,73 +464,29 @@
.collect::<Vec<_>>();
let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
+ let lazy_collection_info =
+ pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(&collection, &owner);
+
#[block]
{
- <Pallet<T>>::set_token_properties(
- &collection,
- &owner,
+ let mut property_writer =
+ pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+
+ property_writer.write_token_properties(
item,
props.into_iter(),
- &Unlimited,
+ crate::erc::ERC721TokenEvent::TokenChanged {
+ token_id: item.into(),
+ }
+ .to_log(T::ContractAddress::get()),
)?;
}
Ok(())
}
- // TODO:
#[benchmark]
- fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
- // bench_init! {
- // owner: sub; collection: collection(owner);
- // owner: cross_from_sub;
- // };
-
- // let perms = (0..b)
- // .map(|k| PropertyKeyPermission {
- // key: property_key(k as usize),
- // permission: PropertyPermission {
- // mutable: false,
- // collection_admin: true,
- // token_owner: true,
- // },
- // })
- // .collect::<Vec<_>>();
- // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
-
- #[block]
- {}
- // let props = (0..b).map(|k| Property {
- // key: property_key(k as usize),
- // value: property_value(),
- // }).collect::<Vec<_>>();
- // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
-
- // let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner)
- // let mut property_writer = pallet_common::collection_info_loaded_property_writer(
- // &collection,
- // is_collection_admin,
- // property_permissions,
- // );
-
- // #[block]
- // {
- // property_writer.write_token_properties(
- // true,
- // item,
- // props.into_iter(),
- // crate::erc::ERC721TokenEvent::TokenChanged {
- // token_id: item.into(),
- // }
- // .to_log(T::ContractAddress::get()),
- // )?;
- // }
-
- Ok(())
- }
-
- #[benchmark]
- fn delete_token_properties(
+ fn set_token_property_permissions(
b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
) -> Result<(), BenchmarkError> {
bench_init! {
@@ -553,38 +497,16 @@
.map(|k| PropertyKeyPermission {
key: property_key(k as usize),
permission: PropertyPermission {
- mutable: true,
- collection_admin: true,
- token_owner: true,
+ mutable: false,
+ collection_admin: false,
+ token_owner: false,
},
- })
- .collect::<Vec<_>>();
- <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
- let props = (0..b)
- .map(|k| Property {
- key: property_key(k as usize),
- value: property_value(),
})
.collect::<Vec<_>>();
- let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
- <Pallet<T>>::set_token_properties(
- &collection,
- &owner,
- item,
- props.into_iter(),
- &Unlimited,
- )?;
- let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
#[block]
{
- <Pallet<T>>::delete_token_properties(
- &collection,
- &owner,
- item,
- to_delete.into_iter(),
- &Unlimited,
- )?;
+ <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
}
Ok(())
@@ -601,22 +523,6 @@
#[block]
{
<Pallet<T>>::repartition(&collection, &owner, item, 200)?;
- }
-
- Ok(())
- }
-
- #[benchmark]
- fn token_owner() -> Result<(), BenchmarkError> {
- bench_init! {
- owner: sub; collection: collection(owner);
- sender: cross_from_sub(owner); owner: cross_sub;
- };
- let item = create_max_item(&collection, &sender, [(owner, 100)])?;
-
- #[block]
- {
- <Pallet<T>>::token_owner(collection.id, item).unwrap();
}
Ok(())
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -16,14 +16,12 @@
use core::marker::PhantomData;
-use frame_support::{
- dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
-};
+use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
use pallet_common::{
- init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,
- CommonWeightInfo, RefungibleExtensions,
+ weights::WeightInfo as _, with_weight, write_token_properties_total_weight,
+ CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions,
};
-use pallet_structure::{Error as StructureError, Pallet as PalletStructure};
+use pallet_structure::Pallet as PalletStructure;
use sp_runtime::DispatchError;
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
use up_data_structs::{
@@ -49,35 +47,27 @@
pub struct CommonWeights<T: Config>(PhantomData<T>);
impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
- <SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
- init_token_properties_delta::<T, _>(
- data.iter().map(|data| match data {
- up_data_structs::CreateItemData::ReFungible(rft_data) => {
- rft_data.properties.len() as u32
- }
- _ => 0,
- }),
- <SelfWeightOf<T>>::init_token_properties,
- ),
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items(data.len() as u32),
+ data.iter().map(|data| match data {
+ up_data_structs::CreateItemData::ReFungible(rft_data) => {
+ rft_data.properties.len() as u32
+ }
+ _ => 0,
+ }),
)
}
fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {
match call {
- CreateItemExData::RefungibleMultipleOwners(i) => {
- <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)
- .saturating_add(init_token_properties_delta::<T, _>(
- [i.properties.len() as u32].into_iter(),
- <SelfWeightOf<T>>::init_token_properties,
- ))
- }
- CreateItemExData::RefungibleMultipleItems(i) => {
- <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)
- .saturating_add(init_token_properties_delta::<T, _>(
- i.iter().map(|d| d.properties.len() as u32),
- <SelfWeightOf<T>>::init_token_properties,
- ))
- }
+ CreateItemExData::RefungibleMultipleOwners(i) => mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32),
+ [i.properties.len() as u32].into_iter(),
+ ),
+ CreateItemExData::RefungibleMultipleItems(i) => mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32),
+ i.iter().map(|d| d.properties.len() as u32),
+ ),
_ => Weight::zero(),
}
}
@@ -88,18 +78,13 @@
fn set_collection_properties(amount: u32) -> Weight {
<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
- }
-
- fn delete_collection_properties(amount: u32) -> Weight {
- <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
}
fn set_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::set_token_properties(amount)
- }
-
- fn delete_token_properties(amount: u32) -> Weight {
- <SelfWeightOf<T>>::delete_token_properties(amount)
+ write_token_properties_total_weight::<T, _>([amount].into_iter(), |amount| {
+ <SelfWeightOf<T>>::load_token_properties()
+ .saturating_add(<SelfWeightOf<T>>::write_token_properties(amount))
+ })
}
fn set_token_property_permissions(amount: u32) -> Weight {
@@ -136,19 +121,6 @@
<SelfWeightOf<T>>::burn_from()
}
- fn burn_recursively_self_raw() -> Weight {
- // Read to get total balance
- Self::burn_item() + T::DbWeight::get().reads(1)
- }
- fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
- // Refungible token can't have children
- Weight::zero()
- }
-
- fn token_owner() -> Weight {
- <SelfWeightOf<T>>::token_owner()
- }
-
fn set_allowance_for_all() -> Weight {
<SelfWeightOf<T>>::set_allowance_for_all()
}
@@ -158,6 +130,20 @@
}
}
+/// Weight of minting tokens with properties
+/// * `create_no_data_weight` -- the weight of minting without properties
+/// * `token_properties_nums` -- number of properties of each token
+#[inline]
+pub(crate) fn mint_with_props_weight<T: Config>(
+ create_no_data_weight: Weight,
+ token_properties_nums: impl Iterator<Item = u32> + Clone,
+) -> Weight {
+ create_no_data_weight.saturating_add(write_token_properties_total_weight::<T, _>(
+ token_properties_nums,
+ <SelfWeightOf<T>>::write_token_properties,
+ ))
+}
+
fn map_create_data<T: Config>(
data: up_data_structs::CreateItemData,
to: &T::CrossAccountId,
@@ -262,25 +248,6 @@
with_weight(
<Pallet<T>>::burn(self, &sender, token, amount),
<CommonWeights<T>>::burn_item(),
- )
- }
-
- fn burn_item_recursively(
- &self,
- sender: T::CrossAccountId,
- token: TokenId,
- self_budget: &dyn Budget,
- _breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
- with_weight(
- <Pallet<T>>::burn(
- self,
- &sender,
- token,
- <Balance<T>>::get((self.id, token, &sender)),
- ),
- <CommonWeights<T>>::burn_recursively_self_raw(),
)
}
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -32,26 +32,28 @@
use pallet_common::{
erc::{static_property::key, CollectionCall, CommonEvmHandler},
eth::{self, TokenUri},
- CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
+ CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations, CommonWeightInfo,
Error as CommonError,
};
use pallet_evm::{account::CrossAccountId, PrecompileHandle};
use pallet_evm_coder_substrate::{
call, dispatch_to_evm,
execution::{Error, PreDispatch, Result},
- frontier_contract,
+ frontier_contract, SubstrateRecorder,
};
use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::{Get, H160, U256};
use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
use up_data_structs::{
- mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property, PropertyKey,
- PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,
+ budget::Budget, mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property,
+ PropertyKey, PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,
};
use crate::{
- weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle,
- SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
+ common::{mint_with_props_weight, CommonWeights},
+ weights::WeightInfo,
+ AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,
+ TokenProperties, TokensMinted, TotalSupply,
};
frontier_contract! {
@@ -90,6 +92,10 @@
pub properties: Vec<eth::Property>,
}
+pub fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
+ recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
+}
+
/// @title A contract that allows to set and delete token properties and change token property permissions.
#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
impl<T: Config> RefungibleHandle<T> {
@@ -158,7 +164,7 @@
/// @param key Property key.
/// @param value Property value.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(<CommonWeights<T>>::set_token_properties(1))]
fn set_property(
&mut self,
caller: Caller,
@@ -172,17 +178,13 @@
.try_into()
.map_err(|_| "key too long")?;
let value = value.0.try_into().map_err(|_| "value too long")?;
-
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
<Pallet<T>>::set_token_property(
self,
&caller,
TokenId(token_id),
Property { key, value },
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -191,7 +193,7 @@
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param properties settable properties
- #[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+ #[weight(<CommonWeights<T>>::set_token_properties(properties.len() as u32))]
fn set_properties(
&mut self,
caller: Caller,
@@ -201,10 +203,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
let properties = properties
.into_iter()
.map(eth::Property::try_into)
@@ -215,7 +213,7 @@
&caller,
TokenId(token_id),
properties.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -225,7 +223,7 @@
/// @param tokenId ID of the token.
/// @param key Property key.
#[solidity(hide)]
- #[weight(<SelfWeightOf<T>>::delete_token_properties(1))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(1))]
fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -233,19 +231,21 @@
.try_into()
.map_err(|_| "key too long")?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
- <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)
- .map_err(dispatch_to_evm::<T>)
+ <Pallet<T>>::delete_token_property(
+ self,
+ &caller,
+ TokenId(token_id),
+ key,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)
}
/// @notice Delete token properties value.
/// @dev Throws error if `msg.sender` has no permission to edit the property.
/// @param tokenId ID of the token.
/// @param keys Properties key.
- #[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]
+ #[weight(<CommonWeights<T>>::delete_token_properties(keys.len() as u32))]
fn delete_properties(
&mut self,
token_id: U256,
@@ -259,16 +259,12 @@
.map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
.collect::<Result<Vec<_>>>()?;
- let nesting_budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
<Pallet<T>>::delete_token_properties(
self,
&caller,
TokenId(token_id),
keys.into_iter(),
- &nesting_budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)
}
@@ -497,15 +493,20 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &from)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -629,9 +630,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -653,7 +651,7 @@
users,
properties: CollectionPropertiesVec::default(),
},
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
@@ -665,7 +663,7 @@
/// @param tokenUri Token URI that would be stored in the NFT properties
/// @return uint256 The id of the newly minted token
#[solidity(rename_selector = "mintWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
fn mint_with_token_uri(
&mut self,
caller: Caller,
@@ -687,7 +685,7 @@
/// @param tokenId ID of the minted RFT
/// @param tokenUri Token URI that would be stored in the RFT properties
#[solidity(hide, rename_selector = "mintWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+ #[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
fn mint_with_token_uri_check_id(
&mut self,
caller: Caller,
@@ -704,9 +702,6 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
if <TokensMinted<T>>::get(self.id)
.checked_add(1)
@@ -736,7 +731,7 @@
self,
&caller,
CreateItemData::<T> { users, properties },
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
@@ -865,15 +860,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &caller)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -893,15 +892,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &caller)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -923,15 +926,20 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let token_id = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token_id, &from)?;
ensure_single_owner(self, token_id, balance)?;
- Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ Pallet::<T>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ token_id,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -948,15 +956,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &from)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -977,15 +989,19 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let token = token_id.try_into()?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let balance = balance(self, token, &from)?;
ensure_single_owner(self, token, balance)?;
- <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ token,
+ balance,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(())
}
@@ -1010,9 +1026,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let total_tokens = token_ids.len();
for id in token_ids.into_iter() {
@@ -1035,31 +1048,32 @@
.map(|_| create_item_data.clone())
.collect();
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
/// @notice Function to mint a token.
- /// @param tokenProperties Properties of minted token
- #[weight(if token_properties.len() == 1 {
- <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_properties.iter().next().unwrap().owners.len() as u32)
+ /// @param tokensData Data of minted token(s)
+ #[weight(if tokens_data.len() == 1 {
+ let token_data = tokens_data.first().unwrap();
+
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_data.owners.len() as u32),
+ [token_data.properties.len() as u32].into_iter(),
+ )
} else {
- <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(token_properties.len() as u32)
- } + <SelfWeightOf<T>>::set_token_properties(token_properties.len() as u32))]
- fn mint_bulk_cross(
- &mut self,
- caller: Caller,
- token_properties: Vec<MintTokenData>,
- ) -> Result<bool> {
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(tokens_data.len() as u32),
+ tokens_data.iter().map(|d| d.properties.len() as u32),
+ )
+ })]
+ fn mint_bulk_cross(&mut self, caller: Caller, tokens_data: Vec<MintTokenData>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- let has_multiple_tokens = token_properties.len() > 1;
+ let has_multiple_tokens = tokens_data.len() > 1;
- let mut create_rft_data = Vec::with_capacity(token_properties.len());
- for MintTokenData { owners, properties } in token_properties {
+ let mut create_rft_data = Vec::with_capacity(tokens_data.len());
+ for MintTokenData { owners, properties } in tokens_data {
let has_multiple_owners = owners.len() > 1;
if has_multiple_tokens & has_multiple_owners {
return Err(
@@ -1084,8 +1098,13 @@
});
}
- <Pallet<T>>::create_multiple_items(self, &caller, create_rft_data, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::create_multiple_items(
+ self,
+ &caller,
+ create_rft_data,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1095,7 +1114,12 @@
/// @param to The new owner
/// @param tokens array of pairs of token ID and token URI for minted tokens
#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]
- #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]
+ #[weight(
+ mint_with_props_weight::<T>(
+ <SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32),
+ tokens.iter().map(|_| 1),
+ )
+ )]
fn mint_bulk_with_token_uri(
&mut self,
caller: Caller,
@@ -1108,9 +1132,6 @@
let mut expected_index = <TokensMinted<T>>::get(self.id)
.checked_add(1)
.ok_or("item id overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
let mut data = Vec::with_capacity(tokens.len());
let users: BoundedBTreeMap<_, _, _> = [(to, 1)]
@@ -1143,7 +1164,7 @@
data.push(create_item_data);
}
- <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)
+ <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
.map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -1152,7 +1173,7 @@
/// @param to The new owner crossAccountId
/// @param properties Properties of minted token
/// @return uint256 The id of the newly minted token
- #[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+ #[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [properties.len() as u32].into_iter()))]
fn mint_cross(
&mut self,
caller: Caller,
@@ -1174,10 +1195,6 @@
let caller = T::CrossAccountId::from_eth(caller);
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
-
let users = [(to, 1)]
.into_iter()
.collect::<BTreeMap<_, _>>()
@@ -1187,7 +1204,7 @@
self,
&caller,
CreateItemData::<T> { users, properties },
- &budget,
+ &nesting_budget(&self.recorder),
)
.map_err(dispatch_to_evm::<T>)?;
pallets/refungible/src/erc_token.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc_token.rs
+++ b/pallets/refungible/src/erc_token.rs
@@ -37,14 +37,13 @@
execution::{PreDispatch, Result},
frontier_contract, WithRecorder,
};
-use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
use sp_core::U256;
use sp_std::vec::Vec;
use up_data_structs::TokenId;
use crate::{
- common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, Pallet,
- RefungibleHandle, SelfWeightOf, TotalSupply,
+ common::CommonWeights, erc::nesting_budget, weights::WeightInfo, Allowance, Balance, Config,
+ Pallet, RefungibleHandle, SelfWeightOf, TotalSupply,
};
/// Refungible token handle contains information about token's collection and id
@@ -140,12 +139,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -165,12 +168,17 @@
let from = T::CrossAccountId::from_eth(from);
let to = T::CrossAccountId::from_eth(to);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -231,12 +239,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = T::CrossAccountId::from_eth(from);
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -254,12 +266,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let from = from.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::burn_from(self, &caller, &from, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::burn_from(
+ self,
+ &caller,
+ &from,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -315,12 +331,16 @@
let caller = T::CrossAccountId::from_eth(caller);
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer(
+ self,
+ &caller,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
@@ -340,12 +360,17 @@
let from = from.into_sub_cross_account::<T>()?;
let to = to.into_sub_cross_account::<T>()?;
let amount = amount.try_into().map_err(|_| "amount overflow")?;
- let budget = self
- .recorder
- .weight_calls_budget(<StructureWeight<T>>::find_parent());
- <Pallet<T>>::transfer_from(self, &caller, &from, &to, self.1, amount, &budget)
- .map_err(dispatch_to_evm::<T>)?;
+ <Pallet<T>>::transfer_from(
+ self,
+ &caller,
+ &from,
+ &to,
+ self.1,
+ amount,
+ &nesting_budget(&self.recorder),
+ )
+ .map_err(dispatch_to_evm::<T>)?;
Ok(true)
}
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -507,7 +507,7 @@
nesting_budget: &dyn Budget,
) -> DispatchResult {
let mut property_writer =
- pallet_common::property_writer_for_existing_token(collection, sender);
+ pallet_common::ExistingTokenPropertyWriter::new(collection, sender);
property_writer.write_token_properties(
sender,
@@ -858,7 +858,7 @@
// =========
- let mut property_writer = pallet_common::property_writer_for_new_token(collection, sender);
+ let mut property_writer = pallet_common::NewTokenPropertyWriter::new(collection, sender);
with_transaction(|| {
for (i, data) in data.iter().enumerate() {
pallets/refungible/src/weights.rsdiffbeforeafterboth--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -3,13 +3,13 @@
//! Autogenerated weights for pallet_refungible
//!
//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
-//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`
+//! DATE: 2023-10-13, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
//! WORST CASE MAP SIZE: `1000000`
-//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`
-//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
+//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
+//! EXECUTION: , WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
// Executed Command:
-// target/production/unique-collator
+// ./target/production/unique-collator
// benchmark
// pallet
// --pallet
@@ -20,7 +20,7 @@
// *
// --template=.maintain/frame-weight-template.hbs
// --steps=50
-// --repeat=400
+// --repeat=80
// --heap-pages=4096
// --output=./pallets/refungible/src/weights.rs
@@ -50,12 +50,10 @@
fn transfer_from_removing() -> Weight;
fn transfer_from_creating_removing() -> Weight;
fn burn_from() -> Weight;
+ fn load_token_properties() -> Weight;
+ fn write_token_properties(b: u32, ) -> Weight;
fn set_token_property_permissions(b: u32, ) -> Weight;
- fn set_token_properties(b: u32, ) -> Weight;
- fn init_token_properties(b: u32, ) -> Weight;
- fn delete_token_properties(b: u32, ) -> Weight;
fn repartition_item() -> Weight;
- fn token_owner() -> Weight;
fn set_allowance_for_all() -> Weight;
fn allowance_for_all() -> Weight;
fn repair_item() -> Weight;
@@ -64,435 +62,399 @@
/// Weights for pallet_refungible using the Substrate node and recommended hardware.
pub struct SubstrateWeight<T>(PhantomData<T>);
impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn create_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 11_341_000 picoseconds.
- Weight::from_parts(11_741_000, 3530)
+ // Minimum execution time: 19_400_000 picoseconds.
+ Weight::from_parts(19_890_000, 3530)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:200)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:200)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:200)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:200)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:200)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:200)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 2_665_000 picoseconds.
- Weight::from_parts(2_791_000, 3530)
- // Standard Error: 996
- .saturating_add(Weight::from_parts(4_343_736, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_120_000 picoseconds.
+ Weight::from_parts(3_310_000, 3530)
+ // Standard Error: 2_748
+ .saturating_add(Weight::from_parts(11_489_631, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))
}
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:200 w:200)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:200)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:200)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:200)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:200 w:200)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:200)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:200)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:200)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 2_616_000 picoseconds.
- Weight::from_parts(2_726_000, 3481)
- // Standard Error: 665
- .saturating_add(Weight::from_parts(5_554_066, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_180_000 picoseconds.
+ Weight::from_parts(2_015_490, 3481)
+ // Standard Error: 6_052
+ .saturating_add(Weight::from_parts(14_837_077, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(1_u64))
.saturating_add(T::DbWeight::get().writes((4_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))
}
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:200 w:200)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:200)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:200)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:200 w:200)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:200)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:200)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 3_697_000 picoseconds.
- Weight::from_parts(2_136_481, 3481)
- // Standard Error: 567
- .saturating_add(Weight::from_parts(4_390_621, 0).saturating_mul(b.into()))
+ // Minimum execution time: 5_200_000 picoseconds.
+ Weight::from_parts(25_301_631, 3481)
+ // Standard Error: 6_177
+ .saturating_add(Weight::from_parts(11_197_931, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(T::DbWeight::get().writes(2_u64))
.saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))
}
- /// Storage: Refungible Balance (r:3 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:3 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn burn_item_partial() -> Weight {
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `8682`
- // Minimum execution time: 22_859_000 picoseconds.
- Weight::from_parts(23_295_000, 8682)
+ // Minimum execution time: 29_540_000 picoseconds.
+ Weight::from_parts(30_190_000, 8682)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
- /// Storage: Refungible Balance (r:1 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TokensBurnt (r:1 w:1)
- /// Proof: Refungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:0 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:1 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Refungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_item_fully() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `3554`
- // Minimum execution time: 21_477_000 picoseconds.
- Weight::from_parts(22_037_000, 3554)
+ // Minimum execution time: 30_650_000 picoseconds.
+ Weight::from_parts(31_370_000, 3554)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
fn transfer_normal() -> Weight {
// Proof Size summary in bytes:
// Measured: `365`
// Estimated: `6118`
- // Minimum execution time: 13_714_000 picoseconds.
- Weight::from_parts(14_050_000, 6118)
+ // Minimum execution time: 18_530_000 picoseconds.
+ Weight::from_parts(19_010_000, 6118)
.saturating_add(T::DbWeight::get().reads(3_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 15_879_000 picoseconds.
- Weight::from_parts(16_266_000, 6118)
+ // Minimum execution time: 24_240_000 picoseconds.
+ Weight::from_parts(24_760_000, 6118)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `6118`
- // Minimum execution time: 18_186_000 picoseconds.
- Weight::from_parts(18_682_000, 6118)
+ // Minimum execution time: 25_990_000 picoseconds.
+ Weight::from_parts(26_650_000, 6118)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(4_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:2 w:2)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:2)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:2 w:2)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:2)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_creating_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 17_943_000 picoseconds.
- Weight::from_parts(18_333_000, 6118)
+ // Minimum execution time: 29_550_000 picoseconds.
+ Weight::from_parts(30_530_000, 6118)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(6_u64))
}
- /// Storage: Refungible Balance (r:1 w:0)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible Allowance (r:0 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:1 w:0)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Allowance` (r:0 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
fn approve() -> Weight {
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `3554`
- // Minimum execution time: 8_391_000 picoseconds.
- Weight::from_parts(8_637_000, 3554)
+ // Minimum execution time: 11_420_000 picoseconds.
+ Weight::from_parts(11_810_000, 3554)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Refungible Balance (r:1 w:0)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible Allowance (r:0 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:1 w:0)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Allowance` (r:0 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
fn approve_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `211`
// Estimated: `3554`
- // Minimum execution time: 8_519_000 picoseconds.
- Weight::from_parts(8_760_000, 3554)
+ // Minimum execution time: 11_610_000 picoseconds.
+ Weight::from_parts(11_950_000, 3554)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
fn transfer_from_normal() -> Weight {
// Proof Size summary in bytes:
// Measured: `495`
// Estimated: `6118`
- // Minimum execution time: 19_554_000 picoseconds.
- Weight::from_parts(20_031_000, 6118)
+ // Minimum execution time: 28_510_000 picoseconds.
+ Weight::from_parts(29_180_000, 6118)
.saturating_add(T::DbWeight::get().reads(4_u64))
.saturating_add(T::DbWeight::get().writes(3_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_from_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 21_338_000 picoseconds.
- Weight::from_parts(21_803_000, 6118)
+ // Minimum execution time: 34_370_000 picoseconds.
+ Weight::from_parts(35_270_000, 6118)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_from_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `586`
// Estimated: `6118`
- // Minimum execution time: 24_179_000 picoseconds.
- Weight::from_parts(24_647_000, 6118)
+ // Minimum execution time: 36_490_000 picoseconds.
+ Weight::from_parts(37_160_000, 6118)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(5_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:2 w:2)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:2)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:2 w:2)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:2)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_from_creating_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 24_008_000 picoseconds.
- Weight::from_parts(24_545_000, 6118)
+ // Minimum execution time: 40_080_000 picoseconds.
+ Weight::from_parts(48_310_000, 6118)
.saturating_add(T::DbWeight::get().reads(6_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:1 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TokensBurnt (r:1 w:1)
- /// Proof: Refungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:0 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:1 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Refungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `3570`
- // Minimum execution time: 27_907_000 picoseconds.
- Weight::from_parts(28_489_000, 3570)
+ // Minimum execution time: 41_100_000 picoseconds.
+ Weight::from_parts(42_060_000, 3570)
.saturating_add(T::DbWeight::get().reads(5_u64))
.saturating_add(T::DbWeight::get().writes(7_u64))
- }
- /// Storage: Common CollectionPropertyPermissions (r:1 w:1)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_property_permissions(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `314`
- // Estimated: `20191`
- // Minimum execution time: 1_460_000 picoseconds.
- Weight::from_parts(1_564_000, 20191)
- // Standard Error: 14_117
- .saturating_add(Weight::from_parts(8_196_214, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(1_u64))
- .saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:1 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_properties(b: u32, ) -> Weight {
+ /// Storage: `Refungible::TokenProperties` (r:1 w:0)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
+ fn load_token_properties() -> Weight {
// Proof Size summary in bytes:
- // Measured: `502 + b * (261 ±0)`
+ // Measured: `120`
// Estimated: `36269`
- // Minimum execution time: 1_012_000 picoseconds.
- Weight::from_parts(1_081_000, 36269)
- // Standard Error: 6_838
- .saturating_add(Weight::from_parts(5_801_181, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(3_u64))
- .saturating_add(T::DbWeight::get().writes(1_u64))
+ // Minimum execution time: 2_520_000 picoseconds.
+ Weight::from_parts(2_670_000, 36269)
+ .saturating_add(T::DbWeight::get().reads(1_u64))
}
- /// Storage: Refungible TokenProperties (r:0 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn init_token_properties(b: u32, ) -> Weight {
+ fn write_token_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 229_000 picoseconds.
- Weight::from_parts(253_000, 0)
- // Standard Error: 100_218
- .saturating_add(Weight::from_parts(12_632_221, 0).saturating_mul(b.into()))
+ // Minimum execution time: 490_000 picoseconds.
+ Weight::from_parts(3_457_547, 0)
+ // Standard Error: 24_239
+ .saturating_add(Weight::from_parts(19_382_722, 0).saturating_mul(b.into()))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:1 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Common::CollectionPropertyPermissions` (r:1 w:1)
+ /// Proof: `Common::CollectionPropertyPermissions` (`max_values`: None, `max_size`: Some(16726), added: 19201, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn delete_token_properties(b: u32, ) -> Weight {
+ fn set_token_property_permissions(b: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `561 + b * (33291 ±0)`
- // Estimated: `36269`
- // Minimum execution time: 1_014_000 picoseconds.
- Weight::from_parts(1_065_000, 36269)
- // Standard Error: 39_536
- .saturating_add(Weight::from_parts(24_125_838, 0).saturating_mul(b.into()))
- .saturating_add(T::DbWeight::get().reads(3_u64))
+ // Measured: `314`
+ // Estimated: `20191`
+ // Minimum execution time: 1_500_000 picoseconds.
+ Weight::from_parts(1_590_000, 20191)
+ // Standard Error: 123_927
+ .saturating_add(Weight::from_parts(27_355_093, 0).saturating_mul(b.into()))
+ .saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:1 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:1 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
fn repartition_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `288`
// Estimated: `3554`
- // Minimum execution time: 10_315_000 picoseconds.
- Weight::from_parts(10_601_000, 3554)
+ // Minimum execution time: 14_340_000 picoseconds.
+ Weight::from_parts(14_590_000, 3554)
.saturating_add(T::DbWeight::get().reads(2_u64))
.saturating_add(T::DbWeight::get().writes(2_u64))
- }
- /// Storage: Refungible Balance (r:2 w:0)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- fn token_owner() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `288`
- // Estimated: `6118`
- // Minimum execution time: 4_898_000 picoseconds.
- Weight::from_parts(5_136_000, 6118)
- .saturating_add(T::DbWeight::get().reads(2_u64))
}
- /// Storage: Refungible CollectionAllowance (r:0 w:1)
- /// Proof: Refungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Refungible::CollectionAllowance` (r:0 w:1)
+ /// Proof: `Refungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn set_allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 4_146_000 picoseconds.
- Weight::from_parts(4_337_000, 0)
+ // Minimum execution time: 6_390_000 picoseconds.
+ Weight::from_parts(6_650_000, 0)
.saturating_add(T::DbWeight::get().writes(1_u64))
}
- /// Storage: Refungible CollectionAllowance (r:1 w:0)
- /// Proof: Refungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Refungible::CollectionAllowance` (r:1 w:0)
+ /// Proof: `Refungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3576`
- // Minimum execution time: 2_170_000 picoseconds.
- Weight::from_parts(2_301_000, 3576)
+ // Minimum execution time: 3_060_000 picoseconds.
+ Weight::from_parts(3_210_000, 3576)
.saturating_add(T::DbWeight::get().reads(1_u64))
}
- /// Storage: Refungible TokenProperties (r:1 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokenProperties` (r:1 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn repair_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `120`
// Estimated: `36269`
- // Minimum execution time: 2_098_000 picoseconds.
- Weight::from_parts(2_251_000, 36269)
+ // Minimum execution time: 2_480_000 picoseconds.
+ Weight::from_parts(2_620_000, 36269)
.saturating_add(T::DbWeight::get().reads(1_u64))
.saturating_add(T::DbWeight::get().writes(1_u64))
}
@@ -500,435 +462,399 @@
// For backwards compatibility and tests
impl WeightInfo for () {
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn create_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 11_341_000 picoseconds.
- Weight::from_parts(11_741_000, 3530)
+ // Minimum execution time: 19_400_000 picoseconds.
+ Weight::from_parts(19_890_000, 3530)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:200)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:200)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:200)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:200)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:200)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:200)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3530`
- // Minimum execution time: 2_665_000 picoseconds.
- Weight::from_parts(2_791_000, 3530)
- // Standard Error: 996
- .saturating_add(Weight::from_parts(4_343_736, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_120_000 picoseconds.
+ Weight::from_parts(3_310_000, 3530)
+ // Standard Error: 2_748
+ .saturating_add(Weight::from_parts(11_489_631, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))
}
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:200 w:200)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:200)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:200)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:200)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:200 w:200)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:200)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:200)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:200)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items_ex_multiple_items(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 2_616_000 picoseconds.
- Weight::from_parts(2_726_000, 3481)
- // Standard Error: 665
- .saturating_add(Weight::from_parts(5_554_066, 0).saturating_mul(b.into()))
+ // Minimum execution time: 3_180_000 picoseconds.
+ Weight::from_parts(2_015_490, 3481)
+ // Standard Error: 6_052
+ .saturating_add(Weight::from_parts(14_837_077, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(1_u64))
.saturating_add(RocksDbWeight::get().writes((4_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))
}
- /// Storage: Refungible TokensMinted (r:1 w:1)
- /// Proof: Refungible TokensMinted (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:200 w:200)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:0 w:200)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:0 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:200)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokensMinted` (r:1 w:1)
+ /// Proof: `Refungible::TokensMinted` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:200 w:200)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:0 w:200)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:0 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:200)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 200]`.
fn create_multiple_items_ex_multiple_owners(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3481 + b * (2540 ±0)`
- // Minimum execution time: 3_697_000 picoseconds.
- Weight::from_parts(2_136_481, 3481)
- // Standard Error: 567
- .saturating_add(Weight::from_parts(4_390_621, 0).saturating_mul(b.into()))
+ // Minimum execution time: 5_200_000 picoseconds.
+ Weight::from_parts(25_301_631, 3481)
+ // Standard Error: 6_177
+ .saturating_add(Weight::from_parts(11_197_931, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
.saturating_add(RocksDbWeight::get().writes(2_u64))
.saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))
.saturating_add(Weight::from_parts(0, 2540).saturating_mul(b.into()))
}
- /// Storage: Refungible Balance (r:3 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:3 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn burn_item_partial() -> Weight {
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `8682`
- // Minimum execution time: 22_859_000 picoseconds.
- Weight::from_parts(23_295_000, 8682)
+ // Minimum execution time: 29_540_000 picoseconds.
+ Weight::from_parts(30_190_000, 8682)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
- /// Storage: Refungible Balance (r:1 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TokensBurnt (r:1 w:1)
- /// Proof: Refungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:0 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:1 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Refungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_item_fully() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `3554`
- // Minimum execution time: 21_477_000 picoseconds.
- Weight::from_parts(22_037_000, 3554)
+ // Minimum execution time: 30_650_000 picoseconds.
+ Weight::from_parts(31_370_000, 3554)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
fn transfer_normal() -> Weight {
// Proof Size summary in bytes:
// Measured: `365`
// Estimated: `6118`
- // Minimum execution time: 13_714_000 picoseconds.
- Weight::from_parts(14_050_000, 6118)
+ // Minimum execution time: 18_530_000 picoseconds.
+ Weight::from_parts(19_010_000, 6118)
.saturating_add(RocksDbWeight::get().reads(3_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 15_879_000 picoseconds.
- Weight::from_parts(16_266_000, 6118)
+ // Minimum execution time: 24_240_000 picoseconds.
+ Weight::from_parts(24_760_000, 6118)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `456`
// Estimated: `6118`
- // Minimum execution time: 18_186_000 picoseconds.
- Weight::from_parts(18_682_000, 6118)
+ // Minimum execution time: 25_990_000 picoseconds.
+ Weight::from_parts(26_650_000, 6118)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(4_u64))
}
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:2 w:2)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:2)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:2 w:2)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:2)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_creating_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `341`
// Estimated: `6118`
- // Minimum execution time: 17_943_000 picoseconds.
- Weight::from_parts(18_333_000, 6118)
+ // Minimum execution time: 29_550_000 picoseconds.
+ Weight::from_parts(30_530_000, 6118)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(6_u64))
}
- /// Storage: Refungible Balance (r:1 w:0)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible Allowance (r:0 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:1 w:0)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Allowance` (r:0 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
fn approve() -> Weight {
// Proof Size summary in bytes:
// Measured: `223`
// Estimated: `3554`
- // Minimum execution time: 8_391_000 picoseconds.
- Weight::from_parts(8_637_000, 3554)
+ // Minimum execution time: 11_420_000 picoseconds.
+ Weight::from_parts(11_810_000, 3554)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Refungible Balance (r:1 w:0)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible Allowance (r:0 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Balance` (r:1 w:0)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Allowance` (r:0 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
fn approve_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `211`
// Estimated: `3554`
- // Minimum execution time: 8_519_000 picoseconds.
- Weight::from_parts(8_760_000, 3554)
+ // Minimum execution time: 11_610_000 picoseconds.
+ Weight::from_parts(11_950_000, 3554)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
fn transfer_from_normal() -> Weight {
// Proof Size summary in bytes:
// Measured: `495`
// Estimated: `6118`
- // Minimum execution time: 19_554_000 picoseconds.
- Weight::from_parts(20_031_000, 6118)
+ // Minimum execution time: 28_510_000 picoseconds.
+ Weight::from_parts(29_180_000, 6118)
.saturating_add(RocksDbWeight::get().reads(4_u64))
.saturating_add(RocksDbWeight::get().writes(3_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_from_creating() -> Weight {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 21_338_000 picoseconds.
- Weight::from_parts(21_803_000, 6118)
+ // Minimum execution time: 34_370_000 picoseconds.
+ Weight::from_parts(35_270_000, 6118)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_from_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `586`
// Estimated: `6118`
- // Minimum execution time: 24_179_000 picoseconds.
- Weight::from_parts(24_647_000, 6118)
+ // Minimum execution time: 36_490_000 picoseconds.
+ Weight::from_parts(37_160_000, 6118)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(5_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:2 w:2)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:2 w:2)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:2)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:2 w:2)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:2 w:2)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:0)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:2)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
fn transfer_from_creating_removing() -> Weight {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `6118`
- // Minimum execution time: 24_008_000 picoseconds.
- Weight::from_parts(24_545_000, 6118)
+ // Minimum execution time: 40_080_000 picoseconds.
+ Weight::from_parts(48_310_000, 6118)
.saturating_add(RocksDbWeight::get().reads(6_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
- /// Storage: Refungible Allowance (r:1 w:1)
- /// Proof: Refungible Allowance (max_values: None, max_size: Some(105), added: 2580, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:1 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible AccountBalance (r:1 w:1)
- /// Proof: Refungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
- /// Storage: Refungible TokensBurnt (r:1 w:1)
- /// Proof: Refungible TokensBurnt (max_values: None, max_size: Some(16), added: 2491, mode: MaxEncodedLen)
- /// Storage: Refungible Owned (r:0 w:1)
- /// Proof: Refungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:0 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::Allowance` (r:1 w:1)
+ /// Proof: `Refungible::Allowance` (`max_values`: None, `max_size`: Some(105), added: 2580, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:1 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::AccountBalance` (r:1 w:1)
+ /// Proof: `Refungible::AccountBalance` (`max_values`: None, `max_size`: Some(65), added: 2540, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokensBurnt` (r:1 w:1)
+ /// Proof: `Refungible::TokensBurnt` (`max_values`: None, `max_size`: Some(16), added: 2491, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Owned` (r:0 w:1)
+ /// Proof: `Refungible::Owned` (`max_values`: None, `max_size`: Some(74), added: 2549, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn burn_from() -> Weight {
// Proof Size summary in bytes:
// Measured: `471`
// Estimated: `3570`
- // Minimum execution time: 27_907_000 picoseconds.
- Weight::from_parts(28_489_000, 3570)
+ // Minimum execution time: 41_100_000 picoseconds.
+ Weight::from_parts(42_060_000, 3570)
.saturating_add(RocksDbWeight::get().reads(5_u64))
.saturating_add(RocksDbWeight::get().writes(7_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:1)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_property_permissions(b: u32, ) -> Weight {
+ /// Storage: `Refungible::TokenProperties` (r:1 w:0)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
+ fn load_token_properties() -> Weight {
// Proof Size summary in bytes:
- // Measured: `314`
- // Estimated: `20191`
- // Minimum execution time: 1_460_000 picoseconds.
- Weight::from_parts(1_564_000, 20191)
- // Standard Error: 14_117
- .saturating_add(Weight::from_parts(8_196_214, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(1_u64))
- .saturating_add(RocksDbWeight::get().writes(1_u64))
- }
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:1 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// The range of component `b` is `[0, 64]`.
- fn set_token_properties(b: u32, ) -> Weight {
- // Proof Size summary in bytes:
- // Measured: `502 + b * (261 ±0)`
+ // Measured: `120`
// Estimated: `36269`
- // Minimum execution time: 1_012_000 picoseconds.
- Weight::from_parts(1_081_000, 36269)
- // Standard Error: 6_838
- .saturating_add(Weight::from_parts(5_801_181, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(3_u64))
- .saturating_add(RocksDbWeight::get().writes(1_u64))
+ // Minimum execution time: 2_520_000 picoseconds.
+ Weight::from_parts(2_670_000, 36269)
+ .saturating_add(RocksDbWeight::get().reads(1_u64))
}
- /// Storage: Refungible TokenProperties (r:0 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokenProperties` (r:0 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn init_token_properties(b: u32, ) -> Weight {
+ fn write_token_properties(b: u32, ) -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 229_000 picoseconds.
- Weight::from_parts(253_000, 0)
- // Standard Error: 100_218
- .saturating_add(Weight::from_parts(12_632_221, 0).saturating_mul(b.into()))
+ // Minimum execution time: 490_000 picoseconds.
+ Weight::from_parts(3_457_547, 0)
+ // Standard Error: 24_239
+ .saturating_add(Weight::from_parts(19_382_722, 0).saturating_mul(b.into()))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
- /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
- /// Storage: Refungible TotalSupply (r:1 w:0)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible TokenProperties (r:1 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Common::CollectionPropertyPermissions` (r:1 w:1)
+ /// Proof: `Common::CollectionPropertyPermissions` (`max_values`: None, `max_size`: Some(16726), added: 19201, mode: `MaxEncodedLen`)
/// The range of component `b` is `[0, 64]`.
- fn delete_token_properties(b: u32, ) -> Weight {
+ fn set_token_property_permissions(b: u32, ) -> Weight {
// Proof Size summary in bytes:
- // Measured: `561 + b * (33291 ±0)`
- // Estimated: `36269`
- // Minimum execution time: 1_014_000 picoseconds.
- Weight::from_parts(1_065_000, 36269)
- // Standard Error: 39_536
- .saturating_add(Weight::from_parts(24_125_838, 0).saturating_mul(b.into()))
- .saturating_add(RocksDbWeight::get().reads(3_u64))
+ // Measured: `314`
+ // Estimated: `20191`
+ // Minimum execution time: 1_500_000 picoseconds.
+ Weight::from_parts(1_590_000, 20191)
+ // Standard Error: 123_927
+ .saturating_add(Weight::from_parts(27_355_093, 0).saturating_mul(b.into()))
+ .saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Refungible TotalSupply (r:1 w:1)
- /// Proof: Refungible TotalSupply (max_values: None, max_size: Some(40), added: 2515, mode: MaxEncodedLen)
- /// Storage: Refungible Balance (r:1 w:1)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TotalSupply` (r:1 w:1)
+ /// Proof: `Refungible::TotalSupply` (`max_values`: None, `max_size`: Some(40), added: 2515, mode: `MaxEncodedLen`)
+ /// Storage: `Refungible::Balance` (r:1 w:1)
+ /// Proof: `Refungible::Balance` (`max_values`: None, `max_size`: Some(89), added: 2564, mode: `MaxEncodedLen`)
fn repartition_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `288`
// Estimated: `3554`
- // Minimum execution time: 10_315_000 picoseconds.
- Weight::from_parts(10_601_000, 3554)
+ // Minimum execution time: 14_340_000 picoseconds.
+ Weight::from_parts(14_590_000, 3554)
.saturating_add(RocksDbWeight::get().reads(2_u64))
.saturating_add(RocksDbWeight::get().writes(2_u64))
}
- /// Storage: Refungible Balance (r:2 w:0)
- /// Proof: Refungible Balance (max_values: None, max_size: Some(89), added: 2564, mode: MaxEncodedLen)
- fn token_owner() -> Weight {
- // Proof Size summary in bytes:
- // Measured: `288`
- // Estimated: `6118`
- // Minimum execution time: 4_898_000 picoseconds.
- Weight::from_parts(5_136_000, 6118)
- .saturating_add(RocksDbWeight::get().reads(2_u64))
- }
- /// Storage: Refungible CollectionAllowance (r:0 w:1)
- /// Proof: Refungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Refungible::CollectionAllowance` (r:0 w:1)
+ /// Proof: `Refungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn set_allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `0`
// Estimated: `0`
- // Minimum execution time: 4_146_000 picoseconds.
- Weight::from_parts(4_337_000, 0)
+ // Minimum execution time: 6_390_000 picoseconds.
+ Weight::from_parts(6_650_000, 0)
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
- /// Storage: Refungible CollectionAllowance (r:1 w:0)
- /// Proof: Refungible CollectionAllowance (max_values: None, max_size: Some(111), added: 2586, mode: MaxEncodedLen)
+ /// Storage: `Refungible::CollectionAllowance` (r:1 w:0)
+ /// Proof: `Refungible::CollectionAllowance` (`max_values`: None, `max_size`: Some(111), added: 2586, mode: `MaxEncodedLen`)
fn allowance_for_all() -> Weight {
// Proof Size summary in bytes:
// Measured: `4`
// Estimated: `3576`
- // Minimum execution time: 2_170_000 picoseconds.
- Weight::from_parts(2_301_000, 3576)
+ // Minimum execution time: 3_060_000 picoseconds.
+ Weight::from_parts(3_210_000, 3576)
.saturating_add(RocksDbWeight::get().reads(1_u64))
}
- /// Storage: Refungible TokenProperties (r:1 w:1)
- /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
+ /// Storage: `Refungible::TokenProperties` (r:1 w:1)
+ /// Proof: `Refungible::TokenProperties` (`max_values`: None, `max_size`: Some(32804), added: 35279, mode: `MaxEncodedLen`)
fn repair_item() -> Weight {
// Proof Size summary in bytes:
// Measured: `120`
// Estimated: `36269`
- // Minimum execution time: 2_098_000 picoseconds.
- Weight::from_parts(2_251_000, 36269)
+ // Minimum execution time: 2_480_000 picoseconds.
+ Weight::from_parts(2_620_000, 36269)
.saturating_add(RocksDbWeight::get().reads(1_u64))
.saturating_add(RocksDbWeight::get().writes(1_u64))
}
pallets/structure/src/lib.rsdiffbeforeafterboth--- a/pallets/structure/src/lib.rs
+++ b/pallets/structure/src/lib.rs
@@ -53,11 +53,7 @@
#![cfg_attr(not(feature = "std"), no_std)]
-use frame_support::{
- dispatch::{DispatchResult, DispatchResultWithPostInfo},
- fail,
- pallet_prelude::*,
-};
+use frame_support::{dispatch::DispatchResult, fail, pallet_prelude::*};
use pallet_common::{
dispatch::CollectionDispatch, erc::CrossAccountId, eth::is_collection,
CommonCollectionOperations,
@@ -267,22 +263,6 @@
}
Err(<Error<T>>::DepthLimit.into())
- }
-
- /// Burn token and all of it's nested tokens
- ///
- /// - `self_budget`: Limit for searching children in depth.
- /// - `breadth_budget`: Limit of breadth of searching children.
- pub fn burn_item_recursively(
- from: T::CrossAccountId,
- collection: CollectionId,
- token: TokenId,
- self_budget: &dyn Budget,
- breadth_budget: &dyn Budget,
- ) -> DispatchResultWithPostInfo {
- let dispatch = T::CollectionDispatch::dispatch(collection)?;
- let dispatch = dispatch.as_dyn();
- dispatch.burn_item_recursively(from, token, self_budget, breadth_budget)
}
/// Check if `token` indirectly owned by `user`
pallets/unique/Cargo.tomldiffbeforeafterboth--- a/pallets/unique/Cargo.toml
+++ b/pallets/unique/Cargo.toml
@@ -31,7 +31,9 @@
'parity-scale-codec/std',
'sp-runtime/std',
'sp-std/std',
+ 'up-common/std',
'up-data-structs/std',
+ 'pallet-structure/std',
]
stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
try-runtime = ["frame-support/try-runtime"]
@@ -53,9 +55,11 @@
pallet-evm-coder-substrate = { workspace = true }
pallet-nonfungible = { workspace = true }
pallet-refungible = { workspace = true }
+pallet-structure = { workspace = true }
scale-info = { workspace = true }
sp-core = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
+up-common = { workspace = true }
up-data-structs = { workspace = true }
pallets/unique/src/lib.rsdiffbeforeafterboth--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -84,13 +84,19 @@
#[frame_support::pallet]
pub mod pallet {
- use frame_support::{dispatch::DispatchResult, ensure, fail, storage::Key, BoundedVec};
+ use frame_support::{
+ dispatch::{DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo},
+ ensure, fail,
+ storage::Key,
+ BoundedVec,
+ };
use frame_system::{ensure_root, ensure_signed};
use pallet_common::{
dispatch::{dispatch_tx, CollectionDispatch},
CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,
};
use pallet_evm::account::CrossAccountId;
+ use pallet_structure::weights::WeightInfo as StructureWeightInfo;
use scale_info::TypeInfo;
use sp_std::{vec, vec::Vec};
use up_data_structs::{
@@ -104,9 +110,6 @@
use weights::WeightInfo;
use super::*;
-
- /// A maximum number of levels of depth in the token nesting tree.
- pub const NESTING_BUDGET: u32 = 5;
/// Errors for the common Unique transactions.
#[pallet::error]
@@ -128,6 +131,8 @@
/// Weight information for common pallet operations.
type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;
+ type StructureWeightInfo: StructureWeightInfo;
+
/// Weight info information for extra refungible pallet operations.
type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;
}
@@ -264,7 +269,7 @@
impl<T: Config> Pallet<T> {
/// A maximum number of levels of depth in the token nesting tree.
fn nesting_budget() -> u32 {
- NESTING_BUDGET
+ 5
}
/// Maximal length of a collection name.
@@ -666,7 +671,7 @@
/// * `owner`: Address of the initial owner of the item.
/// * `data`: Token data describing the item to store on chain.
#[pallet::call_index(11)]
- #[pallet::weight(T::CommonWeightInfo::create_item(data))]
+ #[pallet::weight(T::CommonWeightInfo::create_item(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn create_item(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -674,11 +679,14 @@
data: CreateItemData,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.create_item(sender, owner, data, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.create_item(sender, owner, data, &budget)
+ }),
+ budget,
+ )
}
/// Create multiple items within a collection.
@@ -700,7 +708,7 @@
/// * `owner`: Address of the initial owner of the tokens.
/// * `items_data`: Vector of data describing each item to be created.
#[pallet::call_index(12)]
- #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data))]
+ #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn create_multiple_items(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -709,11 +717,14 @@
) -> DispatchResultWithPostInfo {
ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.create_multiple_items(sender, owner, items_data, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.create_multiple_items(sender, owner, items_data, &budget)
+ }),
+ budget,
+ )
}
/// Add or change collection properties.
@@ -791,7 +802,7 @@
/// * `properties`: Vector of key-value pairs stored as the token's metadata.
/// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[pallet::call_index(15)]
- #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32))]
+ #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn set_token_properties(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -801,11 +812,14 @@
ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.set_token_properties(sender, token_id, properties, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.set_token_properties(sender, token_id, properties, &budget)
+ }),
+ budget,
+ )
}
/// Delete specified token properties. Currently properties only work with NFTs.
@@ -824,7 +838,7 @@
/// * `property_keys`: Vector of keys of the properties to be deleted.
/// Keys support Latin letters, `-`, `_`, and `.` as symbols.
#[pallet::call_index(16)]
- #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32))]
+ #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn delete_token_properties(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -834,11 +848,14 @@
ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.delete_token_properties(sender, token_id, property_keys, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.delete_token_properties(sender, token_id, property_keys, &budget)
+ }),
+ budget,
+ )
}
/// Add or change token property permissions of a collection.
@@ -888,18 +905,21 @@
/// * `collection_id`: ID of the collection to which the tokens would belong.
/// * `data`: Explicit item creation data.
#[pallet::call_index(18)]
- #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data))]
+ #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn create_multiple_items_ex(
origin: OriginFor<T>,
collection_id: CollectionId,
data: CreateItemExData<T::CrossAccountId>,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.create_multiple_items_ex(sender, data, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.create_multiple_items_ex(sender, data, &budget)
+ }),
+ budget,
+ )
}
/// Completely allow or disallow transfers for a particular collection.
@@ -995,7 +1015,7 @@
/// * Fungible Mode: The desired number of pieces to burn.
/// * Re-Fungible Mode: The desired number of pieces to burn.
#[pallet::call_index(21)]
- #[pallet::weight(T::CommonWeightInfo::burn_from())]
+ #[pallet::weight(T::CommonWeightInfo::burn_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn burn_from(
origin: OriginFor<T>,
collection_id: CollectionId,
@@ -1004,11 +1024,14 @@
value: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.burn_from(sender, from, item_id, value, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.burn_from(sender, from, item_id, value, &budget)
+ }),
+ budget,
+ )
}
/// Change ownership of the token.
@@ -1033,7 +1056,7 @@
/// * Fungible Mode: The desired number of pieces to transfer.
/// * Re-Fungible Mode: The desired number of pieces to transfer.
#[pallet::call_index(22)]
- #[pallet::weight(T::CommonWeightInfo::transfer())]
+ #[pallet::weight(T::CommonWeightInfo::transfer() + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn transfer(
origin: OriginFor<T>,
recipient: T::CrossAccountId,
@@ -1042,11 +1065,14 @@
value: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.transfer(sender, recipient, item_id, value, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.transfer(sender, recipient, item_id, value, &budget)
+ }),
+ budget,
+ )
}
/// Allow a non-permissioned address to transfer or burn an item.
@@ -1138,7 +1164,7 @@
/// * Fungible Mode: The desired number of pieces to transfer.
/// * Re-Fungible Mode: The desired number of pieces to transfer.
#[pallet::call_index(25)]
- #[pallet::weight(T::CommonWeightInfo::transfer_from())]
+ #[pallet::weight(T::CommonWeightInfo::transfer_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]
pub fn transfer_from(
origin: OriginFor<T>,
from: T::CrossAccountId,
@@ -1148,11 +1174,14 @@
value: u128,
) -> DispatchResultWithPostInfo {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
- let budget = budget::Value::new(NESTING_BUDGET);
+ let budget = Self::structure_nesting_budget();
- dispatch_tx::<T, _>(collection_id, |d| {
- d.transfer_from(sender, from, recipient, item_id, value, &budget)
- })
+ Self::refund_nesting_budget(
+ dispatch_tx::<T, _>(collection_id, |d| {
+ d.transfer_from(sender, from, recipient, item_id, value, &budget)
+ }),
+ budget,
+ )
}
/// Set specific limits of a collection. Empty, or None fields mean chain default.
@@ -1348,5 +1377,40 @@
Ok(())
}
+
+ fn structure_nesting_budget() -> budget::Value {
+ budget::Value::new(Self::nesting_budget())
+ }
+
+ fn nesting_budget_predispatch_weight() -> Weight {
+ T::StructureWeightInfo::find_parent().saturating_mul(Self::nesting_budget() as u64)
+ }
+
+ pub fn refund_nesting_budget(
+ mut result: DispatchResultWithPostInfo,
+ budget: budget::Value,
+ ) -> DispatchResultWithPostInfo {
+ let refund_amount = budget.refund_amount();
+ let consumed = Self::nesting_budget() - refund_amount;
+
+ match &mut result {
+ Ok(PostDispatchInfo {
+ actual_weight: Some(weight),
+ ..
+ })
+ | Err(DispatchErrorWithPostInfo {
+ post_info: PostDispatchInfo {
+ actual_weight: Some(weight),
+ ..
+ },
+ ..
+ }) => {
+ *weight += T::StructureWeightInfo::find_parent().saturating_mul(consumed as u64)
+ }
+ _ => {}
+ }
+
+ result
+ }
}
}
primitives/common/src/constants.rsdiffbeforeafterboth--- a/primitives/common/src/constants.rs
+++ b/primitives/common/src/constants.rs
@@ -45,6 +45,7 @@
/// Minimum balance required to create or keep an account open.
pub const EXISTENTIAL_DEPOSIT: u128 = 0;
+
/// Amount of Balance reserved for candidate registration.
pub const GENESIS_LICENSE_BOND: u128 = 1_000_000_000_000 * UNIQUE;
/// Amount of maximum collators for Collator Selection.
primitives/data-structs/src/budget.rsdiffbeforeafterboth--- a/primitives/data-structs/src/budget.rs
+++ b/primitives/data-structs/src/budget.rs
@@ -1,4 +1,4 @@
-use core::cell::Cell;
+use sp_std::cell::Cell;
pub trait Budget {
/// Returns true while not exceeded
@@ -22,7 +22,7 @@
pub fn new(v: u32) -> Self {
Self(Cell::new(v))
}
- pub fn refund(self) -> u32 {
+ pub fn refund_amount(self) -> u32 {
self.0.get()
}
}
runtime/common/config/pallets/mod.rsdiffbeforeafterboth--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -116,6 +116,7 @@
impl pallet_unique::Config for Runtime {
type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
type CommonWeightInfo = CommonWeights<Self>;
+ type StructureWeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
type RefungibleExtensionsWeightInfo = CommonWeights<Self>;
}
runtime/common/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/runtime_apis.rs
+++ b/runtime/common/runtime_apis.rs
@@ -84,7 +84,7 @@
}
fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
- let budget = up_data_structs::budget::Value::new(10);
+ let budget = budget::Value::new(10);
<pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)
}
runtime/common/weights/mod.rsdiffbeforeafterboth--- a/runtime/common/weights/mod.rs
+++ b/runtime/common/weights/mod.rs
@@ -98,10 +98,6 @@
dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
}
- fn delete_token_properties(amount: u32) -> Weight {
- dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
- }
-
fn set_token_property_permissions(amount: u32) -> Weight {
dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
}
@@ -124,26 +120,14 @@
fn burn_from() -> Weight {
dispatch_weight::<T>() + max_weight_of!(burn_from())
- }
-
- fn burn_recursively_self_raw() -> Weight {
- max_weight_of!(burn_recursively_self_raw())
- }
-
- fn burn_recursively_breadth_raw(amount: u32) -> Weight {
- max_weight_of!(burn_recursively_breadth_raw(amount))
- }
-
- fn token_owner() -> Weight {
- max_weight_of!(token_owner())
}
fn set_allowance_for_all() -> Weight {
- max_weight_of!(set_allowance_for_all())
+ dispatch_weight::<T>() + max_weight_of!(set_allowance_for_all())
}
fn force_repair_item() -> Weight {
- max_weight_of!(force_repair_item())
+ dispatch_weight::<T>() + max_weight_of!(force_repair_item())
}
}
runtime/tests/src/lib.rsdiffbeforeafterboth--- a/runtime/tests/src/lib.rs
+++ b/runtime/tests/src/lib.rs
@@ -292,6 +292,7 @@
type WeightInfo = ();
type CommonWeightInfo = CommonWeights<Self>;
type RefungibleExtensionsWeightInfo = CommonWeights<Self>;
+ type StructureWeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
}
// Build genesis storage according to the mock runtime.
runtime/tests/src/tests.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Tests to be written here18use frame_support::{assert_err, assert_noop, assert_ok};19use pallet_common::Error as CommonError;20use pallet_evm::account::CrossAccountId;21use pallet_unique::Error as UniqueError;22use sp_std::convert::TryInto;23use up_data_structs::{24 AccessMode, CollectionId, CollectionMode, CollectionPermissions,25 CollectionPropertiesPermissionsVec, CollectionPropertiesVec, CreateCollectionData,26 CreateFungibleData, CreateItemData, CreateNftData, CreateReFungibleData, Property,27 PropertyKeyPermission, PropertyPermission, TokenId, COLLECTION_ADMINS_LIMIT,28 COLLECTION_NUMBER_LIMIT, MAX_DECIMAL_POINTS, MAX_TOKEN_OWNERSHIP,29};3031use crate::{32 new_test_ext, CollectionCreationPrice, RuntimeOrigin, Test, TestCrossAccountId, Unique,33};3435fn add_balance(user: u64, value: u64) {36 const DONOR_USER: u64 = 999;37 assert_ok!(<pallet_balances::Pallet<Test>>::force_set_balance(38 RuntimeOrigin::root(),39 DONOR_USER,40 value,41 ));42 assert_ok!(<pallet_balances::Pallet<Test>>::force_transfer(43 RuntimeOrigin::root(),44 DONOR_USER,45 user,46 value47 ));48}4950fn default_nft_data() -> CreateNftData {51 CreateNftData {52 properties: vec![Property {53 key: b"test-prop".to_vec().try_into().unwrap(),54 value: b"test-nft-prop".to_vec().try_into().unwrap(),55 }]56 .try_into()57 .unwrap(),58 }59}6061fn default_fungible_data() -> CreateFungibleData {62 CreateFungibleData { value: 5 }63}6465fn default_re_fungible_data() -> CreateReFungibleData {66 CreateReFungibleData {67 pieces: 1023,68 properties: vec![Property {69 key: b"test-prop".to_vec().try_into().unwrap(),70 value: b"test-nft-prop".to_vec().try_into().unwrap(),71 }]72 .try_into()73 .unwrap(),74 }75}7677fn create_test_collection_for_owner(78 mode: &CollectionMode,79 owner: u64,80 id: CollectionId,81) -> CollectionId {82 add_balance(owner, CollectionCreationPrice::get() as u64 + 1);8384 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();85 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();86 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();87 let token_property_permissions: CollectionPropertiesPermissionsVec =88 vec![PropertyKeyPermission {89 key: b"test-prop".to_vec().try_into().unwrap(),90 permission: PropertyPermission {91 mutable: true,92 collection_admin: false,93 token_owner: true,94 },95 }]96 .try_into()97 .unwrap();98 let properties: CollectionPropertiesVec = vec![Property {99 key: b"test-collection-prop".to_vec().try_into().unwrap(),100 value: b"test-collection-value".to_vec().try_into().unwrap(),101 }]102 .try_into()103 .unwrap();104105 let data = CreateCollectionData {106 name: col_name1.try_into().unwrap(),107 description: col_desc1.try_into().unwrap(),108 token_prefix: token_prefix1.try_into().unwrap(),109 mode: mode.clone(),110 token_property_permissions: token_property_permissions.clone(),111 properties: properties.clone(),112 ..Default::default()113 };114115 let origin1 = RuntimeOrigin::signed(owner);116 assert_ok!(Unique::create_collection_ex(origin1, data));117118 let saved_col_name: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();119 let saved_description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();120 let saved_prefix: Vec<u8> = b"token_prefix1\0".to_vec();121 assert_eq!(122 <pallet_common::CollectionById<Test>>::get(id)123 .unwrap()124 .owner,125 owner126 );127 assert_eq!(128 <pallet_common::CollectionById<Test>>::get(id).unwrap().name,129 saved_col_name130 );131 assert_eq!(132 <pallet_common::CollectionById<Test>>::get(id).unwrap().mode,133 *mode134 );135 assert_eq!(136 <pallet_common::CollectionById<Test>>::get(id)137 .unwrap()138 .description,139 saved_description140 );141 assert_eq!(142 <pallet_common::CollectionById<Test>>::get(id)143 .unwrap()144 .token_prefix,145 saved_prefix146 );147 assert_eq!(148 get_collection_property_permissions(id).as_slice(),149 token_property_permissions.as_slice()150 );151 assert_eq!(152 get_collection_properties(id).as_slice(),153 properties.as_slice()154 );155 id156}157158fn get_collection_property_permissions(collection_id: CollectionId) -> Vec<PropertyKeyPermission> {159 <pallet_common::Pallet<Test>>::property_permissions(collection_id)160 .into_iter()161 .map(|(key, permission)| PropertyKeyPermission { key, permission })162 .collect()163}164165fn get_collection_properties(collection_id: CollectionId) -> Vec<Property> {166 <pallet_common::Pallet<Test>>::collection_properties(collection_id)167 .into_iter()168 .map(|(key, value)| Property { key, value })169 .collect()170}171172fn get_token_properties(collection_id: CollectionId, token_id: TokenId) -> Vec<Property> {173 <pallet_nonfungible::Pallet<Test>>::token_properties((collection_id, token_id))174 .unwrap_or_default()175 .into_iter()176 .map(|(key, value)| Property { key, value })177 .collect()178}179180fn create_test_collection(mode: &CollectionMode, id: CollectionId) -> CollectionId {181 create_test_collection_for_owner(&mode, 1, id)182}183184fn create_test_item(collection_id: CollectionId, data: &CreateItemData) {185 let origin1 = RuntimeOrigin::signed(1);186 assert_ok!(Unique::create_item(187 origin1,188 collection_id,189 account(1),190 data.clone()191 ));192}193194fn account(sub: u64) -> TestCrossAccountId {195 TestCrossAccountId::from_sub(sub)196}197198// Use cases tests region199// #region200201#[test]202fn check_not_sufficient_founds() {203 new_test_ext().execute_with(|| {204 let acc: u64 = 1;205 <pallet_balances::Pallet<Test>>::force_set_balance(RuntimeOrigin::root(), acc, 0).unwrap();206207 let name: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();208 let description: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();209 let token_prefix: Vec<u8> = b"token_prefix1\0".to_vec();210211 let data = CreateCollectionData {212 name: name.try_into().unwrap(),213 description: description.try_into().unwrap(),214 token_prefix: token_prefix.try_into().unwrap(),215 mode: CollectionMode::NFT,216 ..Default::default()217 };218219 let result = Unique::create_collection_ex(RuntimeOrigin::signed(acc), data);220 assert_err!(result, <CommonError<Test>>::NotSufficientFounds);221 });222}223224#[test]225fn create_fungible_collection_fails_with_large_decimal_numbers() {226 new_test_ext().execute_with(|| {227 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();228 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();229 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();230231 let data = CreateCollectionData {232 name: col_name1.try_into().unwrap(),233 description: col_desc1.try_into().unwrap(),234 token_prefix: token_prefix1.try_into().unwrap(),235 mode: CollectionMode::Fungible(MAX_DECIMAL_POINTS + 1),236 ..Default::default()237 };238239 let origin1 = RuntimeOrigin::signed(1);240 assert_noop!(241 Unique::create_collection_ex(origin1, data),242 UniqueError::<Test>::CollectionDecimalPointLimitExceeded243 );244 });245}246247#[test]248fn create_nft_item() {249 new_test_ext().execute_with(|| {250 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));251252 let data = default_nft_data();253 create_test_item(collection_id, &data.clone().into());254255 assert_eq!(256 get_token_properties(collection_id, TokenId(1)).as_slice(),257 data.properties.as_slice(),258 );259 });260}261262// Use cases tests region263// #region264#[test]265fn create_nft_multiple_items() {266 new_test_ext().execute_with(|| {267 create_test_collection(&CollectionMode::NFT, CollectionId(1));268269 let origin1 = RuntimeOrigin::signed(1);270271 let items_data = vec![default_nft_data(), default_nft_data(), default_nft_data()];272273 assert_ok!(Unique::create_multiple_items(274 origin1,275 CollectionId(1),276 account(1),277 items_data278 .clone()279 .into_iter()280 .map(|d| { d.into() })281 .collect()282 ));283 for (index, data) in items_data.into_iter().enumerate() {284 assert_eq!(285 get_token_properties(CollectionId(1), TokenId(index as u32 + 1)).as_slice(),286 data.properties.as_slice()287 );288 }289 });290}291292#[test]293fn create_refungible_item() {294 new_test_ext().execute_with(|| {295 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));296297 let data = default_re_fungible_data();298 create_test_item(collection_id, &data.clone().into());299 let balance =300 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1)));301 assert_eq!(balance, 1023);302 });303}304305#[test]306fn create_multiple_refungible_items() {307 new_test_ext().execute_with(|| {308 create_test_collection(&CollectionMode::ReFungible, CollectionId(1));309310 let origin1 = RuntimeOrigin::signed(1);311312 let items_data = vec![313 default_re_fungible_data(),314 default_re_fungible_data(),315 default_re_fungible_data(),316 ];317318 assert_ok!(Unique::create_multiple_items(319 origin1,320 CollectionId(1),321 account(1),322 items_data323 .clone()324 .into_iter()325 .map(|d| { d.into() })326 .collect()327 ));328 for (index, _data) in items_data.into_iter().enumerate() {329 let balance = <pallet_refungible::Balance<Test>>::get((330 CollectionId(1),331 TokenId((index + 1) as u32),332 account(1),333 ));334 assert_eq!(balance, 1023);335 }336 });337}338339#[test]340fn create_fungible_item() {341 new_test_ext().execute_with(|| {342 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));343344 let data = default_fungible_data();345 create_test_item(collection_id, &data.into());346347 assert_eq!(348 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),349 5350 );351 });352}353354//#[test]355// fn create_multiple_fungible_items() {356// new_test_ext().execute_with(|| {357// default_limits();358359// create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));360361// let origin1 = RuntimeOrigin::signed(1);362363// let items_data = vec![default_fungible_data(), default_fungible_data(), default_fungible_data()];364365// assert_ok!(Unique::create_multiple_items(366// origin1.clone(),367// 1,368// 1,369// items_data.clone().into_iter().map(|d| { d.into() }).collect()370// ));371372// for (index, _) in items_data.iter().enumerate() {373// assert_eq!(Unique::fungible_item_id(1, (index + 1) as TokenId).value, 5);374// }375// assert_eq!(Unique::balance_count(1, 1), 3000);376// assert_eq!(Unique::address_tokens(1, 1), [1, 2, 3]);377// });378// }379380#[test]381fn transfer_fungible_item() {382 new_test_ext().execute_with(|| {383 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));384385 let origin1 = RuntimeOrigin::signed(1);386 let origin2 = RuntimeOrigin::signed(2);387388 let data = default_fungible_data();389 create_test_item(collection_id, &data.into());390391 assert_eq!(392 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(1))),393 5394 );395396 // change owner scenario397 assert_ok!(Unique::transfer(398 origin1,399 account(2),400 CollectionId(1),401 TokenId(0),402 5403 ));404 assert_eq!(405 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(1))),406 0407 );408409 // split item scenario410 assert_ok!(Unique::transfer(411 origin2.clone(),412 account(3),413 CollectionId(1),414 TokenId(0),415 3416 ));417418 // split item and new owner has account scenario419 assert_ok!(Unique::transfer(420 origin2,421 account(3),422 CollectionId(1),423 TokenId(0),424 1425 ));426 assert_eq!(427 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(2))),428 1429 );430 assert_eq!(431 <pallet_fungible::Balance<Test>>::get((CollectionId(1), account(3))),432 4433 );434 });435}436437#[test]438fn transfer_refungible_item() {439 new_test_ext().execute_with(|| {440 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));441442 // Create RFT 1 in 1023 pieces for account 1443 let data = default_re_fungible_data();444 create_test_item(collection_id, &data.clone().into());445 assert_eq!(446 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),447 1448 );449 assert_eq!(450 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),451 1023452 );453 assert_eq!(454 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),455 true456 );457458 // Account 1 transfers all 1023 pieces of RFT 1 to account 2459 let origin1 = RuntimeOrigin::signed(1);460 let origin2 = RuntimeOrigin::signed(2);461 assert_ok!(Unique::transfer(462 origin1,463 account(2),464 CollectionId(1),465 TokenId(1),466 1023467 ));468 assert_eq!(469 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(2))),470 1023471 );472 assert_eq!(473 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),474 0475 );476 assert_eq!(477 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(2))),478 1479 );480 assert_eq!(481 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),482 false483 );484 assert_eq!(485 <pallet_refungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),486 true487 );488489 // Account 2 transfers 500 pieces of RFT 1 to account 3490 assert_ok!(Unique::transfer(491 origin2.clone(),492 account(3),493 CollectionId(1),494 TokenId(1),495 500496 ));497 assert_eq!(498 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(2))),499 523500 );501 assert_eq!(502 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(3))),503 500504 );505 assert_eq!(506 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(2))),507 1508 );509 assert_eq!(510 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(3))),511 1512 );513 assert_eq!(514 <pallet_refungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),515 true516 );517 assert_eq!(518 <pallet_refungible::Owned<Test>>::get((collection_id, account(3), TokenId(1))),519 true520 );521522 // Account 2 transfers 200 more pieces of RFT 1 to account 3 with pre-existing balance523 assert_ok!(Unique::transfer(524 origin2,525 account(3),526 CollectionId(1),527 TokenId(1),528 200529 ));530 assert_eq!(531 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(2))),532 323533 );534 assert_eq!(535 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(3))),536 700537 );538 assert_eq!(539 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(2))),540 1541 );542 assert_eq!(543 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(3))),544 1545 );546 assert_eq!(547 <pallet_refungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),548 true549 );550 assert_eq!(551 <pallet_refungible::Owned<Test>>::get((collection_id, account(3), TokenId(1))),552 true553 );554 });555}556557#[test]558fn transfer_nft_item() {559 new_test_ext().execute_with(|| {560 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));561562 let data = default_nft_data();563 create_test_item(collection_id, &data.into());564 assert_eq!(565 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),566 1567 );568 assert_eq!(569 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),570 true571 );572573 let origin1 = RuntimeOrigin::signed(1);574 // default scenario575 assert_ok!(Unique::transfer(576 origin1,577 account(2),578 CollectionId(1),579 TokenId(1),580 1581 ));582 assert_eq!(583 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),584 0585 );586 assert_eq!(587 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(2))),588 1589 );590 assert_eq!(591 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),592 false593 );594 assert_eq!(595 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),596 true597 );598 });599}600601#[test]602fn transfer_nft_item_wrong_value() {603 new_test_ext().execute_with(|| {604 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));605606 let data = default_nft_data();607 create_test_item(collection_id, &data.into());608 assert_eq!(609 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),610 1611 );612 assert_eq!(613 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),614 true615 );616617 let origin1 = RuntimeOrigin::signed(1);618619 assert_noop!(620 Unique::transfer(origin1, account(2), CollectionId(1), TokenId(1), 2)621 .map_err(|e| e.error),622 <pallet_nonfungible::Error::<Test>>::NonfungibleItemsHaveNoAmount623 );624 });625}626627#[test]628fn transfer_nft_item_zero_value() {629 new_test_ext().execute_with(|| {630 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));631632 let data = default_nft_data();633 create_test_item(collection_id, &data.into());634 assert_eq!(635 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),636 1637 );638 assert_eq!(639 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),640 true641 );642643 let origin1 = RuntimeOrigin::signed(1);644645 // Transferring 0 amount works on NFT...646 assert_ok!(Unique::transfer(647 origin1,648 account(2),649 CollectionId(1),650 TokenId(1),651 0652 ));653 // ... and results in no transfer654 assert_eq!(655 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),656 1657 );658 assert_eq!(659 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),660 true661 );662 });663}664665#[test]666fn nft_approve_and_transfer_from() {667 new_test_ext().execute_with(|| {668 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));669670 let data = default_nft_data();671 create_test_item(collection_id, &data.into());672673 let origin1 = RuntimeOrigin::signed(1);674 let origin2 = RuntimeOrigin::signed(2);675676 assert_eq!(677 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),678 1679 );680 assert_eq!(681 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),682 true683 );684685 // neg transfer_from686 assert_noop!(687 Unique::transfer_from(688 origin2.clone(),689 account(1),690 account(2),691 CollectionId(1),692 TokenId(1),693 1694 )695 .map_err(|e| e.error),696 CommonError::<Test>::ApprovedValueTooLow697 );698699 // do approve700 assert_ok!(Unique::approve(701 origin1,702 account(2),703 CollectionId(1),704 TokenId(1),705 1706 ));707 assert_eq!(708 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),709 account(2)710 );711712 assert_ok!(Unique::transfer_from(713 origin2,714 account(1),715 account(3),716 CollectionId(1),717 TokenId(1),718 1719 ));720 assert!(721 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).is_none()722 );723 });724}725726#[test]727fn nft_approve_and_transfer_from_allow_list() {728 new_test_ext().execute_with(|| {729 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));730731 let origin1 = RuntimeOrigin::signed(1);732 let origin2 = RuntimeOrigin::signed(2);733734 // Create NFT 1 for account 1735 let data = default_nft_data();736 create_test_item(collection_id, &data.clone().into());737 assert_eq!(738 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),739 1740 );741 assert_eq!(742 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),743 true744 );745746 // Allow allow-list users to mint and add accounts 1, 2, and 3 to allow-list747 assert_ok!(Unique::set_collection_permissions(748 origin1.clone(),749 CollectionId(1),750 CollectionPermissions {751 mint_mode: Some(true),752 access: Some(AccessMode::AllowList),753 nesting: None,754 }755 ));756 assert_ok!(Unique::add_to_allow_list(757 origin1.clone(),758 CollectionId(1),759 account(1)760 ));761 assert_ok!(Unique::add_to_allow_list(762 origin1.clone(),763 CollectionId(1),764 account(2)765 ));766 assert_ok!(Unique::add_to_allow_list(767 origin1.clone(),768 CollectionId(1),769 account(3)770 ));771772 // Account 1 approves account 2 for NFT 1773 assert_ok!(Unique::approve(774 origin1.clone(),775 account(2),776 CollectionId(1),777 TokenId(1),778 1779 ));780 assert_eq!(781 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),782 account(2)783 );784785 // Account 2 transfers NFT 1 from account 1 to account 3786 assert_ok!(Unique::transfer_from(787 origin2,788 account(1),789 account(3),790 CollectionId(1),791 TokenId(1),792 1793 ));794 assert!(795 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).is_none()796 );797 });798}799800#[test]801fn refungible_approve_and_transfer_from() {802 new_test_ext().execute_with(|| {803 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));804805 let origin1 = RuntimeOrigin::signed(1);806 let origin2 = RuntimeOrigin::signed(2);807808 // Create RFT 1 in 1023 pieces for account 1809 let data = default_re_fungible_data();810 create_test_item(collection_id, &data.into());811812 assert_eq!(813 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),814 1815 );816 assert_eq!(817 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),818 1023819 );820 assert_eq!(821 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),822 true823 );824825 // Allow public minting, enable allow-list and add accounts 1, 2, 3 to allow-list826 assert_ok!(Unique::set_collection_permissions(827 origin1.clone(),828 CollectionId(1),829 CollectionPermissions {830 mint_mode: Some(true),831 access: Some(AccessMode::AllowList),832 nesting: None,833 }834 ));835 assert_ok!(Unique::add_to_allow_list(836 origin1.clone(),837 CollectionId(1),838 account(1)839 ));840 assert_ok!(Unique::add_to_allow_list(841 origin1.clone(),842 CollectionId(1),843 account(2)844 ));845 assert_ok!(Unique::add_to_allow_list(846 origin1.clone(),847 CollectionId(1),848 account(3)849 ));850851 // Account 1 approves account 2 for 1023 pieces of RFT 1852 assert_ok!(Unique::approve(853 origin1,854 account(2),855 CollectionId(1),856 TokenId(1),857 1023858 ));859 assert_eq!(860 <pallet_refungible::Allowance<Test>>::get((861 CollectionId(1),862 TokenId(1),863 account(1),864 account(2)865 )),866 1023867 );868869 // Account 2 transfers 100 pieces of RFT 1 from account 1 to account 3870 assert_ok!(Unique::transfer_from(871 origin2,872 account(1),873 account(3),874 CollectionId(1),875 TokenId(1),876 100877 ));878 assert_eq!(879 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),880 1881 );882 assert_eq!(883 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(3))),884 1885 );886 assert_eq!(887 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),888 923889 );890 assert_eq!(891 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(3))),892 100893 );894 assert_eq!(895 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),896 true897 );898 assert_eq!(899 <pallet_refungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),900 true901 );902 assert_eq!(903 <pallet_refungible::Allowance<Test>>::get((904 CollectionId(1),905 TokenId(1),906 account(1),907 account(2)908 )),909 923910 );911 });912}913914#[test]915fn fungible_approve_and_transfer_from() {916 new_test_ext().execute_with(|| {917 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));918919 let data = default_fungible_data();920 create_test_item(collection_id, &data.into());921922 let origin1 = RuntimeOrigin::signed(1);923 let origin2 = RuntimeOrigin::signed(2);924925 assert_ok!(Unique::set_collection_permissions(926 origin1.clone(),927 CollectionId(1),928 CollectionPermissions {929 mint_mode: Some(true),930 access: Some(AccessMode::AllowList),931 nesting: None,932 }933 ));934 assert_ok!(Unique::add_to_allow_list(935 origin1.clone(),936 CollectionId(1),937 account(1)938 ));939 assert_ok!(Unique::add_to_allow_list(940 origin1.clone(),941 CollectionId(1),942 account(2)943 ));944 assert_ok!(Unique::add_to_allow_list(945 origin1.clone(),946 CollectionId(1),947 account(3)948 ));949950 // do approve951 assert_ok!(Unique::approve(952 origin1.clone(),953 account(2),954 CollectionId(1),955 TokenId(0),956 5957 ));958 assert_eq!(959 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(2))),960 5961 );962 assert_ok!(Unique::approve(963 origin1,964 account(3),965 CollectionId(1),966 TokenId(0),967 5968 ));969 assert_eq!(970 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(2))),971 5972 );973 assert_eq!(974 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(3))),975 5976 );977978 assert_ok!(Unique::transfer_from(979 origin2.clone(),980 account(1),981 account(3),982 CollectionId(1),983 TokenId(0),984 4985 ));986987 assert_eq!(988 <pallet_fungible::Allowance<Test>>::get((CollectionId(1), account(1), account(2))),989 1990 );991992 assert_noop!(993 Unique::transfer_from(994 origin2,995 account(1),996 account(3),997 CollectionId(1),998 TokenId(0),999 41000 )1001 .map_err(|e| e.error),1002 CommonError::<Test>::ApprovedValueTooLow1003 );1004 });1005}10061007#[test]1008fn change_collection_owner() {1009 new_test_ext().execute_with(|| {1010 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10111012 let origin1 = RuntimeOrigin::signed(1);1013 assert_ok!(Unique::change_collection_owner(origin1, collection_id, 2));1014 assert_eq!(1015 <pallet_common::CollectionById<Test>>::get(collection_id)1016 .unwrap()1017 .owner,1018 21019 );1020 });1021}10221023#[test]1024fn destroy_collection() {1025 new_test_ext().execute_with(|| {1026 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10271028 let origin1 = RuntimeOrigin::signed(1);1029 assert_ok!(Unique::destroy_collection(origin1, collection_id));1030 });1031}10321033#[test]1034fn burn_nft_item() {1035 new_test_ext().execute_with(|| {1036 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10371038 let origin1 = RuntimeOrigin::signed(1);10391040 let data = default_nft_data();1041 create_test_item(collection_id, &data.into());10421043 // check balance (collection with id = 1, user id = 1)1044 assert_eq!(1045 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1046 11047 );10481049 // burn item1050 assert_ok!(Unique::burn_item(1051 origin1.clone(),1052 collection_id,1053 TokenId(1),1054 11055 ));1056 assert_eq!(1057 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1058 01059 );1060 });1061}10621063#[test]1064fn burn_same_nft_item_twice() {1065 new_test_ext().execute_with(|| {1066 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));10671068 let origin1 = RuntimeOrigin::signed(1);10691070 let data = default_nft_data();1071 create_test_item(collection_id, &data.into());10721073 // check balance (collection with id = 1, user id = 1)1074 assert_eq!(1075 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1076 11077 );10781079 // burn item1080 assert_ok!(Unique::burn_item(1081 origin1.clone(),1082 collection_id,1083 TokenId(1),1084 11085 ));10861087 // burn item again1088 assert_noop!(1089 Unique::burn_item(origin1, collection_id, TokenId(1), 1).map_err(|e| e.error),1090 CommonError::<Test>::TokenNotFound1091 );10921093 assert_eq!(1094 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),1095 01096 );1097 });1098}10991100#[test]1101fn burn_fungible_item() {1102 new_test_ext().execute_with(|| {1103 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));11041105 let origin1 = RuntimeOrigin::signed(1);1106 assert_ok!(Unique::add_collection_admin(1107 origin1.clone(),1108 collection_id,1109 account(2)1110 ));11111112 let data = default_fungible_data();1113 create_test_item(collection_id, &data.into());11141115 // check balance (collection with id = 1, user id = 1)1116 assert_eq!(1117 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),1118 51119 );11201121 // burn item1122 assert_ok!(Unique::burn_item(1123 origin1.clone(),1124 CollectionId(1),1125 TokenId(0),1126 51127 ));1128 assert_noop!(1129 Unique::burn_item(origin1, CollectionId(1), TokenId(0), 5).map_err(|e| e.error),1130 CommonError::<Test>::TokenValueTooLow1131 );11321133 assert_eq!(1134 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),1135 01136 );1137 });1138}11391140#[test]1141fn burn_fungible_item_with_token_id() {1142 new_test_ext().execute_with(|| {1143 let collection_id = create_test_collection(&CollectionMode::Fungible(3), CollectionId(1));11441145 let origin1 = RuntimeOrigin::signed(1);1146 assert_ok!(Unique::add_collection_admin(1147 origin1.clone(),1148 collection_id,1149 account(2)1150 ));11511152 let data = default_fungible_data();1153 create_test_item(collection_id, &data.into());11541155 // check balance (collection with id = 1, user id = 1)1156 assert_eq!(1157 <pallet_fungible::Balance<Test>>::get((collection_id, account(1))),1158 51159 );11601161 // Try to burn item using Token ID1162 assert_noop!(1163 Unique::burn_item(origin1, CollectionId(1), TokenId(1), 5).map_err(|e| e.error),1164 <pallet_fungible::Error::<Test>>::FungibleItemsHaveNoId1165 );1166 });1167}1168#[test]1169fn burn_refungible_item() {1170 new_test_ext().execute_with(|| {1171 let collection_id = create_test_collection(&CollectionMode::ReFungible, CollectionId(1));1172 let origin1 = RuntimeOrigin::signed(1);11731174 assert_ok!(Unique::set_collection_permissions(1175 origin1.clone(),1176 collection_id,1177 CollectionPermissions {1178 mint_mode: Some(true),1179 access: Some(AccessMode::AllowList),1180 nesting: None,1181 }1182 ));1183 assert_ok!(Unique::add_to_allow_list(1184 origin1.clone(),1185 collection_id,1186 account(1)1187 ));11881189 assert_ok!(Unique::add_collection_admin(1190 origin1.clone(),1191 collection_id,1192 account(2)1193 ));11941195 let data = default_re_fungible_data();1196 create_test_item(collection_id, &data.into());11971198 // check balance (collection with id = 1, user id = 2)1199 assert_eq!(1200 <pallet_refungible::AccountBalance<Test>>::get((collection_id, account(1))),1201 11202 );1203 assert_eq!(1204 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),1205 10231206 );12071208 // burn item1209 assert_ok!(Unique::burn_item(1210 origin1.clone(),1211 collection_id,1212 TokenId(1),1213 10231214 ));1215 assert_noop!(1216 Unique::burn_item(origin1, collection_id, TokenId(1), 1023).map_err(|e| e.error),1217 CommonError::<Test>::TokenValueTooLow1218 );12191220 assert_eq!(1221 <pallet_refungible::Balance<Test>>::get((collection_id, TokenId(1), account(1))),1222 01223 );1224 });1225}12261227#[test]1228fn add_collection_admin() {1229 new_test_ext().execute_with(|| {1230 let collection1_id =1231 create_test_collection_for_owner(&CollectionMode::NFT, 1, CollectionId(1));1232 let origin1 = RuntimeOrigin::signed(1);12331234 // Add collection admins1235 assert_ok!(Unique::add_collection_admin(1236 origin1.clone(),1237 collection1_id,1238 account(2)1239 ));1240 assert_ok!(Unique::add_collection_admin(1241 origin1,1242 collection1_id,1243 account(3)1244 ));12451246 // Owner is not an admin by default1247 assert_eq!(1248 <pallet_common::IsAdmin<Test>>::get((CollectionId(1), account(1))),1249 false1250 );1251 assert!(<pallet_common::IsAdmin<Test>>::get((1252 CollectionId(1),1253 account(2)1254 )));1255 assert!(<pallet_common::IsAdmin<Test>>::get((1256 CollectionId(1),1257 account(3)1258 )));1259 });1260}12611262#[test]1263fn remove_collection_admin() {1264 new_test_ext().execute_with(|| {1265 let collection1_id =1266 create_test_collection_for_owner(&CollectionMode::NFT, 1, CollectionId(1));1267 let origin1 = RuntimeOrigin::signed(1);12681269 // Add collection admins 2 and 31270 assert_ok!(Unique::add_collection_admin(1271 origin1.clone(),1272 collection1_id,1273 account(2)1274 ));1275 assert_ok!(Unique::add_collection_admin(1276 origin1.clone(),1277 collection1_id,1278 account(3)1279 ));12801281 assert!(<pallet_common::IsAdmin<Test>>::get((1282 CollectionId(1),1283 account(2)1284 )));1285 assert!(<pallet_common::IsAdmin<Test>>::get((1286 CollectionId(1),1287 account(3)1288 )));12891290 // remove admin 31291 assert_ok!(Unique::remove_collection_admin(1292 origin1,1293 CollectionId(1),1294 account(3)1295 ));12961297 // 2 is still admin, 3 is not an admin anymore1298 assert!(<pallet_common::IsAdmin<Test>>::get((1299 CollectionId(1),1300 account(2)1301 )));1302 assert_eq!(1303 <pallet_common::IsAdmin<Test>>::get((CollectionId(1), account(3))),1304 false1305 );1306 });1307}13081309#[test]1310fn balance_of() {1311 new_test_ext().execute_with(|| {1312 let nft_collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1313 let fungible_collection_id =1314 create_test_collection(&CollectionMode::Fungible(3), CollectionId(2));1315 let re_fungible_collection_id =1316 create_test_collection(&CollectionMode::ReFungible, CollectionId(3));13171318 // check balance before1319 assert_eq!(1320 <pallet_nonfungible::AccountBalance<Test>>::get((nft_collection_id, account(1))),1321 01322 );1323 assert_eq!(1324 <pallet_fungible::Balance<Test>>::get((fungible_collection_id, account(1))),1325 01326 );1327 assert_eq!(1328 <pallet_refungible::AccountBalance<Test>>::get((re_fungible_collection_id, account(1))),1329 01330 );13311332 let nft_data = default_nft_data();1333 create_test_item(nft_collection_id, &nft_data.into());13341335 let fungible_data = default_fungible_data();1336 create_test_item(fungible_collection_id, &fungible_data.into());13371338 let re_fungible_data = default_re_fungible_data();1339 create_test_item(re_fungible_collection_id, &re_fungible_data.into());13401341 // check balance (collection with id = 1, user id = 1)1342 assert_eq!(1343 <pallet_nonfungible::AccountBalance<Test>>::get((nft_collection_id, account(1))),1344 11345 );1346 assert_eq!(1347 <pallet_fungible::Balance<Test>>::get((fungible_collection_id, account(1))),1348 51349 );1350 assert_eq!(1351 <pallet_refungible::AccountBalance<Test>>::get((re_fungible_collection_id, account(1))),1352 11353 );13541355 assert_eq!(1356 <pallet_nonfungible::Owned<Test>>::get((nft_collection_id, account(1), TokenId(1))),1357 true1358 );1359 assert_eq!(1360 <pallet_refungible::Owned<Test>>::get((1361 re_fungible_collection_id,1362 account(1),1363 TokenId(1)1364 )),1365 true1366 );1367 });1368}13691370#[test]1371fn approve() {1372 new_test_ext().execute_with(|| {1373 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));13741375 let data = default_nft_data();1376 create_test_item(collection_id, &data.into());13771378 let origin1 = RuntimeOrigin::signed(1);13791380 // approve1381 assert_ok!(Unique::approve(1382 origin1,1383 account(2),1384 CollectionId(1),1385 TokenId(1),1386 11387 ));1388 assert_eq!(1389 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1390 account(2)1391 );1392 });1393}13941395#[test]1396fn transfer_from() {1397 new_test_ext().execute_with(|| {1398 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1399 let origin1 = RuntimeOrigin::signed(1);1400 let origin2 = RuntimeOrigin::signed(2);14011402 let data = default_nft_data();1403 create_test_item(collection_id, &data.into());14041405 // approve1406 assert_ok!(Unique::approve(1407 origin1.clone(),1408 account(2),1409 CollectionId(1),1410 TokenId(1),1411 11412 ));1413 assert_eq!(1414 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1415 account(2)1416 );14171418 assert_ok!(Unique::set_collection_permissions(1419 origin1.clone(),1420 CollectionId(1),1421 CollectionPermissions {1422 mint_mode: Some(true),1423 access: Some(AccessMode::AllowList),1424 nesting: None,1425 }1426 ));1427 assert_ok!(Unique::add_to_allow_list(1428 origin1.clone(),1429 CollectionId(1),1430 account(1)1431 ));1432 assert_ok!(Unique::add_to_allow_list(1433 origin1.clone(),1434 CollectionId(1),1435 account(2)1436 ));1437 assert_ok!(Unique::add_to_allow_list(1438 origin1,1439 CollectionId(1),1440 account(3)1441 ));14421443 assert_ok!(Unique::transfer_from(1444 origin2,1445 account(1),1446 account(2),1447 CollectionId(1),1448 TokenId(1),1449 11450 ));14511452 // after transfer1453 assert_eq!(1454 <pallet_nonfungible::AccountBalance<Test>>::get((CollectionId(1), account(1))),1455 01456 );1457 assert_eq!(1458 <pallet_nonfungible::AccountBalance<Test>>::get((CollectionId(1), account(2))),1459 11460 );1461 });1462}14631464// #endregion14651466// Coverage tests region1467// #region14681469#[test]1470fn owner_can_add_address_to_allow_list() {1471 new_test_ext().execute_with(|| {1472 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));14731474 let origin1 = RuntimeOrigin::signed(1);1475 assert_ok!(Unique::add_to_allow_list(1476 origin1,1477 collection_id,1478 account(2)1479 ));1480 assert!(<pallet_common::Allowlist<Test>>::get((1481 collection_id,1482 account(2)1483 )));1484 });1485}14861487#[test]1488fn admin_can_add_address_to_allow_list() {1489 new_test_ext().execute_with(|| {1490 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1491 let origin1 = RuntimeOrigin::signed(1);1492 let origin2 = RuntimeOrigin::signed(2);14931494 assert_ok!(Unique::add_collection_admin(1495 origin1,1496 collection_id,1497 account(2)1498 ));1499 assert_ok!(Unique::add_to_allow_list(1500 origin2,1501 collection_id,1502 account(3)1503 ));1504 assert!(<pallet_common::Allowlist<Test>>::get((1505 collection_id,1506 account(3)1507 )));1508 });1509}15101511#[test]1512fn nonprivileged_user_cannot_add_address_to_allow_list() {1513 new_test_ext().execute_with(|| {1514 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));15151516 let origin2 = RuntimeOrigin::signed(2);1517 assert_noop!(1518 Unique::add_to_allow_list(origin2, collection_id, account(3)),1519 CommonError::<Test>::NoPermission1520 );1521 });1522}15231524#[test]1525fn nobody_can_add_address_to_allow_list_of_nonexisting_collection() {1526 new_test_ext().execute_with(|| {1527 let origin1 = RuntimeOrigin::signed(1);15281529 assert_noop!(1530 Unique::add_to_allow_list(origin1, CollectionId(1), account(2)),1531 CommonError::<Test>::CollectionNotFound1532 );1533 });1534}15351536#[test]1537fn nobody_can_add_address_to_allow_list_of_deleted_collection() {1538 new_test_ext().execute_with(|| {1539 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));15401541 let origin1 = RuntimeOrigin::signed(1);1542 assert_ok!(Unique::destroy_collection(origin1.clone(), collection_id));1543 assert_noop!(1544 Unique::add_to_allow_list(origin1, collection_id, account(2)),1545 CommonError::<Test>::CollectionNotFound1546 );1547 });1548}15491550// If address is already added to allow list, nothing happens1551#[test]1552fn address_is_already_added_to_allow_list() {1553 new_test_ext().execute_with(|| {1554 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1555 let origin1 = RuntimeOrigin::signed(1);15561557 assert_ok!(Unique::add_to_allow_list(1558 origin1.clone(),1559 collection_id,1560 account(2)1561 ));1562 assert_ok!(Unique::add_to_allow_list(1563 origin1,1564 collection_id,1565 account(2)1566 ));1567 assert!(<pallet_common::Allowlist<Test>>::get((1568 collection_id,1569 account(2)1570 )));1571 });1572}15731574#[test]1575fn owner_can_remove_address_from_allow_list() {1576 new_test_ext().execute_with(|| {1577 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));15781579 let origin1 = RuntimeOrigin::signed(1);1580 assert_ok!(Unique::add_to_allow_list(1581 origin1.clone(),1582 collection_id,1583 account(2)1584 ));1585 assert_ok!(Unique::remove_from_allow_list(1586 origin1,1587 collection_id,1588 account(2)1589 ));1590 assert_eq!(1591 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1592 false1593 );1594 });1595}15961597#[test]1598fn admin_can_remove_address_from_allow_list() {1599 new_test_ext().execute_with(|| {1600 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1601 let origin1 = RuntimeOrigin::signed(1);1602 let origin2 = RuntimeOrigin::signed(2);16031604 // Owner adds admin1605 assert_ok!(Unique::add_collection_admin(1606 origin1.clone(),1607 collection_id,1608 account(2)1609 ));16101611 // Owner adds address 3 to allow list1612 assert_ok!(Unique::add_to_allow_list(1613 origin1,1614 collection_id,1615 account(3)1616 ));16171618 // Admin removes address 3 from allow list1619 assert_ok!(Unique::remove_from_allow_list(1620 origin2,1621 collection_id,1622 account(3)1623 ));1624 assert_eq!(1625 <pallet_common::Allowlist<Test>>::get((collection_id, account(3))),1626 false1627 );1628 });1629}16301631#[test]1632fn nonprivileged_user_cannot_remove_address_from_allow_list() {1633 new_test_ext().execute_with(|| {1634 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1635 let origin1 = RuntimeOrigin::signed(1);1636 let origin2 = RuntimeOrigin::signed(2);16371638 assert_ok!(Unique::add_to_allow_list(1639 origin1,1640 collection_id,1641 account(2)1642 ));1643 assert_noop!(1644 Unique::remove_from_allow_list(origin2, collection_id, account(2)),1645 CommonError::<Test>::NoPermission1646 );1647 assert!(<pallet_common::Allowlist<Test>>::get((1648 collection_id,1649 account(2)1650 )));1651 });1652}16531654#[test]1655fn nobody_can_remove_address_from_allow_list_of_nonexisting_collection() {1656 new_test_ext().execute_with(|| {1657 let origin1 = RuntimeOrigin::signed(1);16581659 assert_noop!(1660 Unique::remove_from_allow_list(origin1, CollectionId(1), account(2)),1661 CommonError::<Test>::CollectionNotFound1662 );1663 });1664}16651666#[test]1667fn nobody_can_remove_address_from_allow_list_of_deleted_collection() {1668 new_test_ext().execute_with(|| {1669 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1670 let origin1 = RuntimeOrigin::signed(1);1671 let origin2 = RuntimeOrigin::signed(2);16721673 // Add account 2 to allow list1674 assert_ok!(Unique::add_to_allow_list(1675 origin1.clone(),1676 collection_id,1677 account(2)1678 ));16791680 // Account 2 is in collection allow-list1681 assert!(<pallet_common::Allowlist<Test>>::get((1682 collection_id,1683 account(2)1684 )));16851686 // Destroy collection1687 assert_ok!(Unique::destroy_collection(origin1, collection_id));16881689 // Attempt to remove account 2 from collection allow-list => error1690 assert_noop!(1691 Unique::remove_from_allow_list(origin2, collection_id, account(2)),1692 CommonError::<Test>::CollectionNotFound1693 );16941695 // Account 2 is not found in collection allow-list anyway1696 assert_eq!(1697 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1698 false1699 );1700 });1701}17021703// If address is already removed from allow list, nothing happens1704#[test]1705fn address_is_already_removed_from_allow_list() {1706 new_test_ext().execute_with(|| {1707 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1708 let origin1 = RuntimeOrigin::signed(1);17091710 assert_ok!(Unique::add_to_allow_list(1711 origin1.clone(),1712 collection_id,1713 account(2)1714 ));1715 assert_ok!(Unique::remove_from_allow_list(1716 origin1.clone(),1717 collection_id,1718 account(2)1719 ));1720 assert_eq!(1721 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1722 false1723 );1724 assert_ok!(Unique::remove_from_allow_list(1725 origin1,1726 collection_id,1727 account(2)1728 ));1729 assert_eq!(1730 <pallet_common::Allowlist<Test>>::get((collection_id, account(2))),1731 false1732 );1733 });1734}17351736// If Public Access mode is set to AllowList, tokens can’t be transferred from a non-allowlisted address with transfer or transferFrom (2 tests)1737#[test]1738fn allow_list_test_1() {1739 new_test_ext().execute_with(|| {1740 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));17411742 let origin1 = RuntimeOrigin::signed(1);1743 assert_ok!(Unique::add_collection_admin(1744 origin1.clone(),1745 collection_id,1746 account(1)1747 ));17481749 let data = default_nft_data();1750 create_test_item(collection_id, &data.into());17511752 assert_ok!(Unique::set_collection_permissions(1753 origin1.clone(),1754 collection_id,1755 CollectionPermissions {1756 mint_mode: None,1757 access: Some(AccessMode::AllowList),1758 nesting: None,1759 }1760 ));1761 assert_ok!(Unique::add_to_allow_list(1762 origin1.clone(),1763 collection_id,1764 account(2)1765 ));17661767 assert_noop!(1768 Unique::transfer(origin1, account(3), CollectionId(1), TokenId(1), 1)1769 .map_err(|e| e.error),1770 CommonError::<Test>::AddressNotInAllowlist1771 );1772 });1773}17741775#[test]1776fn allow_list_test_2() {1777 new_test_ext().execute_with(|| {1778 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));1779 let origin1 = RuntimeOrigin::signed(1);17801781 let data = default_nft_data();1782 create_test_item(collection_id, &data.into());17831784 assert_ok!(Unique::set_collection_permissions(1785 origin1.clone(),1786 collection_id,1787 CollectionPermissions {1788 mint_mode: None,1789 access: Some(AccessMode::AllowList),1790 nesting: None,1791 }1792 ));1793 assert_ok!(Unique::add_to_allow_list(1794 origin1.clone(),1795 collection_id,1796 account(1)1797 ));1798 assert_ok!(Unique::add_to_allow_list(1799 origin1.clone(),1800 collection_id,1801 account(2)1802 ));18031804 // do approve1805 assert_ok!(Unique::approve(1806 origin1.clone(),1807 account(1),1808 collection_id,1809 TokenId(1),1810 11811 ));1812 assert_eq!(1813 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1814 account(1)1815 );18161817 assert_ok!(Unique::remove_from_allow_list(1818 origin1.clone(),1819 collection_id,1820 account(1)1821 ));18221823 assert_noop!(1824 Unique::transfer_from(1825 origin1,1826 account(1),1827 account(3),1828 CollectionId(1),1829 TokenId(1),1830 11831 )1832 .map_err(|e| e.error),1833 CommonError::<Test>::AddressNotInAllowlist1834 );1835 });1836}18371838// If Public Access mode is set to AllowList, tokens can’t be transferred to a non-allowlisted address with transfer or transferFrom (2 tests)1839#[test]1840fn allow_list_test_3() {1841 new_test_ext().execute_with(|| {1842 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));18431844 let origin1 = RuntimeOrigin::signed(1);18451846 let data = default_nft_data();1847 create_test_item(collection_id, &data.into());18481849 assert_ok!(Unique::set_collection_permissions(1850 origin1.clone(),1851 collection_id,1852 CollectionPermissions {1853 mint_mode: None,1854 access: Some(AccessMode::AllowList),1855 nesting: None,1856 }1857 ));1858 assert_ok!(Unique::add_to_allow_list(1859 origin1.clone(),1860 collection_id,1861 account(1)1862 ));18631864 assert_noop!(1865 Unique::transfer(origin1, account(3), collection_id, TokenId(1), 1)1866 .map_err(|e| e.error),1867 CommonError::<Test>::AddressNotInAllowlist1868 );1869 });1870}18711872#[test]1873fn allow_list_test_4() {1874 new_test_ext().execute_with(|| {1875 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));18761877 let origin1 = RuntimeOrigin::signed(1);18781879 let data = default_nft_data();1880 create_test_item(collection_id, &data.into());18811882 assert_ok!(Unique::set_collection_permissions(1883 origin1.clone(),1884 collection_id,1885 CollectionPermissions {1886 mint_mode: None,1887 access: Some(AccessMode::AllowList),1888 nesting: None,1889 }1890 ));1891 assert_ok!(Unique::add_to_allow_list(1892 origin1.clone(),1893 collection_id,1894 account(1)1895 ));1896 assert_ok!(Unique::add_to_allow_list(1897 origin1.clone(),1898 collection_id,1899 account(2)1900 ));19011902 // do approve1903 assert_ok!(Unique::approve(1904 origin1.clone(),1905 account(1),1906 collection_id,1907 TokenId(1),1908 11909 ));1910 assert_eq!(1911 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),1912 account(1)1913 );19141915 assert_ok!(Unique::remove_from_allow_list(1916 origin1.clone(),1917 collection_id,1918 account(2)1919 ));19201921 assert_noop!(1922 Unique::transfer_from(1923 origin1,1924 account(1),1925 account(3),1926 collection_id,1927 TokenId(1),1928 11929 )1930 .map_err(|e| e.error),1931 CommonError::<Test>::AddressNotInAllowlist1932 );1933 });1934}19351936// If Public Access mode is set to AllowList, tokens can’t be destroyed by a non-allowlisted address (even if it owned them before enabling AllowList mode)1937#[test]1938fn allow_list_test_5() {1939 new_test_ext().execute_with(|| {1940 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));19411942 let origin1 = RuntimeOrigin::signed(1);19431944 let data = default_nft_data();1945 create_test_item(collection_id, &data.into());19461947 assert_ok!(Unique::set_collection_permissions(1948 origin1.clone(),1949 collection_id,1950 CollectionPermissions {1951 mint_mode: None,1952 access: Some(AccessMode::AllowList),1953 nesting: None,1954 }1955 ));1956 assert_noop!(1957 Unique::burn_item(origin1.clone(), CollectionId(1), TokenId(1), 1).map_err(|e| e.error),1958 CommonError::<Test>::AddressNotInAllowlist1959 );1960 });1961}19621963// If Public Access mode is set to AllowList, token transfers can’t be Approved by a non-allowlisted address (see Approve method).1964#[test]1965fn allow_list_test_6() {1966 new_test_ext().execute_with(|| {1967 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));19681969 let origin1 = RuntimeOrigin::signed(1);19701971 let data = default_nft_data();1972 create_test_item(collection_id, &data.into());19731974 assert_ok!(Unique::set_collection_permissions(1975 origin1.clone(),1976 collection_id,1977 CollectionPermissions {1978 mint_mode: None,1979 access: Some(AccessMode::AllowList),1980 nesting: None,1981 }1982 ));19831984 // do approve1985 assert_noop!(1986 Unique::approve(origin1, account(1), CollectionId(1), TokenId(1), 1)1987 .map_err(|e| e.error),1988 CommonError::<Test>::AddressNotInAllowlist1989 );1990 });1991}19921993// If Public Access mode is set to AllowList, tokens can be transferred from a allowlisted address with transfer or transferFrom (2 tests) and1994// tokens can be transferred from a allowlisted address with transfer or transferFrom (2 tests)1995#[test]1996fn allow_list_test_7() {1997 new_test_ext().execute_with(|| {1998 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));19992000 let data = default_nft_data();2001 create_test_item(collection_id, &data.into());20022003 let origin1 = RuntimeOrigin::signed(1);20042005 assert_ok!(Unique::set_collection_permissions(2006 origin1.clone(),2007 collection_id,2008 CollectionPermissions {2009 mint_mode: None,2010 access: Some(AccessMode::AllowList),2011 nesting: None,2012 }2013 ));2014 assert_ok!(Unique::add_to_allow_list(2015 origin1.clone(),2016 collection_id,2017 account(1)2018 ));2019 assert_ok!(Unique::add_to_allow_list(2020 origin1.clone(),2021 collection_id,2022 account(2)2023 ));20242025 assert_ok!(Unique::transfer(2026 origin1,2027 account(2),2028 CollectionId(1),2029 TokenId(1),2030 12031 ));2032 });2033}20342035#[test]2036fn allow_list_test_8() {2037 new_test_ext().execute_with(|| {2038 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));20392040 // Create NFT for account 12041 let data = default_nft_data();2042 create_test_item(collection_id, &data.into());20432044 let origin1 = RuntimeOrigin::signed(1);20452046 // Toggle Allow List mode and add accounts 1 and 22047 assert_ok!(Unique::set_collection_permissions(2048 origin1.clone(),2049 collection_id,2050 CollectionPermissions {2051 mint_mode: None,2052 access: Some(AccessMode::AllowList),2053 nesting: None,2054 }2055 ));2056 assert_ok!(Unique::add_to_allow_list(2057 origin1.clone(),2058 collection_id,2059 account(1)2060 ));2061 assert_ok!(Unique::add_to_allow_list(2062 origin1.clone(),2063 collection_id,2064 account(2)2065 ));20662067 // Sself-approve account 1 for NFT 12068 assert_ok!(Unique::approve(2069 origin1.clone(),2070 account(1),2071 CollectionId(1),2072 TokenId(1),2073 12074 ));2075 assert_eq!(2076 <pallet_nonfungible::Allowance<Test>>::get((CollectionId(1), TokenId(1))).unwrap(),2077 account(1)2078 );20792080 // Transfer from 1 to 22081 assert_ok!(Unique::transfer_from(2082 origin1,2083 account(1),2084 account(2),2085 CollectionId(1),2086 TokenId(1),2087 12088 ));2089 });2090}20912092// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by owner.2093#[test]2094fn allow_list_test_9() {2095 new_test_ext().execute_with(|| {2096 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));2097 let origin1 = RuntimeOrigin::signed(1);20982099 assert_ok!(Unique::set_collection_permissions(2100 origin1.clone(),2101 collection_id,2102 CollectionPermissions {2103 mint_mode: Some(false),2104 access: Some(AccessMode::AllowList),2105 nesting: None,2106 }2107 ));21082109 let data = default_nft_data();2110 create_test_item(collection_id, &data.into());2111 });2112}21132114// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens can be created by admin.2115#[test]2116fn allow_list_test_10() {2117 new_test_ext().execute_with(|| {2118 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));21192120 let origin1 = RuntimeOrigin::signed(1);2121 let origin2 = RuntimeOrigin::signed(2);21222123 assert_ok!(Unique::set_collection_permissions(2124 origin1.clone(),2125 collection_id,2126 CollectionPermissions {2127 mint_mode: Some(false),2128 access: Some(AccessMode::AllowList),2129 nesting: None,2130 }2131 ));21322133 assert_ok!(Unique::add_collection_admin(2134 origin1,2135 collection_id,2136 account(2)2137 ));21382139 assert_ok!(Unique::create_item(2140 origin2,2141 collection_id,2142 account(2),2143 default_nft_data().into()2144 ));2145 });2146}21472148// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and allow listed address.2149#[test]2150fn allow_list_test_11() {2151 new_test_ext().execute_with(|| {2152 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));21532154 let origin1 = RuntimeOrigin::signed(1);2155 let origin2 = RuntimeOrigin::signed(2);21562157 assert_ok!(Unique::set_collection_permissions(2158 origin1.clone(),2159 collection_id,2160 CollectionPermissions {2161 mint_mode: Some(false),2162 access: Some(AccessMode::AllowList),2163 nesting: None,2164 }2165 ));2166 assert_ok!(Unique::add_to_allow_list(2167 origin1,2168 collection_id,2169 account(2)2170 ));21712172 assert_noop!(2173 Unique::create_item(2174 origin2,2175 CollectionId(1),2176 account(2),2177 default_nft_data().into()2178 )2179 .map_err(|e| e.error),2180 CommonError::<Test>::PublicMintingNotAllowed2181 );2182 });2183}21842185// If Public Access mode is set to AllowList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-allow listed address.2186#[test]2187fn allow_list_test_12() {2188 new_test_ext().execute_with(|| {2189 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));21902191 let origin1 = RuntimeOrigin::signed(1);2192 let origin2 = RuntimeOrigin::signed(2);21932194 assert_ok!(Unique::set_collection_permissions(2195 origin1.clone(),2196 collection_id,2197 CollectionPermissions {2198 mint_mode: Some(false),2199 access: Some(AccessMode::AllowList),2200 nesting: None,2201 }2202 ));22032204 assert_noop!(2205 Unique::create_item(2206 origin2,2207 CollectionId(1),2208 account(2),2209 default_nft_data().into()2210 )2211 .map_err(|e| e.error),2212 CommonError::<Test>::PublicMintingNotAllowed2213 );2214 });2215}22162217// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by owner.2218#[test]2219fn allow_list_test_13() {2220 new_test_ext().execute_with(|| {2221 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));22222223 let origin1 = RuntimeOrigin::signed(1);22242225 assert_ok!(Unique::set_collection_permissions(2226 origin1.clone(),2227 collection_id,2228 CollectionPermissions {2229 mint_mode: Some(true),2230 access: Some(AccessMode::AllowList),2231 nesting: None,2232 }2233 ));22342235 let data = default_nft_data();2236 create_test_item(collection_id, &data.into());2237 });2238}22392240// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by admin.2241#[test]2242fn allow_list_test_14() {2243 new_test_ext().execute_with(|| {2244 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));22452246 let origin1 = RuntimeOrigin::signed(1);2247 let origin2 = RuntimeOrigin::signed(2);22482249 assert_ok!(Unique::set_collection_permissions(2250 origin1.clone(),2251 collection_id,2252 CollectionPermissions {2253 mint_mode: Some(true),2254 access: Some(AccessMode::AllowList),2255 nesting: None,2256 }2257 ));22582259 assert_ok!(Unique::add_collection_admin(2260 origin1,2261 collection_id,2262 account(2)2263 ));22642265 assert_ok!(Unique::create_item(2266 origin2,2267 collection_id,2268 account(2),2269 default_nft_data().into()2270 ));2271 });2272}22732274// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-allow listed address.2275#[test]2276fn allow_list_test_15() {2277 new_test_ext().execute_with(|| {2278 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));22792280 let origin1 = RuntimeOrigin::signed(1);2281 let origin2 = RuntimeOrigin::signed(2);22822283 assert_ok!(Unique::set_collection_permissions(2284 origin1.clone(),2285 collection_id,2286 CollectionPermissions {2287 mint_mode: Some(true),2288 access: Some(AccessMode::AllowList),2289 nesting: None,2290 }2291 ));22922293 assert_noop!(2294 Unique::create_item(2295 origin2,2296 collection_id,2297 account(2),2298 default_nft_data().into()2299 )2300 .map_err(|e| e.error),2301 CommonError::<Test>::AddressNotInAllowlist2302 );2303 });2304}23052306// If Public Access mode is set to AllowList, and Mint Permission is set to true, tokens can be created by non-privileged and allow listed address.2307#[test]2308fn allow_list_test_16() {2309 new_test_ext().execute_with(|| {2310 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));23112312 let origin1 = RuntimeOrigin::signed(1);2313 let origin2 = RuntimeOrigin::signed(2);23142315 assert_ok!(Unique::set_collection_permissions(2316 origin1.clone(),2317 collection_id,2318 CollectionPermissions {2319 mint_mode: Some(true),2320 access: Some(AccessMode::AllowList),2321 nesting: None,2322 }2323 ));2324 assert_ok!(Unique::add_to_allow_list(2325 origin1,2326 collection_id,2327 account(2)2328 ));23292330 assert_ok!(Unique::create_item(2331 origin2,2332 collection_id,2333 account(2),2334 default_nft_data().into()2335 ));2336 });2337}23382339// Total number of collections. Positive test2340#[test]2341fn total_number_collections_bound() {2342 new_test_ext().execute_with(|| {2343 create_test_collection(&CollectionMode::NFT, CollectionId(1));2344 });2345}23462347#[test]2348fn create_max_collections() {2349 new_test_ext().execute_with(|| {2350 for i in 1..COLLECTION_NUMBER_LIMIT {2351 create_test_collection(&CollectionMode::NFT, CollectionId(i));2352 }2353 });2354}23552356// Total number of collections. Negative test2357#[test]2358fn total_number_collections_bound_neg() {2359 new_test_ext().execute_with(|| {2360 let origin1 = RuntimeOrigin::signed(1);23612362 for i in 1..=COLLECTION_NUMBER_LIMIT {2363 create_test_collection(&CollectionMode::NFT, CollectionId(i));2364 }23652366 let col_name1: Vec<u16> = "Test1\0".encode_utf16().collect::<Vec<u16>>();2367 let col_desc1: Vec<u16> = "TestDescription1\0".encode_utf16().collect::<Vec<u16>>();2368 let token_prefix1: Vec<u8> = b"token_prefix1\0".to_vec();23692370 let data = CreateCollectionData {2371 name: col_name1.try_into().unwrap(),2372 description: col_desc1.try_into().unwrap(),2373 token_prefix: token_prefix1.try_into().unwrap(),2374 mode: CollectionMode::NFT,2375 ..Default::default()2376 };23772378 // 11-th collection in chain. Expects error2379 assert_noop!(2380 Unique::create_collection_ex(origin1, data),2381 CommonError::<Test>::TotalCollectionsLimitExceeded2382 );2383 });2384}23852386// Owned tokens by a single address. Positive test2387#[test]2388fn owned_tokens_bound() {2389 new_test_ext().execute_with(|| {2390 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));23912392 let data = default_nft_data();2393 create_test_item(collection_id, &data.clone().into());2394 create_test_item(collection_id, &data.into());2395 });2396}23972398// Owned tokens by a single address. Negotive test2399#[test]2400fn owned_tokens_bound_neg() {2401 new_test_ext().execute_with(|| {2402 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));24032404 let origin1 = RuntimeOrigin::signed(1);24052406 for _ in 1..=MAX_TOKEN_OWNERSHIP {2407 let data = default_nft_data();2408 create_test_item(collection_id, &data.clone().into());2409 }24102411 let data = default_nft_data();2412 assert_noop!(2413 Unique::create_item(origin1, CollectionId(1), account(1), data.into())2414 .map_err(|e| e.error),2415 CommonError::<Test>::AccountTokenLimitExceeded2416 );2417 });2418}24192420// Number of collection admins. Positive test2421#[test]2422fn collection_admins_bound() {2423 new_test_ext().execute_with(|| {2424 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));24252426 let origin1 = RuntimeOrigin::signed(1);24272428 assert_ok!(Unique::add_collection_admin(2429 origin1.clone(),2430 collection_id,2431 account(2)2432 ));2433 assert_ok!(Unique::add_collection_admin(2434 origin1,2435 collection_id,2436 account(3)2437 ));2438 });2439}24402441// Number of collection admins. Negotive test2442#[test]2443fn collection_admins_bound_neg() {2444 new_test_ext().execute_with(|| {2445 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));24462447 let origin1 = RuntimeOrigin::signed(1);24482449 for i in 0..COLLECTION_ADMINS_LIMIT {2450 assert_ok!(Unique::add_collection_admin(2451 origin1.clone(),2452 collection_id,2453 account((2 + i).into())2454 ));2455 }2456 assert_noop!(2457 Unique::add_collection_admin(2458 origin1,2459 collection_id,2460 account((3 + COLLECTION_ADMINS_LIMIT).into())2461 ),2462 CommonError::<Test>::CollectionAdminCountExceeded2463 );2464 });2465}2466// #endregion24672468#[test]2469fn collection_transfer_flag_works() {2470 new_test_ext().execute_with(|| {2471 let origin1 = RuntimeOrigin::signed(1);24722473 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));2474 assert_ok!(Unique::set_transfers_enabled_flag(2475 origin1,2476 collection_id,2477 true2478 ));24792480 let data = default_nft_data();2481 create_test_item(collection_id, &data.into());2482 assert_eq!(2483 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2484 12485 );2486 assert_eq!(2487 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2488 true2489 );24902491 let origin1 = RuntimeOrigin::signed(1);24922493 // default scenario2494 assert_ok!(Unique::transfer(2495 origin1,2496 account(2),2497 collection_id,2498 TokenId(1),2499 12500 ));2501 assert_eq!(2502 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2503 false2504 );2505 assert_eq!(2506 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),2507 true2508 );2509 assert_eq!(2510 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2511 02512 );2513 assert_eq!(2514 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(2))),2515 12516 );2517 });2518}25192520#[test]2521fn collection_transfer_flag_works_neg() {2522 new_test_ext().execute_with(|| {2523 let origin1 = RuntimeOrigin::signed(1);25242525 let collection_id = create_test_collection(&CollectionMode::NFT, CollectionId(1));2526 assert_ok!(Unique::set_transfers_enabled_flag(2527 origin1,2528 collection_id,2529 false2530 ));25312532 let data = default_nft_data();2533 create_test_item(collection_id, &data.into());2534 assert_eq!(2535 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2536 12537 );2538 assert_eq!(2539 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2540 true2541 );25422543 let origin1 = RuntimeOrigin::signed(1);25442545 // default scenario2546 assert_noop!(2547 Unique::transfer(origin1, account(2), CollectionId(1), TokenId(1), 1)2548 .map_err(|e| e.error),2549 CommonError::<Test>::TransferNotAllowed2550 );2551 assert_eq!(2552 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(1))),2553 12554 );2555 assert_eq!(2556 <pallet_nonfungible::AccountBalance<Test>>::get((collection_id, account(2))),2557 02558 );2559 assert_eq!(2560 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(1), TokenId(1))),2561 true2562 );2563 assert_eq!(2564 <pallet_nonfungible::Owned<Test>>::get((collection_id, account(2), TokenId(1))),2565 false2566 );2567 });2568}25692570#[test]2571fn collection_sponsoring() {2572 new_test_ext().execute_with(|| {2573 // default_limits();2574 let user1 = 1_u64;2575 let user2 = 777_u64;2576 let origin1 = RuntimeOrigin::signed(user1);2577 let origin2 = RuntimeOrigin::signed(user2);2578 let account2 = account(user2);25792580 let collection_id =2581 create_test_collection_for_owner(&CollectionMode::NFT, user1, CollectionId(1));2582 assert_ok!(Unique::set_collection_sponsor(2583 origin1.clone(),2584 collection_id,2585 user12586 ));2587 assert_ok!(Unique::confirm_sponsorship(origin1.clone(), collection_id));25882589 // Expect error while have no permissions2590 assert!(Unique::create_item(2591 origin2.clone(),2592 collection_id,2593 account2.clone(),2594 default_nft_data().into()2595 )2596 .is_err());25972598 assert_ok!(Unique::set_collection_permissions(2599 origin1.clone(),2600 collection_id,2601 CollectionPermissions {2602 mint_mode: Some(true),2603 access: Some(AccessMode::AllowList),2604 nesting: None,2605 }2606 ));2607 assert_ok!(Unique::add_to_allow_list(2608 origin1.clone(),2609 collection_id,2610 account2.clone()2611 ));26122613 assert_ok!(Unique::create_item(2614 origin2,2615 collection_id,2616 account2,2617 default_nft_data().into()2618 ));2619 });2620}26212622mod check_token_permissions {2623 use pallet_common::LazyValue;26242625 use super::*;26262627 fn test<FTE: FnOnce() -> bool>(2628 i: usize,2629 test_case: &pallet_common::tests::TestCase,2630 check_token_existence: &mut LazyValue<bool, FTE>,2631 ) {2632 let collection_admin = test_case.collection_admin;2633 let mut is_collection_admin = LazyValue::new(|| test_case.is_collection_admin);2634 let token_owner = test_case.token_owner;2635 let mut is_token_owner = LazyValue::new(|| Ok(test_case.is_token_owner));2636 let is_no_permission = test_case.no_permission;26372638 let result = pallet_common::tests::check_token_permissions::<Test, _, _, FTE>(2639 collection_admin,2640 token_owner,2641 &mut is_collection_admin,2642 &mut is_token_owner,2643 check_token_existence,2644 );26452646 if is_no_permission {2647 assert!(2648 result.is_err(),2649 "{i}: {test_case:?}, token_exist: {}",2650 check_token_existence.value()2651 );2652 assert_err!(result, pallet_common::Error::<Test>::NoPermission,);2653 } else if check_token_existence.has_value() && !check_token_existence.value() {2654 assert!(2655 result.is_err(),2656 "{i}: {test_case:?}, token_exist: {}",2657 check_token_existence.value()2658 );2659 assert_err!(result, pallet_common::Error::<Test>::TokenNotFound,);2660 }2661 }26622663 #[test]2664 fn no_permission_only() {2665 new_test_ext().execute_with(|| {2666 let mut check_token_existence = LazyValue::new(|| true);2667 for (i, row) in pallet_common::tests::TABLE.iter().enumerate() {2668 test(i, row, &mut check_token_existence);2669 }2670 });2671 }26722673 #[test]2674 fn no_permission_and_token_not_found() {2675 new_test_ext().execute_with(|| {2676 for (i, row) in pallet_common::tests::TABLE.iter().enumerate() {2677 // This is inside the loop to keep track of whether the lambda was called2678 let mut check_token_existence = LazyValue::new(|| false);2679 test(i, row, &mut check_token_existence);2680 }2681 });2682 }2683}tests/src/eth/nativeFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nativeFungible.test.ts
+++ b/tests/src/eth/nativeFungible.test.ts
@@ -33,7 +33,7 @@
const collectionAddress = helper.ethAddress.fromCollectionId(0);
const contract = await helper.ethNativeContract.collection(collectionAddress, 'ft', owner);
- await expect(contract.methods.approve(spender, 100).call({from: owner})).to.be.rejectedWith('Approve not supported');
+ await expect(contract.methods.approve(spender, 100).call({from: owner})).to.be.rejectedWith('approve not supported');
});
itEth('balanceOf()', async ({helper}) => {
@@ -170,4 +170,4 @@
await expect(contract.methods.transferFromCross(receiver, receiver, 50).call({from: owner.eth})).to.be.rejectedWith('no permission');
});
-});
\ No newline at end of file
+});
tests/src/util/playgrounds/unique.tsdiffbeforeafterboth--- a/tests/src/util/playgrounds/unique.ts
+++ b/tests/src/util/playgrounds/unique.ts
@@ -3119,9 +3119,9 @@
async getTokenPropertiesConsumedSpace(tokenId: number): Promise<number> {
const api = this.helper.getApi();
- const props = (await api.query.nonfungible.tokenProperties(this.collectionId, tokenId)).toJSON();
+ const props = (await api.query.nonfungible.tokenProperties(this.collectionId, tokenId)).toJSON() as any;
- return (props! as any).consumedSpace;
+ return props?.consumedSpace ?? 0;
}
async transferToken(signer: TSigner, tokenId: number, addressObj: ICrossAccountId) {
@@ -3224,9 +3224,9 @@
async getTokenPropertiesConsumedSpace(tokenId: number): Promise<number> {
const api = this.helper.getApi();
- const props = (await api.query.refungible.tokenProperties(this.collectionId, tokenId)).toJSON();
+ const props = (await api.query.refungible.tokenProperties(this.collectionId, tokenId)).toJSON() as any;
- return (props! as any).consumedSpace;
+ return props?.consumedSpace ?? 0;
}
async transferToken(signer: TSigner, tokenId: number, addressObj: ICrossAccountId, amount = 1n) {