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.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//! # Unique Pallet18//!19//! A pallet governing Unique transactions.20//!21//! - [`Config`]22//! - [`Call`]23//! - [`Pallet`]24//!25//! ## Overview26//!27//! The Unique pallet's purpose is to be the primary interface between28//! external users and the inner structure of the Unique chains.29//!30//! It also contains an implementation of [`CollectionHelpers`][`eth`],31//! an Ethereum contract dealing with collection operations.32//!33//! ## Interface34//!35//! ### Dispatchables36//!37//! - `create_collection` - Create a collection of tokens. **Deprecated**, use `create_collection_ex`.38//! - `create_collection_ex` - Create a collection of tokens with explicit parameters.39//! - `destroy_collection` - Destroy a collection if no tokens exist within.40//! - `add_to_allow_list` - Add an address to allow list.41//! - `remove_from_allow_list` - Remove an address from allow list.42//! - `change_collection_owner` - Change the owner of the collection.43//! - `add_collection_admin` - Add an admin to a collection.44//! - `remove_collection_admin` - Remove admin of a collection.45//! - `set_collection_sponsor` - Invite a new collection sponsor.46//! - `confirm_sponsorship` - Confirm own sponsorship of a collection, becoming the sponsor.47//! - `remove_collection_sponsor` - Remove a sponsor from a collection.48//! - `create_item` - Create an item within a collection.49//! - `create_multiple_items` - Create multiple items within a collection.50//! - `set_collection_properties` - Add or change collection properties.51//! - `delete_collection_properties` - Delete specified collection properties.52//! - `set_token_properties` - Add or change token properties.53//! - `delete_token_properties` - Delete token properties.54//! - `set_token_property_permissions` - Add or change token property permissions of a collection.55//! - `create_multiple_items_ex` - Create multiple items within a collection with explicitly specified initial parameters.56//! - `set_transfers_enabled_flag` - Completely allow or disallow transfers for a particular collection.57//! - `burn_item` - Destroy an item.58//! - `burn_from` - Destroy an item on behalf of the owner as a non-owner account.59//! - `transfer` - Change ownership of the token.60//! - `transfer_from` - Change ownership of the token on behalf of the owner as a non-owner account.61//! - `approve` - Allow a non-permissioned address to transfer or burn an item.62//! - `set_collection_limits` - Set specific limits of a collection.63//! - `set_collection_permissions` - Set specific permissions of a collection.64//! - `repartition` - Re-partition a refungible token, while owning all of its parts.6566#![recursion_limit = "1024"]67#![cfg_attr(not(feature = "std"), no_std)]68#![allow(69 clippy::too_many_arguments,70 clippy::unnecessary_mut_passed,71 clippy::unused_unit72)]7374extern crate alloc;7576use frame_support::pallet_prelude::*;77use frame_system::pallet_prelude::*;78pub use pallet::*;79pub mod eth;8081#[cfg(feature = "runtime-benchmarks")]82pub mod benchmarking;83pub mod weights;8485#[frame_support::pallet]86pub mod pallet {87 use frame_support::{dispatch::DispatchResult, ensure, fail, storage::Key, BoundedVec};88 use frame_system::{ensure_root, ensure_signed};89 use pallet_common::{90 dispatch::{dispatch_tx, CollectionDispatch},91 CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,92 };93 use pallet_evm::account::CrossAccountId;94 use scale_info::TypeInfo;95 use sp_std::{vec, vec::Vec};96 use up_data_structs::{97 budget, CollectionId, CollectionLimits, CollectionMode, CollectionPermissions,98 CreateCollectionData, CreateItemData, CreateItemExData, Property, PropertyKey,99 PropertyKeyPermission, TokenId, COLLECTION_ADMINS_LIMIT, MAX_COLLECTION_DESCRIPTION_LENGTH,100 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_PROPERTIES_SIZE, MAX_PROPERTIES_PER_ITEM,101 MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH, MAX_TOKEN_PREFIX_LENGTH,102 MAX_TOKEN_PROPERTIES_SIZE,103 };104 use weights::WeightInfo;105106 use super::*;107108 /// A maximum number of levels of depth in the token nesting tree.109 pub const NESTING_BUDGET: u32 = 5;110111 /// Errors for the common Unique transactions.112 #[pallet::error]113 pub enum Error<T> {114 /// Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].115 CollectionDecimalPointLimitExceeded,116 /// Length of items properties must be greater than 0.117 EmptyArgument,118 /// Repertition is only supported by refungible collection.119 RepartitionCalledOnNonRefungibleCollection,120 }121122 /// Configuration trait of this pallet.123 #[pallet::config]124 pub trait Config: frame_system::Config + pallet_common::Config + Sized + TypeInfo {125 /// Weight information for extrinsics in this pallet.126 type WeightInfo: WeightInfo;127128 /// Weight information for common pallet operations.129 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;130131 /// Weight info information for extra refungible pallet operations.132 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;133 }134135 #[pallet::pallet]136 pub struct Pallet<T>(_);137138 pub type SelfWeightOf<T> = <T as Config>::WeightInfo;139140 // # Used definitions141 //142 // ## User control levels143 //144 // chain-controlled - key is uncontrolled by user145 // i.e autoincrementing index146 // can use non-cryptographic hash147 // real - key is controlled by user148 // but it is hard to generate enough colliding values, i.e owner of signed txs149 // can use non-cryptographic hash150 // controlled - key is completly controlled by users151 // i.e maps with mutable keys152 // should use cryptographic hash153 //154 // ## User control level downgrade reasons155 //156 // ?1 - chain-controlled -> controlled157 // collections/tokens can be destroyed, resulting in massive holes158 // ?2 - chain-controlled -> controlled159 // same as ?1, but can be only added, resulting in easier exploitation160 // ?3 - real -> controlled161 // no confirmation required, so addresses can be easily generated162163 //#region Private members164 /// Used for migrations165 #[pallet::storage]166 pub type ChainVersion<T> = StorageValue<_, u64, ValueQuery>;167 //#endregion168169 //#region Tokens transfer sponosoring rate limit baskets170 /// (Collection id (controlled?2), who created (real))171 /// TODO: Off chain worker should remove from this map when collection gets removed172 #[pallet::storage]173 #[pallet::getter(fn create_item_busket)]174 pub type CreateItemBasket<T: Config> = StorageMap<175 Hasher = Blake2_128Concat,176 Key = (CollectionId, T::AccountId),177 Value = BlockNumberFor<T>,178 QueryKind = OptionQuery,179 >;180 /// Collection id (controlled?2), token id (controlled?2)181 #[pallet::storage]182 #[pallet::getter(fn nft_transfer_basket)]183 pub type NftTransferBasket<T: Config> = StorageDoubleMap<184 Hasher1 = Blake2_128Concat,185 Key1 = CollectionId,186 Hasher2 = Blake2_128Concat,187 Key2 = TokenId,188 Value = BlockNumberFor<T>,189 QueryKind = OptionQuery,190 >;191 /// Collection id (controlled?2), owning user (real)192 #[pallet::storage]193 #[pallet::getter(fn fungible_transfer_basket)]194 pub type FungibleTransferBasket<T: Config> = StorageDoubleMap<195 Hasher1 = Blake2_128Concat,196 Key1 = CollectionId,197 Hasher2 = Twox64Concat,198 Key2 = T::AccountId,199 Value = BlockNumberFor<T>,200 QueryKind = OptionQuery,201 >;202 /// Collection id (controlled?2), token id (controlled?2)203 #[pallet::storage]204 #[pallet::getter(fn refungible_transfer_basket)]205 pub type ReFungibleTransferBasket<T: Config> = StorageNMap<206 Key = (207 Key<Blake2_128Concat, CollectionId>,208 Key<Blake2_128Concat, TokenId>,209 Key<Twox64Concat, T::AccountId>,210 ),211 Value = BlockNumberFor<T>,212 QueryKind = OptionQuery,213 >;214 //#endregion215216 /// Last sponsoring of token property setting // todo:doc rephrase this and the following217 #[pallet::storage]218 #[pallet::getter(fn token_property_basket)]219 pub type TokenPropertyBasket<T: Config> = StorageDoubleMap<220 Hasher1 = Blake2_128Concat,221 Key1 = CollectionId,222 Hasher2 = Blake2_128Concat,223 Key2 = TokenId,224 Value = BlockNumberFor<T>,225 QueryKind = OptionQuery,226 >;227228 /// Last sponsoring of NFT approval in a collection229 #[pallet::storage]230 #[pallet::getter(fn nft_approve_basket)]231 pub type NftApproveBasket<T: Config> = StorageDoubleMap<232 Hasher1 = Blake2_128Concat,233 Key1 = CollectionId,234 Hasher2 = Blake2_128Concat,235 Key2 = TokenId,236 Value = BlockNumberFor<T>,237 QueryKind = OptionQuery,238 >;239 /// Last sponsoring of fungible tokens approval in a collection240 #[pallet::storage]241 #[pallet::getter(fn fungible_approve_basket)]242 pub type FungibleApproveBasket<T: Config> = StorageDoubleMap<243 Hasher1 = Blake2_128Concat,244 Key1 = CollectionId,245 Hasher2 = Twox64Concat,246 Key2 = T::AccountId,247 Value = BlockNumberFor<T>,248 QueryKind = OptionQuery,249 >;250 /// Last sponsoring of RFT approval in a collection251 #[pallet::storage]252 #[pallet::getter(fn refungible_approve_basket)]253 pub type RefungibleApproveBasket<T: Config> = StorageNMap<254 Key = (255 Key<Blake2_128Concat, CollectionId>,256 Key<Blake2_128Concat, TokenId>,257 Key<Twox64Concat, T::AccountId>,258 ),259 Value = BlockNumberFor<T>,260 QueryKind = OptionQuery,261 >;262263 #[pallet::extra_constants]264 impl<T: Config> Pallet<T> {265 /// A maximum number of levels of depth in the token nesting tree.266 fn nesting_budget() -> u32 {267 NESTING_BUDGET268 }269270 /// Maximal length of a collection name.271 fn max_collection_name_length() -> u32 {272 MAX_COLLECTION_NAME_LENGTH273 }274275 /// Maximal length of a collection description.276 fn max_collection_description_length() -> u32 {277 MAX_COLLECTION_DESCRIPTION_LENGTH278 }279280 /// Maximal length of a token prefix.281 fn max_token_prefix_length() -> u32 {282 MAX_TOKEN_PREFIX_LENGTH283 }284285 /// Maximum admins per collection.286 fn collection_admins_limit() -> u32 {287 COLLECTION_ADMINS_LIMIT288 }289290 /// Maximal length of a property key.291 fn max_property_key_length() -> u32 {292 MAX_PROPERTY_KEY_LENGTH293 }294295 /// Maximal length of a property value.296 fn max_property_value_length() -> u32 {297 MAX_PROPERTY_VALUE_LENGTH298 }299300 /// A maximum number of token properties.301 fn max_properties_per_item() -> u32 {302 MAX_PROPERTIES_PER_ITEM303 }304305 /// Maximum size for all collection properties.306 fn max_collection_properties_size() -> u32 {307 MAX_COLLECTION_PROPERTIES_SIZE308 }309310 /// Maximum size of all token properties.311 fn max_token_properties_size() -> u32 {312 MAX_TOKEN_PROPERTIES_SIZE313 }314315 /// Default NFT collection limit.316 fn nft_default_collection_limits() -> CollectionLimits {317 CollectionLimits::with_default_limits(CollectionMode::NFT)318 }319320 /// Default RFT collection limit.321 fn rft_default_collection_limits() -> CollectionLimits {322 CollectionLimits::with_default_limits(CollectionMode::ReFungible)323 }324325 /// Default FT collection limit.326 fn ft_default_collection_limits() -> CollectionLimits {327 CollectionLimits::with_default_limits(CollectionMode::Fungible(0))328 }329 }330331 /// Type alias to Pallet, to be used by construct_runtime.332 #[pallet::call]333 impl<T: Config> Pallet<T> {334 /// Create a collection of tokens.335 ///336 /// Each Token may have multiple properties encoded as an array of bytes337 /// of certain length. The initial owner of the collection is set338 /// to the address that signed the transaction and can be changed later.339 ///340 /// Prefer the more advanced [`create_collection_ex`][`Pallet::create_collection_ex`] instead.341 ///342 /// # Permissions343 ///344 /// * Anyone - becomes the owner of the new collection.345 ///346 /// # Arguments347 ///348 /// * `collection_name`: Wide-character string with collection name349 /// (limit [`MAX_COLLECTION_NAME_LENGTH`]).350 /// * `collection_description`: Wide-character string with collection description351 /// (limit [`MAX_COLLECTION_DESCRIPTION_LENGTH`]).352 /// * `token_prefix`: Byte string containing the token prefix to mark a collection353 /// to which a token belongs (limit [`MAX_TOKEN_PREFIX_LENGTH`]).354 /// * `mode`: Type of items stored in the collection and type dependent data.355 ///356 /// returns collection ID357 ///358 /// Deprecated: `create_collection_ex` is more up-to-date and advanced, prefer it instead.359 #[pallet::call_index(0)]360 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]361 pub fn create_collection(362 origin: OriginFor<T>,363 collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,364 collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,365 token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,366 mode: CollectionMode,367 ) -> DispatchResult {368 let data: CreateCollectionData<T::CrossAccountId> = CreateCollectionData {369 name: collection_name,370 description: collection_description,371 token_prefix,372 mode,373 ..Default::default()374 };375 Self::create_collection_ex(origin, data)376 }377378 /// Create a collection with explicit parameters.379 ///380 /// Prefer it to the deprecated [`create_collection`][`Pallet::create_collection`] method.381 ///382 /// # Permissions383 ///384 /// * Anyone - becomes the owner of the new collection.385 ///386 /// # Arguments387 ///388 /// * `data`: Explicit data of a collection used for its creation.389 #[pallet::call_index(1)]390 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]391 pub fn create_collection_ex(392 origin: OriginFor<T>,393 data: CreateCollectionData<T::CrossAccountId>,394 ) -> DispatchResult {395 let sender = ensure_signed(origin)?;396397 // =========398 let sender = T::CrossAccountId::from_sub(sender);399 let _id = T::CollectionDispatch::create(sender.clone(), sender, data)?;400401 Ok(())402 }403404 /// Destroy a collection if no tokens exist within.405 ///406 /// # Permissions407 ///408 /// * Collection owner409 ///410 /// # Arguments411 ///412 /// * `collection_id`: Collection to destroy.413 #[pallet::call_index(2)]414 #[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]415 pub fn destroy_collection(416 origin: OriginFor<T>,417 collection_id: CollectionId,418 ) -> DispatchResult {419 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);420421 Self::destroy_collection_internal(sender, collection_id)422 }423424 /// Add an address to allow list.425 ///426 /// # Permissions427 ///428 /// * Collection owner429 /// * Collection admin430 ///431 /// # Arguments432 ///433 /// * `collection_id`: ID of the modified collection.434 /// * `address`: ID of the address to be added to the allowlist.435 #[pallet::call_index(3)]436 #[pallet::weight(<SelfWeightOf<T>>::add_to_allow_list())]437 pub fn add_to_allow_list(438 origin: OriginFor<T>,439 collection_id: CollectionId,440 address: T::CrossAccountId,441 ) -> DispatchResult {442 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {443 fail!(<pallet_common::Error<T>>::UnsupportedOperation);444 }445446 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);447 let collection = <CollectionHandle<T>>::try_get(collection_id)?;448 collection.check_is_internal()?;449450 <PalletCommon<T>>::toggle_allowlist(&collection, &sender, &address, true)?;451452 Ok(())453 }454455 /// Remove an address from allow list.456 ///457 /// # Permissions458 ///459 /// * Collection owner460 /// * Collection admin461 ///462 /// # Arguments463 ///464 /// * `collection_id`: ID of the modified collection.465 /// * `address`: ID of the address to be removed from the allowlist.466 #[pallet::call_index(4)]467 #[pallet::weight(<SelfWeightOf<T>>::remove_from_allow_list())]468 pub fn remove_from_allow_list(469 origin: OriginFor<T>,470 collection_id: CollectionId,471 address: T::CrossAccountId,472 ) -> DispatchResult {473 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {474 fail!(<pallet_common::Error<T>>::UnsupportedOperation);475 }476477 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);478 let collection = <CollectionHandle<T>>::try_get(collection_id)?;479 collection.check_is_internal()?;480481 <PalletCommon<T>>::toggle_allowlist(&collection, &sender, &address, false)?;482483 Ok(())484 }485486 /// Change the owner of the collection.487 ///488 /// # Permissions489 ///490 /// * Collection owner491 ///492 /// # Arguments493 ///494 /// * `collection_id`: ID of the modified collection.495 /// * `new_owner`: ID of the account that will become the owner.496 #[pallet::call_index(5)]497 #[pallet::weight(<SelfWeightOf<T>>::change_collection_owner())]498 pub fn change_collection_owner(499 origin: OriginFor<T>,500 collection_id: CollectionId,501 new_owner: T::AccountId,502 ) -> DispatchResult {503 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {504 fail!(<pallet_common::Error<T>>::UnsupportedOperation);505 }506 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);507 let new_owner = T::CrossAccountId::from_sub(new_owner);508 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;509 target_collection.change_owner(sender, new_owner)510 }511512 /// Add an admin to a collection.513 ///514 /// NFT Collection can be controlled by multiple admin addresses515 /// (some which can also be servers, for example). Admins can issue516 /// and burn NFTs, as well as add and remove other admins,517 /// but cannot change NFT or Collection ownership.518 ///519 /// # Permissions520 ///521 /// * Collection owner522 /// * Collection admin523 ///524 /// # Arguments525 ///526 /// * `collection_id`: ID of the Collection to add an admin for.527 /// * `new_admin`: Address of new admin to add.528 #[pallet::call_index(6)]529 #[pallet::weight(<SelfWeightOf<T>>::add_collection_admin())]530 pub fn add_collection_admin(531 origin: OriginFor<T>,532 collection_id: CollectionId,533 new_admin_id: T::CrossAccountId,534 ) -> DispatchResult {535 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {536 fail!(<pallet_common::Error<T>>::UnsupportedOperation);537 }538 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);539 let collection = <CollectionHandle<T>>::try_get(collection_id)?;540 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)541 }542543 /// Remove admin of a collection.544 ///545 /// An admin address can remove itself. List of admins may become empty,546 /// in which case only Collection Owner will be able to add an Admin.547 ///548 /// # Permissions549 ///550 /// * Collection owner551 /// * Collection admin552 ///553 /// # Arguments554 ///555 /// * `collection_id`: ID of the collection to remove the admin for.556 /// * `account_id`: Address of the admin to remove.557 #[pallet::call_index(7)]558 #[pallet::weight(<SelfWeightOf<T>>::remove_collection_admin())]559 pub fn remove_collection_admin(560 origin: OriginFor<T>,561 collection_id: CollectionId,562 account_id: T::CrossAccountId,563 ) -> DispatchResult {564 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {565 fail!(<pallet_common::Error<T>>::UnsupportedOperation);566 }567 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);568 let collection = <CollectionHandle<T>>::try_get(collection_id)?;569 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)570 }571572 /// Set (invite) a new collection sponsor.573 ///574 /// If successful, confirmation from the sponsor-to-be will be pending.575 ///576 /// # Permissions577 ///578 /// * Collection owner579 /// * Collection admin580 ///581 /// # Arguments582 ///583 /// * `collection_id`: ID of the modified collection.584 /// * `new_sponsor`: ID of the account of the sponsor-to-be.585 #[pallet::call_index(8)]586 #[pallet::weight(<SelfWeightOf<T>>::set_collection_sponsor())]587 pub fn set_collection_sponsor(588 origin: OriginFor<T>,589 collection_id: CollectionId,590 new_sponsor: T::AccountId,591 ) -> DispatchResult {592 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {593 fail!(<pallet_common::Error<T>>::UnsupportedOperation);594 }595 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);596 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;597 target_collection.set_sponsor(&sender, new_sponsor.clone())598 }599600 /// Confirm own sponsorship of a collection, becoming the sponsor.601 ///602 /// An invitation must be pending, see [`set_collection_sponsor`][`Pallet::set_collection_sponsor`].603 /// Sponsor can pay the fees of a transaction instead of the sender,604 /// but only within specified limits.605 ///606 /// # Permissions607 ///608 /// * Sponsor-to-be609 ///610 /// # Arguments611 ///612 /// * `collection_id`: ID of the collection with the pending sponsor.613 #[pallet::call_index(9)]614 #[pallet::weight(<SelfWeightOf<T>>::confirm_sponsorship())]615 pub fn confirm_sponsorship(616 origin: OriginFor<T>,617 collection_id: CollectionId,618 ) -> DispatchResult {619 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {620 fail!(<pallet_common::Error<T>>::UnsupportedOperation);621 }622 let sender = ensure_signed(origin)?;623 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;624 target_collection.confirm_sponsorship(&sender)625 }626627 /// Remove a collection's a sponsor, making everyone pay for their own transactions.628 ///629 /// # Permissions630 ///631 /// * Collection owner632 ///633 /// # Arguments634 ///635 /// * `collection_id`: ID of the collection with the sponsor to remove.636 #[pallet::call_index(10)]637 #[pallet::weight(<SelfWeightOf<T>>::remove_collection_sponsor())]638 pub fn remove_collection_sponsor(639 origin: OriginFor<T>,640 collection_id: CollectionId,641 ) -> DispatchResult {642 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {643 fail!(<pallet_common::Error<T>>::UnsupportedOperation);644 }645 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);646 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;647 target_collection.remove_sponsor(&sender)648 }649650 /// Mint an item within a collection.651 ///652 /// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].653 ///654 /// # Permissions655 ///656 /// * Collection owner657 /// * Collection admin658 /// * Anyone if659 /// * Allow List is enabled, and660 /// * Address is added to allow list, and661 /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])662 ///663 /// # Arguments664 ///665 /// * `collection_id`: ID of the collection to which an item would belong.666 /// * `owner`: Address of the initial owner of the item.667 /// * `data`: Token data describing the item to store on chain.668 #[pallet::call_index(11)]669 #[pallet::weight(T::CommonWeightInfo::create_item(data))]670 pub fn create_item(671 origin: OriginFor<T>,672 collection_id: CollectionId,673 owner: T::CrossAccountId,674 data: CreateItemData,675 ) -> DispatchResultWithPostInfo {676 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);677 let budget = budget::Value::new(NESTING_BUDGET);678679 dispatch_tx::<T, _>(collection_id, |d| {680 d.create_item(sender, owner, data, &budget)681 })682 }683684 /// Create multiple items within a collection.685 ///686 /// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].687 ///688 /// # Permissions689 ///690 /// * Collection owner691 /// * Collection admin692 /// * Anyone if693 /// * Allow List is enabled, and694 /// * Address is added to the allow list, and695 /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])696 ///697 /// # Arguments698 ///699 /// * `collection_id`: ID of the collection to which the tokens would belong.700 /// * `owner`: Address of the initial owner of the tokens.701 /// * `items_data`: Vector of data describing each item to be created.702 #[pallet::call_index(12)]703 #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data))]704 pub fn create_multiple_items(705 origin: OriginFor<T>,706 collection_id: CollectionId,707 owner: T::CrossAccountId,708 items_data: Vec<CreateItemData>,709 ) -> DispatchResultWithPostInfo {710 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);711 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);712 let budget = budget::Value::new(NESTING_BUDGET);713714 dispatch_tx::<T, _>(collection_id, |d| {715 d.create_multiple_items(sender, owner, items_data, &budget)716 })717 }718719 /// Add or change collection properties.720 ///721 /// # Permissions722 ///723 /// * Collection owner724 /// * Collection admin725 ///726 /// # Arguments727 ///728 /// * `collection_id`: ID of the modified collection.729 /// * `properties`: Vector of key-value pairs stored as the collection's metadata.730 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.731 #[pallet::call_index(13)]732 #[pallet::weight(T::CommonWeightInfo::set_collection_properties(properties.len() as u32))]733 pub fn set_collection_properties(734 origin: OriginFor<T>,735 collection_id: CollectionId,736 properties: Vec<Property>,737 ) -> DispatchResultWithPostInfo {738 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);739740 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);741742 dispatch_tx::<T, _>(collection_id, |d| {743 d.set_collection_properties(sender, properties)744 })745 }746747 /// Delete specified collection properties.748 ///749 /// # Permissions750 ///751 /// * Collection Owner752 /// * Collection Admin753 ///754 /// # Arguments755 ///756 /// * `collection_id`: ID of the modified collection.757 /// * `property_keys`: Vector of keys of the properties to be deleted.758 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.759 #[pallet::call_index(14)]760 #[pallet::weight(T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32))]761 pub fn delete_collection_properties(762 origin: OriginFor<T>,763 collection_id: CollectionId,764 property_keys: Vec<PropertyKey>,765 ) -> DispatchResultWithPostInfo {766 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);767768 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);769770 dispatch_tx::<T, _>(collection_id, |d| {771 d.delete_collection_properties(&sender, property_keys)772 })773 }774775 /// Add or change token properties according to collection's permissions.776 /// Currently properties only work with NFTs.777 ///778 /// # Permissions779 ///780 /// * Depends on collection's token property permissions and specified property mutability:781 /// * Collection owner782 /// * Collection admin783 /// * Token owner784 ///785 /// See [`set_token_property_permissions`][`Pallet::set_token_property_permissions`].786 ///787 /// # Arguments788 ///789 /// * `collection_id: ID of the collection to which the token belongs.790 /// * `token_id`: ID of the modified token.791 /// * `properties`: Vector of key-value pairs stored as the token's metadata.792 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.793 #[pallet::call_index(15)]794 #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32))]795 pub fn set_token_properties(796 origin: OriginFor<T>,797 collection_id: CollectionId,798 token_id: TokenId,799 properties: Vec<Property>,800 ) -> DispatchResultWithPostInfo {801 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);802803 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);804 let budget = budget::Value::new(NESTING_BUDGET);805806 dispatch_tx::<T, _>(collection_id, |d| {807 d.set_token_properties(sender, token_id, properties, &budget)808 })809 }810811 /// Delete specified token properties. Currently properties only work with NFTs.812 ///813 /// # Permissions814 ///815 /// * Depends on collection's token property permissions and specified property mutability:816 /// * Collection owner817 /// * Collection admin818 /// * Token owner819 ///820 /// # Arguments821 ///822 /// * `collection_id`: ID of the collection to which the token belongs.823 /// * `token_id`: ID of the modified token.824 /// * `property_keys`: Vector of keys of the properties to be deleted.825 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.826 #[pallet::call_index(16)]827 #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32))]828 pub fn delete_token_properties(829 origin: OriginFor<T>,830 collection_id: CollectionId,831 token_id: TokenId,832 property_keys: Vec<PropertyKey>,833 ) -> DispatchResultWithPostInfo {834 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);835836 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);837 let budget = budget::Value::new(NESTING_BUDGET);838839 dispatch_tx::<T, _>(collection_id, |d| {840 d.delete_token_properties(sender, token_id, property_keys, &budget)841 })842 }843844 /// Add or change token property permissions of a collection.845 ///846 /// Without a permission for a particular key, a property with that key847 /// cannot be created in a token.848 ///849 /// # Permissions850 ///851 /// * Collection owner852 /// * Collection admin853 ///854 /// # Arguments855 ///856 /// * `collection_id`: ID of the modified collection.857 /// * `property_permissions`: Vector of permissions for property keys.858 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.859 #[pallet::call_index(17)]860 #[pallet::weight(T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32))]861 pub fn set_token_property_permissions(862 origin: OriginFor<T>,863 collection_id: CollectionId,864 property_permissions: Vec<PropertyKeyPermission>,865 ) -> DispatchResultWithPostInfo {866 ensure!(!property_permissions.is_empty(), Error::<T>::EmptyArgument);867868 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);869870 dispatch_tx::<T, _>(collection_id, |d| {871 d.set_token_property_permissions(&sender, property_permissions)872 })873 }874875 /// Create multiple items within a collection with explicitly specified initial parameters.876 ///877 /// # Permissions878 ///879 /// * Collection owner880 /// * Collection admin881 /// * Anyone if882 /// * Allow List is enabled, and883 /// * Address is added to allow list, and884 /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])885 ///886 /// # Arguments887 ///888 /// * `collection_id`: ID of the collection to which the tokens would belong.889 /// * `data`: Explicit item creation data.890 #[pallet::call_index(18)]891 #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data))]892 pub fn create_multiple_items_ex(893 origin: OriginFor<T>,894 collection_id: CollectionId,895 data: CreateItemExData<T::CrossAccountId>,896 ) -> DispatchResultWithPostInfo {897 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);898 let budget = budget::Value::new(NESTING_BUDGET);899900 dispatch_tx::<T, _>(collection_id, |d| {901 d.create_multiple_items_ex(sender, data, &budget)902 })903 }904905 /// Completely allow or disallow transfers for a particular collection.906 ///907 /// # Permissions908 ///909 /// * Collection owner910 ///911 /// # Arguments912 ///913 /// * `collection_id`: ID of the collection.914 /// * `value`: New value of the flag, are transfers allowed?915 #[pallet::call_index(19)]916 #[pallet::weight(<SelfWeightOf<T>>::set_transfers_enabled_flag())]917 pub fn set_transfers_enabled_flag(918 origin: OriginFor<T>,919 collection_id: CollectionId,920 value: bool,921 ) -> DispatchResult {922 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {923 fail!(<pallet_common::Error<T>>::UnsupportedOperation);924 }925 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);926 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;927 target_collection.check_is_internal()?;928 target_collection.check_is_owner(&sender)?;929930 // =========931932 target_collection.limits.transfers_enabled = Some(value);933 target_collection.save()934 }935936 /// Destroy an item.937 ///938 /// # Permissions939 ///940 /// * Collection owner941 /// * Collection admin942 /// * Current item owner943 ///944 /// # Arguments945 ///946 /// * `collection_id`: ID of the collection to which the item belongs.947 /// * `item_id`: ID of item to burn.948 /// * `value`: Number of pieces of the item to destroy.949 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.950 /// * Fungible Mode: The desired number of pieces to burn.951 /// * Re-Fungible Mode: The desired number of pieces to burn.952 #[pallet::call_index(20)]953 #[pallet::weight(T::CommonWeightInfo::burn_item())]954 pub fn burn_item(955 origin: OriginFor<T>,956 collection_id: CollectionId,957 item_id: TokenId,958 value: u128,959 ) -> DispatchResultWithPostInfo {960 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);961962 let post_info =963 dispatch_tx::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))?;964 if value == 1 {965 <NftTransferBasket<T>>::remove(collection_id, item_id);966 <NftApproveBasket<T>>::remove(collection_id, item_id);967 }968 // Those maps should be cleared only if token disappears completly, need to move this part of logic to pallets?969 // <FungibleApproveBasket<T>>::remove(collection_id, sender.as_sub());970 // <RefungibleApproveBasket<T>>::remove((collection_id, item_id, sender.as_sub()));971 Ok(post_info)972 }973974 /// Destroy a token on behalf of the owner as a non-owner account.975 ///976 /// See also: [`approve`][`Pallet::approve`].977 ///978 /// After this method executes, one approval is removed from the total so that979 /// the approved address will not be able to transfer this item again from this owner.980 ///981 /// # Permissions982 ///983 /// * Collection owner984 /// * Collection admin985 /// * Current token owner986 /// * Address approved by current item owner987 ///988 /// # Arguments989 ///990 /// * `from`: The owner of the burning item.991 /// * `collection_id`: ID of the collection to which the item belongs.992 /// * `item_id`: ID of item to burn.993 /// * `value`: Number of pieces to burn.994 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.995 /// * Fungible Mode: The desired number of pieces to burn.996 /// * Re-Fungible Mode: The desired number of pieces to burn.997 #[pallet::call_index(21)]998 #[pallet::weight(T::CommonWeightInfo::burn_from())]999 pub fn burn_from(1000 origin: OriginFor<T>,1001 collection_id: CollectionId,1002 from: T::CrossAccountId,1003 item_id: TokenId,1004 value: u128,1005 ) -> DispatchResultWithPostInfo {1006 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1007 let budget = budget::Value::new(NESTING_BUDGET);10081009 dispatch_tx::<T, _>(collection_id, |d| {1010 d.burn_from(sender, from, item_id, value, &budget)1011 })1012 }10131014 /// Change ownership of the token.1015 ///1016 /// # Permissions1017 ///1018 /// * Collection owner1019 /// * Collection admin1020 /// * Current token owner1021 ///1022 /// # Arguments1023 ///1024 /// * `recipient`: Address of token recipient.1025 /// * `collection_id`: ID of the collection the item belongs to.1026 /// * `item_id`: ID of the item.1027 /// * Non-Fungible Mode: Required.1028 /// * Fungible Mode: Ignored.1029 /// * Re-Fungible Mode: Required.1030 ///1031 /// * `value`: Amount to transfer.1032 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1033 /// * Fungible Mode: The desired number of pieces to transfer.1034 /// * Re-Fungible Mode: The desired number of pieces to transfer.1035 #[pallet::call_index(22)]1036 #[pallet::weight(T::CommonWeightInfo::transfer())]1037 pub fn transfer(1038 origin: OriginFor<T>,1039 recipient: T::CrossAccountId,1040 collection_id: CollectionId,1041 item_id: TokenId,1042 value: u128,1043 ) -> DispatchResultWithPostInfo {1044 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1045 let budget = budget::Value::new(NESTING_BUDGET);10461047 dispatch_tx::<T, _>(collection_id, |d| {1048 d.transfer(sender, recipient, item_id, value, &budget)1049 })1050 }10511052 /// Allow a non-permissioned address to transfer or burn an item.1053 ///1054 /// # Permissions1055 ///1056 /// * Collection owner1057 /// * Collection admin1058 /// * Current item owner1059 ///1060 /// # Arguments1061 ///1062 /// * `spender`: Account to be approved to make specific transactions on non-owned tokens.1063 /// * `collection_id`: ID of the collection the item belongs to.1064 /// * `item_id`: ID of the item transactions on which are now approved.1065 /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).1066 /// Set to 0 to revoke the approval.1067 #[pallet::call_index(23)]1068 #[pallet::weight(T::CommonWeightInfo::approve())]1069 pub fn approve(1070 origin: OriginFor<T>,1071 spender: T::CrossAccountId,1072 collection_id: CollectionId,1073 item_id: TokenId,1074 amount: u128,1075 ) -> DispatchResultWithPostInfo {1076 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);10771078 dispatch_tx::<T, _>(collection_id, |d| {1079 d.approve(sender, spender, item_id, amount)1080 })1081 }10821083 /// Allow a non-permissioned address to transfer or burn an item from owner's eth mirror.1084 ///1085 /// # Permissions1086 ///1087 /// * Collection owner1088 /// * Collection admin1089 /// * Current item owner1090 ///1091 /// # Arguments1092 ///1093 /// * `from`: Owner's account eth mirror1094 /// * `to`: Account to be approved to make specific transactions on non-owned tokens.1095 /// * `collection_id`: ID of the collection the item belongs to.1096 /// * `item_id`: ID of the item transactions on which are now approved.1097 /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).1098 /// Set to 0 to revoke the approval.1099 #[pallet::call_index(24)]1100 #[pallet::weight(T::CommonWeightInfo::approve_from())]1101 pub fn approve_from(1102 origin: OriginFor<T>,1103 from: T::CrossAccountId,1104 to: T::CrossAccountId,1105 collection_id: CollectionId,1106 item_id: TokenId,1107 amount: u128,1108 ) -> DispatchResultWithPostInfo {1109 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);11101111 dispatch_tx::<T, _>(collection_id, |d| {1112 d.approve_from(sender, from, to, item_id, amount)1113 })1114 }11151116 /// Change ownership of an item on behalf of the owner as a non-owner account.1117 ///1118 /// See the [`approve`][`Pallet::approve`] method for additional information.1119 ///1120 /// After this method executes, one approval is removed from the total so that1121 /// the approved address will not be able to transfer this item again from this owner.1122 ///1123 /// # Permissions1124 ///1125 /// * Collection owner1126 /// * Collection admin1127 /// * Current item owner1128 /// * Address approved by current item owner1129 ///1130 /// # Arguments1131 ///1132 /// * `from`: Address that currently owns the token.1133 /// * `recipient`: Address of the new token-owner-to-be.1134 /// * `collection_id`: ID of the collection the item.1135 /// * `item_id`: ID of the item to be transferred.1136 /// * `value`: Amount to transfer.1137 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1138 /// * Fungible Mode: The desired number of pieces to transfer.1139 /// * Re-Fungible Mode: The desired number of pieces to transfer.1140 #[pallet::call_index(25)]1141 #[pallet::weight(T::CommonWeightInfo::transfer_from())]1142 pub fn transfer_from(1143 origin: OriginFor<T>,1144 from: T::CrossAccountId,1145 recipient: T::CrossAccountId,1146 collection_id: CollectionId,1147 item_id: TokenId,1148 value: u128,1149 ) -> DispatchResultWithPostInfo {1150 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1151 let budget = budget::Value::new(NESTING_BUDGET);11521153 dispatch_tx::<T, _>(collection_id, |d| {1154 d.transfer_from(sender, from, recipient, item_id, value, &budget)1155 })1156 }11571158 /// Set specific limits of a collection. Empty, or None fields mean chain default.1159 ///1160 /// # Permissions1161 ///1162 /// * Collection owner1163 /// * Collection admin1164 ///1165 /// # Arguments1166 ///1167 /// * `collection_id`: ID of the modified collection.1168 /// * `new_limit`: New limits of the collection. Fields that are not set (None)1169 /// will not overwrite the old ones.1170 #[pallet::call_index(26)]1171 #[pallet::weight(<SelfWeightOf<T>>::set_collection_limits())]1172 pub fn set_collection_limits(1173 origin: OriginFor<T>,1174 collection_id: CollectionId,1175 new_limit: CollectionLimits,1176 ) -> DispatchResult {1177 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1178 fail!(<pallet_common::Error<T>>::UnsupportedOperation);1179 }1180 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1181 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1182 <PalletCommon<T>>::update_limits(&sender, &mut target_collection, new_limit)1183 }11841185 /// Set specific permissions of a collection. Empty, or None fields mean chain default.1186 ///1187 /// # Permissions1188 ///1189 /// * Collection owner1190 /// * Collection admin1191 ///1192 /// # Arguments1193 ///1194 /// * `collection_id`: ID of the modified collection.1195 /// * `new_permission`: New permissions of the collection. Fields that are not set (None)1196 /// will not overwrite the old ones.1197 #[pallet::call_index(27)]1198 #[pallet::weight(<SelfWeightOf<T>>::set_collection_limits())]1199 pub fn set_collection_permissions(1200 origin: OriginFor<T>,1201 collection_id: CollectionId,1202 new_permission: CollectionPermissions,1203 ) -> DispatchResult {1204 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1205 fail!(<pallet_common::Error<T>>::UnsupportedOperation);1206 }1207 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1208 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1209 <PalletCommon<T>>::update_permissions(&sender, &mut target_collection, new_permission)1210 }12111212 /// Re-partition a refungible token, while owning all of its parts/pieces.1213 ///1214 /// # Permissions1215 ///1216 /// * Token owner (must own every part)1217 ///1218 /// # Arguments1219 ///1220 /// * `collection_id`: ID of the collection the RFT belongs to.1221 /// * `token_id`: ID of the RFT.1222 /// * `amount`: New number of parts/pieces into which the token shall be partitioned.1223 #[pallet::call_index(28)]1224 #[pallet::weight(T::RefungibleExtensionsWeightInfo::repartition())]1225 pub fn repartition(1226 origin: OriginFor<T>,1227 collection_id: CollectionId,1228 token_id: TokenId,1229 amount: u128,1230 ) -> DispatchResultWithPostInfo {1231 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1232 dispatch_tx::<T, _>(collection_id, |d| {1233 if let Some(refungible_extensions) = d.refungible_extensions() {1234 refungible_extensions.repartition(&sender, token_id, amount)1235 } else {1236 fail!(<Error<T>>::RepartitionCalledOnNonRefungibleCollection)1237 }1238 })1239 }12401241 /// Sets or unsets the approval of a given operator.1242 ///1243 /// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.1244 ///1245 /// # Arguments1246 ///1247 /// * `owner`: Token owner1248 /// * `operator`: Operator1249 /// * `approve`: Should operator status be granted or revoked?1250 #[pallet::call_index(29)]1251 #[pallet::weight(T::CommonWeightInfo::set_allowance_for_all())]1252 pub fn set_allowance_for_all(1253 origin: OriginFor<T>,1254 collection_id: CollectionId,1255 operator: T::CrossAccountId,1256 approve: bool,1257 ) -> DispatchResultWithPostInfo {1258 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1259 dispatch_tx::<T, _>(collection_id, |d| {1260 d.set_allowance_for_all(sender, operator, approve)1261 })1262 }12631264 /// Repairs a collection if the data was somehow corrupted.1265 ///1266 /// # Arguments1267 ///1268 /// * `collection_id`: ID of the collection to repair.1269 #[pallet::call_index(30)]1270 #[pallet::weight(<SelfWeightOf<T>>::force_repair_collection())]1271 pub fn force_repair_collection(1272 origin: OriginFor<T>,1273 collection_id: CollectionId,1274 ) -> DispatchResult {1275 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1276 fail!(<pallet_common::Error<T>>::UnsupportedOperation);1277 }1278 ensure_root(origin)?;1279 <PalletCommon<T>>::repair_collection(collection_id)1280 }12811282 /// Repairs a token if the data was somehow corrupted.1283 ///1284 /// # Arguments1285 ///1286 /// * `collection_id`: ID of the collection the item belongs to.1287 /// * `item_id`: ID of the item.1288 #[pallet::call_index(31)]1289 #[pallet::weight(T::CommonWeightInfo::force_repair_item())]1290 pub fn force_repair_item(1291 origin: OriginFor<T>,1292 collection_id: CollectionId,1293 item_id: TokenId,1294 ) -> DispatchResultWithPostInfo {1295 ensure_root(origin)?;1296 dispatch_tx::<T, _>(collection_id, |d| d.repair_item(item_id))1297 }1298 }12991300 impl<T: Config> Pallet<T> {1301 /// Force set `sponsor` for `collection`.1302 ///1303 /// Differs from [`set_collection_sponsor`][`Pallet::set_collection_sponsor`] in that confirmation1304 /// from the `sponsor` is not required.1305 ///1306 /// # Arguments1307 ///1308 /// * `sponsor`: ID of the account of the sponsor-to-be.1309 /// * `collection_id`: ID of the modified collection.1310 pub fn force_set_sponsor(1311 sponsor: T::AccountId,1312 collection_id: CollectionId,1313 ) -> DispatchResult {1314 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1315 target_collection.force_set_sponsor(sponsor)1316 }13171318 /// Force remove `sponsor` for `collection`.1319 ///1320 /// Differs from `remove_sponsor` in that1321 /// it doesn't require consent from the `owner` of the collection.1322 ///1323 /// # Arguments1324 ///1325 /// * `collection_id`: ID of the modified collection.1326 pub fn force_remove_collection_sponsor(collection_id: CollectionId) -> DispatchResult {1327 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1328 target_collection.force_remove_sponsor()1329 }13301331 #[inline(always)]1332 pub(crate) fn destroy_collection_internal(1333 sender: T::CrossAccountId,1334 collection_id: CollectionId,1335 ) -> DispatchResult {1336 T::CollectionDispatch::destroy(sender, collection_id)?;13371338 // TODO: basket cleanup should be moved elsewhere1339 // Maybe runtime dispatch.rs should perform it?13401341 let _ = <NftTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1342 let _ = <FungibleTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1343 let _ = <ReFungibleTransferBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);13441345 let _ = <NftApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1346 let _ = <FungibleApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1347 let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);13481349 Ok(())1350 }1351 }1352}1// 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//! # Unique Pallet18//!19//! A pallet governing Unique transactions.20//!21//! - [`Config`]22//! - [`Call`]23//! - [`Pallet`]24//!25//! ## Overview26//!27//! The Unique pallet's purpose is to be the primary interface between28//! external users and the inner structure of the Unique chains.29//!30//! It also contains an implementation of [`CollectionHelpers`][`eth`],31//! an Ethereum contract dealing with collection operations.32//!33//! ## Interface34//!35//! ### Dispatchables36//!37//! - `create_collection` - Create a collection of tokens. **Deprecated**, use `create_collection_ex`.38//! - `create_collection_ex` - Create a collection of tokens with explicit parameters.39//! - `destroy_collection` - Destroy a collection if no tokens exist within.40//! - `add_to_allow_list` - Add an address to allow list.41//! - `remove_from_allow_list` - Remove an address from allow list.42//! - `change_collection_owner` - Change the owner of the collection.43//! - `add_collection_admin` - Add an admin to a collection.44//! - `remove_collection_admin` - Remove admin of a collection.45//! - `set_collection_sponsor` - Invite a new collection sponsor.46//! - `confirm_sponsorship` - Confirm own sponsorship of a collection, becoming the sponsor.47//! - `remove_collection_sponsor` - Remove a sponsor from a collection.48//! - `create_item` - Create an item within a collection.49//! - `create_multiple_items` - Create multiple items within a collection.50//! - `set_collection_properties` - Add or change collection properties.51//! - `delete_collection_properties` - Delete specified collection properties.52//! - `set_token_properties` - Add or change token properties.53//! - `delete_token_properties` - Delete token properties.54//! - `set_token_property_permissions` - Add or change token property permissions of a collection.55//! - `create_multiple_items_ex` - Create multiple items within a collection with explicitly specified initial parameters.56//! - `set_transfers_enabled_flag` - Completely allow or disallow transfers for a particular collection.57//! - `burn_item` - Destroy an item.58//! - `burn_from` - Destroy an item on behalf of the owner as a non-owner account.59//! - `transfer` - Change ownership of the token.60//! - `transfer_from` - Change ownership of the token on behalf of the owner as a non-owner account.61//! - `approve` - Allow a non-permissioned address to transfer or burn an item.62//! - `set_collection_limits` - Set specific limits of a collection.63//! - `set_collection_permissions` - Set specific permissions of a collection.64//! - `repartition` - Re-partition a refungible token, while owning all of its parts.6566#![recursion_limit = "1024"]67#![cfg_attr(not(feature = "std"), no_std)]68#![allow(69 clippy::too_many_arguments,70 clippy::unnecessary_mut_passed,71 clippy::unused_unit72)]7374extern crate alloc;7576use frame_support::pallet_prelude::*;77use frame_system::pallet_prelude::*;78pub use pallet::*;79pub mod eth;8081#[cfg(feature = "runtime-benchmarks")]82pub mod benchmarking;83pub mod weights;8485#[frame_support::pallet]86pub mod pallet {87 use frame_support::{88 dispatch::{DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo},89 ensure, fail,90 storage::Key,91 BoundedVec,92 };93 use frame_system::{ensure_root, ensure_signed};94 use pallet_common::{95 dispatch::{dispatch_tx, CollectionDispatch},96 CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,97 };98 use pallet_evm::account::CrossAccountId;99 use pallet_structure::weights::WeightInfo as StructureWeightInfo;100 use scale_info::TypeInfo;101 use sp_std::{vec, vec::Vec};102 use up_data_structs::{103 budget, CollectionId, CollectionLimits, CollectionMode, CollectionPermissions,104 CreateCollectionData, CreateItemData, CreateItemExData, Property, PropertyKey,105 PropertyKeyPermission, TokenId, COLLECTION_ADMINS_LIMIT, MAX_COLLECTION_DESCRIPTION_LENGTH,106 MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_PROPERTIES_SIZE, MAX_PROPERTIES_PER_ITEM,107 MAX_PROPERTY_KEY_LENGTH, MAX_PROPERTY_VALUE_LENGTH, MAX_TOKEN_PREFIX_LENGTH,108 MAX_TOKEN_PROPERTIES_SIZE,109 };110 use weights::WeightInfo;111112 use super::*;113114 /// Errors for the common Unique transactions.115 #[pallet::error]116 pub enum Error<T> {117 /// Decimal_points parameter must be lower than [`up_data_structs::MAX_DECIMAL_POINTS`].118 CollectionDecimalPointLimitExceeded,119 /// Length of items properties must be greater than 0.120 EmptyArgument,121 /// Repertition is only supported by refungible collection.122 RepartitionCalledOnNonRefungibleCollection,123 }124125 /// Configuration trait of this pallet.126 #[pallet::config]127 pub trait Config: frame_system::Config + pallet_common::Config + Sized + TypeInfo {128 /// Weight information for extrinsics in this pallet.129 type WeightInfo: WeightInfo;130131 /// Weight information for common pallet operations.132 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;133134 type StructureWeightInfo: StructureWeightInfo;135136 /// Weight info information for extra refungible pallet operations.137 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;138 }139140 #[pallet::pallet]141 pub struct Pallet<T>(_);142143 pub type SelfWeightOf<T> = <T as Config>::WeightInfo;144145 // # Used definitions146 //147 // ## User control levels148 //149 // chain-controlled - key is uncontrolled by user150 // i.e autoincrementing index151 // can use non-cryptographic hash152 // real - key is controlled by user153 // but it is hard to generate enough colliding values, i.e owner of signed txs154 // can use non-cryptographic hash155 // controlled - key is completly controlled by users156 // i.e maps with mutable keys157 // should use cryptographic hash158 //159 // ## User control level downgrade reasons160 //161 // ?1 - chain-controlled -> controlled162 // collections/tokens can be destroyed, resulting in massive holes163 // ?2 - chain-controlled -> controlled164 // same as ?1, but can be only added, resulting in easier exploitation165 // ?3 - real -> controlled166 // no confirmation required, so addresses can be easily generated167168 //#region Private members169 /// Used for migrations170 #[pallet::storage]171 pub type ChainVersion<T> = StorageValue<_, u64, ValueQuery>;172 //#endregion173174 //#region Tokens transfer sponosoring rate limit baskets175 /// (Collection id (controlled?2), who created (real))176 /// TODO: Off chain worker should remove from this map when collection gets removed177 #[pallet::storage]178 #[pallet::getter(fn create_item_busket)]179 pub type CreateItemBasket<T: Config> = StorageMap<180 Hasher = Blake2_128Concat,181 Key = (CollectionId, T::AccountId),182 Value = BlockNumberFor<T>,183 QueryKind = OptionQuery,184 >;185 /// Collection id (controlled?2), token id (controlled?2)186 #[pallet::storage]187 #[pallet::getter(fn nft_transfer_basket)]188 pub type NftTransferBasket<T: Config> = StorageDoubleMap<189 Hasher1 = Blake2_128Concat,190 Key1 = CollectionId,191 Hasher2 = Blake2_128Concat,192 Key2 = TokenId,193 Value = BlockNumberFor<T>,194 QueryKind = OptionQuery,195 >;196 /// Collection id (controlled?2), owning user (real)197 #[pallet::storage]198 #[pallet::getter(fn fungible_transfer_basket)]199 pub type FungibleTransferBasket<T: Config> = StorageDoubleMap<200 Hasher1 = Blake2_128Concat,201 Key1 = CollectionId,202 Hasher2 = Twox64Concat,203 Key2 = T::AccountId,204 Value = BlockNumberFor<T>,205 QueryKind = OptionQuery,206 >;207 /// Collection id (controlled?2), token id (controlled?2)208 #[pallet::storage]209 #[pallet::getter(fn refungible_transfer_basket)]210 pub type ReFungibleTransferBasket<T: Config> = StorageNMap<211 Key = (212 Key<Blake2_128Concat, CollectionId>,213 Key<Blake2_128Concat, TokenId>,214 Key<Twox64Concat, T::AccountId>,215 ),216 Value = BlockNumberFor<T>,217 QueryKind = OptionQuery,218 >;219 //#endregion220221 /// Last sponsoring of token property setting // todo:doc rephrase this and the following222 #[pallet::storage]223 #[pallet::getter(fn token_property_basket)]224 pub type TokenPropertyBasket<T: Config> = StorageDoubleMap<225 Hasher1 = Blake2_128Concat,226 Key1 = CollectionId,227 Hasher2 = Blake2_128Concat,228 Key2 = TokenId,229 Value = BlockNumberFor<T>,230 QueryKind = OptionQuery,231 >;232233 /// Last sponsoring of NFT approval in a collection234 #[pallet::storage]235 #[pallet::getter(fn nft_approve_basket)]236 pub type NftApproveBasket<T: Config> = StorageDoubleMap<237 Hasher1 = Blake2_128Concat,238 Key1 = CollectionId,239 Hasher2 = Blake2_128Concat,240 Key2 = TokenId,241 Value = BlockNumberFor<T>,242 QueryKind = OptionQuery,243 >;244 /// Last sponsoring of fungible tokens approval in a collection245 #[pallet::storage]246 #[pallet::getter(fn fungible_approve_basket)]247 pub type FungibleApproveBasket<T: Config> = StorageDoubleMap<248 Hasher1 = Blake2_128Concat,249 Key1 = CollectionId,250 Hasher2 = Twox64Concat,251 Key2 = T::AccountId,252 Value = BlockNumberFor<T>,253 QueryKind = OptionQuery,254 >;255 /// Last sponsoring of RFT approval in a collection256 #[pallet::storage]257 #[pallet::getter(fn refungible_approve_basket)]258 pub type RefungibleApproveBasket<T: Config> = StorageNMap<259 Key = (260 Key<Blake2_128Concat, CollectionId>,261 Key<Blake2_128Concat, TokenId>,262 Key<Twox64Concat, T::AccountId>,263 ),264 Value = BlockNumberFor<T>,265 QueryKind = OptionQuery,266 >;267268 #[pallet::extra_constants]269 impl<T: Config> Pallet<T> {270 /// A maximum number of levels of depth in the token nesting tree.271 fn nesting_budget() -> u32 {272 5273 }274275 /// Maximal length of a collection name.276 fn max_collection_name_length() -> u32 {277 MAX_COLLECTION_NAME_LENGTH278 }279280 /// Maximal length of a collection description.281 fn max_collection_description_length() -> u32 {282 MAX_COLLECTION_DESCRIPTION_LENGTH283 }284285 /// Maximal length of a token prefix.286 fn max_token_prefix_length() -> u32 {287 MAX_TOKEN_PREFIX_LENGTH288 }289290 /// Maximum admins per collection.291 fn collection_admins_limit() -> u32 {292 COLLECTION_ADMINS_LIMIT293 }294295 /// Maximal length of a property key.296 fn max_property_key_length() -> u32 {297 MAX_PROPERTY_KEY_LENGTH298 }299300 /// Maximal length of a property value.301 fn max_property_value_length() -> u32 {302 MAX_PROPERTY_VALUE_LENGTH303 }304305 /// A maximum number of token properties.306 fn max_properties_per_item() -> u32 {307 MAX_PROPERTIES_PER_ITEM308 }309310 /// Maximum size for all collection properties.311 fn max_collection_properties_size() -> u32 {312 MAX_COLLECTION_PROPERTIES_SIZE313 }314315 /// Maximum size of all token properties.316 fn max_token_properties_size() -> u32 {317 MAX_TOKEN_PROPERTIES_SIZE318 }319320 /// Default NFT collection limit.321 fn nft_default_collection_limits() -> CollectionLimits {322 CollectionLimits::with_default_limits(CollectionMode::NFT)323 }324325 /// Default RFT collection limit.326 fn rft_default_collection_limits() -> CollectionLimits {327 CollectionLimits::with_default_limits(CollectionMode::ReFungible)328 }329330 /// Default FT collection limit.331 fn ft_default_collection_limits() -> CollectionLimits {332 CollectionLimits::with_default_limits(CollectionMode::Fungible(0))333 }334 }335336 /// Type alias to Pallet, to be used by construct_runtime.337 #[pallet::call]338 impl<T: Config> Pallet<T> {339 /// Create a collection of tokens.340 ///341 /// Each Token may have multiple properties encoded as an array of bytes342 /// of certain length. The initial owner of the collection is set343 /// to the address that signed the transaction and can be changed later.344 ///345 /// Prefer the more advanced [`create_collection_ex`][`Pallet::create_collection_ex`] instead.346 ///347 /// # Permissions348 ///349 /// * Anyone - becomes the owner of the new collection.350 ///351 /// # Arguments352 ///353 /// * `collection_name`: Wide-character string with collection name354 /// (limit [`MAX_COLLECTION_NAME_LENGTH`]).355 /// * `collection_description`: Wide-character string with collection description356 /// (limit [`MAX_COLLECTION_DESCRIPTION_LENGTH`]).357 /// * `token_prefix`: Byte string containing the token prefix to mark a collection358 /// to which a token belongs (limit [`MAX_TOKEN_PREFIX_LENGTH`]).359 /// * `mode`: Type of items stored in the collection and type dependent data.360 ///361 /// returns collection ID362 ///363 /// Deprecated: `create_collection_ex` is more up-to-date and advanced, prefer it instead.364 #[pallet::call_index(0)]365 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]366 pub fn create_collection(367 origin: OriginFor<T>,368 collection_name: BoundedVec<u16, ConstU32<MAX_COLLECTION_NAME_LENGTH>>,369 collection_description: BoundedVec<u16, ConstU32<MAX_COLLECTION_DESCRIPTION_LENGTH>>,370 token_prefix: BoundedVec<u8, ConstU32<MAX_TOKEN_PREFIX_LENGTH>>,371 mode: CollectionMode,372 ) -> DispatchResult {373 let data: CreateCollectionData<T::CrossAccountId> = CreateCollectionData {374 name: collection_name,375 description: collection_description,376 token_prefix,377 mode,378 ..Default::default()379 };380 Self::create_collection_ex(origin, data)381 }382383 /// Create a collection with explicit parameters.384 ///385 /// Prefer it to the deprecated [`create_collection`][`Pallet::create_collection`] method.386 ///387 /// # Permissions388 ///389 /// * Anyone - becomes the owner of the new collection.390 ///391 /// # Arguments392 ///393 /// * `data`: Explicit data of a collection used for its creation.394 #[pallet::call_index(1)]395 #[pallet::weight(<SelfWeightOf<T>>::create_collection())]396 pub fn create_collection_ex(397 origin: OriginFor<T>,398 data: CreateCollectionData<T::CrossAccountId>,399 ) -> DispatchResult {400 let sender = ensure_signed(origin)?;401402 // =========403 let sender = T::CrossAccountId::from_sub(sender);404 let _id = T::CollectionDispatch::create(sender.clone(), sender, data)?;405406 Ok(())407 }408409 /// Destroy a collection if no tokens exist within.410 ///411 /// # Permissions412 ///413 /// * Collection owner414 ///415 /// # Arguments416 ///417 /// * `collection_id`: Collection to destroy.418 #[pallet::call_index(2)]419 #[pallet::weight(<SelfWeightOf<T>>::destroy_collection())]420 pub fn destroy_collection(421 origin: OriginFor<T>,422 collection_id: CollectionId,423 ) -> DispatchResult {424 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);425426 Self::destroy_collection_internal(sender, collection_id)427 }428429 /// Add an address to allow list.430 ///431 /// # Permissions432 ///433 /// * Collection owner434 /// * Collection admin435 ///436 /// # Arguments437 ///438 /// * `collection_id`: ID of the modified collection.439 /// * `address`: ID of the address to be added to the allowlist.440 #[pallet::call_index(3)]441 #[pallet::weight(<SelfWeightOf<T>>::add_to_allow_list())]442 pub fn add_to_allow_list(443 origin: OriginFor<T>,444 collection_id: CollectionId,445 address: T::CrossAccountId,446 ) -> DispatchResult {447 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {448 fail!(<pallet_common::Error<T>>::UnsupportedOperation);449 }450451 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);452 let collection = <CollectionHandle<T>>::try_get(collection_id)?;453 collection.check_is_internal()?;454455 <PalletCommon<T>>::toggle_allowlist(&collection, &sender, &address, true)?;456457 Ok(())458 }459460 /// Remove an address from allow list.461 ///462 /// # Permissions463 ///464 /// * Collection owner465 /// * Collection admin466 ///467 /// # Arguments468 ///469 /// * `collection_id`: ID of the modified collection.470 /// * `address`: ID of the address to be removed from the allowlist.471 #[pallet::call_index(4)]472 #[pallet::weight(<SelfWeightOf<T>>::remove_from_allow_list())]473 pub fn remove_from_allow_list(474 origin: OriginFor<T>,475 collection_id: CollectionId,476 address: T::CrossAccountId,477 ) -> DispatchResult {478 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {479 fail!(<pallet_common::Error<T>>::UnsupportedOperation);480 }481482 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);483 let collection = <CollectionHandle<T>>::try_get(collection_id)?;484 collection.check_is_internal()?;485486 <PalletCommon<T>>::toggle_allowlist(&collection, &sender, &address, false)?;487488 Ok(())489 }490491 /// Change the owner of the collection.492 ///493 /// # Permissions494 ///495 /// * Collection owner496 ///497 /// # Arguments498 ///499 /// * `collection_id`: ID of the modified collection.500 /// * `new_owner`: ID of the account that will become the owner.501 #[pallet::call_index(5)]502 #[pallet::weight(<SelfWeightOf<T>>::change_collection_owner())]503 pub fn change_collection_owner(504 origin: OriginFor<T>,505 collection_id: CollectionId,506 new_owner: T::AccountId,507 ) -> DispatchResult {508 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {509 fail!(<pallet_common::Error<T>>::UnsupportedOperation);510 }511 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);512 let new_owner = T::CrossAccountId::from_sub(new_owner);513 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;514 target_collection.change_owner(sender, new_owner)515 }516517 /// Add an admin to a collection.518 ///519 /// NFT Collection can be controlled by multiple admin addresses520 /// (some which can also be servers, for example). Admins can issue521 /// and burn NFTs, as well as add and remove other admins,522 /// but cannot change NFT or Collection ownership.523 ///524 /// # Permissions525 ///526 /// * Collection owner527 /// * Collection admin528 ///529 /// # Arguments530 ///531 /// * `collection_id`: ID of the Collection to add an admin for.532 /// * `new_admin`: Address of new admin to add.533 #[pallet::call_index(6)]534 #[pallet::weight(<SelfWeightOf<T>>::add_collection_admin())]535 pub fn add_collection_admin(536 origin: OriginFor<T>,537 collection_id: CollectionId,538 new_admin_id: T::CrossAccountId,539 ) -> DispatchResult {540 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {541 fail!(<pallet_common::Error<T>>::UnsupportedOperation);542 }543 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);544 let collection = <CollectionHandle<T>>::try_get(collection_id)?;545 <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)546 }547548 /// Remove admin of a collection.549 ///550 /// An admin address can remove itself. List of admins may become empty,551 /// in which case only Collection Owner will be able to add an Admin.552 ///553 /// # Permissions554 ///555 /// * Collection owner556 /// * Collection admin557 ///558 /// # Arguments559 ///560 /// * `collection_id`: ID of the collection to remove the admin for.561 /// * `account_id`: Address of the admin to remove.562 #[pallet::call_index(7)]563 #[pallet::weight(<SelfWeightOf<T>>::remove_collection_admin())]564 pub fn remove_collection_admin(565 origin: OriginFor<T>,566 collection_id: CollectionId,567 account_id: T::CrossAccountId,568 ) -> DispatchResult {569 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {570 fail!(<pallet_common::Error<T>>::UnsupportedOperation);571 }572 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);573 let collection = <CollectionHandle<T>>::try_get(collection_id)?;574 <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)575 }576577 /// Set (invite) a new collection sponsor.578 ///579 /// If successful, confirmation from the sponsor-to-be will be pending.580 ///581 /// # Permissions582 ///583 /// * Collection owner584 /// * Collection admin585 ///586 /// # Arguments587 ///588 /// * `collection_id`: ID of the modified collection.589 /// * `new_sponsor`: ID of the account of the sponsor-to-be.590 #[pallet::call_index(8)]591 #[pallet::weight(<SelfWeightOf<T>>::set_collection_sponsor())]592 pub fn set_collection_sponsor(593 origin: OriginFor<T>,594 collection_id: CollectionId,595 new_sponsor: T::AccountId,596 ) -> DispatchResult {597 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {598 fail!(<pallet_common::Error<T>>::UnsupportedOperation);599 }600 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);601 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;602 target_collection.set_sponsor(&sender, new_sponsor.clone())603 }604605 /// Confirm own sponsorship of a collection, becoming the sponsor.606 ///607 /// An invitation must be pending, see [`set_collection_sponsor`][`Pallet::set_collection_sponsor`].608 /// Sponsor can pay the fees of a transaction instead of the sender,609 /// but only within specified limits.610 ///611 /// # Permissions612 ///613 /// * Sponsor-to-be614 ///615 /// # Arguments616 ///617 /// * `collection_id`: ID of the collection with the pending sponsor.618 #[pallet::call_index(9)]619 #[pallet::weight(<SelfWeightOf<T>>::confirm_sponsorship())]620 pub fn confirm_sponsorship(621 origin: OriginFor<T>,622 collection_id: CollectionId,623 ) -> DispatchResult {624 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {625 fail!(<pallet_common::Error<T>>::UnsupportedOperation);626 }627 let sender = ensure_signed(origin)?;628 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;629 target_collection.confirm_sponsorship(&sender)630 }631632 /// Remove a collection's a sponsor, making everyone pay for their own transactions.633 ///634 /// # Permissions635 ///636 /// * Collection owner637 ///638 /// # Arguments639 ///640 /// * `collection_id`: ID of the collection with the sponsor to remove.641 #[pallet::call_index(10)]642 #[pallet::weight(<SelfWeightOf<T>>::remove_collection_sponsor())]643 pub fn remove_collection_sponsor(644 origin: OriginFor<T>,645 collection_id: CollectionId,646 ) -> DispatchResult {647 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {648 fail!(<pallet_common::Error<T>>::UnsupportedOperation);649 }650 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);651 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;652 target_collection.remove_sponsor(&sender)653 }654655 /// Mint an item within a collection.656 ///657 /// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].658 ///659 /// # Permissions660 ///661 /// * Collection owner662 /// * Collection admin663 /// * Anyone if664 /// * Allow List is enabled, and665 /// * Address is added to allow list, and666 /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])667 ///668 /// # Arguments669 ///670 /// * `collection_id`: ID of the collection to which an item would belong.671 /// * `owner`: Address of the initial owner of the item.672 /// * `data`: Token data describing the item to store on chain.673 #[pallet::call_index(11)]674 #[pallet::weight(T::CommonWeightInfo::create_item(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]675 pub fn create_item(676 origin: OriginFor<T>,677 collection_id: CollectionId,678 owner: T::CrossAccountId,679 data: CreateItemData,680 ) -> DispatchResultWithPostInfo {681 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);682 let budget = Self::structure_nesting_budget();683684 Self::refund_nesting_budget(685 dispatch_tx::<T, _>(collection_id, |d| {686 d.create_item(sender, owner, data, &budget)687 }),688 budget,689 )690 }691692 /// Create multiple items within a collection.693 ///694 /// A collection must exist first, see [`create_collection_ex`][`Pallet::create_collection_ex`].695 ///696 /// # Permissions697 ///698 /// * Collection owner699 /// * Collection admin700 /// * Anyone if701 /// * Allow List is enabled, and702 /// * Address is added to the allow list, and703 /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])704 ///705 /// # Arguments706 ///707 /// * `collection_id`: ID of the collection to which the tokens would belong.708 /// * `owner`: Address of the initial owner of the tokens.709 /// * `items_data`: Vector of data describing each item to be created.710 #[pallet::call_index(12)]711 #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data) + <Pallet<T>>::nesting_budget_predispatch_weight())]712 pub fn create_multiple_items(713 origin: OriginFor<T>,714 collection_id: CollectionId,715 owner: T::CrossAccountId,716 items_data: Vec<CreateItemData>,717 ) -> DispatchResultWithPostInfo {718 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);719 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);720 let budget = Self::structure_nesting_budget();721722 Self::refund_nesting_budget(723 dispatch_tx::<T, _>(collection_id, |d| {724 d.create_multiple_items(sender, owner, items_data, &budget)725 }),726 budget,727 )728 }729730 /// Add or change collection properties.731 ///732 /// # Permissions733 ///734 /// * Collection owner735 /// * Collection admin736 ///737 /// # Arguments738 ///739 /// * `collection_id`: ID of the modified collection.740 /// * `properties`: Vector of key-value pairs stored as the collection's metadata.741 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.742 #[pallet::call_index(13)]743 #[pallet::weight(T::CommonWeightInfo::set_collection_properties(properties.len() as u32))]744 pub fn set_collection_properties(745 origin: OriginFor<T>,746 collection_id: CollectionId,747 properties: Vec<Property>,748 ) -> DispatchResultWithPostInfo {749 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);750751 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);752753 dispatch_tx::<T, _>(collection_id, |d| {754 d.set_collection_properties(sender, properties)755 })756 }757758 /// Delete specified collection properties.759 ///760 /// # Permissions761 ///762 /// * Collection Owner763 /// * Collection Admin764 ///765 /// # Arguments766 ///767 /// * `collection_id`: ID of the modified collection.768 /// * `property_keys`: Vector of keys of the properties to be deleted.769 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.770 #[pallet::call_index(14)]771 #[pallet::weight(T::CommonWeightInfo::delete_collection_properties(property_keys.len() as u32))]772 pub fn delete_collection_properties(773 origin: OriginFor<T>,774 collection_id: CollectionId,775 property_keys: Vec<PropertyKey>,776 ) -> DispatchResultWithPostInfo {777 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);778779 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);780781 dispatch_tx::<T, _>(collection_id, |d| {782 d.delete_collection_properties(&sender, property_keys)783 })784 }785786 /// Add or change token properties according to collection's permissions.787 /// Currently properties only work with NFTs.788 ///789 /// # Permissions790 ///791 /// * Depends on collection's token property permissions and specified property mutability:792 /// * Collection owner793 /// * Collection admin794 /// * Token owner795 ///796 /// See [`set_token_property_permissions`][`Pallet::set_token_property_permissions`].797 ///798 /// # Arguments799 ///800 /// * `collection_id: ID of the collection to which the token belongs.801 /// * `token_id`: ID of the modified token.802 /// * `properties`: Vector of key-value pairs stored as the token's metadata.803 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.804 #[pallet::call_index(15)]805 #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]806 pub fn set_token_properties(807 origin: OriginFor<T>,808 collection_id: CollectionId,809 token_id: TokenId,810 properties: Vec<Property>,811 ) -> DispatchResultWithPostInfo {812 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);813814 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);815 let budget = Self::structure_nesting_budget();816817 Self::refund_nesting_budget(818 dispatch_tx::<T, _>(collection_id, |d| {819 d.set_token_properties(sender, token_id, properties, &budget)820 }),821 budget,822 )823 }824825 /// Delete specified token properties. Currently properties only work with NFTs.826 ///827 /// # Permissions828 ///829 /// * Depends on collection's token property permissions and specified property mutability:830 /// * Collection owner831 /// * Collection admin832 /// * Token owner833 ///834 /// # Arguments835 ///836 /// * `collection_id`: ID of the collection to which the token belongs.837 /// * `token_id`: ID of the modified token.838 /// * `property_keys`: Vector of keys of the properties to be deleted.839 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.840 #[pallet::call_index(16)]841 #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]842 pub fn delete_token_properties(843 origin: OriginFor<T>,844 collection_id: CollectionId,845 token_id: TokenId,846 property_keys: Vec<PropertyKey>,847 ) -> DispatchResultWithPostInfo {848 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);849850 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);851 let budget = Self::structure_nesting_budget();852853 Self::refund_nesting_budget(854 dispatch_tx::<T, _>(collection_id, |d| {855 d.delete_token_properties(sender, token_id, property_keys, &budget)856 }),857 budget,858 )859 }860861 /// Add or change token property permissions of a collection.862 ///863 /// Without a permission for a particular key, a property with that key864 /// cannot be created in a token.865 ///866 /// # Permissions867 ///868 /// * Collection owner869 /// * Collection admin870 ///871 /// # Arguments872 ///873 /// * `collection_id`: ID of the modified collection.874 /// * `property_permissions`: Vector of permissions for property keys.875 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.876 #[pallet::call_index(17)]877 #[pallet::weight(T::CommonWeightInfo::set_token_property_permissions(property_permissions.len() as u32))]878 pub fn set_token_property_permissions(879 origin: OriginFor<T>,880 collection_id: CollectionId,881 property_permissions: Vec<PropertyKeyPermission>,882 ) -> DispatchResultWithPostInfo {883 ensure!(!property_permissions.is_empty(), Error::<T>::EmptyArgument);884885 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);886887 dispatch_tx::<T, _>(collection_id, |d| {888 d.set_token_property_permissions(&sender, property_permissions)889 })890 }891892 /// Create multiple items within a collection with explicitly specified initial parameters.893 ///894 /// # Permissions895 ///896 /// * Collection owner897 /// * Collection admin898 /// * Anyone if899 /// * Allow List is enabled, and900 /// * Address is added to allow list, and901 /// * MintPermission is enabled (see [`set_collection_permissions`][`Pallet::set_collection_permissions`])902 ///903 /// # Arguments904 ///905 /// * `collection_id`: ID of the collection to which the tokens would belong.906 /// * `data`: Explicit item creation data.907 #[pallet::call_index(18)]908 #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]909 pub fn create_multiple_items_ex(910 origin: OriginFor<T>,911 collection_id: CollectionId,912 data: CreateItemExData<T::CrossAccountId>,913 ) -> DispatchResultWithPostInfo {914 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);915 let budget = Self::structure_nesting_budget();916917 Self::refund_nesting_budget(918 dispatch_tx::<T, _>(collection_id, |d| {919 d.create_multiple_items_ex(sender, data, &budget)920 }),921 budget,922 )923 }924925 /// Completely allow or disallow transfers for a particular collection.926 ///927 /// # Permissions928 ///929 /// * Collection owner930 ///931 /// # Arguments932 ///933 /// * `collection_id`: ID of the collection.934 /// * `value`: New value of the flag, are transfers allowed?935 #[pallet::call_index(19)]936 #[pallet::weight(<SelfWeightOf<T>>::set_transfers_enabled_flag())]937 pub fn set_transfers_enabled_flag(938 origin: OriginFor<T>,939 collection_id: CollectionId,940 value: bool,941 ) -> DispatchResult {942 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {943 fail!(<pallet_common::Error<T>>::UnsupportedOperation);944 }945 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);946 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;947 target_collection.check_is_internal()?;948 target_collection.check_is_owner(&sender)?;949950 // =========951952 target_collection.limits.transfers_enabled = Some(value);953 target_collection.save()954 }955956 /// Destroy an item.957 ///958 /// # Permissions959 ///960 /// * Collection owner961 /// * Collection admin962 /// * Current item owner963 ///964 /// # Arguments965 ///966 /// * `collection_id`: ID of the collection to which the item belongs.967 /// * `item_id`: ID of item to burn.968 /// * `value`: Number of pieces of the item to destroy.969 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.970 /// * Fungible Mode: The desired number of pieces to burn.971 /// * Re-Fungible Mode: The desired number of pieces to burn.972 #[pallet::call_index(20)]973 #[pallet::weight(T::CommonWeightInfo::burn_item())]974 pub fn burn_item(975 origin: OriginFor<T>,976 collection_id: CollectionId,977 item_id: TokenId,978 value: u128,979 ) -> DispatchResultWithPostInfo {980 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);981982 let post_info =983 dispatch_tx::<T, _>(collection_id, |d| d.burn_item(sender, item_id, value))?;984 if value == 1 {985 <NftTransferBasket<T>>::remove(collection_id, item_id);986 <NftApproveBasket<T>>::remove(collection_id, item_id);987 }988 // Those maps should be cleared only if token disappears completly, need to move this part of logic to pallets?989 // <FungibleApproveBasket<T>>::remove(collection_id, sender.as_sub());990 // <RefungibleApproveBasket<T>>::remove((collection_id, item_id, sender.as_sub()));991 Ok(post_info)992 }993994 /// Destroy a token on behalf of the owner as a non-owner account.995 ///996 /// See also: [`approve`][`Pallet::approve`].997 ///998 /// After this method executes, one approval is removed from the total so that999 /// the approved address will not be able to transfer this item again from this owner.1000 ///1001 /// # Permissions1002 ///1003 /// * Collection owner1004 /// * Collection admin1005 /// * Current token owner1006 /// * Address approved by current item owner1007 ///1008 /// # Arguments1009 ///1010 /// * `from`: The owner of the burning item.1011 /// * `collection_id`: ID of the collection to which the item belongs.1012 /// * `item_id`: ID of item to burn.1013 /// * `value`: Number of pieces to burn.1014 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1015 /// * Fungible Mode: The desired number of pieces to burn.1016 /// * Re-Fungible Mode: The desired number of pieces to burn.1017 #[pallet::call_index(21)]1018 #[pallet::weight(T::CommonWeightInfo::burn_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]1019 pub fn burn_from(1020 origin: OriginFor<T>,1021 collection_id: CollectionId,1022 from: T::CrossAccountId,1023 item_id: TokenId,1024 value: u128,1025 ) -> DispatchResultWithPostInfo {1026 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1027 let budget = Self::structure_nesting_budget();10281029 Self::refund_nesting_budget(1030 dispatch_tx::<T, _>(collection_id, |d| {1031 d.burn_from(sender, from, item_id, value, &budget)1032 }),1033 budget,1034 )1035 }10361037 /// Change ownership of the token.1038 ///1039 /// # Permissions1040 ///1041 /// * Collection owner1042 /// * Collection admin1043 /// * Current token owner1044 ///1045 /// # Arguments1046 ///1047 /// * `recipient`: Address of token recipient.1048 /// * `collection_id`: ID of the collection the item belongs to.1049 /// * `item_id`: ID of the item.1050 /// * Non-Fungible Mode: Required.1051 /// * Fungible Mode: Ignored.1052 /// * Re-Fungible Mode: Required.1053 ///1054 /// * `value`: Amount to transfer.1055 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1056 /// * Fungible Mode: The desired number of pieces to transfer.1057 /// * Re-Fungible Mode: The desired number of pieces to transfer.1058 #[pallet::call_index(22)]1059 #[pallet::weight(T::CommonWeightInfo::transfer() + <Pallet<T>>::nesting_budget_predispatch_weight())]1060 pub fn transfer(1061 origin: OriginFor<T>,1062 recipient: T::CrossAccountId,1063 collection_id: CollectionId,1064 item_id: TokenId,1065 value: u128,1066 ) -> DispatchResultWithPostInfo {1067 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1068 let budget = Self::structure_nesting_budget();10691070 Self::refund_nesting_budget(1071 dispatch_tx::<T, _>(collection_id, |d| {1072 d.transfer(sender, recipient, item_id, value, &budget)1073 }),1074 budget,1075 )1076 }10771078 /// Allow a non-permissioned address to transfer or burn an item.1079 ///1080 /// # Permissions1081 ///1082 /// * Collection owner1083 /// * Collection admin1084 /// * Current item owner1085 ///1086 /// # Arguments1087 ///1088 /// * `spender`: Account to be approved to make specific transactions on non-owned tokens.1089 /// * `collection_id`: ID of the collection the item belongs to.1090 /// * `item_id`: ID of the item transactions on which are now approved.1091 /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).1092 /// Set to 0 to revoke the approval.1093 #[pallet::call_index(23)]1094 #[pallet::weight(T::CommonWeightInfo::approve())]1095 pub fn approve(1096 origin: OriginFor<T>,1097 spender: T::CrossAccountId,1098 collection_id: CollectionId,1099 item_id: TokenId,1100 amount: u128,1101 ) -> DispatchResultWithPostInfo {1102 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);11031104 dispatch_tx::<T, _>(collection_id, |d| {1105 d.approve(sender, spender, item_id, amount)1106 })1107 }11081109 /// Allow a non-permissioned address to transfer or burn an item from owner's eth mirror.1110 ///1111 /// # Permissions1112 ///1113 /// * Collection owner1114 /// * Collection admin1115 /// * Current item owner1116 ///1117 /// # Arguments1118 ///1119 /// * `from`: Owner's account eth mirror1120 /// * `to`: Account to be approved to make specific transactions on non-owned tokens.1121 /// * `collection_id`: ID of the collection the item belongs to.1122 /// * `item_id`: ID of the item transactions on which are now approved.1123 /// * `amount`: Number of pieces of the item approved for a transaction (maximum of 1 for NFTs).1124 /// Set to 0 to revoke the approval.1125 #[pallet::call_index(24)]1126 #[pallet::weight(T::CommonWeightInfo::approve_from())]1127 pub fn approve_from(1128 origin: OriginFor<T>,1129 from: T::CrossAccountId,1130 to: T::CrossAccountId,1131 collection_id: CollectionId,1132 item_id: TokenId,1133 amount: u128,1134 ) -> DispatchResultWithPostInfo {1135 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);11361137 dispatch_tx::<T, _>(collection_id, |d| {1138 d.approve_from(sender, from, to, item_id, amount)1139 })1140 }11411142 /// Change ownership of an item on behalf of the owner as a non-owner account.1143 ///1144 /// See the [`approve`][`Pallet::approve`] method for additional information.1145 ///1146 /// After this method executes, one approval is removed from the total so that1147 /// the approved address will not be able to transfer this item again from this owner.1148 ///1149 /// # Permissions1150 ///1151 /// * Collection owner1152 /// * Collection admin1153 /// * Current item owner1154 /// * Address approved by current item owner1155 ///1156 /// # Arguments1157 ///1158 /// * `from`: Address that currently owns the token.1159 /// * `recipient`: Address of the new token-owner-to-be.1160 /// * `collection_id`: ID of the collection the item.1161 /// * `item_id`: ID of the item to be transferred.1162 /// * `value`: Amount to transfer.1163 /// * Non-Fungible Mode: An NFT is indivisible, there is always 1 corresponding to an ID.1164 /// * Fungible Mode: The desired number of pieces to transfer.1165 /// * Re-Fungible Mode: The desired number of pieces to transfer.1166 #[pallet::call_index(25)]1167 #[pallet::weight(T::CommonWeightInfo::transfer_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]1168 pub fn transfer_from(1169 origin: OriginFor<T>,1170 from: T::CrossAccountId,1171 recipient: T::CrossAccountId,1172 collection_id: CollectionId,1173 item_id: TokenId,1174 value: u128,1175 ) -> DispatchResultWithPostInfo {1176 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1177 let budget = Self::structure_nesting_budget();11781179 Self::refund_nesting_budget(1180 dispatch_tx::<T, _>(collection_id, |d| {1181 d.transfer_from(sender, from, recipient, item_id, value, &budget)1182 }),1183 budget,1184 )1185 }11861187 /// Set specific limits of a collection. Empty, or None fields mean chain default.1188 ///1189 /// # Permissions1190 ///1191 /// * Collection owner1192 /// * Collection admin1193 ///1194 /// # Arguments1195 ///1196 /// * `collection_id`: ID of the modified collection.1197 /// * `new_limit`: New limits of the collection. Fields that are not set (None)1198 /// will not overwrite the old ones.1199 #[pallet::call_index(26)]1200 #[pallet::weight(<SelfWeightOf<T>>::set_collection_limits())]1201 pub fn set_collection_limits(1202 origin: OriginFor<T>,1203 collection_id: CollectionId,1204 new_limit: CollectionLimits,1205 ) -> DispatchResult {1206 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1207 fail!(<pallet_common::Error<T>>::UnsupportedOperation);1208 }1209 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1210 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1211 <PalletCommon<T>>::update_limits(&sender, &mut target_collection, new_limit)1212 }12131214 /// Set specific permissions of a collection. Empty, or None fields mean chain default.1215 ///1216 /// # Permissions1217 ///1218 /// * Collection owner1219 /// * Collection admin1220 ///1221 /// # Arguments1222 ///1223 /// * `collection_id`: ID of the modified collection.1224 /// * `new_permission`: New permissions of the collection. Fields that are not set (None)1225 /// will not overwrite the old ones.1226 #[pallet::call_index(27)]1227 #[pallet::weight(<SelfWeightOf<T>>::set_collection_limits())]1228 pub fn set_collection_permissions(1229 origin: OriginFor<T>,1230 collection_id: CollectionId,1231 new_permission: CollectionPermissions,1232 ) -> DispatchResult {1233 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1234 fail!(<pallet_common::Error<T>>::UnsupportedOperation);1235 }1236 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1237 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1238 <PalletCommon<T>>::update_permissions(&sender, &mut target_collection, new_permission)1239 }12401241 /// Re-partition a refungible token, while owning all of its parts/pieces.1242 ///1243 /// # Permissions1244 ///1245 /// * Token owner (must own every part)1246 ///1247 /// # Arguments1248 ///1249 /// * `collection_id`: ID of the collection the RFT belongs to.1250 /// * `token_id`: ID of the RFT.1251 /// * `amount`: New number of parts/pieces into which the token shall be partitioned.1252 #[pallet::call_index(28)]1253 #[pallet::weight(T::RefungibleExtensionsWeightInfo::repartition())]1254 pub fn repartition(1255 origin: OriginFor<T>,1256 collection_id: CollectionId,1257 token_id: TokenId,1258 amount: u128,1259 ) -> DispatchResultWithPostInfo {1260 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1261 dispatch_tx::<T, _>(collection_id, |d| {1262 if let Some(refungible_extensions) = d.refungible_extensions() {1263 refungible_extensions.repartition(&sender, token_id, amount)1264 } else {1265 fail!(<Error<T>>::RepartitionCalledOnNonRefungibleCollection)1266 }1267 })1268 }12691270 /// Sets or unsets the approval of a given operator.1271 ///1272 /// The `operator` is allowed to transfer all tokens of the `owner` on their behalf.1273 ///1274 /// # Arguments1275 ///1276 /// * `owner`: Token owner1277 /// * `operator`: Operator1278 /// * `approve`: Should operator status be granted or revoked?1279 #[pallet::call_index(29)]1280 #[pallet::weight(T::CommonWeightInfo::set_allowance_for_all())]1281 pub fn set_allowance_for_all(1282 origin: OriginFor<T>,1283 collection_id: CollectionId,1284 operator: T::CrossAccountId,1285 approve: bool,1286 ) -> DispatchResultWithPostInfo {1287 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1288 dispatch_tx::<T, _>(collection_id, |d| {1289 d.set_allowance_for_all(sender, operator, approve)1290 })1291 }12921293 /// Repairs a collection if the data was somehow corrupted.1294 ///1295 /// # Arguments1296 ///1297 /// * `collection_id`: ID of the collection to repair.1298 #[pallet::call_index(30)]1299 #[pallet::weight(<SelfWeightOf<T>>::force_repair_collection())]1300 pub fn force_repair_collection(1301 origin: OriginFor<T>,1302 collection_id: CollectionId,1303 ) -> DispatchResult {1304 if collection_id == pallet_common::NATIVE_FUNGIBLE_COLLECTION_ID {1305 fail!(<pallet_common::Error<T>>::UnsupportedOperation);1306 }1307 ensure_root(origin)?;1308 <PalletCommon<T>>::repair_collection(collection_id)1309 }13101311 /// Repairs a token if the data was somehow corrupted.1312 ///1313 /// # Arguments1314 ///1315 /// * `collection_id`: ID of the collection the item belongs to.1316 /// * `item_id`: ID of the item.1317 #[pallet::call_index(31)]1318 #[pallet::weight(T::CommonWeightInfo::force_repair_item())]1319 pub fn force_repair_item(1320 origin: OriginFor<T>,1321 collection_id: CollectionId,1322 item_id: TokenId,1323 ) -> DispatchResultWithPostInfo {1324 ensure_root(origin)?;1325 dispatch_tx::<T, _>(collection_id, |d| d.repair_item(item_id))1326 }1327 }13281329 impl<T: Config> Pallet<T> {1330 /// Force set `sponsor` for `collection`.1331 ///1332 /// Differs from [`set_collection_sponsor`][`Pallet::set_collection_sponsor`] in that confirmation1333 /// from the `sponsor` is not required.1334 ///1335 /// # Arguments1336 ///1337 /// * `sponsor`: ID of the account of the sponsor-to-be.1338 /// * `collection_id`: ID of the modified collection.1339 pub fn force_set_sponsor(1340 sponsor: T::AccountId,1341 collection_id: CollectionId,1342 ) -> DispatchResult {1343 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1344 target_collection.force_set_sponsor(sponsor)1345 }13461347 /// Force remove `sponsor` for `collection`.1348 ///1349 /// Differs from `remove_sponsor` in that1350 /// it doesn't require consent from the `owner` of the collection.1351 ///1352 /// # Arguments1353 ///1354 /// * `collection_id`: ID of the modified collection.1355 pub fn force_remove_collection_sponsor(collection_id: CollectionId) -> DispatchResult {1356 let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;1357 target_collection.force_remove_sponsor()1358 }13591360 #[inline(always)]1361 pub(crate) fn destroy_collection_internal(1362 sender: T::CrossAccountId,1363 collection_id: CollectionId,1364 ) -> DispatchResult {1365 T::CollectionDispatch::destroy(sender, collection_id)?;13661367 // TODO: basket cleanup should be moved elsewhere1368 // Maybe runtime dispatch.rs should perform it?13691370 let _ = <NftTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1371 let _ = <FungibleTransferBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1372 let _ = <ReFungibleTransferBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);13731374 let _ = <NftApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1375 let _ = <FungibleApproveBasket<T>>::clear_prefix(collection_id, u32::MAX, None);1376 let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);13771378 Ok(())1379 }13801381 fn structure_nesting_budget() -> budget::Value {1382 budget::Value::new(Self::nesting_budget())1383 }13841385 fn nesting_budget_predispatch_weight() -> Weight {1386 T::StructureWeightInfo::find_parent().saturating_mul(Self::nesting_budget() as u64)1387 }13881389 pub fn refund_nesting_budget(1390 mut result: DispatchResultWithPostInfo,1391 budget: budget::Value,1392 ) -> DispatchResultWithPostInfo {1393 let refund_amount = budget.refund_amount();1394 let consumed = Self::nesting_budget() - refund_amount;13951396 match &mut result {1397 Ok(PostDispatchInfo {1398 actual_weight: Some(weight),1399 ..1400 })1401 | Err(DispatchErrorWithPostInfo {1402 post_info: PostDispatchInfo {1403 actual_weight: Some(weight),1404 ..1405 },1406 ..1407 }) => {1408 *weight += T::StructureWeightInfo::find_parent().saturating_mul(consumed as u64)1409 }1410 _ => {}1411 }14121413 result1414 }1415 }1416}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.rsdiffbeforeafterboth--- a/runtime/tests/src/tests.rs
+++ b/runtime/tests/src/tests.rs
@@ -2624,10 +2624,10 @@
use super::*;
- fn test<FTE: FnOnce() -> bool>(
+ fn test(
i: usize,
test_case: &pallet_common::tests::TestCase,
- check_token_existence: &mut LazyValue<bool, FTE>,
+ check_token_existence: &mut LazyValue<bool>,
) {
let collection_admin = test_case.collection_admin;
let mut is_collection_admin = LazyValue::new(|| test_case.is_collection_admin);
@@ -2635,7 +2635,7 @@
let mut is_token_owner = LazyValue::new(|| Ok(test_case.is_token_owner));
let is_no_permission = test_case.no_permission;
- let result = pallet_common::tests::check_token_permissions::<Test, _, _, FTE>(
+ let result = pallet_common::tests::check_token_permissions::<Test>(
collection_admin,
token_owner,
&mut is_collection_admin,
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) {