git.delta.rocks / unique-network / refs/commits / 437764b749e7

difftreelog

refactor property writer / fix set_token_props weight

Daniel Shiposha2023-10-05parent: #90ad566.patch.diff
in: master

27 files changed

modifiedpallets/balances-adapter/src/common.rsdiffbeforeafterboth
30 Weight::default()30 Weight::default()
31 }31 }
32
33 fn delete_collection_properties(_amount: u32) -> Weight {
34 Weight::default()
35 }
3632
37 fn set_token_properties(_amount: u32) -> Weight {33 fn set_token_properties(_amount: u32) -> Weight {
38 Weight::default()34 Weight::default()
39 }35 }
40
41 fn delete_token_properties(_amount: u32) -> Weight {
42 Weight::default()
43 }
4436
45 fn set_token_property_permissions(_amount: u32) -> Weight {37 fn set_token_property_permissions(_amount: u32) -> Weight {
46 Weight::default()38 Weight::default()
66 Weight::default()58 Weight::default()
67 }59 }
68
69 fn burn_recursively_self_raw() -> Weight {
70 Weight::default()
71 }
72
73 fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
74 Weight::default()
75 }
76
77 fn token_owner() -> Weight {
78 Weight::default()
79 }
8060
81 fn set_allowance_for_all() -> Weight {61 fn set_allowance_for_all() -> Weight {
82 Weight::default()62 Weight::default()
128 fail!(<pallet_common::Error<T>>::UnsupportedOperation);108 fail!(<pallet_common::Error<T>>::UnsupportedOperation);
129 }109 }
130
131 fn burn_item_recursively(
132 &self,
133 _sender: <T>::CrossAccountId,
134 _token: TokenId,
135 _self_budget: &dyn up_data_structs::budget::Budget,
136 _breadth_budget: &dyn up_data_structs::budget::Budget,
137 ) -> frame_support::pallet_prelude::DispatchResultWithPostInfo {
138 fail!(<pallet_common::Error<T>>::UnsupportedOperation);
139 }
140110
141 fn set_collection_properties(111 fn set_collection_properties(
142 &self,112 &self,
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
34 MAX_TOKEN_PREFIX_LENGTH,34 MAX_TOKEN_PREFIX_LENGTH,
35};35};
3636
37use crate::{CollectionHandle, Config, Pallet};37use crate::{BenchmarkPropertyWriter, CollectionHandle, Config, Pallet};
3838
39const SEED: u32 = 1;39const SEED: u32 = 1;
4040
126 )126 )
127}127}
128
129pub fn load_is_admin_and_property_permissions<T: Config>(
130 collection: &CollectionHandle<T>,
131 sender: &T::CrossAccountId,
132) -> (bool, PropertiesPermissionMap) {
133 (
134 collection.is_owner_or_admin(sender),
135 <Pallet<T>>::property_permissions(collection.id),
136 )
137}
138128
139/// Helper macros, which handles all benchmarking preparation in semi-declarative way129/// Helper macros, which handles all benchmarking preparation in semi-declarative way
140///130///
272262
273 #[block]263 #[block]
274 {264 {
275 load_is_admin_and_property_permissions(&collection, &sender);265 <BenchmarkPropertyWriter<T>>::load_collection_info(&&collection, &sender);
276 }266 }
277267
278 Ok(())268 Ok(())
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
872}872}
873873
874/// Value representation with delayed initialization time.874/// Value representation with delayed initialization time.
875pub struct LazyValue<T, F: FnOnce() -> T> {875pub struct LazyValue<T, F> {
876 value: Option<T>,876 value: Option<T>,
877 f: Option<F>,877 f: Option<F>,
878}878}
1902 /// Collection property deletion weight.1902 /// Collection property deletion weight.
1903 ///1903 ///
1904 /// * `amount`- The number of properties to set.1904 /// * `amount`- The number of properties to set.
1905 fn delete_collection_properties(amount: u32) -> Weight;1905 fn delete_collection_properties(amount: u32) -> Weight {
1906 Self::set_collection_properties(amount)
1907 }
19061908
1907 /// Token property setting weight.1909 /// Token property setting weight.
1908 ///1910 ///
1912 /// Token property deletion weight.1914 /// Token property deletion weight.
1913 ///1915 ///
1914 /// * `amount`- The number of properties to delete.1916 /// * `amount`- The number of properties to delete.
1915 fn delete_token_properties(amount: u32) -> Weight;1917 fn delete_token_properties(amount: u32) -> Weight {
1918 Self::set_token_properties(amount)
1919 }
19161920
1917 /// Token property permissions set weight.1921 /// Token property permissions set weight.
1918 ///1922 ///
1934 /// The price of burning a token from another user.1938 /// The price of burning a token from another user.
1935 fn burn_from() -> Weight;1939 fn burn_from() -> Weight;
19361940
1937 /// Differs from burn_item in case of Fungible and Refungible, as it should burn
1938 /// whole users's balance.
1939 ///
1940 /// This method shouldn't be used directly, as it doesn't count breadth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead
1941 fn burn_recursively_self_raw() -> Weight;
1942
1943 /// Cost of iterating over `amount` children while burning, without counting child burning itself.
1944 ///
1945 /// This method shouldn't be used directly, as it doesn't count depth price, use [burn_recursively](CommonWeightInfo::burn_recursively) instead
1946 fn burn_recursively_breadth_raw(amount: u32) -> Weight;
1947
1948 /// The price of recursive burning a token.
1949 ///
1950 /// `max_selfs` - The maximum burning weight of the token itself.
1951 /// `max_breadth` - The maximum number of nested tokens to burn.
1952 fn burn_recursively(max_selfs: u32, max_breadth: u32) -> Weight {
1953 Self::burn_recursively_self_raw()
1954 .saturating_mul(max_selfs.max(1) as u64)
1955 .saturating_add(Self::burn_recursively_breadth_raw(max_breadth))
1956 }
1957
1958 /// The price of retrieving token owner
1959 fn token_owner() -> Weight;
1960
1961 /// The price of setting approval for all1941 /// The price of setting approval for all
1962 fn set_allowance_for_all() -> Weight;1942 fn set_allowance_for_all() -> Weight;
19631943
2029 amount: u128,2009 amount: u128,
2030 ) -> DispatchResultWithPostInfo;2010 ) -> DispatchResultWithPostInfo;
20312011
2032 /// Burn token and all nested tokens recursievly.
2033 ///
2034 /// * `sender` - The user who owns the token.
2035 /// * `token` - Token id that will burned.
2036 /// * `self_budget` - The budget that can be spent on burning tokens.
2037 /// * `breadth_budget` - The budget that can be spent on burning nested tokens.
2038 fn burn_item_recursively(
2039 &self,
2040 sender: T::CrossAccountId,
2041 token: TokenId,
2042 self_budget: &dyn Budget,
2043 breadth_budget: &dyn Budget,
2044 ) -> DispatchResultWithPostInfo;
2045
2046 /// Set collection properties.2012 /// Set collection properties.
2047 ///2013 ///
2048 /// * `sender` - Must be either the owner of the collection or its admin.2014 /// * `sender` - Must be either the owner of the collection or its admin.
2374 }2340 }
2375}2341}
23762342
2377/// A marker structure that enables the writer implementation
2378/// to provide the interface to write properties to **newly created** tokens.
2379pub struct NewTokenPropertyWriter;
2380
2381/// A marker structure that enables the writer implementation
2382/// to provide the interface to write properties to **already existing** tokens.
2383pub struct ExistingTokenPropertyWriter;
2384
2385/// The type-safe interface for writing properties (setting or deleting) to tokens.2343/// The type-safe interface for writing properties (setting or deleting) to tokens.
2386/// It has two distinct implementations for newly created tokens and existing ones.2344/// It has two distinct implementations for newly created tokens and existing ones.
2387///2345///
2388/// This type utilizes the lazy evaluation to avoid repeating the computation2346/// This type utilizes the lazy evaluation to avoid repeating the computation
2389/// of several performance-heavy or PoV-heavy tasks,2347/// of several performance-heavy or PoV-heavy tasks,
2390/// such as checking the indirect ownership or reading the token property permissions.2348/// such as checking the indirect ownership or reading the token property permissions.
2391pub struct PropertyWriter<2349pub struct PropertyWriter<'a, WriterVariant, T, Handle, FIsAdmin, FPropertyPermissions> {
2392 'a,
2393 T,
2394 Handle,
2395 WriterVariant,
2396 FIsAdmin,
2397 FPropertyPermissions,
2398 FCheckTokenExist,
2399 FGetProperties,
2400> where
2401 T: Config,
2402 FIsAdmin: FnOnce() -> bool,
2403 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2404{
2405 collection: &'a Handle,2350 collection: &'a Handle,
2406 is_collection_admin: LazyValue<bool, FIsAdmin>,2351 collection_lazy_info: PropertyWriterLazyCollectionInfo<FIsAdmin, FPropertyPermissions>,
2407 property_permissions: LazyValue<PropertiesPermissionMap, FPropertyPermissions>,
2408 check_token_exist: FCheckTokenExist,
2409 get_properties: FGetProperties,
2410 _phantom: PhantomData<(T, WriterVariant)>,2352 _phantom: PhantomData<(T, WriterVariant)>,
2411}2353}
24122354
2413impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>2355impl<'a, T, Handle, WriterVariant, FIsAdmin, FPropertyPermissions>
2414 PropertyWriter<2356 PropertyWriter<'a, WriterVariant, T, Handle, FIsAdmin, FPropertyPermissions>
2415 'a,
2416 T,
2417 Handle,
2418 NewTokenPropertyWriter,
2419 FIsAdmin,
2420 FPropertyPermissions,
2421 FCheckTokenExist,
2422 FGetProperties,
2423 > where2357where
2424 T: Config,2358 T: Config,
2425 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2359 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2426 FIsAdmin: FnOnce() -> bool,2360 FIsAdmin: FnOnce() -> bool,
2427 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,2361 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2428 FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
2429 FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
2430{2362{
2431 /// A function to write properties to a **newly created** token.2363 fn internal_write_token_properties<FCheckTokenExist, FCheckTokenOwner, FGetProperties>(
2432 pub fn write_token_properties(
2433 &mut self,2364 &mut self,
2434 mint_target_is_sender: bool,
2435 token_id: TokenId,2365 token_id: TokenId,
2436 properties_updates: impl Iterator<Item = Property>,2366 mut token_lazy_info: PropertyWriterLazyTokenInfo<
2437 log: evm_coder::ethereum::Log,
2438 ) -> DispatchResult {
2439 self.internal_write_token_properties(
2440 token_id,
2441 properties_updates.map(|p| (p.key, Some(p.value))),
2442 |_| Ok(mint_target_is_sender),
2443 log,
2444 )
2445 }
2446}
2447
2448impl<'a, T, Handle, FIsAdmin, FPropertyPermissions, FCheckTokenExist, FGetProperties>
2449 PropertyWriter<2367 FCheckTokenExist,
2450 'a,
2451 T,
2452 Handle,
2453 ExistingTokenPropertyWriter,
2454 FIsAdmin,
2455 FPropertyPermissions,
2456 FCheckTokenExist,
2457 FGetProperties,2368 FCheckTokenOwner,
2458 > where
2459 T: Config,
2460 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2369 FGetProperties,
2461 FIsAdmin: FnOnce() -> bool,
2462 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2463 FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
2464 FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
2465{
2466 /// A function to write properties to an **already existing** token.2370 >,
2467 pub fn write_token_properties(
2468 &mut self,
2469 sender: &T::CrossAccountId,
2470 token_id: TokenId,
2471 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,2371 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
2472 nesting_budget: &dyn Budget,
2473 log: evm_coder::ethereum::Log,2372 log: evm_coder::ethereum::Log,
2474 ) -> DispatchResult {
2475 self.internal_write_token_properties(
2476 token_id,
2477 properties_updates,
2478 |collection| collection.check_token_indirect_owner(token_id, sender, nesting_budget),
2479 log,
2480 )
2481 }
2482}
2483
2484impl<
2485 'a,
2486 T,
2487 Handle,
2488 WriterVariant,
2489 FIsAdmin,
2490 FPropertyPermissions,
2491 FCheckTokenExist,
2492 FGetProperties,
2493 >
2494 PropertyWriter<
2495 'a,
2496 T,
2497 Handle,
2498 WriterVariant,
2499 FIsAdmin,
2500 FPropertyPermissions,
2501 FCheckTokenExist,
2502 FGetProperties,
2503 > where
2504 T: Config,
2505 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2506 FIsAdmin: FnOnce() -> bool,
2507 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2508 FCheckTokenExist: Copy + FnOnce(TokenId) -> bool,
2509 FGetProperties: Copy + FnOnce(TokenId) -> TokenProperties,
2510{
2511 fn internal_write_token_properties<FCheckTokenOwner>(
2512 &mut self,
2513 token_id: TokenId,
2514 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
2515 check_token_owner: FCheckTokenOwner,
2516 log: evm_coder::ethereum::Log,
2517 ) -> DispatchResult2373 ) -> DispatchResult
2518 where2374 where
2519 FCheckTokenOwner: FnOnce(&Handle) -> Result<bool, DispatchError>,2375 FCheckTokenExist: FnOnce() -> bool,
2376 FCheckTokenOwner: FnOnce() -> Result<bool, DispatchError>,
2377 FGetProperties: FnOnce() -> TokenProperties,
2520 {2378 {
2521 let get_properties = self.get_properties;
2522 let mut stored_properties = LazyValue::new(move || get_properties(token_id));
2523
2524 let mut is_token_owner = LazyValue::new(|| check_token_owner(self.collection));
2525
2526 let check_token_exist = self.check_token_exist;
2527 let mut is_token_exist = LazyValue::new(move || check_token_exist(token_id));
2528
2529 for (key, value) in properties_updates {2379 for (key, value) in properties_updates {
2530 let permission = self2380 let permission = self
2381 .collection_lazy_info
2531 .property_permissions2382 .property_permissions
2532 .value()2383 .value()
2533 .get(&key)2384 .get(&key)
25362387
2537 match permission {2388 match permission {
2538 PropertyPermission { mutable: false, .. }2389 PropertyPermission { mutable: false, .. }
2539 if stored_properties.value().get(&key).is_some() =>2390 if token_lazy_info
2391 .stored_properties
2392 .value()
2393 .get(&key)
2394 .is_some() =>
2540 {2395 {
2541 return Err(<Error<T>>::NoPermission.into());2396 return Err(<Error<T>>::NoPermission.into());
2542 }2397 }
2548 } => check_token_permissions::<T, _, _, _>(2403 } => check_token_permissions::<T, _, _, _>(
2549 collection_admin,2404 collection_admin,
2550 token_owner,2405 token_owner,
2551 &mut self.is_collection_admin,2406 &mut self.collection_lazy_info.is_collection_admin,
2552 &mut is_token_owner,2407 &mut token_lazy_info.is_token_owner,
2553 &mut is_token_exist,2408 &mut token_lazy_info.is_token_exist,
2554 )?,2409 )?,
2555 }2410 }
25562411
2557 match value {2412 match value {
2558 Some(value) => {2413 Some(value) => {
2559 stored_properties2414 token_lazy_info
2415 .stored_properties
2560 .value_mut()2416 .value_mut()
2561 .try_set(key.clone(), value)2417 .try_set(key.clone(), value)
2562 .map_err(<Error<T>>::from)?;2418 .map_err(<Error<T>>::from)?;
2568 ));2424 ));
2569 }2425 }
2570 None => {2426 None => {
2571 stored_properties2427 token_lazy_info
2428 .stored_properties
2572 .value_mut()2429 .value_mut()
2573 .remove(&key)2430 .remove(&key)
2574 .map_err(<Error<T>>::from)?;2431 .map_err(<Error<T>>::from)?;
2582 }2439 }
2583 }2440 }
25842441
2585 let properties_changed = stored_properties.has_value();2442 let properties_changed = token_lazy_info.stored_properties.has_value();
2586 if properties_changed {2443 if properties_changed {
2587 <PalletEvm<T>>::deposit_log(log);2444 <PalletEvm<T>>::deposit_log(log);
25882445
2589 self.collection2446 self.collection
2590 .set_token_properties_raw(token_id, stored_properties.into_inner());2447 .set_token_properties_raw(token_id, token_lazy_info.stored_properties.into_inner());
2591 }2448 }
25922449
2593 Ok(())2450 Ok(())
2594 }2451 }
2595}2452}
25962453
2597/// Create a [`PropertyWriter`] for newly created tokens.2454/// A helper structure for the [`PropertyWriter`] that holds
2455/// the collection-related info. The info is loaded using lazy evaluation.
2456/// This info is common for any token for which we write properties.
2598pub fn property_writer_for_new_token<'a, T, Handle>(2457pub struct PropertyWriterLazyCollectionInfo<FIsAdmin, FPropertyPermissions> {
2599 collection: &'a Handle,2458 is_collection_admin: LazyValue<bool, FIsAdmin>,
2600 sender: &'a T::CrossAccountId,2459 property_permissions: LazyValue<PropertiesPermissionMap, FPropertyPermissions>,
2601) -> PropertyWriter<2460}
2602 'a,2461
2603 T,
2604 Handle,
2605 NewTokenPropertyWriter,
2606 impl FnOnce() -> bool + 'a,2462/// A helper structure for the [`PropertyWriter`] that holds
2607 impl FnOnce() -> PropertiesPermissionMap + 'a,2463/// the token-related info. The info is loaded using lazy evaluation.
2608 impl Copy + FnOnce(TokenId) -> bool + 'a,2464pub struct PropertyWriterLazyTokenInfo<FCheckTokenExist, FCheckTokenOwner, FGetProperties> {
2465 is_token_exist: LazyValue<bool, FCheckTokenExist>,
2609 impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,2466 is_token_owner: LazyValue<Result<bool, DispatchError>, FCheckTokenOwner>,
2467 stored_properties: LazyValue<TokenProperties, FGetProperties>,
2468}
2469
2470impl<FCheckTokenExist, FCheckTokenOwner, FGetProperties>
2610>2471 PropertyWriterLazyTokenInfo<FCheckTokenExist, FCheckTokenOwner, FGetProperties>
2611where2472where
2473 FCheckTokenExist: FnOnce() -> bool,
2474 FCheckTokenOwner: FnOnce() -> Result<bool, DispatchError>,
2475 FGetProperties: FnOnce() -> TokenProperties,
2476{
2477 /// Create a lazy token info.
2478 pub fn new(
2479 check_token_exist: FCheckTokenExist,
2480 check_token_owner: FCheckTokenOwner,
2481 get_token_properties: FGetProperties,
2482 ) -> Self {
2483 Self {
2484 is_token_exist: LazyValue::new(check_token_exist),
2485 is_token_owner: LazyValue::new(check_token_owner),
2486 stored_properties: LazyValue::new(get_token_properties),
2487 }
2488 }
2489}
2490
2491/// A marker structure that enables the writer implementation
2492/// to provide the interface to write properties to **newly created** tokens.
2493pub struct NewTokenPropertyWriter<T>(PhantomData<T>);
2494impl<T: Config> NewTokenPropertyWriter<T> {
2495 /// Creates a [`PropertyWriter`] for **newly created** tokens.
2496 pub fn new<'a, Handle>(
2497 collection: &'a Handle,
2498 sender: &'a T::CrossAccountId,
2499 ) -> PropertyWriter<
2500 'a,
2501 Self,
2502 T,
2503 Handle,
2504 impl FnOnce() -> bool + 'a,
2505 impl FnOnce() -> PropertiesPermissionMap + 'a,
2506 >
2507 where
2508 T: Config,
2509 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2510 {
2511 PropertyWriter {
2512 collection,
2513 collection_lazy_info: PropertyWriterLazyCollectionInfo {
2514 is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
2515 property_permissions: LazyValue::new(|| {
2516 <Pallet<T>>::property_permissions(collection.id)
2517 }),
2518 },
2519 _phantom: PhantomData,
2520 }
2521 }
2522}
2523
2524impl<'a, T, Handle, FIsAdmin, FPropertyPermissions>
2525 PropertyWriter<'a, NewTokenPropertyWriter<T>, T, Handle, FIsAdmin, FPropertyPermissions>
2526where
2612 T: Config,2527 T: Config,
2613 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2528 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2529 FIsAdmin: FnOnce() -> bool,
2530 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2614{2531{
2615 PropertyWriter {2532 /// A function to write properties to a **newly created** token.
2616 collection,2533 pub fn write_token_properties(
2534 &mut self,
2617 is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),2535 mint_target_is_sender: bool,
2536 token_id: TokenId,
2618 property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),2537 properties_updates: impl Iterator<Item = Property>,
2538 log: evm_coder::ethereum::Log,
2619 check_token_exist: |token_id| {2539 ) -> DispatchResult {
2540 let check_token_exist = || {
2620 debug_assert!(collection.token_exists(token_id));2541 debug_assert!(self.collection.token_exists(token_id));
2621 true2542 true
2622 },2543 };
2544
2623 get_properties: |token_id| {2545 let check_token_owner = || Ok(mint_target_is_sender);
2546
2547 let get_token_properties = || {
2624 debug_assert!(collection.get_token_properties_raw(token_id).is_none());2548 debug_assert!(self.collection.get_token_properties_raw(token_id).is_none());
2625 TokenProperties::new()2549 TokenProperties::new()
2626 },2550 };
2551
2552 self.internal_write_token_properties(
2553 token_id,
2627 _phantom: PhantomData,2554 PropertyWriterLazyTokenInfo::new(
2555 check_token_exist,
2556 check_token_owner,
2557 get_token_properties,
2558 ),
2559 properties_updates.map(|p| (p.key, Some(p.value))),
2560 log,
2561 )
2628 }2562 }
2629}2563}
26302564
2631#[cfg(feature = "runtime-benchmarks")]
2632/// Create a `PropertyWriter` with preloaded `is_collection_admin` and `property_permissions.2565/// A marker structure that enables the writer implementation
2633/// Also:2566/// to provide the interface to write properties to **already existing** tokens.
2634/// * it will return `true` for the token ownership check.
2635/// * it will return empty stored properties without reading them from the storage.2567pub struct ExistingTokenPropertyWriter<T>(PhantomData<T>);
2568impl<T: Config> ExistingTokenPropertyWriter<T> {
2569 /// Creates a [`PropertyWriter`] for **already existing** tokens.
2636pub fn collection_info_loaded_property_writer<T, Handle>(2570 pub fn new<'a, Handle>(
2637 collection: &Handle,2571 collection: &'a Handle,
2638 is_collection_admin: bool,2572 sender: &'a T::CrossAccountId,
2639 property_permissions: PropertiesPermissionMap,2573 ) -> PropertyWriter<
2640) -> PropertyWriter<
2641 T,2574 'a,
2642 Handle,2575 Self,
2643 NewTokenPropertyWriter,2576 T,
2644 impl FnOnce() -> bool,2577 Handle,
2578 impl FnOnce() -> bool + 'a,
2645 impl FnOnce() -> PropertiesPermissionMap,2579 impl FnOnce() -> PropertiesPermissionMap + 'a,
2646 impl Copy + FnOnce(TokenId) -> bool,2580 >
2581 where
2582 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2583 {
2584 PropertyWriter {
2585 collection,
2586 collection_lazy_info: PropertyWriterLazyCollectionInfo {
2587 is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),
2588 property_permissions: LazyValue::new(|| {
2589 <Pallet<T>>::property_permissions(collection.id)
2590 }),
2591 },
2592 _phantom: PhantomData,
2647 impl Copy + FnOnce(TokenId) -> TokenProperties,2593 }
2594 }
2595}
2596
2597impl<'a, T, Handle, FIsAdmin, FPropertyPermissions>
2648>2598 PropertyWriter<'a, ExistingTokenPropertyWriter<T>, T, Handle, FIsAdmin, FPropertyPermissions>
2649where2599where
2650 T: Config,2600 T: Config,
2651 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2601 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2602 FIsAdmin: FnOnce() -> bool,
2603 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2652{2604{
2653 PropertyWriter {2605 /// A function to write properties to an **already existing** token.
2654 collection,2606 pub fn write_token_properties(
2607 &mut self,
2655 is_collection_admin: LazyValue::new(move || is_collection_admin),2608 sender: &T::CrossAccountId,
2609 token_id: TokenId,
2610 properties_updates: impl Iterator<Item = (PropertyKey, Option<PropertyValue>)>,
2656 property_permissions: LazyValue::new(move || property_permissions),2611 nesting_budget: &dyn Budget,
2612 log: evm_coder::ethereum::Log,
2613 ) -> DispatchResult {
2614 let check_token_exist = || self.collection.token_exists(token_id);
2657 check_token_exist: |_token_id| true,2615 let check_token_owner = || {
2616 self.collection
2617 .check_token_indirect_owner(token_id, sender, nesting_budget)
2658 get_properties: |_token_id| TokenProperties::new(),2618 };
2619 let get_token_properties = || {
2620 self.collection
2621 .get_token_properties_raw(token_id)
2622 .unwrap_or_default()
2623 };
2624
2625 self.internal_write_token_properties(
2626 token_id,
2627 PropertyWriterLazyTokenInfo::new(
2628 check_token_exist,
2629 check_token_owner,
2630 get_token_properties,
2631 ),
2659 _phantom: PhantomData,2632 properties_updates,
2633 log,
2634 )
2660 }2635 }
2661}2636}
26622637
2663/// Create a [`PropertyWriter`] for already existing tokens.2638/// A marker structure that enables the writer implementation
2639/// to benchmark the token properties writing.
2640#[cfg(feature = "runtime-benchmarks")]
2641pub struct BenchmarkPropertyWriter<T>(PhantomData<T>);
2642
2643#[cfg(feature = "runtime-benchmarks")]
2644impl<T: Config> BenchmarkPropertyWriter<T> {
2645 /// Creates a [`PropertyWriter`] for benchmarking tokens properties writing.
2664pub fn property_writer_for_existing_token<'a, T, Handle>(2646 pub fn new<'a, Handle, FIsAdmin, FPropertyPermissions>(
2665 collection: &'a Handle,2647 collection: &Handle,
2648 collection_lazy_info: PropertyWriterLazyCollectionInfo<FIsAdmin, FPropertyPermissions>,
2649 ) -> PropertyWriter<Self, T, Handle, FIsAdmin, FPropertyPermissions>
2666 sender: &'a T::CrossAccountId,2650 where
2651 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2652 FIsAdmin: FnOnce() -> bool,
2667) -> PropertyWriter<2653 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2654 {
2655 PropertyWriter {
2668 'a,2656 collection,
2669 T,2657 collection_lazy_info,
2670 Handle,2658 _phantom: PhantomData,
2659 }
2660 }
2661
2662 /// Load the [`PropertyWriterLazyCollectionInfo`] from the storage.
2663 pub fn load_collection_info<Handle>(
2664 collection_handle: &Handle,
2671 ExistingTokenPropertyWriter,2665 sender: &T::CrossAccountId,
2672 impl FnOnce() -> bool + 'a,2666 ) -> PropertyWriterLazyCollectionInfo<
2667 impl FnOnce() -> bool,
2673 impl FnOnce() -> PropertiesPermissionMap + 'a,2668 impl FnOnce() -> PropertiesPermissionMap,
2669 >
2670 where
2671 Handle: Deref<Target = CollectionHandle<T>>,
2674 impl Copy + FnOnce(TokenId) -> bool + 'a,2672 {
2673 let is_collection_admin = collection_handle.is_owner_or_admin(sender);
2674 let property_permissions = <Pallet<T>>::property_permissions(collection_handle.id);
2675
2676 PropertyWriterLazyCollectionInfo {
2677 is_collection_admin: LazyValue::new(move || is_collection_admin),
2678 property_permissions: LazyValue::new(move || property_permissions),
2679 }
2680 }
2681
2682 /// Load the [`PropertyWriterLazyTokenInfo`] with token properties from the storage.
2683 pub fn load_token_properties<Handle>(
2684 collection: &Handle,
2685 token_id: TokenId,
2686 ) -> PropertyWriterLazyTokenInfo<
2687 impl FnOnce() -> bool,
2675 impl Copy + FnOnce(TokenId) -> TokenProperties + 'a,2688 impl FnOnce() -> Result<bool, DispatchError>,
2689 impl FnOnce() -> TokenProperties,
2690 >
2691 where
2692 Handle: CommonCollectionOperations<T>,
2693 {
2694 let stored_properties = collection
2695 .get_token_properties_raw(token_id)
2696 .unwrap_or_default();
2697
2698 PropertyWriterLazyTokenInfo {
2699 is_token_exist: LazyValue::new(|| true),
2700 is_token_owner: LazyValue::new(|| Ok(true)),
2701 stored_properties: LazyValue::new(move || stored_properties),
2702 }
2703 }
2704}
2705
2706#[cfg(feature = "runtime-benchmarks")]
2707impl<'a, T, Handle, FIsAdmin, FPropertyPermissions>
2676>2708 PropertyWriter<'a, BenchmarkPropertyWriter<T>, T, Handle, FIsAdmin, FPropertyPermissions>
2677where2709where
2678 T: Config,2710 T: Config,
2679 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,2711 Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
2712 FIsAdmin: FnOnce() -> bool,
2713 FPropertyPermissions: FnOnce() -> PropertiesPermissionMap,
2680{2714{
2681 PropertyWriter {2715 /// A function to benchmark the writing of token properties.
2682 collection,2716 pub fn write_token_properties(
2717 &mut self,
2683 is_collection_admin: LazyValue::new(|| collection.is_owner_or_admin(sender)),2718 token_id: TokenId,
2719 properties_updates: impl Iterator<Item = Property>,
2684 property_permissions: LazyValue::new(|| <Pallet<T>>::property_permissions(collection.id)),2720 log: evm_coder::ethereum::Log,
2685 check_token_exist: |token_id| collection.token_exists(token_id),2721 ) -> DispatchResult {
2722 let check_token_exist = || true;
2723 let check_token_owner = || Ok(true);
2686 get_properties: |token_id| {2724 let get_token_properties = || TokenProperties::new();
2725
2687 collection2726 self.internal_write_token_properties(
2727 token_id,
2688 .get_token_properties_raw(token_id)2728 PropertyWriterLazyTokenInfo::new(
2729 check_token_exist,
2730 check_token_owner,
2731 get_token_properties,
2732 ),
2689 .unwrap_or_default()2733 properties_updates.map(|p| (p.key, Some(p.value))),
2690 },2734 log,
2691 _phantom: PhantomData,2735 )
2692 }2736 }
2693}2737}
26942738
2695/// Computes the weight delta for newly created tokens with properties.2739/// Computes the weight of writing properties to tokens.
2696/// * `properties_nums` - The properties num of each created token.2740/// * `properties_nums` - The properties num of each created token.
2697/// * `init_token_properties` - The function to obtain the weight from a token's properties num.2741/// * `per_token_weight_weight` - The function to obtain the weight
2742/// of writing properties from a token's properties num.
2698pub fn init_token_properties_delta<T: Config, I: Fn(u32) -> Weight>(2743pub fn write_token_properties_total_weight<T: Config, I: Fn(u32) -> Weight>(
2699 properties_nums: impl Iterator<Item = u32>,2744 properties_nums: impl Iterator<Item = u32>,
2700 init_token_properties: I,2745 per_token_weight: I,
2701) -> Weight {2746) -> Weight {
2702 let mut delta = properties_nums2747 let mut weight = properties_nums
2703 .filter_map(|properties_num| {2748 .filter_map(|properties_num| {
2704 if properties_num > 0 {2749 if properties_num > 0 {
2705 Some(init_token_properties(properties_num))2750 Some(per_token_weight(properties_num))
2706 } else {2751 } else {
2707 None2752 None
2708 }2753 }
2709 })2754 })
2710 .fold(Weight::zero(), |a, b| a.saturating_add(b));2755 .fold(Weight::zero(), |a, b| a.saturating_add(b));
2756
2757 if !weight.is_zero() {
2758 // If we are here, it means the token properties were written at least once.
2759 // Because of that, some common collection data was also loaded; we must add this weight.
2760 // However, this common data was loaded only once, which is guaranteed by the `PropertyWriter`.
27112761
2712 // If at least once the `init_token_properties` was called,2762 weight = weight.saturating_add(<SelfWeightOf<T>>::property_writer_load_collection_info());
2713 // it means at least one newly created token has properties.
2714 // Becuase of that, some common collection data also was loaded and we need to add this weight.
2715 // However, these common data was loaded only once which is guaranteed by the `PropertyWriter`.
2716 if !delta.is_zero() {
2717 delta = delta.saturating_add(<SelfWeightOf<T>>::init_token_properties_common())
2718 }2763 }
27192764
2720 delta2765 weight
2721}2766}
27222767
2723#[cfg(any(feature = "tests", test))]2768#[cfg(any(feature = "tests", test))]
modifiedpallets/common/src/weights.rsdiffbeforeafterboth
3//! Autogenerated weights for pallet_common3//! Autogenerated weights for pallet_common
4//!4//!
5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
6//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2023-10-05, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
7//! WORST CASE MAP SIZE: `1000000`7//! WORST CASE MAP SIZE: `1000000`
8//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`8//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
9//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10249//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
1010
11// Executed Command:11// Executed Command:
20// *20// *
21// --template=.maintain/frame-weight-template.hbs21// --template=.maintain/frame-weight-template.hbs
22// --steps=5022// --steps=50
23// --repeat=40023// --repeat=80
24// --heap-pages=409624// --heap-pages=4096
25// --output=./pallets/common/src/weights.rs25// --output=./pallets/common/src/weights.rs
2626
36 fn set_collection_properties(b: u32, ) -> Weight;36 fn set_collection_properties(b: u32, ) -> Weight;
37 fn delete_collection_properties(b: u32, ) -> Weight;37 fn delete_collection_properties(b: u32, ) -> Weight;
38 fn check_accesslist() -> Weight;38 fn check_accesslist() -> Weight;
39 fn init_token_properties_common() -> Weight;39 fn property_writer_load_collection_info() -> Weight;
40}40}
4141
42/// Weights for pallet_common using the Substrate node and recommended hardware.42/// Weights for pallet_common using the Substrate node and recommended hardware.
49 // Proof Size summary in bytes:49 // Proof Size summary in bytes:
50 // Measured: `298`50 // Measured: `298`
51 // Estimated: `44457`51 // Estimated: `44457`
52 // Minimum execution time: 4_987_000 picoseconds.52 // Minimum execution time: 2_840_000 picoseconds.
53 Weight::from_parts(5_119_000, 44457)53 Weight::from_parts(1_988_405, 44457)
54 // Standard Error: 7_60954 // Standard Error: 7_834
55 .saturating_add(Weight::from_parts(5_750_459, 0).saturating_mul(b.into()))55 .saturating_add(Weight::from_parts(3_053_965, 0).saturating_mul(b.into()))
56 .saturating_add(T::DbWeight::get().reads(1_u64))56 .saturating_add(T::DbWeight::get().reads(1_u64))
57 .saturating_add(T::DbWeight::get().writes(1_u64))57 .saturating_add(T::DbWeight::get().writes(1_u64))
58 }58 }
63 // Proof Size summary in bytes:63 // Proof Size summary in bytes:
64 // Measured: `303 + b * (33030 ±0)`64 // Measured: `303 + b * (33030 ±0)`
65 // Estimated: `44457`65 // Estimated: `44457`
66 // Minimum execution time: 4_923_000 picoseconds.66 // Minimum execution time: 2_770_000 picoseconds.
67 Weight::from_parts(5_074_000, 44457)67 Weight::from_parts(2_940_000, 44457)
68 // Standard Error: 36_65168 // Standard Error: 30_686
69 .saturating_add(Weight::from_parts(23_145_677, 0).saturating_mul(b.into()))69 .saturating_add(Weight::from_parts(9_801_835, 0).saturating_mul(b.into()))
70 .saturating_add(T::DbWeight::get().reads(1_u64))70 .saturating_add(T::DbWeight::get().reads(1_u64))
71 .saturating_add(T::DbWeight::get().writes(1_u64))71 .saturating_add(T::DbWeight::get().writes(1_u64))
72 }72 }
76 // Proof Size summary in bytes:76 // Proof Size summary in bytes:
77 // Measured: `373`77 // Measured: `373`
78 // Estimated: `3535`78 // Estimated: `3535`
79 // Minimum execution time: 4_271_000 picoseconds.79 // Minimum execution time: 2_830_000 picoseconds.
80 Weight::from_parts(4_461_000, 3535)80 Weight::from_parts(2_950_000, 3535)
81 .saturating_add(T::DbWeight::get().reads(1_u64))81 .saturating_add(T::DbWeight::get().reads(1_u64))
82 }82 }
83 /// Storage: Common IsAdmin (r:1 w:0)83 /// Storage: Common IsAdmin (r:1 w:0)
84 /// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)84 /// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
85 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)85 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
86 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)86 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
87 fn init_token_properties_common() -> Weight {87 fn property_writer_load_collection_info() -> Weight {
88 // Proof Size summary in bytes:88 // Proof Size summary in bytes:
89 // Measured: `326`89 // Measured: `326`
90 // Estimated: `20191`90 // Estimated: `20191`
91 // Minimum execution time: 5_889_000 picoseconds.91 // Minimum execution time: 3_970_000 picoseconds.
92 Weight::from_parts(6_138_000, 20191)92 Weight::from_parts(4_140_000, 20191)
93 .saturating_add(T::DbWeight::get().reads(2_u64))93 .saturating_add(T::DbWeight::get().reads(2_u64))
94 }94 }
95}95}
103 // Proof Size summary in bytes:103 // Proof Size summary in bytes:
104 // Measured: `298`104 // Measured: `298`
105 // Estimated: `44457`105 // Estimated: `44457`
106 // Minimum execution time: 4_987_000 picoseconds.106 // Minimum execution time: 2_840_000 picoseconds.
107 Weight::from_parts(5_119_000, 44457)107 Weight::from_parts(1_988_405, 44457)
108 // Standard Error: 7_609108 // Standard Error: 7_834
109 .saturating_add(Weight::from_parts(5_750_459, 0).saturating_mul(b.into()))109 .saturating_add(Weight::from_parts(3_053_965, 0).saturating_mul(b.into()))
110 .saturating_add(RocksDbWeight::get().reads(1_u64))110 .saturating_add(RocksDbWeight::get().reads(1_u64))
111 .saturating_add(RocksDbWeight::get().writes(1_u64))111 .saturating_add(RocksDbWeight::get().writes(1_u64))
112 }112 }
117 // Proof Size summary in bytes:117 // Proof Size summary in bytes:
118 // Measured: `303 + b * (33030 ±0)`118 // Measured: `303 + b * (33030 ±0)`
119 // Estimated: `44457`119 // Estimated: `44457`
120 // Minimum execution time: 4_923_000 picoseconds.120 // Minimum execution time: 2_770_000 picoseconds.
121 Weight::from_parts(5_074_000, 44457)121 Weight::from_parts(2_940_000, 44457)
122 // Standard Error: 36_651122 // Standard Error: 30_686
123 .saturating_add(Weight::from_parts(23_145_677, 0).saturating_mul(b.into()))123 .saturating_add(Weight::from_parts(9_801_835, 0).saturating_mul(b.into()))
124 .saturating_add(RocksDbWeight::get().reads(1_u64))124 .saturating_add(RocksDbWeight::get().reads(1_u64))
125 .saturating_add(RocksDbWeight::get().writes(1_u64))125 .saturating_add(RocksDbWeight::get().writes(1_u64))
126 }126 }
130 // Proof Size summary in bytes:130 // Proof Size summary in bytes:
131 // Measured: `373`131 // Measured: `373`
132 // Estimated: `3535`132 // Estimated: `3535`
133 // Minimum execution time: 4_271_000 picoseconds.133 // Minimum execution time: 2_830_000 picoseconds.
134 Weight::from_parts(4_461_000, 3535)134 Weight::from_parts(2_950_000, 3535)
135 .saturating_add(RocksDbWeight::get().reads(1_u64))135 .saturating_add(RocksDbWeight::get().reads(1_u64))
136 }136 }
137 /// Storage: Common IsAdmin (r:1 w:0)137 /// Storage: Common IsAdmin (r:1 w:0)
138 /// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)138 /// Proof: Common IsAdmin (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
139 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)139 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
140 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)140 /// Proof: Common CollectionPropertyPermissions (max_values: None, max_size: Some(16726), added: 19201, mode: MaxEncodedLen)
141 fn init_token_properties_common() -> Weight {141 fn property_writer_load_collection_info() -> Weight {
142 // Proof Size summary in bytes:142 // Proof Size summary in bytes:
143 // Measured: `326`143 // Measured: `326`
144 // Estimated: `20191`144 // Estimated: `20191`
145 // Minimum execution time: 5_889_000 picoseconds.145 // Minimum execution time: 3_970_000 picoseconds.
146 Weight::from_parts(6_138_000, 20191)146 Weight::from_parts(4_140_000, 20191)
147 .saturating_add(RocksDbWeight::get().reads(2_u64))147 .saturating_add(RocksDbWeight::get().reads(2_u64))
148 }148 }
149}149}
modifiedpallets/evm-coder-substrate/src/lib.rsdiffbeforeafterboth
84}84}
85impl<T: Config> budget::Budget for GasCallsBudget<'_, T> {85impl<T: Config> budget::Budget for GasCallsBudget<'_, T> {
86 fn consume_custom(&self, calls: u32) -> bool {86 fn consume_custom(&self, calls: u32) -> bool {
87 let (gas, overflown) = (calls as u64).overflowing_add(self.gas_per_call);87 let (gas, overflown) = (calls as u64).overflowing_mul(self.gas_per_call);
88 if overflown {88 if overflown {
89 return false;89 return false;
90 }90 }
modifiedpallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth
23use pallet_common::{CollectionHandle, CommonCollectionOperations};23use pallet_common::{CollectionHandle, CommonCollectionOperations};
24use pallet_fungible::FungibleHandle;24use pallet_fungible::FungibleHandle;
25use sp_runtime::traits::{CheckedAdd, CheckedSub};25use sp_runtime::traits::{CheckedAdd, CheckedSub};
26use up_data_structs::budget::Value;26use up_data_structs::budget;
2727
28use super::*;28use super::*;
2929
327 &collection,327 &collection,
328 &account,328 &account,
329 amount_data,329 amount_data,
330 &Value::new(0),330 &budget::Value::new(0),
331 )?;331 )?;
332332
333 Ok(amount)333 Ok(amount)
440 &T::CrossAccountId::from_sub(source.clone()),440 &T::CrossAccountId::from_sub(source.clone()),
441 &T::CrossAccountId::from_sub(dest.clone()),441 &T::CrossAccountId::from_sub(dest.clone()),
442 amount.into(),442 amount.into(),
443 &Value::new(0),443 &budget::Value::new(0),
444 )444 )
445 .map_err(|e| e.error)?;445 .map_err(|e| e.error)?;
446446
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
17use core::marker::PhantomData;17use core::marker::PhantomData;
1818
19use frame_support::{19use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
20 dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
21};
22use pallet_common::{20use pallet_common::{
23 weights::WeightInfo as _, with_weight, CommonCollectionOperations, CommonWeightInfo,21 weights::WeightInfo as _, with_weight, CommonCollectionOperations, CommonWeightInfo,
24 RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,22 RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,
25};23};
26use pallet_structure::Error as StructureError;
27use sp_runtime::{ArithmeticError, DispatchError};24use sp_runtime::{ArithmeticError, DispatchError};
28use sp_std::{vec, vec::Vec};25use sp_std::{vec, vec::Vec};
29use up_data_structs::{26use up_data_structs::{
60 <pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)57 <pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
61 }58 }
62
63 fn delete_collection_properties(amount: u32) -> Weight {
64 <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
65 }
6659
67 fn set_token_properties(_amount: u32) -> Weight {60 fn set_token_properties(_amount: u32) -> Weight {
68 // Error61 // Error
69 Weight::zero()62 Weight::zero()
70 }63 }
71
72 fn delete_token_properties(_amount: u32) -> Weight {
73 // Error
74 Weight::zero()
75 }
7664
77 fn set_token_property_permissions(_amount: u32) -> Weight {65 fn set_token_property_permissions(_amount: u32) -> Weight {
78 // Error66 // Error
79 Weight::zero()67 Weight::zero()
80 }68 }
8169
82 fn transfer() -> Weight {70 fn transfer() -> Weight {
83 <SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 271 <SelfWeightOf<T>>::transfer_raw()
72 .saturating_add(<PalletCommonWeightOf<T>>::check_accesslist().saturating_mul(2))
84 }73 }
8574
86 fn approve() -> Weight {75 fn approve() -> Weight {
9382
94 fn transfer_from() -> Weight {83 fn transfer_from() -> Weight {
95 Self::transfer()84 Self::transfer()
96 + <SelfWeightOf<T>>::check_allowed_raw()85 .saturating_add(<SelfWeightOf<T>>::check_allowed_raw())
97 + <SelfWeightOf<T>>::set_allowance_unchecked_raw()86 .saturating_add(<SelfWeightOf<T>>::set_allowance_unchecked_raw())
98 }87 }
9988
100 fn burn_from() -> Weight {89 fn burn_from() -> Weight {
101 <SelfWeightOf<T>>::burn_from()90 <SelfWeightOf<T>>::burn_from()
102 }91 }
103
104 fn burn_recursively_self_raw() -> Weight {
105 // Read to get total balance
106 Self::burn_item() + T::DbWeight::get().reads(1)
107 }
108
109 fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
110 // Fungible tokens can't have children
111 Weight::zero()
112 }
113
114 fn token_owner() -> Weight {
115 Weight::zero()
116 }
11792
118 fn set_allowance_for_all() -> Weight {93 fn set_allowance_for_all() -> Weight {
119 Weight::zero()94 Weight::zero()
203 )178 )
204 }179 }
205
206 fn burn_item_recursively(
207 &self,
208 sender: T::CrossAccountId,
209 token: TokenId,
210 self_budget: &dyn Budget,
211 _breadth_budget: &dyn Budget,
212 ) -> DispatchResultWithPostInfo {
213 // Should not happen?
214 ensure!(
215 token == TokenId::default(),
216 <Error<T>>::FungibleItemsHaveNoId
217 );
218 ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
219
220 with_weight(
221 <Pallet<T>>::burn(self, &sender, <Balance<T>>::get((self.id, &sender))),
222 <CommonWeights<T>>::burn_recursively_self_raw(),
223 )
224 }
225180
226 fn transfer(181 fn transfer(
227 &self,182 &self,
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
32use pallet_evm_coder_substrate::{32use pallet_evm_coder_substrate::{
33 call, dispatch_to_evm,33 call, dispatch_to_evm,
34 execution::{PreDispatch, Result},34 execution::{PreDispatch, Result},
35 frontier_contract,35 frontier_contract, SubstrateRecorder,
36};36};
37use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};37use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
38use sp_core::{Get, U256};38use sp_core::{Get, U256};
39use sp_std::vec::Vec;39use sp_std::vec::Vec;
40use up_data_structs::CollectionMode;40use up_data_structs::{budget::Budget, CollectionMode};
4141
42use crate::{42use crate::{
43 common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, FungibleHandle, Pallet,43 common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, FungibleHandle, Pallet,
73 amount: U256,73 amount: U256,
74}74}
75
76fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
77 recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
78}
7579
76#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]80#[solidity_interface(name = ERC20, events(ERC20Events), enum(derive(PreDispatch)), enum_attr(weight), expect_selector = 0x942e8b22)]
77impl<T: Config> FungibleHandle<T> {81impl<T: Config> FungibleHandle<T> {
106 let caller = T::CrossAccountId::from_eth(caller);110 let caller = T::CrossAccountId::from_eth(caller);
107 let to = T::CrossAccountId::from_eth(to);111 let to = T::CrossAccountId::from_eth(to);
108 let amount = amount.try_into().map_err(|_| "amount overflow")?;112 let amount = amount.try_into().map_err(|_| "amount overflow")?;
109 let budget = self
110 .recorder
111 .weight_calls_budget(<StructureWeight<T>>::find_parent());
112113
113 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget)114 <Pallet<T>>::transfer(self, &caller, &to, amount, &nesting_budget(&self.recorder))
114 .map_err(|e| dispatch_to_evm::<T>(e.error))?;115 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
115 Ok(true)116 Ok(true)
116 }117 }
127 let from = T::CrossAccountId::from_eth(from);128 let from = T::CrossAccountId::from_eth(from);
128 let to = T::CrossAccountId::from_eth(to);129 let to = T::CrossAccountId::from_eth(to);
129 let amount = amount.try_into().map_err(|_| "amount overflow")?;130 let amount = amount.try_into().map_err(|_| "amount overflow")?;
130 let budget = self
131 .recorder
132 .weight_calls_budget(<StructureWeight<T>>::find_parent());
133131
134 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)132 <Pallet<T>>::transfer_from(
133 self,
134 &caller,
135 &from,
136 &to,
137 amount,
138 &nesting_budget(&self.recorder),
139 )
135 .map_err(|e| dispatch_to_evm::<T>(e.error))?;140 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
136 Ok(true)141 Ok(true)
164 let caller = T::CrossAccountId::from_eth(caller);169 let caller = T::CrossAccountId::from_eth(caller);
165 let to = T::CrossAccountId::from_eth(to);170 let to = T::CrossAccountId::from_eth(to);
166 let amount = amount.try_into().map_err(|_| "amount overflow")?;171 let amount = amount.try_into().map_err(|_| "amount overflow")?;
167 let budget = self172
168 .recorder
169 .weight_calls_budget(<StructureWeight<T>>::find_parent());
170 <Pallet<T>>::create_item(self, &caller, (to, amount), &budget)173 <Pallet<T>>::create_item(self, &caller, (to, amount), &nesting_budget(&self.recorder))
171 .map_err(dispatch_to_evm::<T>)?;174 .map_err(dispatch_to_evm::<T>)?;
172 Ok(true)175 Ok(true)
173 }176 }
201 let caller = T::CrossAccountId::from_eth(caller);204 let caller = T::CrossAccountId::from_eth(caller);
202 let to = to.into_sub_cross_account::<T>()?;205 let to = to.into_sub_cross_account::<T>()?;
203 let amount = amount.try_into().map_err(|_| "amount overflow")?;206 let amount = amount.try_into().map_err(|_| "amount overflow")?;
204 let budget = self207
205 .recorder
206 .weight_calls_budget(<StructureWeight<T>>::find_parent());
207 <Pallet<T>>::create_item(self, &caller, (to, amount), &budget)208 <Pallet<T>>::create_item(self, &caller, (to, amount), &nesting_budget(&self.recorder))
208 .map_err(dispatch_to_evm::<T>)?;209 .map_err(dispatch_to_evm::<T>)?;
209 Ok(true)210 Ok(true)
210 }211 }
236 let caller = T::CrossAccountId::from_eth(caller);237 let caller = T::CrossAccountId::from_eth(caller);
237 let from = T::CrossAccountId::from_eth(from);238 let from = T::CrossAccountId::from_eth(from);
238 let amount = amount.try_into().map_err(|_| "amount overflow")?;239 let amount = amount.try_into().map_err(|_| "amount overflow")?;
239 let budget = self
240 .recorder
241 .weight_calls_budget(<StructureWeight<T>>::find_parent());
242240
243 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)241 <Pallet<T>>::burn_from(
242 self,
243 &caller,
244 &from,
245 amount,
246 &nesting_budget(&self.recorder),
247 )
244 .map_err(dispatch_to_evm::<T>)?;248 .map_err(dispatch_to_evm::<T>)?;
245 Ok(true)249 Ok(true)
260 let caller = T::CrossAccountId::from_eth(caller);264 let caller = T::CrossAccountId::from_eth(caller);
261 let from = from.into_sub_cross_account::<T>()?;265 let from = from.into_sub_cross_account::<T>()?;
262 let amount = amount.try_into().map_err(|_| "amount overflow")?;266 let amount = amount.try_into().map_err(|_| "amount overflow")?;
263 let budget = self
264 .recorder
265 .weight_calls_budget(<StructureWeight<T>>::find_parent());
266267
267 <Pallet<T>>::burn_from(self, &caller, &from, amount, &budget)268 <Pallet<T>>::burn_from(
269 self,
270 &caller,
271 &from,
272 amount,
273 &nesting_budget(&self.recorder),
274 )
268 .map_err(dispatch_to_evm::<T>)?;275 .map_err(dispatch_to_evm::<T>)?;
269 Ok(true)276 Ok(true)
274 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]281 #[weight(<SelfWeightOf<T>>::create_multiple_items_ex(amounts.len() as u32))]
275 fn mint_bulk(&mut self, caller: Caller, amounts: Vec<AmountForAddress>) -> Result<bool> {282 fn mint_bulk(&mut self, caller: Caller, amounts: Vec<AmountForAddress>) -> Result<bool> {
276 let caller = T::CrossAccountId::from_eth(caller);283 let caller = T::CrossAccountId::from_eth(caller);
277 let budget = self
278 .recorder
279 .weight_calls_budget(<StructureWeight<T>>::find_parent());
280 let amounts = amounts284 let amounts = amounts
281 .into_iter()285 .into_iter()
282 .map(|AmountForAddress { to, amount }| {286 .map(|AmountForAddress { to, amount }| {
287 })291 })
288 .collect::<Result<_>>()?;292 .collect::<Result<_>>()?;
289293
290 <Pallet<T>>::create_multiple_items(self, &caller, amounts, &budget)294 <Pallet<T>>::create_multiple_items(self, &caller, amounts, &nesting_budget(&self.recorder))
291 .map_err(dispatch_to_evm::<T>)?;295 .map_err(dispatch_to_evm::<T>)?;
292 Ok(true)296 Ok(true)
293 }297 }
297 let caller = T::CrossAccountId::from_eth(caller);301 let caller = T::CrossAccountId::from_eth(caller);
298 let to = to.into_sub_cross_account::<T>()?;302 let to = to.into_sub_cross_account::<T>()?;
299 let amount = amount.try_into().map_err(|_| "amount overflow")?;303 let amount = amount.try_into().map_err(|_| "amount overflow")?;
300 let budget = self
301 .recorder
302 .weight_calls_budget(<StructureWeight<T>>::find_parent());
303304
304 <Pallet<T>>::transfer(self, &caller, &to, amount, &budget).map_err(|_| "transfer error")?;305 <Pallet<T>>::transfer(self, &caller, &to, amount, &nesting_budget(&self.recorder))
306 .map_err(|_| "transfer error")?;
305 Ok(true)307 Ok(true)
306 }308 }
317 let from = from.into_sub_cross_account::<T>()?;319 let from = from.into_sub_cross_account::<T>()?;
318 let to = to.into_sub_cross_account::<T>()?;320 let to = to.into_sub_cross_account::<T>()?;
319 let amount = amount.try_into().map_err(|_| "amount overflow")?;321 let amount = amount.try_into().map_err(|_| "amount overflow")?;
320 let budget = self
321 .recorder
322 .weight_calls_budget(<StructureWeight<T>>::find_parent());
323322
324 <Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)323 <Pallet<T>>::transfer_from(
324 self,
325 &caller,
326 &from,
327 &to,
328 amount,
329 &nesting_budget(&self.recorder),
330 )
325 .map_err(|e| dispatch_to_evm::<T>(e.error))?;331 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
326 Ok(true)332 Ok(true)
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
263 <Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?;263 <Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?;
264 }264 }
265
266 Ok(())
267 }265 }
266
267 // set_token_properties {
268 // let b in 0..MAX_PROPERTIES_PER_ITEM;
269 // bench_init!{
270 // owner: sub; collection: collection(owner);
271 // owner: cross_from_sub;
272 // };
273 // let perms = (0..b).map(|k| PropertyKeyPermission {
274 // key: property_key(k as usize),
275 // permission: PropertyPermission {
276 // mutable: false,
277 // collection_admin: true,
278 // token_owner: true,
279 // },
280 // }).collect::<Vec<_>>();
281 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
282 // let props = (0..b).map(|k| Property {
283 // key: property_key(k as usize),
284 // value: property_value(),
285 // }).collect::<Vec<_>>();
286 // let item = create_max_item(&collection, &owner, owner.clone())?;
287 // }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
288
289 // load_token_properties {
290 // bench_init!{
291 // owner: sub; collection: collection(owner);
292 // owner: cross_from_sub;
293 // };
294
295 // let item = create_max_item(&collection, &owner, owner.clone())?;
296 // }: {
297 // pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(
298 // &collection,
299 // item,
300 // )
301 // }
302
303 // write_token_properties {
304 // let b in 0..MAX_PROPERTIES_PER_ITEM;
305 // bench_init!{
306 // owner: sub; collection: collection(owner);
307 // owner: cross_from_sub;
308 // };
309
310 // let perms = (0..b).map(|k| PropertyKeyPermission {
311 // key: property_key(k as usize),
312 // permission: PropertyPermission {
313 // mutable: false,
314 // collection_admin: true,
315 // token_owner: true,
316 // },
317 // }).collect::<Vec<_>>();
318 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
319 // let props = (0..b).map(|k| Property {
320 // key: property_key(k as usize),
321 // value: property_value(),
322 // }).collect::<Vec<_>>();
323 // let item = create_max_item(&collection, &owner, owner.clone())?;
324
325 // let lazy_collection_info = pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(
326 // &collection,
327 // &owner,
328 // );
329 // }: {
330 // let mut property_writer = pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
331
332 // property_writer.write_token_properties(
333 // item,
334 // props.into_iter(),
335 // crate::erc::ERC721TokenEvent::TokenChanged {
336 // token_id: item.into(),
337 // }
338 // .to_log(T::ContractAddress::get()),
339 // )?
340 // }
268341
269 #[benchmark]342 #[benchmark]
270 fn set_token_property_permissions(343 fn set_token_property_permissions(
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
1818
19use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};19use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
20use pallet_common::{20use pallet_common::{
21 init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,21 weights::WeightInfo as _, with_weight, write_token_properties_total_weight,
22 CommonWeightInfo, RefungibleExtensions, SelfWeightOf as PalletCommonWeightOf,22 CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions,
23 SelfWeightOf as PalletCommonWeightOf,
23};24};
39 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {40 fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
40 match data {41 match data {
41 CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)42 CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)
42 .saturating_add(init_token_properties_delta::<T, _>(43 .saturating_add(write_token_properties_total_weight::<T, _>(
43 t.iter().map(|t| t.properties.len() as u32),44 t.iter().map(|t| t.properties.len() as u32),
44 <SelfWeightOf<T>>::init_token_properties,45 <SelfWeightOf<T>>::write_token_properties,
45 )),46 )),
46 _ => Weight::zero(),47 _ => Weight::zero(),
47 }48 }
48 }49 }
4950
50 fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {51 fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
51 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(52 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
52 init_token_properties_delta::<T, _>(53 write_token_properties_total_weight::<T, _>(
53 data.iter().map(|t| match t {54 data.iter().map(|t| match t {
54 up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,55 up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,
55 _ => 0,56 _ => 0,
56 }),57 }),
57 <SelfWeightOf<T>>::init_token_properties,58 <SelfWeightOf<T>>::write_token_properties,
58 ),59 ),
59 )60 )
60 }61 }
67 <pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)68 <pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
68 }69 }
69
70 fn delete_collection_properties(amount: u32) -> Weight {
71 <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
72 }
7370
74 fn set_token_properties(amount: u32) -> Weight {71 fn set_token_properties(amount: u32) -> Weight {
72 write_token_properties_total_weight::<T, _>([amount].into_iter(), |amount| {
75 <SelfWeightOf<T>>::set_token_properties(amount)73 <SelfWeightOf<T>>::load_token_properties()
74 .saturating_add(<SelfWeightOf<T>>::write_token_properties(amount))
75 })
76 }76 }
7777
78 fn delete_token_properties(amount: u32) -> Weight {78 fn delete_token_properties(amount: u32) -> Weight {
79 <SelfWeightOf<T>>::delete_token_properties(amount)79 Self::set_token_properties(amount)
80 }80 }
8181
82 fn set_token_property_permissions(amount: u32) -> Weight {82 fn set_token_property_permissions(amount: u32) -> Weight {
83 <SelfWeightOf<T>>::set_token_property_permissions(amount)83 <SelfWeightOf<T>>::set_token_property_permissions(amount)
84 }84 }
8585
86 fn transfer() -> Weight {86 fn transfer() -> Weight {
87 <SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 287 <SelfWeightOf<T>>::transfer_raw()
88 .saturating_add(<PalletCommonWeightOf<T>>::check_accesslist().saturating_mul(2))
88 }89 }
8990
90 fn approve() -> Weight {91 fn approve() -> Weight {
96 }97 }
9798
98 fn transfer_from() -> Weight {99 fn transfer_from() -> Weight {
99 Self::transfer() + <SelfWeightOf<T>>::check_allowed_raw()100 Self::transfer().saturating_add(<SelfWeightOf<T>>::check_allowed_raw())
100 }101 }
101102
102 fn burn_from() -> Weight {103 fn burn_from() -> Weight {
103 <SelfWeightOf<T>>::burn_from()104 <SelfWeightOf<T>>::burn_from()
104 }105 }
105
106 fn burn_recursively_self_raw() -> Weight {
107 <SelfWeightOf<T>>::burn_recursively_self_raw()
108 }
109
110 fn burn_recursively_breadth_raw(amount: u32) -> Weight {
111 <SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)
112 .saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))
113 }
114
115 fn token_owner() -> Weight {
116 <SelfWeightOf<T>>::token_owner()
117 }
118106
119 fn set_allowance_for_all() -> Weight {107 fn set_allowance_for_all() -> Weight {
120 <SelfWeightOf<T>>::set_allowance_for_all()108 <SelfWeightOf<T>>::set_allowance_for_all()
308 }296 }
309 }297 }
310
311 fn burn_item_recursively(
312 &self,
313 sender: T::CrossAccountId,
314 token: TokenId,
315 self_budget: &dyn Budget,
316 breadth_budget: &dyn Budget,
317 ) -> DispatchResultWithPostInfo {
318 <Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)
319 }
320298
321 fn transfer(299 fn transfer(
322 &self,300 &self,
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
38use pallet_evm_coder_substrate::{38use pallet_evm_coder_substrate::{
39 call, dispatch_to_evm,39 call, dispatch_to_evm,
40 execution::{Error, PreDispatch, Result},40 execution::{Error, PreDispatch, Result},
41 frontier_contract,41 frontier_contract, SubstrateRecorder,
42};42};
43use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};43use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
44use sp_core::{Get, U256};44use sp_core::{Get, U256};
45use sp_std::{vec, vec::Vec};45use sp_std::{vec, vec::Vec};
46use up_data_structs::{46use up_data_structs::{
47 CollectionId, CollectionPropertiesVec, Property, PropertyKey, PropertyKeyPermission,47 budget::Budget, CollectionId, CollectionPropertiesVec, Property, PropertyKey,
48 PropertyPermission, TokenId,48 PropertyKeyPermission, PropertyPermission, TokenId,
49};49};
5050
78 impl<T: Config> Contract for NonfungibleHandle<T> {...}78 impl<T: Config> Contract for NonfungibleHandle<T> {...}
79}79}
80
81fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
82 recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
83}
8084
81/// @title A contract that allows to set and delete token properties and change token property permissions.85/// @title A contract that allows to set and delete token properties and change token property permissions.
82#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]86#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
146 /// @param key Property key.150 /// @param key Property key.
147 /// @param value Property value.151 /// @param value Property value.
148 #[solidity(hide)]152 #[solidity(hide)]
149 #[weight(<SelfWeightOf<T>>::set_token_properties(1))]153 #[weight(<CommonWeights<T>>::set_token_properties(1))]
150 fn set_property(154 fn set_property(
151 &mut self,155 &mut self,
152 caller: Caller,156 caller: Caller,
161 .map_err(|_| "key too long")?;165 .map_err(|_| "key too long")?;
162 let value = value.0.try_into().map_err(|_| "value too long")?;166 let value = value.0.try_into().map_err(|_| "value too long")?;
163
164 let nesting_budget = self
165 .recorder
166 .weight_calls_budget(<StructureWeight<T>>::find_parent());
167167
168 <Pallet<T>>::set_token_property(168 <Pallet<T>>::set_token_property(
169 self,169 self,
170 &caller,170 &caller,
171 TokenId(token_id),171 TokenId(token_id),
172 Property { key, value },172 Property { key, value },
173 &nesting_budget,173 &nesting_budget(&self.recorder),
174 )174 )
175 .map_err(dispatch_to_evm::<T>)175 .map_err(dispatch_to_evm::<T>)
176 }176 }
179 /// @dev Throws error if `msg.sender` has no permission to edit the property.179 /// @dev Throws error if `msg.sender` has no permission to edit the property.
180 /// @param tokenId ID of the token.180 /// @param tokenId ID of the token.
181 /// @param properties settable properties181 /// @param properties settable properties
182 #[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]182 #[weight(<CommonWeights<T>>::set_token_properties(properties.len() as u32))]
183 fn set_properties(183 fn set_properties(
184 &mut self,184 &mut self,
185 caller: Caller,185 caller: Caller,
189 let caller = T::CrossAccountId::from_eth(caller);189 let caller = T::CrossAccountId::from_eth(caller);
190 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;190 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
191
192 let nesting_budget = self
193 .recorder
194 .weight_calls_budget(<StructureWeight<T>>::find_parent());
195191
196 let properties = properties192 let properties = properties
197 .into_iter()193 .into_iter()
203 &caller,199 &caller,
204 TokenId(token_id),200 TokenId(token_id),
205 properties.into_iter(),201 properties.into_iter(),
206 &nesting_budget,202 &nesting_budget(&self.recorder),
207 )203 )
208 .map_err(dispatch_to_evm::<T>)204 .map_err(dispatch_to_evm::<T>)
209 }205 }
213 /// @param tokenId ID of the token.209 /// @param tokenId ID of the token.
214 /// @param key Property key.210 /// @param key Property key.
215 #[solidity(hide)]211 #[solidity(hide)]
216 #[weight(<SelfWeightOf<T>>::delete_token_properties(1))]212 #[weight(<CommonWeights<T>>::delete_token_properties(1))]
217 fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {213 fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
218 let caller = T::CrossAccountId::from_eth(caller);214 let caller = T::CrossAccountId::from_eth(caller);
219 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;215 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
220 let key = <Vec<u8>>::from(key)216 let key = <Vec<u8>>::from(key)
221 .try_into()217 .try_into()
222 .map_err(|_| "key too long")?;218 .map_err(|_| "key too long")?;
223
224 let nesting_budget = self
225 .recorder
226 .weight_calls_budget(<StructureWeight<T>>::find_parent());
227219
228 <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)220 <Pallet<T>>::delete_token_property(
221 self,
222 &caller,
223 TokenId(token_id),
224 key,
225 &nesting_budget(&self.recorder),
226 )
229 .map_err(dispatch_to_evm::<T>)227 .map_err(dispatch_to_evm::<T>)
230 }228 }
231229
232 /// @notice Delete token properties value.230 /// @notice Delete token properties value.
233 /// @dev Throws error if `msg.sender` has no permission to edit the property.231 /// @dev Throws error if `msg.sender` has no permission to edit the property.
234 /// @param tokenId ID of the token.232 /// @param tokenId ID of the token.
235 /// @param keys Properties key.233 /// @param keys Properties key.
236 #[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]234 #[weight(<CommonWeights<T>>::delete_token_properties(keys.len() as u32))]
237 fn delete_properties(235 fn delete_properties(
238 &mut self,236 &mut self,
239 token_id: U256,237 token_id: U256,
247 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))245 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
248 .collect::<Result<Vec<_>>>()?;246 .collect::<Result<Vec<_>>>()?;
249
250 let nesting_budget = self
251 .recorder
252 .weight_calls_budget(<StructureWeight<T>>::find_parent());
253247
254 <Pallet<T>>::delete_token_properties(248 <Pallet<T>>::delete_token_properties(
255 self,249 self,
256 &caller,250 &caller,
257 TokenId(token_id),251 TokenId(token_id),
258 keys.into_iter(),252 keys.into_iter(),
259 &nesting_budget,253 &nesting_budget(&self.recorder),
260 )254 )
261 .map_err(dispatch_to_evm::<T>)255 .map_err(dispatch_to_evm::<T>)
262 }256 }
481 let from = T::CrossAccountId::from_eth(from);475 let from = T::CrossAccountId::from_eth(from);
482 let to = T::CrossAccountId::from_eth(to);476 let to = T::CrossAccountId::from_eth(to);
483 let token = token_id.try_into()?;477 let token = token_id.try_into()?;
484 let budget = self
485 .recorder
486 .weight_calls_budget(<StructureWeight<T>>::find_parent());
487478
488 <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, &budget)479 <Pallet<T>>::transfer_from(
480 self,
481 &caller,
482 &from,
483 &to,
484 token,
485 &nesting_budget(&self.recorder),
486 )
489 .map_err(|e| dispatch_to_evm::<T>(e.error))?;487 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
490 Ok(())488 Ok(())
594 let caller = T::CrossAccountId::from_eth(caller);592 let caller = T::CrossAccountId::from_eth(caller);
595 let to = T::CrossAccountId::from_eth(to);593 let to = T::CrossAccountId::from_eth(to);
596 let token_id: u32 = token_id.try_into()?;594 let token_id: u32 = token_id.try_into()?;
597 let budget = self
598 .recorder
599 .weight_calls_budget(<StructureWeight<T>>::find_parent());
600595
601 if <TokensMinted<T>>::get(self.id)596 if <TokensMinted<T>>::get(self.id)
602 .checked_add(1)597 .checked_add(1)
613 properties: BoundedVec::default(),608 properties: BoundedVec::default(),
614 owner: to,609 owner: to,
615 },610 },
616 &budget,611 &nesting_budget(&self.recorder),
617 )612 )
618 .map_err(dispatch_to_evm::<T>)?;613 .map_err(dispatch_to_evm::<T>)?;
619614
664 let caller = T::CrossAccountId::from_eth(caller);659 let caller = T::CrossAccountId::from_eth(caller);
665 let to = T::CrossAccountId::from_eth(to);660 let to = T::CrossAccountId::from_eth(to);
666 let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;661 let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
667 let budget = self
668 .recorder
669 .weight_calls_budget(<StructureWeight<T>>::find_parent());
670662
671 if <TokensMinted<T>>::get(self.id)663 if <TokensMinted<T>>::get(self.id)
672 .checked_add(1)664 .checked_add(1)
694 properties,686 properties,
695 owner: to,687 owner: to,
696 },688 },
697 &budget,689 &nesting_budget(&self.recorder),
698 )690 )
699 .map_err(dispatch_to_evm::<T>)?;691 .map_err(dispatch_to_evm::<T>)?;
700 Ok(true)692 Ok(true)
840 let caller = T::CrossAccountId::from_eth(caller);832 let caller = T::CrossAccountId::from_eth(caller);
841 let to = T::CrossAccountId::from_eth(to);833 let to = T::CrossAccountId::from_eth(to);
842 let token = token_id.try_into()?;834 let token = token_id.try_into()?;
843 let budget = self
844 .recorder
845 .weight_calls_budget(<StructureWeight<T>>::find_parent());
846835
847 <Pallet<T>>::transfer(self, &caller, &to, token, &budget)836 <Pallet<T>>::transfer(self, &caller, &to, token, &nesting_budget(&self.recorder))
848 .map_err(|e| dispatch_to_evm::<T>(e.error))?;837 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
849 Ok(())838 Ok(())
850 }839 }
864 let caller = T::CrossAccountId::from_eth(caller);853 let caller = T::CrossAccountId::from_eth(caller);
865 let to = to.into_sub_cross_account::<T>()?;854 let to = to.into_sub_cross_account::<T>()?;
866 let token = token_id.try_into()?;855 let token = token_id.try_into()?;
867 let budget = self
868 .recorder
869 .weight_calls_budget(<StructureWeight<T>>::find_parent());
870856
871 <Pallet<T>>::transfer(self, &caller, &to, token, &budget)857 <Pallet<T>>::transfer(self, &caller, &to, token, &nesting_budget(&self.recorder))
872 .map_err(|e| dispatch_to_evm::<T>(e.error))?;858 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
873 Ok(())859 Ok(())
874 }860 }
891 let from = from.into_sub_cross_account::<T>()?;877 let from = from.into_sub_cross_account::<T>()?;
892 let to = to.into_sub_cross_account::<T>()?;878 let to = to.into_sub_cross_account::<T>()?;
893 let token_id = token_id.try_into()?;879 let token_id = token_id.try_into()?;
894 let budget = self880
895 .recorder
896 .weight_calls_budget(<StructureWeight<T>>::find_parent());
897 Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, &budget)881 Pallet::<T>::transfer_from(
882 self,
883 &caller,
884 &from,
885 &to,
886 token_id,
887 &nesting_budget(&self.recorder),
888 )
898 .map_err(|e| dispatch_to_evm::<T>(e.error))?;889 .map_err(|e| dispatch_to_evm::<T>(e.error))?;
899 Ok(())890 Ok(())
911 let caller = T::CrossAccountId::from_eth(caller);902 let caller = T::CrossAccountId::from_eth(caller);
912 let from = T::CrossAccountId::from_eth(from);903 let from = T::CrossAccountId::from_eth(from);
913 let token = token_id.try_into()?;904 let token = token_id.try_into()?;
914 let budget = self
915 .recorder
916 .weight_calls_budget(<StructureWeight<T>>::find_parent());
917905
918 <Pallet<T>>::burn_from(self, &caller, &from, token, &budget)906 <Pallet<T>>::burn_from(self, &caller, &from, token, &nesting_budget(&self.recorder))
919 .map_err(dispatch_to_evm::<T>)?;907 .map_err(dispatch_to_evm::<T>)?;
920 Ok(())908 Ok(())
921 }909 }
936 let caller = T::CrossAccountId::from_eth(caller);924 let caller = T::CrossAccountId::from_eth(caller);
937 let from = from.into_sub_cross_account::<T>()?;925 let from = from.into_sub_cross_account::<T>()?;
938 let token = token_id.try_into()?;926 let token = token_id.try_into()?;
939 let budget = self
940 .recorder
941 .weight_calls_budget(<StructureWeight<T>>::find_parent());
942927
943 <Pallet<T>>::burn_from(self, &caller, &from, token, &budget)928 <Pallet<T>>::burn_from(self, &caller, &from, token, &nesting_budget(&self.recorder))
944 .map_err(dispatch_to_evm::<T>)?;929 .map_err(dispatch_to_evm::<T>)?;
945 Ok(())930 Ok(())
946 }931 }
966 let mut expected_index = <TokensMinted<T>>::get(self.id)951 let mut expected_index = <TokensMinted<T>>::get(self.id)
967 .checked_add(1)952 .checked_add(1)
968 .ok_or("item id overflow")?;953 .ok_or("item id overflow")?;
969 let budget = self
970 .recorder
971 .weight_calls_budget(<StructureWeight<T>>::find_parent());
972954
973 let total_tokens = token_ids.len();955 let total_tokens = token_ids.len();
974 for id in token_ids.into_iter() {956 for id in token_ids.into_iter() {
985 })967 })
986 .collect();968 .collect();
987969
988 <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)970 <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
989 .map_err(dispatch_to_evm::<T>)?;971 .map_err(dispatch_to_evm::<T>)?;
990 Ok(true)972 Ok(true)
991 }973 }
995 #[weight(<SelfWeightOf<T>>::create_multiple_items(data.len() as u32) + <SelfWeightOf<T>>::set_token_properties(data.len() as u32))]977 #[weight(<SelfWeightOf<T>>::create_multiple_items(data.len() as u32) + <SelfWeightOf<T>>::set_token_properties(data.len() as u32))]
996 fn mint_bulk_cross(&mut self, caller: Caller, data: Vec<MintTokenData>) -> Result<bool> {978 fn mint_bulk_cross(&mut self, caller: Caller, data: Vec<MintTokenData>) -> Result<bool> {
997 let caller = T::CrossAccountId::from_eth(caller);979 let caller = T::CrossAccountId::from_eth(caller);
998 let budget = self
999 .recorder
1000 .weight_calls_budget(<StructureWeight<T>>::find_parent());
1001980
1002 let mut create_nft_data = Vec::with_capacity(data.len());981 let mut create_nft_data = Vec::with_capacity(data.len());
1003 for MintTokenData { owner, properties } in data {982 for MintTokenData { owner, properties } in data {
1013 });992 });
1014 }993 }
1015994
1016 <Pallet<T>>::create_multiple_items(self, &caller, create_nft_data, &budget)995 <Pallet<T>>::create_multiple_items(
996 self,
997 &caller,
998 create_nft_data,
999 &nesting_budget(&self.recorder),
1000 )
1017 .map_err(dispatch_to_evm::<T>)?;1001 .map_err(dispatch_to_evm::<T>)?;
1018 Ok(true)1002 Ok(true)
1037 let mut expected_index = <TokensMinted<T>>::get(self.id)1021 let mut expected_index = <TokensMinted<T>>::get(self.id)
1038 .checked_add(1)1022 .checked_add(1)
1039 .ok_or("item id overflow")?;1023 .ok_or("item id overflow")?;
1040 let budget = self
1041 .recorder
1042 .weight_calls_budget(<StructureWeight<T>>::find_parent());
10431024
1044 let mut data = Vec::with_capacity(tokens.len());1025 let mut data = Vec::with_capacity(tokens.len());
1045 for TokenUri { id, uri } in tokens {1026 for TokenUri { id, uri } in tokens {
1066 });1047 });
1067 }1048 }
10681049
1069 <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1050 <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
1070 .map_err(dispatch_to_evm::<T>)?;1051 .map_err(dispatch_to_evm::<T>)?;
1071 Ok(true)1052 Ok(true)
1072 }1053 }
10971078
1098 let caller = T::CrossAccountId::from_eth(caller);1079 let caller = T::CrossAccountId::from_eth(caller);
1099
1100 let budget = self
1101 .recorder
1102 .weight_calls_budget(<StructureWeight<T>>::find_parent());
11031080
1104 <Pallet<T>>::create_item(1081 <Pallet<T>>::create_item(
1105 self,1082 self,
1108 properties,1085 properties,
1109 owner: to,1086 owner: to,
1110 },1087 },
1111 &budget,1088 &nesting_budget(&self.recorder),
1112 )1089 )
1113 .map_err(dispatch_to_evm::<T>)?;1090 .map_err(dispatch_to_evm::<T>)?;
11141091
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
109};109};
110use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};110use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
111use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};111use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
112use pallet_structure::{Error as StructureError, Pallet as PalletStructure};112use pallet_structure::Pallet as PalletStructure;
113use parity_scale_codec::{Decode, Encode, MaxEncodedLen};113use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
114use scale_info::TypeInfo;114use scale_info::TypeInfo;
115use sp_core::{Get, H160};115use sp_core::{Get, H160};
503 Ok(())503 Ok(())
504 }504 }
505
506 /// Same as [`burn`] but burns all the tokens that are nested in the token first
507 ///
508 /// - `self_budget`: Limit for searching children in depth.
509 /// - `breadth_budget`: Limit of breadth of searching children.
510 ///
511 /// [`burn`]: struct.Pallet.html#method.burn
512 #[transactional]
513 pub fn burn_recursively(
514 collection: &NonfungibleHandle<T>,
515 sender: &T::CrossAccountId,
516 token: TokenId,
517 self_budget: &dyn Budget,
518 breadth_budget: &dyn Budget,
519 ) -> DispatchResultWithPostInfo {
520 ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
521
522 let current_token_account =
523 T::CrossTokenAddressMapping::token_to_address(collection.id, token);
524
525 let mut weight = Weight::zero();
526
527 // This method is transactional, if user in fact doesn't have permissions to remove token -
528 // tokens removed here will be restored after rejected transaction
529 for ((collection, token), _) in <TokenChildren<T>>::iter_prefix((collection.id, token)) {
530 ensure!(breadth_budget.consume(), <StructureError<T>>::BreadthLimit,);
531 let PostDispatchInfo { actual_weight, .. } =
532 <PalletStructure<T>>::burn_item_recursively(
533 current_token_account.clone(),
534 collection,
535 token,
536 self_budget,
537 breadth_budget,
538 )?;
539 if let Some(actual_weight) = actual_weight {
540 weight = weight.saturating_add(actual_weight);
541 }
542 }
543
544 Self::burn(collection, sender, token)?;
545 DispatchResultWithPostInfo::Ok(PostDispatchInfo {
546 actual_weight: Some(weight + <SelfWeightOf<T>>::burn_item()),
547 pays_fee: Pays::Yes,
548 })
549 }
550505
551 /// A batch operation to add, edit or remove properties for a token.506 /// A batch operation to add, edit or remove properties for a token.
552 ///507 ///
568 nesting_budget: &dyn Budget,523 nesting_budget: &dyn Budget,
569 ) -> DispatchResult {524 ) -> DispatchResult {
570 let mut property_writer =525 let mut property_writer =
571 pallet_common::property_writer_for_existing_token(collection, sender);526 pallet_common::ExistingTokenPropertyWriter::new(collection, sender);
572527
573 property_writer.write_token_properties(528 property_writer.write_token_properties(
574 sender,529 sender,
915870
916 // =========871 // =========
917872
918 let mut property_writer = pallet_common::property_writer_for_new_token(collection, sender);873 let mut property_writer = pallet_common::NewTokenPropertyWriter::new(collection, sender);
919874
920 with_transaction(|| {875 with_transaction(|| {
921 for (i, data) in data.iter().enumerate() {876 for (i, data) in data.iter().enumerate() {
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
3//! Autogenerated weights for pallet_nonfungible3//! Autogenerated weights for pallet_nonfungible
4//!4//!
5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
6//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2023-10-05, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
7//! WORST CASE MAP SIZE: `1000000`7//! WORST CASE MAP SIZE: `1000000`
8//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`8//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
9//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10249//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
1010
11// Executed Command:11// Executed Command:
20// *20// *
21// --template=.maintain/frame-weight-template.hbs21// --template=.maintain/frame-weight-template.hbs
22// --steps=5022// --steps=50
23// --repeat=40023// --repeat=80
24// --heap-pages=409624// --heap-pages=4096
25// --output=./pallets/nonfungible/src/weights.rs25// --output=./pallets/nonfungible/src/weights.rs
2626
46 fn burn_from() -> Weight;46 fn burn_from() -> Weight;
47 fn set_token_property_permissions(b: u32, ) -> Weight;47 fn set_token_property_permissions(b: u32, ) -> Weight;
48 fn set_token_properties(b: u32, ) -> Weight;48 fn set_token_properties(b: u32, ) -> Weight;
49 fn load_token_properties() -> Weight;
49 fn init_token_properties(b: u32, ) -> Weight;50 fn write_token_properties(b: u32, ) -> Weight;
50 fn delete_token_properties(b: u32, ) -> Weight;51 fn delete_token_properties(b: u32, ) -> Weight;
51 fn token_owner() -> Weight;52 fn token_owner() -> Weight;
52 fn set_allowance_for_all() -> Weight;53 fn set_allowance_for_all() -> Weight;
69 // Proof Size summary in bytes:70 // Proof Size summary in bytes:
70 // Measured: `142`71 // Measured: `142`
71 // Estimated: `3530`72 // Estimated: `3530`
72 // Minimum execution time: 9_726_000 picoseconds.73 // Minimum execution time: 4_990_000 picoseconds.
73 Weight::from_parts(10_059_000, 3530)74 Weight::from_parts(5_170_000, 3530)
74 .saturating_add(T::DbWeight::get().reads(2_u64))75 .saturating_add(T::DbWeight::get().reads(2_u64))
75 .saturating_add(T::DbWeight::get().writes(4_u64))76 .saturating_add(T::DbWeight::get().writes(4_u64))
76 }77 }
87 // Proof Size summary in bytes:88 // Proof Size summary in bytes:
88 // Measured: `142`89 // Measured: `142`
89 // Estimated: `3530`90 // Estimated: `3530`
90 // Minimum execution time: 3_270_000 picoseconds.91 // Minimum execution time: 1_680_000 picoseconds.
91 Weight::from_parts(3_693_659, 3530)92 Weight::from_parts(1_720_000, 3530)
92 // Standard Error: 25593 // Standard Error: 674
93 .saturating_add(Weight::from_parts(3_024_284, 0).saturating_mul(b.into()))94 .saturating_add(Weight::from_parts(2_406_591, 0).saturating_mul(b.into()))
94 .saturating_add(T::DbWeight::get().reads(2_u64))95 .saturating_add(T::DbWeight::get().reads(2_u64))
95 .saturating_add(T::DbWeight::get().writes(2_u64))96 .saturating_add(T::DbWeight::get().writes(2_u64))
96 .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))97 .saturating_add(T::DbWeight::get().writes((2_u64).saturating_mul(b.into())))
108 // Proof Size summary in bytes:109 // Proof Size summary in bytes:
109 // Measured: `142`110 // Measured: `142`
110 // Estimated: `3481 + b * (2540 ±0)`111 // Estimated: `3481 + b * (2540 ±0)`
111 // Minimum execution time: 3_188_000 picoseconds.112 // Minimum execution time: 1_680_000 picoseconds.
112 Weight::from_parts(3_307_000, 3481)113 Weight::from_parts(1_720_000, 3481)
113 // Standard Error: 567114 // Standard Error: 1_729
114 .saturating_add(Weight::from_parts(4_320_449, 0).saturating_mul(b.into()))115 .saturating_add(Weight::from_parts(3_418_983, 0).saturating_mul(b.into()))
115 .saturating_add(T::DbWeight::get().reads(1_u64))116 .saturating_add(T::DbWeight::get().reads(1_u64))
116 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))117 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
117 .saturating_add(T::DbWeight::get().writes(1_u64))118 .saturating_add(T::DbWeight::get().writes(1_u64))
136 // Proof Size summary in bytes:137 // Proof Size summary in bytes:
137 // Measured: `380`138 // Measured: `380`
138 // Estimated: `3530`139 // Estimated: `3530`
139 // Minimum execution time: 18_062_000 picoseconds.140 // Minimum execution time: 10_700_000 picoseconds.
140 Weight::from_parts(18_433_000, 3530)141 Weight::from_parts(11_180_000, 3530)
141 .saturating_add(T::DbWeight::get().reads(5_u64))142 .saturating_add(T::DbWeight::get().reads(5_u64))
142 .saturating_add(T::DbWeight::get().writes(5_u64))143 .saturating_add(T::DbWeight::get().writes(5_u64))
143 }144 }
159 // Proof Size summary in bytes:160 // Proof Size summary in bytes:
160 // Measured: `380`161 // Measured: `380`
161 // Estimated: `3530`162 // Estimated: `3530`
162 // Minimum execution time: 22_942_000 picoseconds.163 // Minimum execution time: 13_650_000 picoseconds.
163 Weight::from_parts(23_527_000, 3530)164 Weight::from_parts(13_910_000, 3530)
164 .saturating_add(T::DbWeight::get().reads(5_u64))165 .saturating_add(T::DbWeight::get().reads(5_u64))
165 .saturating_add(T::DbWeight::get().writes(5_u64))166 .saturating_add(T::DbWeight::get().writes(5_u64))
166 }167 }
185 // Proof Size summary in bytes:186 // Proof Size summary in bytes:
186 // Measured: `1500 + b * (58 ±0)`187 // Measured: `1500 + b * (58 ±0)`
187 // Estimated: `5874 + b * (5032 ±0)`188 // Estimated: `5874 + b * (5032 ±0)`
188 // Minimum execution time: 22_709_000 picoseconds.189 // Minimum execution time: 13_500_000 picoseconds.
189 Weight::from_parts(23_287_000, 5874)190 Weight::from_parts(13_830_000, 5874)
190 // Standard Error: 89_471191 // Standard Error: 136_447
191 .saturating_add(Weight::from_parts(63_285_201, 0).saturating_mul(b.into()))192 .saturating_add(Weight::from_parts(43_149_279, 0).saturating_mul(b.into()))
192 .saturating_add(T::DbWeight::get().reads(7_u64))193 .saturating_add(T::DbWeight::get().reads(7_u64))
193 .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(b.into())))194 .saturating_add(T::DbWeight::get().reads((4_u64).saturating_mul(b.into())))
194 .saturating_add(T::DbWeight::get().writes(6_u64))195 .saturating_add(T::DbWeight::get().writes(6_u64))
207 // Proof Size summary in bytes:208 // Proof Size summary in bytes:
208 // Measured: `380`209 // Measured: `380`
209 // Estimated: `6070`210 // Estimated: `6070`
210 // Minimum execution time: 13_652_000 picoseconds.211 // Minimum execution time: 8_440_000 picoseconds.
211 Weight::from_parts(13_981_000, 6070)212 Weight::from_parts(8_680_000, 6070)
212 .saturating_add(T::DbWeight::get().reads(4_u64))213 .saturating_add(T::DbWeight::get().reads(4_u64))
213 .saturating_add(T::DbWeight::get().writes(5_u64))214 .saturating_add(T::DbWeight::get().writes(5_u64))
214 }215 }
220 // Proof Size summary in bytes:221 // Proof Size summary in bytes:
221 // Measured: `326`222 // Measured: `326`
222 // Estimated: `3522`223 // Estimated: `3522`
223 // Minimum execution time: 7_837_000 picoseconds.224 // Minimum execution time: 4_580_000 picoseconds.
224 Weight::from_parts(8_113_000, 3522)225 Weight::from_parts(4_850_000, 3522)
225 .saturating_add(T::DbWeight::get().reads(2_u64))226 .saturating_add(T::DbWeight::get().reads(2_u64))
226 .saturating_add(T::DbWeight::get().writes(1_u64))227 .saturating_add(T::DbWeight::get().writes(1_u64))
227 }228 }
233 // Proof Size summary in bytes:234 // Proof Size summary in bytes:
234 // Measured: `313`235 // Measured: `313`
235 // Estimated: `3522`236 // Estimated: `3522`
236 // Minimum execution time: 7_769_000 picoseconds.237 // Minimum execution time: 4_650_000 picoseconds.
237 Weight::from_parts(7_979_000, 3522)238 Weight::from_parts(4_890_000, 3522)
238 .saturating_add(T::DbWeight::get().reads(2_u64))239 .saturating_add(T::DbWeight::get().reads(2_u64))
239 .saturating_add(T::DbWeight::get().writes(1_u64))240 .saturating_add(T::DbWeight::get().writes(1_u64))
240 }241 }
244 // Proof Size summary in bytes:245 // Proof Size summary in bytes:
245 // Measured: `362`246 // Measured: `362`
246 // Estimated: `3522`247 // Estimated: `3522`
247 // Minimum execution time: 4_194_000 picoseconds.248 // Minimum execution time: 2_630_000 picoseconds.
248 Weight::from_parts(4_353_000, 3522)249 Weight::from_parts(2_760_000, 3522)
249 .saturating_add(T::DbWeight::get().reads(1_u64))250 .saturating_add(T::DbWeight::get().reads(1_u64))
250 }251 }
251 /// Storage: Nonfungible Allowance (r:1 w:1)252 /// Storage: Nonfungible Allowance (r:1 w:1)
266 // Proof Size summary in bytes:267 // Proof Size summary in bytes:
267 // Measured: `463`268 // Measured: `463`
268 // Estimated: `3530`269 // Estimated: `3530`
269 // Minimum execution time: 21_978_000 picoseconds.270 // Minimum execution time: 13_300_000 picoseconds.
270 Weight::from_parts(22_519_000, 3530)271 Weight::from_parts(13_650_000, 3530)
271 .saturating_add(T::DbWeight::get().reads(5_u64))272 .saturating_add(T::DbWeight::get().reads(5_u64))
272 .saturating_add(T::DbWeight::get().writes(6_u64))273 .saturating_add(T::DbWeight::get().writes(6_u64))
273 }274 }
278 // Proof Size summary in bytes:279 // Proof Size summary in bytes:
279 // Measured: `314`280 // Measured: `314`
280 // Estimated: `20191`281 // Estimated: `20191`
281 // Minimum execution time: 1_457_000 picoseconds.282 // Minimum execution time: 550_000 picoseconds.
282 Weight::from_parts(1_563_000, 20191)283 Weight::from_parts(600_000, 20191)
283 // Standard Error: 14_041284 // Standard Error: 23_117
284 .saturating_add(Weight::from_parts(8_452_415, 0).saturating_mul(b.into()))285 .saturating_add(Weight::from_parts(6_048_092, 0).saturating_mul(b.into()))
285 .saturating_add(T::DbWeight::get().reads(1_u64))286 .saturating_add(T::DbWeight::get().reads(1_u64))
286 .saturating_add(T::DbWeight::get().writes(1_u64))287 .saturating_add(T::DbWeight::get().writes(1_u64))
287 }288 }
296 // Proof Size summary in bytes:297 // Proof Size summary in bytes:
297 // Measured: `640 + b * (261 ±0)`298 // Measured: `640 + b * (261 ±0)`
298 // Estimated: `36269`299 // Estimated: `36269`
299 // Minimum execution time: 963_000 picoseconds.300 // Minimum execution time: 340_000 picoseconds.
300 Weight::from_parts(1_126_511, 36269)301 Weight::from_parts(7_359_078, 36269)
301 // Standard Error: 9_175302 // Standard Error: 9_052
302 .saturating_add(Weight::from_parts(5_096_011, 0).saturating_mul(b.into()))303 .saturating_add(Weight::from_parts(2_763_267, 0).saturating_mul(b.into()))
303 .saturating_add(T::DbWeight::get().reads(3_u64))304 .saturating_add(T::DbWeight::get().reads(3_u64))
304 .saturating_add(T::DbWeight::get().writes(1_u64))305 .saturating_add(T::DbWeight::get().writes(1_u64))
305 }306 }
307 /// Storage: Nonfungible TokenProperties (r:1 w:0)
308 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
309 fn load_token_properties() -> Weight {
310 // Proof Size summary in bytes:
311 // Measured: `279`
312 // Estimated: `36269`
313 // Minimum execution time: 1_610_000 picoseconds.
314 Weight::from_parts(1_690_000, 36269)
315 .saturating_add(T::DbWeight::get().reads(1_u64))
316 }
306 /// Storage: Nonfungible TokenProperties (r:0 w:1)317 /// Storage: Nonfungible TokenProperties (r:0 w:1)
307 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)318 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
308 /// The range of component `b` is `[0, 64]`.319 /// The range of component `b` is `[0, 64]`.
309 fn init_token_properties(b: u32, ) -> Weight {320 fn write_token_properties(b: u32, ) -> Weight {
310 // Proof Size summary in bytes:321 // Proof Size summary in bytes:
311 // Measured: `0`322 // Measured: `0`
312 // Estimated: `0`323 // Estimated: `0`
313 // Minimum execution time: 194_000 picoseconds.324 // Minimum execution time: 70_000 picoseconds.
314 Weight::from_parts(222_000, 0)325 Weight::from_parts(3_262_181, 0)
315 // Standard Error: 7_295326 // Standard Error: 5_240
316 .saturating_add(Weight::from_parts(4_499_463, 0).saturating_mul(b.into()))327 .saturating_add(Weight::from_parts(2_426_582, 0).saturating_mul(b.into()))
317 .saturating_add(T::DbWeight::get().writes(1_u64))328 .saturating_add(T::DbWeight::get().writes(1_u64))
318 }329 }
319 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)330 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
327 // Proof Size summary in bytes:338 // Proof Size summary in bytes:
328 // Measured: `699 + b * (33291 ±0)`339 // Measured: `699 + b * (33291 ±0)`
329 // Estimated: `36269`340 // Estimated: `36269`
330 // Minimum execution time: 992_000 picoseconds.341 // Minimum execution time: 350_000 picoseconds.
331 Weight::from_parts(1_043_000, 36269)342 Weight::from_parts(370_000, 36269)
332 // Standard Error: 37_370343 // Standard Error: 29_081
333 .saturating_add(Weight::from_parts(23_672_870, 0).saturating_mul(b.into()))344 .saturating_add(Weight::from_parts(9_667_268, 0).saturating_mul(b.into()))
334 .saturating_add(T::DbWeight::get().reads(3_u64))345 .saturating_add(T::DbWeight::get().reads(3_u64))
335 .saturating_add(T::DbWeight::get().writes(1_u64))346 .saturating_add(T::DbWeight::get().writes(1_u64))
336 }347 }
340 // Proof Size summary in bytes:351 // Proof Size summary in bytes:
341 // Measured: `326`352 // Measured: `326`
342 // Estimated: `3522`353 // Estimated: `3522`
343 // Minimum execution time: 3_743_000 picoseconds.354 // Minimum execution time: 2_380_000 picoseconds.
344 Weight::from_parts(3_908_000, 3522)355 Weight::from_parts(2_500_000, 3522)
345 .saturating_add(T::DbWeight::get().reads(1_u64))356 .saturating_add(T::DbWeight::get().reads(1_u64))
346 }357 }
347 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)358 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)
350 // Proof Size summary in bytes:361 // Proof Size summary in bytes:
351 // Measured: `0`362 // Measured: `0`
352 // Estimated: `0`363 // Estimated: `0`
353 // Minimum execution time: 4_106_000 picoseconds.364 // Minimum execution time: 2_060_000 picoseconds.
354 Weight::from_parts(4_293_000, 0)365 Weight::from_parts(2_150_000, 0)
355 .saturating_add(T::DbWeight::get().writes(1_u64))366 .saturating_add(T::DbWeight::get().writes(1_u64))
356 }367 }
357 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)368 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)
360 // Proof Size summary in bytes:371 // Proof Size summary in bytes:
361 // Measured: `142`372 // Measured: `142`
362 // Estimated: `3576`373 // Estimated: `3576`
363 // Minimum execution time: 2_775_000 picoseconds.374 // Minimum execution time: 1_630_000 picoseconds.
364 Weight::from_parts(2_923_000, 3576)375 Weight::from_parts(1_730_000, 3576)
365 .saturating_add(T::DbWeight::get().reads(1_u64))376 .saturating_add(T::DbWeight::get().reads(1_u64))
366 }377 }
367 /// Storage: Nonfungible TokenProperties (r:1 w:1)378 /// Storage: Nonfungible TokenProperties (r:1 w:1)
370 // Proof Size summary in bytes:381 // Proof Size summary in bytes:
371 // Measured: `279`382 // Measured: `279`
372 // Estimated: `36269`383 // Estimated: `36269`
373 // Minimum execution time: 3_033_000 picoseconds.384 // Minimum execution time: 1_700_000 picoseconds.
374 Weight::from_parts(3_174_000, 36269)385 Weight::from_parts(1_780_000, 36269)
375 .saturating_add(T::DbWeight::get().reads(1_u64))386 .saturating_add(T::DbWeight::get().reads(1_u64))
376 .saturating_add(T::DbWeight::get().writes(1_u64))387 .saturating_add(T::DbWeight::get().writes(1_u64))
377 }388 }
391 // Proof Size summary in bytes:402 // Proof Size summary in bytes:
392 // Measured: `142`403 // Measured: `142`
393 // Estimated: `3530`404 // Estimated: `3530`
394 // Minimum execution time: 9_726_000 picoseconds.405 // Minimum execution time: 4_990_000 picoseconds.
395 Weight::from_parts(10_059_000, 3530)406 Weight::from_parts(5_170_000, 3530)
396 .saturating_add(RocksDbWeight::get().reads(2_u64))407 .saturating_add(RocksDbWeight::get().reads(2_u64))
397 .saturating_add(RocksDbWeight::get().writes(4_u64))408 .saturating_add(RocksDbWeight::get().writes(4_u64))
398 }409 }
409 // Proof Size summary in bytes:420 // Proof Size summary in bytes:
410 // Measured: `142`421 // Measured: `142`
411 // Estimated: `3530`422 // Estimated: `3530`
412 // Minimum execution time: 3_270_000 picoseconds.423 // Minimum execution time: 1_680_000 picoseconds.
413 Weight::from_parts(3_693_659, 3530)424 Weight::from_parts(1_720_000, 3530)
414 // Standard Error: 255425 // Standard Error: 674
415 .saturating_add(Weight::from_parts(3_024_284, 0).saturating_mul(b.into()))426 .saturating_add(Weight::from_parts(2_406_591, 0).saturating_mul(b.into()))
416 .saturating_add(RocksDbWeight::get().reads(2_u64))427 .saturating_add(RocksDbWeight::get().reads(2_u64))
417 .saturating_add(RocksDbWeight::get().writes(2_u64))428 .saturating_add(RocksDbWeight::get().writes(2_u64))
418 .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))429 .saturating_add(RocksDbWeight::get().writes((2_u64).saturating_mul(b.into())))
430 // Proof Size summary in bytes:441 // Proof Size summary in bytes:
431 // Measured: `142`442 // Measured: `142`
432 // Estimated: `3481 + b * (2540 ±0)`443 // Estimated: `3481 + b * (2540 ±0)`
433 // Minimum execution time: 3_188_000 picoseconds.444 // Minimum execution time: 1_680_000 picoseconds.
434 Weight::from_parts(3_307_000, 3481)445 Weight::from_parts(1_720_000, 3481)
435 // Standard Error: 567446 // Standard Error: 1_729
436 .saturating_add(Weight::from_parts(4_320_449, 0).saturating_mul(b.into()))447 .saturating_add(Weight::from_parts(3_418_983, 0).saturating_mul(b.into()))
437 .saturating_add(RocksDbWeight::get().reads(1_u64))448 .saturating_add(RocksDbWeight::get().reads(1_u64))
438 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))449 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
439 .saturating_add(RocksDbWeight::get().writes(1_u64))450 .saturating_add(RocksDbWeight::get().writes(1_u64))
458 // Proof Size summary in bytes:469 // Proof Size summary in bytes:
459 // Measured: `380`470 // Measured: `380`
460 // Estimated: `3530`471 // Estimated: `3530`
461 // Minimum execution time: 18_062_000 picoseconds.472 // Minimum execution time: 10_700_000 picoseconds.
462 Weight::from_parts(18_433_000, 3530)473 Weight::from_parts(11_180_000, 3530)
463 .saturating_add(RocksDbWeight::get().reads(5_u64))474 .saturating_add(RocksDbWeight::get().reads(5_u64))
464 .saturating_add(RocksDbWeight::get().writes(5_u64))475 .saturating_add(RocksDbWeight::get().writes(5_u64))
465 }476 }
481 // Proof Size summary in bytes:492 // Proof Size summary in bytes:
482 // Measured: `380`493 // Measured: `380`
483 // Estimated: `3530`494 // Estimated: `3530`
484 // Minimum execution time: 22_942_000 picoseconds.495 // Minimum execution time: 13_650_000 picoseconds.
485 Weight::from_parts(23_527_000, 3530)496 Weight::from_parts(13_910_000, 3530)
486 .saturating_add(RocksDbWeight::get().reads(5_u64))497 .saturating_add(RocksDbWeight::get().reads(5_u64))
487 .saturating_add(RocksDbWeight::get().writes(5_u64))498 .saturating_add(RocksDbWeight::get().writes(5_u64))
488 }499 }
507 // Proof Size summary in bytes:518 // Proof Size summary in bytes:
508 // Measured: `1500 + b * (58 ±0)`519 // Measured: `1500 + b * (58 ±0)`
509 // Estimated: `5874 + b * (5032 ±0)`520 // Estimated: `5874 + b * (5032 ±0)`
510 // Minimum execution time: 22_709_000 picoseconds.521 // Minimum execution time: 13_500_000 picoseconds.
511 Weight::from_parts(23_287_000, 5874)522 Weight::from_parts(13_830_000, 5874)
512 // Standard Error: 89_471523 // Standard Error: 136_447
513 .saturating_add(Weight::from_parts(63_285_201, 0).saturating_mul(b.into()))524 .saturating_add(Weight::from_parts(43_149_279, 0).saturating_mul(b.into()))
514 .saturating_add(RocksDbWeight::get().reads(7_u64))525 .saturating_add(RocksDbWeight::get().reads(7_u64))
515 .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(b.into())))526 .saturating_add(RocksDbWeight::get().reads((4_u64).saturating_mul(b.into())))
516 .saturating_add(RocksDbWeight::get().writes(6_u64))527 .saturating_add(RocksDbWeight::get().writes(6_u64))
529 // Proof Size summary in bytes:540 // Proof Size summary in bytes:
530 // Measured: `380`541 // Measured: `380`
531 // Estimated: `6070`542 // Estimated: `6070`
532 // Minimum execution time: 13_652_000 picoseconds.543 // Minimum execution time: 8_440_000 picoseconds.
533 Weight::from_parts(13_981_000, 6070)544 Weight::from_parts(8_680_000, 6070)
534 .saturating_add(RocksDbWeight::get().reads(4_u64))545 .saturating_add(RocksDbWeight::get().reads(4_u64))
535 .saturating_add(RocksDbWeight::get().writes(5_u64))546 .saturating_add(RocksDbWeight::get().writes(5_u64))
536 }547 }
542 // Proof Size summary in bytes:553 // Proof Size summary in bytes:
543 // Measured: `326`554 // Measured: `326`
544 // Estimated: `3522`555 // Estimated: `3522`
545 // Minimum execution time: 7_837_000 picoseconds.556 // Minimum execution time: 4_580_000 picoseconds.
546 Weight::from_parts(8_113_000, 3522)557 Weight::from_parts(4_850_000, 3522)
547 .saturating_add(RocksDbWeight::get().reads(2_u64))558 .saturating_add(RocksDbWeight::get().reads(2_u64))
548 .saturating_add(RocksDbWeight::get().writes(1_u64))559 .saturating_add(RocksDbWeight::get().writes(1_u64))
549 }560 }
555 // Proof Size summary in bytes:566 // Proof Size summary in bytes:
556 // Measured: `313`567 // Measured: `313`
557 // Estimated: `3522`568 // Estimated: `3522`
558 // Minimum execution time: 7_769_000 picoseconds.569 // Minimum execution time: 4_650_000 picoseconds.
559 Weight::from_parts(7_979_000, 3522)570 Weight::from_parts(4_890_000, 3522)
560 .saturating_add(RocksDbWeight::get().reads(2_u64))571 .saturating_add(RocksDbWeight::get().reads(2_u64))
561 .saturating_add(RocksDbWeight::get().writes(1_u64))572 .saturating_add(RocksDbWeight::get().writes(1_u64))
562 }573 }
566 // Proof Size summary in bytes:577 // Proof Size summary in bytes:
567 // Measured: `362`578 // Measured: `362`
568 // Estimated: `3522`579 // Estimated: `3522`
569 // Minimum execution time: 4_194_000 picoseconds.580 // Minimum execution time: 2_630_000 picoseconds.
570 Weight::from_parts(4_353_000, 3522)581 Weight::from_parts(2_760_000, 3522)
571 .saturating_add(RocksDbWeight::get().reads(1_u64))582 .saturating_add(RocksDbWeight::get().reads(1_u64))
572 }583 }
573 /// Storage: Nonfungible Allowance (r:1 w:1)584 /// Storage: Nonfungible Allowance (r:1 w:1)
588 // Proof Size summary in bytes:599 // Proof Size summary in bytes:
589 // Measured: `463`600 // Measured: `463`
590 // Estimated: `3530`601 // Estimated: `3530`
591 // Minimum execution time: 21_978_000 picoseconds.602 // Minimum execution time: 13_300_000 picoseconds.
592 Weight::from_parts(22_519_000, 3530)603 Weight::from_parts(13_650_000, 3530)
593 .saturating_add(RocksDbWeight::get().reads(5_u64))604 .saturating_add(RocksDbWeight::get().reads(5_u64))
594 .saturating_add(RocksDbWeight::get().writes(6_u64))605 .saturating_add(RocksDbWeight::get().writes(6_u64))
595 }606 }
600 // Proof Size summary in bytes:611 // Proof Size summary in bytes:
601 // Measured: `314`612 // Measured: `314`
602 // Estimated: `20191`613 // Estimated: `20191`
603 // Minimum execution time: 1_457_000 picoseconds.614 // Minimum execution time: 550_000 picoseconds.
604 Weight::from_parts(1_563_000, 20191)615 Weight::from_parts(600_000, 20191)
605 // Standard Error: 14_041616 // Standard Error: 23_117
606 .saturating_add(Weight::from_parts(8_452_415, 0).saturating_mul(b.into()))617 .saturating_add(Weight::from_parts(6_048_092, 0).saturating_mul(b.into()))
607 .saturating_add(RocksDbWeight::get().reads(1_u64))618 .saturating_add(RocksDbWeight::get().reads(1_u64))
608 .saturating_add(RocksDbWeight::get().writes(1_u64))619 .saturating_add(RocksDbWeight::get().writes(1_u64))
609 }620 }
618 // Proof Size summary in bytes:629 // Proof Size summary in bytes:
619 // Measured: `640 + b * (261 ±0)`630 // Measured: `640 + b * (261 ±0)`
620 // Estimated: `36269`631 // Estimated: `36269`
621 // Minimum execution time: 963_000 picoseconds.632 // Minimum execution time: 340_000 picoseconds.
622 Weight::from_parts(1_126_511, 36269)633 Weight::from_parts(7_359_078, 36269)
623 // Standard Error: 9_175634 // Standard Error: 9_052
624 .saturating_add(Weight::from_parts(5_096_011, 0).saturating_mul(b.into()))635 .saturating_add(Weight::from_parts(2_763_267, 0).saturating_mul(b.into()))
625 .saturating_add(RocksDbWeight::get().reads(3_u64))636 .saturating_add(RocksDbWeight::get().reads(3_u64))
626 .saturating_add(RocksDbWeight::get().writes(1_u64))637 .saturating_add(RocksDbWeight::get().writes(1_u64))
627 }638 }
639 /// Storage: Nonfungible TokenProperties (r:1 w:0)
640 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
641 fn load_token_properties() -> Weight {
642 // Proof Size summary in bytes:
643 // Measured: `279`
644 // Estimated: `36269`
645 // Minimum execution time: 1_610_000 picoseconds.
646 Weight::from_parts(1_690_000, 36269)
647 .saturating_add(RocksDbWeight::get().reads(1_u64))
648 }
628 /// Storage: Nonfungible TokenProperties (r:0 w:1)649 /// Storage: Nonfungible TokenProperties (r:0 w:1)
629 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)650 /// Proof: Nonfungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
630 /// The range of component `b` is `[0, 64]`.651 /// The range of component `b` is `[0, 64]`.
631 fn init_token_properties(b: u32, ) -> Weight {652 fn write_token_properties(b: u32, ) -> Weight {
632 // Proof Size summary in bytes:653 // Proof Size summary in bytes:
633 // Measured: `0`654 // Measured: `0`
634 // Estimated: `0`655 // Estimated: `0`
635 // Minimum execution time: 194_000 picoseconds.656 // Minimum execution time: 70_000 picoseconds.
636 Weight::from_parts(222_000, 0)657 Weight::from_parts(3_262_181, 0)
637 // Standard Error: 7_295658 // Standard Error: 5_240
638 .saturating_add(Weight::from_parts(4_499_463, 0).saturating_mul(b.into()))659 .saturating_add(Weight::from_parts(2_426_582, 0).saturating_mul(b.into()))
639 .saturating_add(RocksDbWeight::get().writes(1_u64))660 .saturating_add(RocksDbWeight::get().writes(1_u64))
640 }661 }
641 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)662 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
649 // Proof Size summary in bytes:670 // Proof Size summary in bytes:
650 // Measured: `699 + b * (33291 ±0)`671 // Measured: `699 + b * (33291 ±0)`
651 // Estimated: `36269`672 // Estimated: `36269`
652 // Minimum execution time: 992_000 picoseconds.673 // Minimum execution time: 350_000 picoseconds.
653 Weight::from_parts(1_043_000, 36269)674 Weight::from_parts(370_000, 36269)
654 // Standard Error: 37_370675 // Standard Error: 29_081
655 .saturating_add(Weight::from_parts(23_672_870, 0).saturating_mul(b.into()))676 .saturating_add(Weight::from_parts(9_667_268, 0).saturating_mul(b.into()))
656 .saturating_add(RocksDbWeight::get().reads(3_u64))677 .saturating_add(RocksDbWeight::get().reads(3_u64))
657 .saturating_add(RocksDbWeight::get().writes(1_u64))678 .saturating_add(RocksDbWeight::get().writes(1_u64))
658 }679 }
662 // Proof Size summary in bytes:683 // Proof Size summary in bytes:
663 // Measured: `326`684 // Measured: `326`
664 // Estimated: `3522`685 // Estimated: `3522`
665 // Minimum execution time: 3_743_000 picoseconds.686 // Minimum execution time: 2_380_000 picoseconds.
666 Weight::from_parts(3_908_000, 3522)687 Weight::from_parts(2_500_000, 3522)
667 .saturating_add(RocksDbWeight::get().reads(1_u64))688 .saturating_add(RocksDbWeight::get().reads(1_u64))
668 }689 }
669 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)690 /// Storage: Nonfungible CollectionAllowance (r:0 w:1)
672 // Proof Size summary in bytes:693 // Proof Size summary in bytes:
673 // Measured: `0`694 // Measured: `0`
674 // Estimated: `0`695 // Estimated: `0`
675 // Minimum execution time: 4_106_000 picoseconds.696 // Minimum execution time: 2_060_000 picoseconds.
676 Weight::from_parts(4_293_000, 0)697 Weight::from_parts(2_150_000, 0)
677 .saturating_add(RocksDbWeight::get().writes(1_u64))698 .saturating_add(RocksDbWeight::get().writes(1_u64))
678 }699 }
679 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)700 /// Storage: Nonfungible CollectionAllowance (r:1 w:0)
682 // Proof Size summary in bytes:703 // Proof Size summary in bytes:
683 // Measured: `142`704 // Measured: `142`
684 // Estimated: `3576`705 // Estimated: `3576`
685 // Minimum execution time: 2_775_000 picoseconds.706 // Minimum execution time: 1_630_000 picoseconds.
686 Weight::from_parts(2_923_000, 3576)707 Weight::from_parts(1_730_000, 3576)
687 .saturating_add(RocksDbWeight::get().reads(1_u64))708 .saturating_add(RocksDbWeight::get().reads(1_u64))
688 }709 }
689 /// Storage: Nonfungible TokenProperties (r:1 w:1)710 /// Storage: Nonfungible TokenProperties (r:1 w:1)
692 // Proof Size summary in bytes:713 // Proof Size summary in bytes:
693 // Measured: `279`714 // Measured: `279`
694 // Estimated: `36269`715 // Estimated: `36269`
695 // Minimum execution time: 3_033_000 picoseconds.716 // Minimum execution time: 1_700_000 picoseconds.
696 Weight::from_parts(3_174_000, 36269)717 Weight::from_parts(1_780_000, 36269)
697 .saturating_add(RocksDbWeight::get().reads(1_u64))718 .saturating_add(RocksDbWeight::get().reads(1_u64))
698 .saturating_add(RocksDbWeight::get().writes(1_u64))719 .saturating_add(RocksDbWeight::get().writes(1_u64))
699 }720 }
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
20use pallet_common::{20use pallet_common::{
21 bench_init,21 bench_init,
22 benchmarking::{22 benchmarking::{create_collection_raw, property_key, property_value},
23 create_collection_raw, /*load_is_admin_and_property_permissions,*/ property_key,
24 property_value,
25 },
26};23};
27use sp_std::prelude::*;24use sp_std::prelude::*;
424 Ok(())421 Ok(())
425 }422 }
423
424 // set_token_properties {
425 // let b in 0..MAX_PROPERTIES_PER_ITEM;
426 // bench_init!{
427 // owner: sub; collection: collection(owner);
428 // owner: cross_from_sub;
429 // };
430 // let perms = (0..b).map(|k| PropertyKeyPermission {
431 // key: property_key(k as usize),
432 // permission: PropertyPermission {
433 // mutable: false,
434 // collection_admin: true,
435 // token_owner: true,
436 // },
437 // }).collect::<Vec<_>>();
438 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
439 // let props = (0..b).map(|k| Property {
440 // key: property_key(k as usize),
441 // value: property_value(),
442 // }).collect::<Vec<_>>();
443 // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
444 // }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
445
446 // load_token_properties {
447 // bench_init!{
448 // owner: sub; collection: collection(owner);
449 // owner: cross_from_sub;
450 // };
451
452 // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
453 // }: {
454 // pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(
455 // &collection,
456 // item,
457 // )
458 // }
459
460 // write_token_properties {
461 // let b in 0..MAX_PROPERTIES_PER_ITEM;
462 // bench_init!{
463 // owner: sub; collection: collection(owner);
464 // owner: cross_from_sub;
465 // };
466
467 // let perms = (0..b).map(|k| PropertyKeyPermission {
468 // key: property_key(k as usize),
469 // permission: PropertyPermission {
470 // mutable: false,
471 // collection_admin: true,
472 // token_owner: true,
473 // },
474 // }).collect::<Vec<_>>();
475 // <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
476 // let props = (0..b).map(|k| Property {
477 // key: property_key(k as usize),
478 // value: property_value(),
479 // }).collect::<Vec<_>>();
480 // let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
481
482 // let lazy_collection_info = pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(
483 // &collection,
484 // &owner,
485 // );
486 // }: {
487 // let mut property_writer = pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
488
489 // property_writer.write_token_properties(
490 // item,
491 // props.into_iter(),
492 // crate::erc::ERC721TokenEvent::TokenChanged {
493 // token_id: item.into(),
494 // }
495 // .to_log(T::ContractAddress::get()),
496 // )?
497 // }
426498
427 #[benchmark]499 #[benchmark]
428 fn set_token_property_permissions(500 fn set_token_property_permissions(
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
17use core::marker::PhantomData;17use core::marker::PhantomData;
1818
19use frame_support::{19use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
20 dispatch::DispatchResultWithPostInfo, ensure, fail, traits::Get, weights::Weight,
21};
22use pallet_common::{20use pallet_common::{
23 init_token_properties_delta, weights::WeightInfo as _, with_weight, CommonCollectionOperations,21 weights::WeightInfo as _, with_weight, write_token_properties_total_weight,
24 CommonWeightInfo, RefungibleExtensions,22 CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions,
25};23};
26use pallet_structure::{Error as StructureError, Pallet as PalletStructure};24use pallet_structure::Pallet as PalletStructure;
27use sp_runtime::DispatchError;25use sp_runtime::DispatchError;
28use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};26use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
29use up_data_structs::{27use up_data_structs::{
50impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {48impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
51 fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {49 fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
52 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(50 <SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
53 init_token_properties_delta::<T, _>(51 write_token_properties_total_weight::<T, _>(
54 data.iter().map(|data| match data {52 data.iter().map(|data| match data {
55 up_data_structs::CreateItemData::ReFungible(rft_data) => {53 up_data_structs::CreateItemData::ReFungible(rft_data) => {
56 rft_data.properties.len() as u3254 rft_data.properties.len() as u32
57 }55 }
58 _ => 0,56 _ => 0,
59 }),57 }),
60 <SelfWeightOf<T>>::init_token_properties,58 <SelfWeightOf<T>>::write_token_properties,
61 ),59 ),
62 )60 )
63 }61 }
66 match call {64 match call {
67 CreateItemExData::RefungibleMultipleOwners(i) => {65 CreateItemExData::RefungibleMultipleOwners(i) => {
68 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)66 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)
69 .saturating_add(init_token_properties_delta::<T, _>(67 .saturating_add(write_token_properties_total_weight::<T, _>(
70 [i.properties.len() as u32].into_iter(),68 [i.properties.len() as u32].into_iter(),
71 <SelfWeightOf<T>>::init_token_properties,69 <SelfWeightOf<T>>::write_token_properties,
72 ))70 ))
73 }71 }
74 CreateItemExData::RefungibleMultipleItems(i) => {72 CreateItemExData::RefungibleMultipleItems(i) => {
75 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)73 <SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)
76 .saturating_add(init_token_properties_delta::<T, _>(74 .saturating_add(write_token_properties_total_weight::<T, _>(
77 i.iter().map(|d| d.properties.len() as u32),75 i.iter().map(|d| d.properties.len() as u32),
78 <SelfWeightOf<T>>::init_token_properties,76 <SelfWeightOf<T>>::write_token_properties,
79 ))77 ))
80 }78 }
81 _ => Weight::zero(),79 _ => Weight::zero(),
90 <pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)88 <pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)
91 }89 }
9290
93 fn delete_collection_properties(amount: u32) -> Weight {91 fn set_token_properties(amount: u32) -> Weight {
94 <pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)
95 }
96
97 fn set_token_properties(amount: u32) -> Weight {
98 <SelfWeightOf<T>>::set_token_properties(amount)
99 }
100
101 fn delete_token_properties(amount: u32) -> Weight {92 write_token_properties_total_weight::<T, _>([amount].into_iter(), |amount| {
102 <SelfWeightOf<T>>::delete_token_properties(amount)93 <SelfWeightOf<T>>::load_token_properties()
94 + <SelfWeightOf<T>>::write_token_properties(amount)
103 }95 })
96 }
10497
105 fn set_token_property_permissions(amount: u32) -> Weight {98 fn set_token_property_permissions(amount: u32) -> Weight {
106 <SelfWeightOf<T>>::set_token_property_permissions(amount)99 <SelfWeightOf<T>>::set_token_property_permissions(amount)
136 <SelfWeightOf<T>>::burn_from()129 <SelfWeightOf<T>>::burn_from()
137 }130 }
138
139 fn burn_recursively_self_raw() -> Weight {
140 // Read to get total balance
141 Self::burn_item() + T::DbWeight::get().reads(1)
142 }
143 fn burn_recursively_breadth_raw(_amount: u32) -> Weight {
144 // Refungible token can't have children
145 Weight::zero()
146 }
147
148 fn token_owner() -> Weight {
149 <SelfWeightOf<T>>::token_owner()
150 }
151131
152 fn set_allowance_for_all() -> Weight {132 fn set_allowance_for_all() -> Weight {
153 <SelfWeightOf<T>>::set_allowance_for_all()133 <SelfWeightOf<T>>::set_allowance_for_all()
265 )245 )
266 }246 }
267
268 fn burn_item_recursively(
269 &self,
270 sender: T::CrossAccountId,
271 token: TokenId,
272 self_budget: &dyn Budget,
273 _breadth_budget: &dyn Budget,
274 ) -> DispatchResultWithPostInfo {
275 ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);
276 with_weight(
277 <Pallet<T>>::burn(
278 self,
279 &sender,
280 token,
281 <Balance<T>>::get((self.id, token, &sender)),
282 ),
283 <CommonWeights<T>>::burn_recursively_self_raw(),
284 )
285 }
286247
287 fn transfer(248 fn transfer(
288 &self,249 &self,
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
32use pallet_common::{32use pallet_common::{
33 erc::{static_property::key, CollectionCall, CommonEvmHandler},33 erc::{static_property::key, CollectionCall, CommonEvmHandler},
34 eth::{self, TokenUri},34 eth::{self, TokenUri},
35 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,35 CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations, CommonWeightInfo,
36 Error as CommonError,36 Error as CommonError,
37};37};
38use pallet_evm::{account::CrossAccountId, PrecompileHandle};38use pallet_evm::{account::CrossAccountId, PrecompileHandle};
39use pallet_evm_coder_substrate::{39use pallet_evm_coder_substrate::{
40 call, dispatch_to_evm,40 call, dispatch_to_evm,
41 execution::{Error, PreDispatch, Result},41 execution::{Error, PreDispatch, Result},
42 frontier_contract,42 frontier_contract, SubstrateRecorder,
43};43};
44use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};44use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
45use sp_core::{Get, H160, U256};45use sp_core::{Get, H160, U256};
46use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};46use sp_std::{collections::btree_map::BTreeMap, vec, vec::Vec};
47use up_data_structs::{47use up_data_structs::{
48 mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property, PropertyKey,48 budget::Budget, mapping::TokenAddressMapping, CollectionId, CollectionPropertiesVec, Property,
49 PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,49 PropertyKey, PropertyKeyPermission, PropertyPermission, TokenId, TokenOwnerError,
50};50};
5151
52use crate::{52use crate::{
53 weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle,53 common::CommonWeights, weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData,
54 SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,54 Pallet, RefungibleHandle, SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
55};55};
5656
90 pub properties: Vec<eth::Property>,90 pub properties: Vec<eth::Property>,
91}91}
92
93pub fn nesting_budget<T: Config>(recorder: &SubstrateRecorder<T>) -> impl Budget + '_ {
94 recorder.weight_calls_budget(<StructureWeight<T>>::find_parent())
95}
9296
93/// @title A contract that allows to set and delete token properties and change token property permissions.97/// @title A contract that allows to set and delete token properties and change token property permissions.
94#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]98#[solidity_interface(name = TokenProperties, events(ERC721TokenEvent), enum(derive(PreDispatch)), enum_attr(weight))]
158 /// @param key Property key.162 /// @param key Property key.
159 /// @param value Property value.163 /// @param value Property value.
160 #[solidity(hide)]164 #[solidity(hide)]
161 #[weight(<SelfWeightOf<T>>::set_token_properties(1))]165 #[weight(<CommonWeights<T>>::set_token_properties(1))]
162 fn set_property(166 fn set_property(
163 &mut self,167 &mut self,
164 caller: Caller,168 caller: Caller,
173 .map_err(|_| "key too long")?;177 .map_err(|_| "key too long")?;
174 let value = value.0.try_into().map_err(|_| "value too long")?;178 let value = value.0.try_into().map_err(|_| "value too long")?;
175
176 let nesting_budget = self
177 .recorder
178 .weight_calls_budget(<StructureWeight<T>>::find_parent());
179179
180 <Pallet<T>>::set_token_property(180 <Pallet<T>>::set_token_property(
181 self,181 self,
182 &caller,182 &caller,
183 TokenId(token_id),183 TokenId(token_id),
184 Property { key, value },184 Property { key, value },
185 &nesting_budget,185 &nesting_budget(&self.recorder),
186 )186 )
187 .map_err(dispatch_to_evm::<T>)187 .map_err(dispatch_to_evm::<T>)
188 }188 }
191 /// @dev Throws error if `msg.sender` has no permission to edit the property.191 /// @dev Throws error if `msg.sender` has no permission to edit the property.
192 /// @param tokenId ID of the token.192 /// @param tokenId ID of the token.
193 /// @param properties settable properties193 /// @param properties settable properties
194 #[weight(<SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]194 #[weight(<CommonWeights<T>>::set_token_properties(properties.len() as u32))]
195 fn set_properties(195 fn set_properties(
196 &mut self,196 &mut self,
197 caller: Caller,197 caller: Caller,
201 let caller = T::CrossAccountId::from_eth(caller);201 let caller = T::CrossAccountId::from_eth(caller);
202 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;202 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
203
204 let nesting_budget = self
205 .recorder
206 .weight_calls_budget(<StructureWeight<T>>::find_parent());
207203
208 let properties = properties204 let properties = properties
209 .into_iter()205 .into_iter()
215 &caller,211 &caller,
216 TokenId(token_id),212 TokenId(token_id),
217 properties.into_iter(),213 properties.into_iter(),
218 &nesting_budget,214 &nesting_budget(&self.recorder),
219 )215 )
220 .map_err(dispatch_to_evm::<T>)216 .map_err(dispatch_to_evm::<T>)
221 }217 }
225 /// @param tokenId ID of the token.221 /// @param tokenId ID of the token.
226 /// @param key Property key.222 /// @param key Property key.
227 #[solidity(hide)]223 #[solidity(hide)]
228 #[weight(<SelfWeightOf<T>>::delete_token_properties(1))]224 #[weight(<CommonWeights<T>>::delete_token_properties(1))]
229 fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {225 fn delete_property(&mut self, token_id: U256, caller: Caller, key: String) -> Result<()> {
230 let caller = T::CrossAccountId::from_eth(caller);226 let caller = T::CrossAccountId::from_eth(caller);
231 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;227 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
232 let key = <Vec<u8>>::from(key)228 let key = <Vec<u8>>::from(key)
233 .try_into()229 .try_into()
234 .map_err(|_| "key too long")?;230 .map_err(|_| "key too long")?;
235
236 let nesting_budget = self
237 .recorder
238 .weight_calls_budget(<StructureWeight<T>>::find_parent());
239231
240 <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)232 <Pallet<T>>::delete_token_property(
233 self,
234 &caller,
235 TokenId(token_id),
236 key,
237 &nesting_budget(&self.recorder),
238 )
241 .map_err(dispatch_to_evm::<T>)239 .map_err(dispatch_to_evm::<T>)
242 }240 }
243241
244 /// @notice Delete token properties value.242 /// @notice Delete token properties value.
245 /// @dev Throws error if `msg.sender` has no permission to edit the property.243 /// @dev Throws error if `msg.sender` has no permission to edit the property.
246 /// @param tokenId ID of the token.244 /// @param tokenId ID of the token.
247 /// @param keys Properties key.245 /// @param keys Properties key.
248 #[weight(<SelfWeightOf<T>>::delete_token_properties(keys.len() as u32))]246 #[weight(<CommonWeights<T>>::delete_token_properties(keys.len() as u32))]
249 fn delete_properties(247 fn delete_properties(
250 &mut self,248 &mut self,
251 token_id: U256,249 token_id: U256,
259 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))257 .map(|k| Ok(<Vec<u8>>::from(k).try_into().map_err(|_| "key too long")?))
260 .collect::<Result<Vec<_>>>()?;258 .collect::<Result<Vec<_>>>()?;
261
262 let nesting_budget = self
263 .recorder
264 .weight_calls_budget(<StructureWeight<T>>::find_parent());
265259
266 <Pallet<T>>::delete_token_properties(260 <Pallet<T>>::delete_token_properties(
267 self,261 self,
268 &caller,262 &caller,
269 TokenId(token_id),263 TokenId(token_id),
270 keys.into_iter(),264 keys.into_iter(),
271 &nesting_budget,265 &nesting_budget(&self.recorder),
272 )266 )
273 .map_err(dispatch_to_evm::<T>)267 .map_err(dispatch_to_evm::<T>)
274 }268 }
497 let from = T::CrossAccountId::from_eth(from);491 let from = T::CrossAccountId::from_eth(from);
498 let to = T::CrossAccountId::from_eth(to);492 let to = T::CrossAccountId::from_eth(to);
499 let token = token_id.try_into()?;493 let token = token_id.try_into()?;
500 let budget = self
501 .recorder
502 .weight_calls_budget(<StructureWeight<T>>::find_parent());
503494
504 let balance = balance(self, token, &from)?;495 let balance = balance(self, token, &from)?;
505 ensure_single_owner(self, token, balance)?;496 ensure_single_owner(self, token, balance)?;
506497
507 <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)498 <Pallet<T>>::transfer_from(
499 self,
500 &caller,
501 &from,
502 &to,
503 token,
504 balance,
505 &nesting_budget(&self.recorder),
506 )
508 .map_err(dispatch_to_evm::<T>)?;507 .map_err(dispatch_to_evm::<T>)?;
509508
629 let caller = T::CrossAccountId::from_eth(caller);628 let caller = T::CrossAccountId::from_eth(caller);
630 let to = T::CrossAccountId::from_eth(to);629 let to = T::CrossAccountId::from_eth(to);
631 let token_id: u32 = token_id.try_into()?;630 let token_id: u32 = token_id.try_into()?;
632 let budget = self
633 .recorder
634 .weight_calls_budget(<StructureWeight<T>>::find_parent());
635631
636 if <TokensMinted<T>>::get(self.id)632 if <TokensMinted<T>>::get(self.id)
637 .checked_add(1)633 .checked_add(1)
653 users,649 users,
654 properties: CollectionPropertiesVec::default(),650 properties: CollectionPropertiesVec::default(),
655 },651 },
656 &budget,652 &nesting_budget(&self.recorder),
657 )653 )
658 .map_err(dispatch_to_evm::<T>)?;654 .map_err(dispatch_to_evm::<T>)?;
659655
704 let caller = T::CrossAccountId::from_eth(caller);700 let caller = T::CrossAccountId::from_eth(caller);
705 let to = T::CrossAccountId::from_eth(to);701 let to = T::CrossAccountId::from_eth(to);
706 let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;702 let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;
707 let budget = self
708 .recorder
709 .weight_calls_budget(<StructureWeight<T>>::find_parent());
710703
711 if <TokensMinted<T>>::get(self.id)704 if <TokensMinted<T>>::get(self.id)
712 .checked_add(1)705 .checked_add(1)
736 self,729 self,
737 &caller,730 &caller,
738 CreateItemData::<T> { users, properties },731 CreateItemData::<T> { users, properties },
739 &budget,732 &nesting_budget(&self.recorder),
740 )733 )
741 .map_err(dispatch_to_evm::<T>)?;734 .map_err(dispatch_to_evm::<T>)?;
742 Ok(true)735 Ok(true)
865 let caller = T::CrossAccountId::from_eth(caller);858 let caller = T::CrossAccountId::from_eth(caller);
866 let to = T::CrossAccountId::from_eth(to);859 let to = T::CrossAccountId::from_eth(to);
867 let token = token_id.try_into()?;860 let token = token_id.try_into()?;
868 let budget = self
869 .recorder
870 .weight_calls_budget(<StructureWeight<T>>::find_parent());
871861
872 let balance = balance(self, token, &caller)?;862 let balance = balance(self, token, &caller)?;
873 ensure_single_owner(self, token, balance)?;863 ensure_single_owner(self, token, balance)?;
874864
875 <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)865 <Pallet<T>>::transfer(
866 self,
867 &caller,
868 &to,
869 token,
870 balance,
871 &nesting_budget(&self.recorder),
872 )
876 .map_err(dispatch_to_evm::<T>)?;873 .map_err(dispatch_to_evm::<T>)?;
877 Ok(())874 Ok(())
893 let caller = T::CrossAccountId::from_eth(caller);890 let caller = T::CrossAccountId::from_eth(caller);
894 let to = to.into_sub_cross_account::<T>()?;891 let to = to.into_sub_cross_account::<T>()?;
895 let token = token_id.try_into()?;892 let token = token_id.try_into()?;
896 let budget = self
897 .recorder
898 .weight_calls_budget(<StructureWeight<T>>::find_parent());
899893
900 let balance = balance(self, token, &caller)?;894 let balance = balance(self, token, &caller)?;
901 ensure_single_owner(self, token, balance)?;895 ensure_single_owner(self, token, balance)?;
902896
903 <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)897 <Pallet<T>>::transfer(
898 self,
899 &caller,
900 &to,
901 token,
902 balance,
903 &nesting_budget(&self.recorder),
904 )
904 .map_err(dispatch_to_evm::<T>)?;905 .map_err(dispatch_to_evm::<T>)?;
905 Ok(())906 Ok(())
923 let from = from.into_sub_cross_account::<T>()?;924 let from = from.into_sub_cross_account::<T>()?;
924 let to = to.into_sub_cross_account::<T>()?;925 let to = to.into_sub_cross_account::<T>()?;
925 let token_id = token_id.try_into()?;926 let token_id = token_id.try_into()?;
926 let budget = self
927 .recorder
928 .weight_calls_budget(<StructureWeight<T>>::find_parent());
929927
930 let balance = balance(self, token_id, &from)?;928 let balance = balance(self, token_id, &from)?;
931 ensure_single_owner(self, token_id, balance)?;929 ensure_single_owner(self, token_id, balance)?;
932930
933 Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)931 Pallet::<T>::transfer_from(
932 self,
933 &caller,
934 &from,
935 &to,
936 token_id,
937 balance,
938 &nesting_budget(&self.recorder),
939 )
934 .map_err(dispatch_to_evm::<T>)?;940 .map_err(dispatch_to_evm::<T>)?;
935 Ok(())941 Ok(())
948 let caller = T::CrossAccountId::from_eth(caller);954 let caller = T::CrossAccountId::from_eth(caller);
949 let from = T::CrossAccountId::from_eth(from);955 let from = T::CrossAccountId::from_eth(from);
950 let token = token_id.try_into()?;956 let token = token_id.try_into()?;
951 let budget = self
952 .recorder
953 .weight_calls_budget(<StructureWeight<T>>::find_parent());
954957
955 let balance = balance(self, token, &from)?;958 let balance = balance(self, token, &from)?;
956 ensure_single_owner(self, token, balance)?;959 ensure_single_owner(self, token, balance)?;
957960
958 <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)961 <Pallet<T>>::burn_from(
962 self,
963 &caller,
964 &from,
965 token,
966 balance,
967 &nesting_budget(&self.recorder),
968 )
959 .map_err(dispatch_to_evm::<T>)?;969 .map_err(dispatch_to_evm::<T>)?;
960 Ok(())970 Ok(())
977 let caller = T::CrossAccountId::from_eth(caller);987 let caller = T::CrossAccountId::from_eth(caller);
978 let from = from.into_sub_cross_account::<T>()?;988 let from = from.into_sub_cross_account::<T>()?;
979 let token = token_id.try_into()?;989 let token = token_id.try_into()?;
980 let budget = self
981 .recorder
982 .weight_calls_budget(<StructureWeight<T>>::find_parent());
983990
984 let balance = balance(self, token, &from)?;991 let balance = balance(self, token, &from)?;
985 ensure_single_owner(self, token, balance)?;992 ensure_single_owner(self, token, balance)?;
986993
987 <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)994 <Pallet<T>>::burn_from(
995 self,
996 &caller,
997 &from,
998 token,
999 balance,
1000 &nesting_budget(&self.recorder),
1001 )
988 .map_err(dispatch_to_evm::<T>)?;1002 .map_err(dispatch_to_evm::<T>)?;
989 Ok(())1003 Ok(())
1010 let mut expected_index = <TokensMinted<T>>::get(self.id)1024 let mut expected_index = <TokensMinted<T>>::get(self.id)
1011 .checked_add(1)1025 .checked_add(1)
1012 .ok_or("item id overflow")?;1026 .ok_or("item id overflow")?;
1013 let budget = self
1014 .recorder
1015 .weight_calls_budget(<StructureWeight<T>>::find_parent());
10161027
1017 let total_tokens = token_ids.len();1028 let total_tokens = token_ids.len();
1018 for id in token_ids.into_iter() {1029 for id in token_ids.into_iter() {
1035 .map(|_| create_item_data.clone())1046 .map(|_| create_item_data.clone())
1036 .collect();1047 .collect();
10371048
1038 <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1049 <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
1039 .map_err(dispatch_to_evm::<T>)?;1050 .map_err(dispatch_to_evm::<T>)?;
1040 Ok(true)1051 Ok(true)
1041 }1052 }
1053 token_properties: Vec<MintTokenData>,1064 token_properties: Vec<MintTokenData>,
1054 ) -> Result<bool> {1065 ) -> Result<bool> {
1055 let caller = T::CrossAccountId::from_eth(caller);1066 let caller = T::CrossAccountId::from_eth(caller);
1056 let budget = self
1057 .recorder
1058 .weight_calls_budget(<StructureWeight<T>>::find_parent());
1059 let has_multiple_tokens = token_properties.len() > 1;1067 let has_multiple_tokens = token_properties.len() > 1;
10601068
1061 let mut create_rft_data = Vec::with_capacity(token_properties.len());1069 let mut create_rft_data = Vec::with_capacity(token_properties.len());
1084 });1092 });
1085 }1093 }
10861094
1087 <Pallet<T>>::create_multiple_items(self, &caller, create_rft_data, &budget)1095 <Pallet<T>>::create_multiple_items(
1096 self,
1097 &caller,
1098 create_rft_data,
1099 &nesting_budget(&self.recorder),
1100 )
1088 .map_err(dispatch_to_evm::<T>)?;1101 .map_err(dispatch_to_evm::<T>)?;
1089 Ok(true)1102 Ok(true)
1108 let mut expected_index = <TokensMinted<T>>::get(self.id)1121 let mut expected_index = <TokensMinted<T>>::get(self.id)
1109 .checked_add(1)1122 .checked_add(1)
1110 .ok_or("item id overflow")?;1123 .ok_or("item id overflow")?;
1111 let budget = self
1112 .recorder
1113 .weight_calls_budget(<StructureWeight<T>>::find_parent());
11141124
1115 let mut data = Vec::with_capacity(tokens.len());1125 let mut data = Vec::with_capacity(tokens.len());
1116 let users: BoundedBTreeMap<_, _, _> = [(to, 1)]1126 let users: BoundedBTreeMap<_, _, _> = [(to, 1)]
1143 data.push(create_item_data);1153 data.push(create_item_data);
1144 }1154 }
11451155
1146 <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)1156 <Pallet<T>>::create_multiple_items(self, &caller, data, &nesting_budget(&self.recorder))
1147 .map_err(dispatch_to_evm::<T>)?;1157 .map_err(dispatch_to_evm::<T>)?;
1148 Ok(true)1158 Ok(true)
1149 }1159 }
11741184
1175 let caller = T::CrossAccountId::from_eth(caller);1185 let caller = T::CrossAccountId::from_eth(caller);
1176
1177 let budget = self
1178 .recorder
1179 .weight_calls_budget(<StructureWeight<T>>::find_parent());
11801186
1181 let users = [(to, 1)]1187 let users = [(to, 1)]
1182 .into_iter()1188 .into_iter()
1187 self,1193 self,
1188 &caller,1194 &caller,
1189 CreateItemData::<T> { users, properties },1195 CreateItemData::<T> { users, properties },
1190 &budget,1196 &nesting_budget(&self.recorder),
1191 )1197 )
1192 .map_err(dispatch_to_evm::<T>)?;1198 .map_err(dispatch_to_evm::<T>)?;
11931199
modifiedpallets/refungible/src/erc_token.rsdiffbeforeafterboth
37 execution::{PreDispatch, Result},37 execution::{PreDispatch, Result},
38 frontier_contract, WithRecorder,38 frontier_contract, WithRecorder,
39};39};
40use pallet_structure::{weights::WeightInfo as _, SelfWeightOf as StructureWeight};
41use sp_core::U256;40use sp_core::U256;
42use sp_std::vec::Vec;41use sp_std::vec::Vec;
43use up_data_structs::TokenId;42use up_data_structs::TokenId;
4443
45use crate::{44use crate::{
46 common::CommonWeights, weights::WeightInfo, Allowance, Balance, Config, Pallet,45 common::CommonWeights, erc::nesting_budget, weights::WeightInfo, Allowance, Balance, Config,
47 RefungibleHandle, SelfWeightOf, TotalSupply,46 Pallet, RefungibleHandle, SelfWeightOf, TotalSupply,
48};47};
4948
140 let caller = T::CrossAccountId::from_eth(caller);139 let caller = T::CrossAccountId::from_eth(caller);
141 let to = T::CrossAccountId::from_eth(to);140 let to = T::CrossAccountId::from_eth(to);
142 let amount = amount.try_into().map_err(|_| "amount overflow")?;141 let amount = amount.try_into().map_err(|_| "amount overflow")?;
143 let budget = self
144 .recorder
145 .weight_calls_budget(<StructureWeight<T>>::find_parent());
146142
147 <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)143 <Pallet<T>>::transfer(
144 self,
145 &caller,
146 &to,
147 self.1,
148 amount,
149 &nesting_budget(&self.recorder),
150 )
148 .map_err(dispatch_to_evm::<T>)?;151 .map_err(dispatch_to_evm::<T>)?;
149 Ok(true)152 Ok(true)
165 let from = T::CrossAccountId::from_eth(from);168 let from = T::CrossAccountId::from_eth(from);
166 let to = T::CrossAccountId::from_eth(to);169 let to = T::CrossAccountId::from_eth(to);
167 let amount = amount.try_into().map_err(|_| "amount overflow")?;170 let amount = amount.try_into().map_err(|_| "amount overflow")?;
168 let budget = self
169 .recorder
170 .weight_calls_budget(<StructureWeight<T>>::find_parent());
171171
172 <Pallet<T>>::transfer_from(self, &caller, &from, &to, self.1, amount, &budget)172 <Pallet<T>>::transfer_from(
173 self,
174 &caller,
175 &from,
176 &to,
177 self.1,
178 amount,
179 &nesting_budget(&self.recorder),
180 )
173 .map_err(dispatch_to_evm::<T>)?;181 .map_err(dispatch_to_evm::<T>)?;
174 Ok(true)182 Ok(true)
231 let caller = T::CrossAccountId::from_eth(caller);239 let caller = T::CrossAccountId::from_eth(caller);
232 let from = T::CrossAccountId::from_eth(from);240 let from = T::CrossAccountId::from_eth(from);
233 let amount = amount.try_into().map_err(|_| "amount overflow")?;241 let amount = amount.try_into().map_err(|_| "amount overflow")?;
234 let budget = self
235 .recorder
236 .weight_calls_budget(<StructureWeight<T>>::find_parent());
237242
238 <Pallet<T>>::burn_from(self, &caller, &from, self.1, amount, &budget)243 <Pallet<T>>::burn_from(
244 self,
245 &caller,
246 &from,
247 self.1,
248 amount,
249 &nesting_budget(&self.recorder),
250 )
239 .map_err(dispatch_to_evm::<T>)?;251 .map_err(dispatch_to_evm::<T>)?;
240 Ok(true)252 Ok(true)
254 let caller = T::CrossAccountId::from_eth(caller);266 let caller = T::CrossAccountId::from_eth(caller);
255 let from = from.into_sub_cross_account::<T>()?;267 let from = from.into_sub_cross_account::<T>()?;
256 let amount = amount.try_into().map_err(|_| "amount overflow")?;268 let amount = amount.try_into().map_err(|_| "amount overflow")?;
257 let budget = self
258 .recorder
259 .weight_calls_budget(<StructureWeight<T>>::find_parent());
260269
261 <Pallet<T>>::burn_from(self, &caller, &from, self.1, amount, &budget)270 <Pallet<T>>::burn_from(
271 self,
272 &caller,
273 &from,
274 self.1,
275 amount,
276 &nesting_budget(&self.recorder),
277 )
262 .map_err(dispatch_to_evm::<T>)?;278 .map_err(dispatch_to_evm::<T>)?;
263 Ok(true)279 Ok(true)
315 let caller = T::CrossAccountId::from_eth(caller);331 let caller = T::CrossAccountId::from_eth(caller);
316 let to = to.into_sub_cross_account::<T>()?;332 let to = to.into_sub_cross_account::<T>()?;
317 let amount = amount.try_into().map_err(|_| "amount overflow")?;333 let amount = amount.try_into().map_err(|_| "amount overflow")?;
318 let budget = self
319 .recorder
320 .weight_calls_budget(<StructureWeight<T>>::find_parent());
321334
322 <Pallet<T>>::transfer(self, &caller, &to, self.1, amount, &budget)335 <Pallet<T>>::transfer(
336 self,
337 &caller,
338 &to,
339 self.1,
340 amount,
341 &nesting_budget(&self.recorder),
342 )
323 .map_err(dispatch_to_evm::<T>)?;343 .map_err(dispatch_to_evm::<T>)?;
324 Ok(true)344 Ok(true)
340 let from = from.into_sub_cross_account::<T>()?;360 let from = from.into_sub_cross_account::<T>()?;
341 let to = to.into_sub_cross_account::<T>()?;361 let to = to.into_sub_cross_account::<T>()?;
342 let amount = amount.try_into().map_err(|_| "amount overflow")?;362 let amount = amount.try_into().map_err(|_| "amount overflow")?;
343 let budget = self
344 .recorder
345 .weight_calls_budget(<StructureWeight<T>>::find_parent());
346363
347 <Pallet<T>>::transfer_from(self, &caller, &from, &to, self.1, amount, &budget)364 <Pallet<T>>::transfer_from(
365 self,
366 &caller,
367 &from,
368 &to,
369 self.1,
370 amount,
371 &nesting_budget(&self.recorder),
372 )
348 .map_err(dispatch_to_evm::<T>)?;373 .map_err(dispatch_to_evm::<T>)?;
349 Ok(true)374 Ok(true)
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
507 nesting_budget: &dyn Budget,507 nesting_budget: &dyn Budget,
508 ) -> DispatchResult {508 ) -> DispatchResult {
509 let mut property_writer =509 let mut property_writer =
510 pallet_common::property_writer_for_existing_token(collection, sender);510 pallet_common::ExistingTokenPropertyWriter::new(collection, sender);
511511
512 property_writer.write_token_properties(512 property_writer.write_token_properties(
513 sender,513 sender,
858858
859 // =========859 // =========
860860
861 let mut property_writer = pallet_common::property_writer_for_new_token(collection, sender);861 let mut property_writer = pallet_common::NewTokenPropertyWriter::new(collection, sender);
862862
863 with_transaction(|| {863 with_transaction(|| {
864 for (i, data) in data.iter().enumerate() {864 for (i, data) in data.iter().enumerate() {
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
3//! Autogenerated weights for pallet_refungible3//! Autogenerated weights for pallet_refungible
4//!4//!
5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev5//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev
6//! DATE: 2023-09-30, STEPS: `50`, REPEAT: `400`, LOW RANGE: `[]`, HIGH RANGE: `[]`6//! DATE: 2023-10-05, STEPS: `50`, REPEAT: `80`, LOW RANGE: `[]`, HIGH RANGE: `[]`
7//! WORST CASE MAP SIZE: `1000000`7//! WORST CASE MAP SIZE: `1000000`
8//! HOSTNAME: `bench-host`, CPU: `Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz`8//! HOSTNAME: `hearthstone`, CPU: `AMD Ryzen 9 7950X3D 16-Core Processor`
9//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 10249//! EXECUTION: None, WASM-EXECUTION: Compiled, CHAIN: None, DB CACHE: 1024
1010
11// Executed Command:11// Executed Command:
20// *20// *
21// --template=.maintain/frame-weight-template.hbs21// --template=.maintain/frame-weight-template.hbs
22// --steps=5022// --steps=50
23// --repeat=40023// --repeat=80
24// --heap-pages=409624// --heap-pages=4096
25// --output=./pallets/refungible/src/weights.rs25// --output=./pallets/refungible/src/weights.rs
2626
52 fn burn_from() -> Weight;52 fn burn_from() -> Weight;
53 fn set_token_property_permissions(b: u32, ) -> Weight;53 fn set_token_property_permissions(b: u32, ) -> Weight;
54 fn set_token_properties(b: u32, ) -> Weight;54 fn set_token_properties(b: u32, ) -> Weight;
55 fn init_token_properties(b: u32, ) -> Weight;55 fn load_token_properties() -> Weight;
56 fn write_token_properties(b: u32, ) -> Weight;
56 fn delete_token_properties(b: u32, ) -> Weight;57 fn delete_token_properties(b: u32, ) -> Weight;
57 fn repartition_item() -> Weight;58 fn repartition_item() -> Weight;
58 fn token_owner() -> Weight;59 fn token_owner() -> Weight;
78 // Proof Size summary in bytes:79 // Proof Size summary in bytes:
79 // Measured: `4`80 // Measured: `4`
80 // Estimated: `3530`81 // Estimated: `3530`
81 // Minimum execution time: 11_341_000 picoseconds.82 // Minimum execution time: 5_710_000 picoseconds.
82 Weight::from_parts(11_741_000, 3530)83 Weight::from_parts(5_980_000, 3530)
83 .saturating_add(T::DbWeight::get().reads(2_u64))84 .saturating_add(T::DbWeight::get().reads(2_u64))
84 .saturating_add(T::DbWeight::get().writes(5_u64))85 .saturating_add(T::DbWeight::get().writes(5_u64))
85 }86 }
98 // Proof Size summary in bytes:99 // Proof Size summary in bytes:
99 // Measured: `4`100 // Measured: `4`
100 // Estimated: `3530`101 // Estimated: `3530`
101 // Minimum execution time: 2_665_000 picoseconds.102 // Minimum execution time: 1_300_000 picoseconds.
102 Weight::from_parts(2_791_000, 3530)103 Weight::from_parts(1_360_000, 3530)
103 // Standard Error: 996104 // Standard Error: 2_783
104 .saturating_add(Weight::from_parts(4_343_736, 0).saturating_mul(b.into()))105 .saturating_add(Weight::from_parts(3_456_531, 0).saturating_mul(b.into()))
105 .saturating_add(T::DbWeight::get().reads(2_u64))106 .saturating_add(T::DbWeight::get().reads(2_u64))
106 .saturating_add(T::DbWeight::get().writes(2_u64))107 .saturating_add(T::DbWeight::get().writes(2_u64))
107 .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))108 .saturating_add(T::DbWeight::get().writes((3_u64).saturating_mul(b.into())))
121 // Proof Size summary in bytes:122 // Proof Size summary in bytes:
122 // Measured: `4`123 // Measured: `4`
123 // Estimated: `3481 + b * (2540 ±0)`124 // Estimated: `3481 + b * (2540 ±0)`
124 // Minimum execution time: 2_616_000 picoseconds.125 // Minimum execution time: 1_290_000 picoseconds.
125 Weight::from_parts(2_726_000, 3481)126 Weight::from_parts(1_370_000, 3481)
126 // Standard Error: 665127 // Standard Error: 3_198
127 .saturating_add(Weight::from_parts(5_554_066, 0).saturating_mul(b.into()))128 .saturating_add(Weight::from_parts(4_435_305, 0).saturating_mul(b.into()))
128 .saturating_add(T::DbWeight::get().reads(1_u64))129 .saturating_add(T::DbWeight::get().reads(1_u64))
129 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))130 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
130 .saturating_add(T::DbWeight::get().writes(1_u64))131 .saturating_add(T::DbWeight::get().writes(1_u64))
146 // Proof Size summary in bytes:147 // Proof Size summary in bytes:
147 // Measured: `4`148 // Measured: `4`
148 // Estimated: `3481 + b * (2540 ±0)`149 // Estimated: `3481 + b * (2540 ±0)`
149 // Minimum execution time: 3_697_000 picoseconds.150 // Minimum execution time: 1_730_000 picoseconds.
150 Weight::from_parts(2_136_481, 3481)151 Weight::from_parts(1_810_000, 3481)
151 // Standard Error: 567152 // Standard Error: 1_923
152 .saturating_add(Weight::from_parts(4_390_621, 0).saturating_mul(b.into()))153 .saturating_add(Weight::from_parts(3_500_817, 0).saturating_mul(b.into()))
153 .saturating_add(T::DbWeight::get().reads(1_u64))154 .saturating_add(T::DbWeight::get().reads(1_u64))
154 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))155 .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(b.into())))
155 .saturating_add(T::DbWeight::get().writes(2_u64))156 .saturating_add(T::DbWeight::get().writes(2_u64))
168 // Proof Size summary in bytes:169 // Proof Size summary in bytes:
169 // Measured: `456`170 // Measured: `456`
170 // Estimated: `8682`171 // Estimated: `8682`
171 // Minimum execution time: 22_859_000 picoseconds.172 // Minimum execution time: 14_010_000 picoseconds.
172 Weight::from_parts(23_295_000, 8682)173 Weight::from_parts(16_300_000, 8682)
173 .saturating_add(T::DbWeight::get().reads(5_u64))174 .saturating_add(T::DbWeight::get().reads(5_u64))
174 .saturating_add(T::DbWeight::get().writes(4_u64))175 .saturating_add(T::DbWeight::get().writes(4_u64))
175 }176 }
189 // Proof Size summary in bytes:190 // Proof Size summary in bytes:
190 // Measured: `341`191 // Measured: `341`
191 // Estimated: `3554`192 // Estimated: `3554`
192 // Minimum execution time: 21_477_000 picoseconds.193 // Minimum execution time: 13_700_000 picoseconds.
193 Weight::from_parts(22_037_000, 3554)194 Weight::from_parts(14_180_000, 3554)
194 .saturating_add(T::DbWeight::get().reads(4_u64))195 .saturating_add(T::DbWeight::get().reads(4_u64))
195 .saturating_add(T::DbWeight::get().writes(6_u64))196 .saturating_add(T::DbWeight::get().writes(6_u64))
196 }197 }
202 // Proof Size summary in bytes:203 // Proof Size summary in bytes:
203 // Measured: `365`204 // Measured: `365`
204 // Estimated: `6118`205 // Estimated: `6118`
205 // Minimum execution time: 13_714_000 picoseconds.206 // Minimum execution time: 8_990_000 picoseconds.
206 Weight::from_parts(14_050_000, 6118)207 Weight::from_parts(9_400_000, 6118)
207 .saturating_add(T::DbWeight::get().reads(3_u64))208 .saturating_add(T::DbWeight::get().reads(3_u64))
208 .saturating_add(T::DbWeight::get().writes(2_u64))209 .saturating_add(T::DbWeight::get().writes(2_u64))
209 }210 }
219 // Proof Size summary in bytes:220 // Proof Size summary in bytes:
220 // Measured: `341`221 // Measured: `341`
221 // Estimated: `6118`222 // Estimated: `6118`
222 // Minimum execution time: 15_879_000 picoseconds.223 // Minimum execution time: 10_240_000 picoseconds.
223 Weight::from_parts(16_266_000, 6118)224 Weight::from_parts(10_610_000, 6118)
224 .saturating_add(T::DbWeight::get().reads(4_u64))225 .saturating_add(T::DbWeight::get().reads(4_u64))
225 .saturating_add(T::DbWeight::get().writes(4_u64))226 .saturating_add(T::DbWeight::get().writes(4_u64))
226 }227 }
236 // Proof Size summary in bytes:237 // Proof Size summary in bytes:
237 // Measured: `456`238 // Measured: `456`
238 // Estimated: `6118`239 // Estimated: `6118`
239 // Minimum execution time: 18_186_000 picoseconds.240 // Minimum execution time: 12_040_000 picoseconds.
240 Weight::from_parts(18_682_000, 6118)241 Weight::from_parts(12_390_000, 6118)
241 .saturating_add(T::DbWeight::get().reads(4_u64))242 .saturating_add(T::DbWeight::get().reads(4_u64))
242 .saturating_add(T::DbWeight::get().writes(4_u64))243 .saturating_add(T::DbWeight::get().writes(4_u64))
243 }244 }
253 // Proof Size summary in bytes:254 // Proof Size summary in bytes:
254 // Measured: `341`255 // Measured: `341`
255 // Estimated: `6118`256 // Estimated: `6118`
256 // Minimum execution time: 17_943_000 picoseconds.257 // Minimum execution time: 11_940_000 picoseconds.
257 Weight::from_parts(18_333_000, 6118)258 Weight::from_parts(12_240_000, 6118)
258 .saturating_add(T::DbWeight::get().reads(5_u64))259 .saturating_add(T::DbWeight::get().reads(5_u64))
259 .saturating_add(T::DbWeight::get().writes(6_u64))260 .saturating_add(T::DbWeight::get().writes(6_u64))
260 }261 }
266 // Proof Size summary in bytes:267 // Proof Size summary in bytes:
267 // Measured: `223`268 // Measured: `223`
268 // Estimated: `3554`269 // Estimated: `3554`
269 // Minimum execution time: 8_391_000 picoseconds.270 // Minimum execution time: 5_150_000 picoseconds.
270 Weight::from_parts(8_637_000, 3554)271 Weight::from_parts(5_440_000, 3554)
271 .saturating_add(T::DbWeight::get().reads(1_u64))272 .saturating_add(T::DbWeight::get().reads(1_u64))
272 .saturating_add(T::DbWeight::get().writes(1_u64))273 .saturating_add(T::DbWeight::get().writes(1_u64))
273 }274 }
279 // Proof Size summary in bytes:280 // Proof Size summary in bytes:
280 // Measured: `211`281 // Measured: `211`
281 // Estimated: `3554`282 // Estimated: `3554`
282 // Minimum execution time: 8_519_000 picoseconds.283 // Minimum execution time: 5_170_000 picoseconds.
283 Weight::from_parts(8_760_000, 3554)284 Weight::from_parts(5_400_000, 3554)
284 .saturating_add(T::DbWeight::get().reads(1_u64))285 .saturating_add(T::DbWeight::get().reads(1_u64))
285 .saturating_add(T::DbWeight::get().writes(1_u64))286 .saturating_add(T::DbWeight::get().writes(1_u64))
286 }287 }
294 // Proof Size summary in bytes:295 // Proof Size summary in bytes:
295 // Measured: `495`296 // Measured: `495`
296 // Estimated: `6118`297 // Estimated: `6118`
297 // Minimum execution time: 19_554_000 picoseconds.298 // Minimum execution time: 13_150_000 picoseconds.
298 Weight::from_parts(20_031_000, 6118)299 Weight::from_parts(13_600_000, 6118)
299 .saturating_add(T::DbWeight::get().reads(4_u64))300 .saturating_add(T::DbWeight::get().reads(4_u64))
300 .saturating_add(T::DbWeight::get().writes(3_u64))301 .saturating_add(T::DbWeight::get().writes(3_u64))
301 }302 }
313 // Proof Size summary in bytes:314 // Proof Size summary in bytes:
314 // Measured: `471`315 // Measured: `471`
315 // Estimated: `6118`316 // Estimated: `6118`
316 // Minimum execution time: 21_338_000 picoseconds.317 // Minimum execution time: 14_280_000 picoseconds.
317 Weight::from_parts(21_803_000, 6118)318 Weight::from_parts(14_680_000, 6118)
318 .saturating_add(T::DbWeight::get().reads(5_u64))319 .saturating_add(T::DbWeight::get().reads(5_u64))
319 .saturating_add(T::DbWeight::get().writes(5_u64))320 .saturating_add(T::DbWeight::get().writes(5_u64))
320 }321 }
332 // Proof Size summary in bytes:333 // Proof Size summary in bytes:
333 // Measured: `586`334 // Measured: `586`
334 // Estimated: `6118`335 // Estimated: `6118`
335 // Minimum execution time: 24_179_000 picoseconds.336 // Minimum execution time: 16_110_000 picoseconds.
336 Weight::from_parts(24_647_000, 6118)337 Weight::from_parts(16_710_000, 6118)
337 .saturating_add(T::DbWeight::get().reads(5_u64))338 .saturating_add(T::DbWeight::get().reads(5_u64))
338 .saturating_add(T::DbWeight::get().writes(5_u64))339 .saturating_add(T::DbWeight::get().writes(5_u64))
339 }340 }
351 // Proof Size summary in bytes:352 // Proof Size summary in bytes:
352 // Measured: `471`353 // Measured: `471`
353 // Estimated: `6118`354 // Estimated: `6118`
354 // Minimum execution time: 24_008_000 picoseconds.355 // Minimum execution time: 16_130_000 picoseconds.
355 Weight::from_parts(24_545_000, 6118)356 Weight::from_parts(16_680_000, 6118)
356 .saturating_add(T::DbWeight::get().reads(6_u64))357 .saturating_add(T::DbWeight::get().reads(6_u64))
357 .saturating_add(T::DbWeight::get().writes(7_u64))358 .saturating_add(T::DbWeight::get().writes(7_u64))
358 }359 }
374 // Proof Size summary in bytes:375 // Proof Size summary in bytes:
375 // Measured: `471`376 // Measured: `471`
376 // Estimated: `3570`377 // Estimated: `3570`
377 // Minimum execution time: 27_907_000 picoseconds.378 // Minimum execution time: 18_380_000 picoseconds.
378 Weight::from_parts(28_489_000, 3570)379 Weight::from_parts(18_870_000, 3570)
379 .saturating_add(T::DbWeight::get().reads(5_u64))380 .saturating_add(T::DbWeight::get().reads(5_u64))
380 .saturating_add(T::DbWeight::get().writes(7_u64))381 .saturating_add(T::DbWeight::get().writes(7_u64))
381 }382 }
386 // Proof Size summary in bytes:387 // Proof Size summary in bytes:
387 // Measured: `314`388 // Measured: `314`
388 // Estimated: `20191`389 // Estimated: `20191`
389 // Minimum execution time: 1_460_000 picoseconds.390 // Minimum execution time: 580_000 picoseconds.
390 Weight::from_parts(1_564_000, 20191)391 Weight::from_parts(660_000, 20191)
391 // Standard Error: 14_117392 // Standard Error: 29_964
392 .saturating_add(Weight::from_parts(8_196_214, 0).saturating_mul(b.into()))393 .saturating_add(Weight::from_parts(6_251_766, 0).saturating_mul(b.into()))
393 .saturating_add(T::DbWeight::get().reads(1_u64))394 .saturating_add(T::DbWeight::get().reads(1_u64))
394 .saturating_add(T::DbWeight::get().writes(1_u64))395 .saturating_add(T::DbWeight::get().writes(1_u64))
395 }396 }
404 // Proof Size summary in bytes:405 // Proof Size summary in bytes:
405 // Measured: `502 + b * (261 ±0)`406 // Measured: `502 + b * (261 ±0)`
406 // Estimated: `36269`407 // Estimated: `36269`
407 // Minimum execution time: 1_012_000 picoseconds.408 // Minimum execution time: 350_000 picoseconds.
408 Weight::from_parts(1_081_000, 36269)409 Weight::from_parts(2_269_806, 36269)
409 // Standard Error: 6_838410 // Standard Error: 7_751
410 .saturating_add(Weight::from_parts(5_801_181, 0).saturating_mul(b.into()))411 .saturating_add(Weight::from_parts(3_068_126, 0).saturating_mul(b.into()))
411 .saturating_add(T::DbWeight::get().reads(3_u64))412 .saturating_add(T::DbWeight::get().reads(3_u64))
412 .saturating_add(T::DbWeight::get().writes(1_u64))413 .saturating_add(T::DbWeight::get().writes(1_u64))
413 }414 }
415 /// Storage: Refungible TokenProperties (r:1 w:0)
416 /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
417 fn load_token_properties() -> Weight {
418 // Proof Size summary in bytes:
419 // Measured: `120`
420 // Estimated: `36269`
421 // Minimum execution time: 1_010_000 picoseconds.
422 Weight::from_parts(1_080_000, 36269)
423 .saturating_add(T::DbWeight::get().reads(1_u64))
424 }
414 /// Storage: Refungible TokenProperties (r:0 w:1)425 /// Storage: Refungible TokenProperties (r:0 w:1)
415 /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)426 /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
416 /// The range of component `b` is `[0, 64]`.427 /// The range of component `b` is `[0, 64]`.
417 fn init_token_properties(b: u32, ) -> Weight {428 fn write_token_properties(b: u32, ) -> Weight {
418 // Proof Size summary in bytes:429 // Proof Size summary in bytes:
419 // Measured: `0`430 // Measured: `0`
420 // Estimated: `0`431 // Estimated: `0`
421 // Minimum execution time: 229_000 picoseconds.432 // Minimum execution time: 70_000 picoseconds.
422 Weight::from_parts(253_000, 0)433 Weight::from_parts(1_363_449, 0)
423 // Standard Error: 100_218434 // Standard Error: 8_964
424 .saturating_add(Weight::from_parts(12_632_221, 0).saturating_mul(b.into()))435 .saturating_add(Weight::from_parts(2_665_759, 0).saturating_mul(b.into()))
425 .saturating_add(T::DbWeight::get().writes(1_u64))436 .saturating_add(T::DbWeight::get().writes(1_u64))
426 }437 }
427 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)438 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
435 // Proof Size summary in bytes:446 // Proof Size summary in bytes:
436 // Measured: `561 + b * (33291 ±0)`447 // Measured: `561 + b * (33291 ±0)`
437 // Estimated: `36269`448 // Estimated: `36269`
438 // Minimum execution time: 1_014_000 picoseconds.449 // Minimum execution time: 320_000 picoseconds.
439 Weight::from_parts(1_065_000, 36269)450 Weight::from_parts(370_000, 36269)
440 // Standard Error: 39_536451 // Standard Error: 28_541
441 .saturating_add(Weight::from_parts(24_125_838, 0).saturating_mul(b.into()))452 .saturating_add(Weight::from_parts(9_863_065, 0).saturating_mul(b.into()))
442 .saturating_add(T::DbWeight::get().reads(3_u64))453 .saturating_add(T::DbWeight::get().reads(3_u64))
443 .saturating_add(T::DbWeight::get().writes(1_u64))454 .saturating_add(T::DbWeight::get().writes(1_u64))
444 }455 }
450 // Proof Size summary in bytes:461 // Proof Size summary in bytes:
451 // Measured: `288`462 // Measured: `288`
452 // Estimated: `3554`463 // Estimated: `3554`
453 // Minimum execution time: 10_315_000 picoseconds.464 // Minimum execution time: 6_320_000 picoseconds.
454 Weight::from_parts(10_601_000, 3554)465 Weight::from_parts(6_640_000, 3554)
455 .saturating_add(T::DbWeight::get().reads(2_u64))466 .saturating_add(T::DbWeight::get().reads(2_u64))
456 .saturating_add(T::DbWeight::get().writes(2_u64))467 .saturating_add(T::DbWeight::get().writes(2_u64))
457 }468 }
461 // Proof Size summary in bytes:472 // Proof Size summary in bytes:
462 // Measured: `288`473 // Measured: `288`
463 // Estimated: `6118`474 // Estimated: `6118`
464 // Minimum execution time: 4_898_000 picoseconds.475 // Minimum execution time: 2_520_000 picoseconds.
465 Weight::from_parts(5_136_000, 6118)476 Weight::from_parts(2_680_000, 6118)
466 .saturating_add(T::DbWeight::get().reads(2_u64))477 .saturating_add(T::DbWeight::get().reads(2_u64))
467 }478 }
468 /// Storage: Refungible CollectionAllowance (r:0 w:1)479 /// Storage: Refungible CollectionAllowance (r:0 w:1)
471 // Proof Size summary in bytes:482 // Proof Size summary in bytes:
472 // Measured: `0`483 // Measured: `0`
473 // Estimated: `0`484 // Estimated: `0`
474 // Minimum execution time: 4_146_000 picoseconds.485 // Minimum execution time: 2_070_000 picoseconds.
475 Weight::from_parts(4_337_000, 0)486 Weight::from_parts(2_230_000, 0)
476 .saturating_add(T::DbWeight::get().writes(1_u64))487 .saturating_add(T::DbWeight::get().writes(1_u64))
477 }488 }
478 /// Storage: Refungible CollectionAllowance (r:1 w:0)489 /// Storage: Refungible CollectionAllowance (r:1 w:0)
481 // Proof Size summary in bytes:492 // Proof Size summary in bytes:
482 // Measured: `4`493 // Measured: `4`
483 // Estimated: `3576`494 // Estimated: `3576`
484 // Minimum execution time: 2_170_000 picoseconds.495 // Minimum execution time: 1_270_000 picoseconds.
485 Weight::from_parts(2_301_000, 3576)496 Weight::from_parts(1_420_000, 3576)
486 .saturating_add(T::DbWeight::get().reads(1_u64))497 .saturating_add(T::DbWeight::get().reads(1_u64))
487 }498 }
488 /// Storage: Refungible TokenProperties (r:1 w:1)499 /// Storage: Refungible TokenProperties (r:1 w:1)
491 // Proof Size summary in bytes:502 // Proof Size summary in bytes:
492 // Measured: `120`503 // Measured: `120`
493 // Estimated: `36269`504 // Estimated: `36269`
494 // Minimum execution time: 2_098_000 picoseconds.505 // Minimum execution time: 1_010_000 picoseconds.
495 Weight::from_parts(2_251_000, 36269)506 Weight::from_parts(1_160_000, 36269)
496 .saturating_add(T::DbWeight::get().reads(1_u64))507 .saturating_add(T::DbWeight::get().reads(1_u64))
497 .saturating_add(T::DbWeight::get().writes(1_u64))508 .saturating_add(T::DbWeight::get().writes(1_u64))
498 }509 }
514 // Proof Size summary in bytes:525 // Proof Size summary in bytes:
515 // Measured: `4`526 // Measured: `4`
516 // Estimated: `3530`527 // Estimated: `3530`
517 // Minimum execution time: 11_341_000 picoseconds.528 // Minimum execution time: 5_710_000 picoseconds.
518 Weight::from_parts(11_741_000, 3530)529 Weight::from_parts(5_980_000, 3530)
519 .saturating_add(RocksDbWeight::get().reads(2_u64))530 .saturating_add(RocksDbWeight::get().reads(2_u64))
520 .saturating_add(RocksDbWeight::get().writes(5_u64))531 .saturating_add(RocksDbWeight::get().writes(5_u64))
521 }532 }
534 // Proof Size summary in bytes:545 // Proof Size summary in bytes:
535 // Measured: `4`546 // Measured: `4`
536 // Estimated: `3530`547 // Estimated: `3530`
537 // Minimum execution time: 2_665_000 picoseconds.548 // Minimum execution time: 1_300_000 picoseconds.
538 Weight::from_parts(2_791_000, 3530)549 Weight::from_parts(1_360_000, 3530)
539 // Standard Error: 996550 // Standard Error: 2_783
540 .saturating_add(Weight::from_parts(4_343_736, 0).saturating_mul(b.into()))551 .saturating_add(Weight::from_parts(3_456_531, 0).saturating_mul(b.into()))
541 .saturating_add(RocksDbWeight::get().reads(2_u64))552 .saturating_add(RocksDbWeight::get().reads(2_u64))
542 .saturating_add(RocksDbWeight::get().writes(2_u64))553 .saturating_add(RocksDbWeight::get().writes(2_u64))
543 .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))554 .saturating_add(RocksDbWeight::get().writes((3_u64).saturating_mul(b.into())))
557 // Proof Size summary in bytes:568 // Proof Size summary in bytes:
558 // Measured: `4`569 // Measured: `4`
559 // Estimated: `3481 + b * (2540 ±0)`570 // Estimated: `3481 + b * (2540 ±0)`
560 // Minimum execution time: 2_616_000 picoseconds.571 // Minimum execution time: 1_290_000 picoseconds.
561 Weight::from_parts(2_726_000, 3481)572 Weight::from_parts(1_370_000, 3481)
562 // Standard Error: 665573 // Standard Error: 3_198
563 .saturating_add(Weight::from_parts(5_554_066, 0).saturating_mul(b.into()))574 .saturating_add(Weight::from_parts(4_435_305, 0).saturating_mul(b.into()))
564 .saturating_add(RocksDbWeight::get().reads(1_u64))575 .saturating_add(RocksDbWeight::get().reads(1_u64))
565 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))576 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
566 .saturating_add(RocksDbWeight::get().writes(1_u64))577 .saturating_add(RocksDbWeight::get().writes(1_u64))
582 // Proof Size summary in bytes:593 // Proof Size summary in bytes:
583 // Measured: `4`594 // Measured: `4`
584 // Estimated: `3481 + b * (2540 ±0)`595 // Estimated: `3481 + b * (2540 ±0)`
585 // Minimum execution time: 3_697_000 picoseconds.596 // Minimum execution time: 1_730_000 picoseconds.
586 Weight::from_parts(2_136_481, 3481)597 Weight::from_parts(1_810_000, 3481)
587 // Standard Error: 567598 // Standard Error: 1_923
588 .saturating_add(Weight::from_parts(4_390_621, 0).saturating_mul(b.into()))599 .saturating_add(Weight::from_parts(3_500_817, 0).saturating_mul(b.into()))
589 .saturating_add(RocksDbWeight::get().reads(1_u64))600 .saturating_add(RocksDbWeight::get().reads(1_u64))
590 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))601 .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(b.into())))
591 .saturating_add(RocksDbWeight::get().writes(2_u64))602 .saturating_add(RocksDbWeight::get().writes(2_u64))
604 // Proof Size summary in bytes:615 // Proof Size summary in bytes:
605 // Measured: `456`616 // Measured: `456`
606 // Estimated: `8682`617 // Estimated: `8682`
607 // Minimum execution time: 22_859_000 picoseconds.618 // Minimum execution time: 14_010_000 picoseconds.
608 Weight::from_parts(23_295_000, 8682)619 Weight::from_parts(16_300_000, 8682)
609 .saturating_add(RocksDbWeight::get().reads(5_u64))620 .saturating_add(RocksDbWeight::get().reads(5_u64))
610 .saturating_add(RocksDbWeight::get().writes(4_u64))621 .saturating_add(RocksDbWeight::get().writes(4_u64))
611 }622 }
625 // Proof Size summary in bytes:636 // Proof Size summary in bytes:
626 // Measured: `341`637 // Measured: `341`
627 // Estimated: `3554`638 // Estimated: `3554`
628 // Minimum execution time: 21_477_000 picoseconds.639 // Minimum execution time: 13_700_000 picoseconds.
629 Weight::from_parts(22_037_000, 3554)640 Weight::from_parts(14_180_000, 3554)
630 .saturating_add(RocksDbWeight::get().reads(4_u64))641 .saturating_add(RocksDbWeight::get().reads(4_u64))
631 .saturating_add(RocksDbWeight::get().writes(6_u64))642 .saturating_add(RocksDbWeight::get().writes(6_u64))
632 }643 }
638 // Proof Size summary in bytes:649 // Proof Size summary in bytes:
639 // Measured: `365`650 // Measured: `365`
640 // Estimated: `6118`651 // Estimated: `6118`
641 // Minimum execution time: 13_714_000 picoseconds.652 // Minimum execution time: 8_990_000 picoseconds.
642 Weight::from_parts(14_050_000, 6118)653 Weight::from_parts(9_400_000, 6118)
643 .saturating_add(RocksDbWeight::get().reads(3_u64))654 .saturating_add(RocksDbWeight::get().reads(3_u64))
644 .saturating_add(RocksDbWeight::get().writes(2_u64))655 .saturating_add(RocksDbWeight::get().writes(2_u64))
645 }656 }
655 // Proof Size summary in bytes:666 // Proof Size summary in bytes:
656 // Measured: `341`667 // Measured: `341`
657 // Estimated: `6118`668 // Estimated: `6118`
658 // Minimum execution time: 15_879_000 picoseconds.669 // Minimum execution time: 10_240_000 picoseconds.
659 Weight::from_parts(16_266_000, 6118)670 Weight::from_parts(10_610_000, 6118)
660 .saturating_add(RocksDbWeight::get().reads(4_u64))671 .saturating_add(RocksDbWeight::get().reads(4_u64))
661 .saturating_add(RocksDbWeight::get().writes(4_u64))672 .saturating_add(RocksDbWeight::get().writes(4_u64))
662 }673 }
672 // Proof Size summary in bytes:683 // Proof Size summary in bytes:
673 // Measured: `456`684 // Measured: `456`
674 // Estimated: `6118`685 // Estimated: `6118`
675 // Minimum execution time: 18_186_000 picoseconds.686 // Minimum execution time: 12_040_000 picoseconds.
676 Weight::from_parts(18_682_000, 6118)687 Weight::from_parts(12_390_000, 6118)
677 .saturating_add(RocksDbWeight::get().reads(4_u64))688 .saturating_add(RocksDbWeight::get().reads(4_u64))
678 .saturating_add(RocksDbWeight::get().writes(4_u64))689 .saturating_add(RocksDbWeight::get().writes(4_u64))
679 }690 }
689 // Proof Size summary in bytes:700 // Proof Size summary in bytes:
690 // Measured: `341`701 // Measured: `341`
691 // Estimated: `6118`702 // Estimated: `6118`
692 // Minimum execution time: 17_943_000 picoseconds.703 // Minimum execution time: 11_940_000 picoseconds.
693 Weight::from_parts(18_333_000, 6118)704 Weight::from_parts(12_240_000, 6118)
694 .saturating_add(RocksDbWeight::get().reads(5_u64))705 .saturating_add(RocksDbWeight::get().reads(5_u64))
695 .saturating_add(RocksDbWeight::get().writes(6_u64))706 .saturating_add(RocksDbWeight::get().writes(6_u64))
696 }707 }
702 // Proof Size summary in bytes:713 // Proof Size summary in bytes:
703 // Measured: `223`714 // Measured: `223`
704 // Estimated: `3554`715 // Estimated: `3554`
705 // Minimum execution time: 8_391_000 picoseconds.716 // Minimum execution time: 5_150_000 picoseconds.
706 Weight::from_parts(8_637_000, 3554)717 Weight::from_parts(5_440_000, 3554)
707 .saturating_add(RocksDbWeight::get().reads(1_u64))718 .saturating_add(RocksDbWeight::get().reads(1_u64))
708 .saturating_add(RocksDbWeight::get().writes(1_u64))719 .saturating_add(RocksDbWeight::get().writes(1_u64))
709 }720 }
715 // Proof Size summary in bytes:726 // Proof Size summary in bytes:
716 // Measured: `211`727 // Measured: `211`
717 // Estimated: `3554`728 // Estimated: `3554`
718 // Minimum execution time: 8_519_000 picoseconds.729 // Minimum execution time: 5_170_000 picoseconds.
719 Weight::from_parts(8_760_000, 3554)730 Weight::from_parts(5_400_000, 3554)
720 .saturating_add(RocksDbWeight::get().reads(1_u64))731 .saturating_add(RocksDbWeight::get().reads(1_u64))
721 .saturating_add(RocksDbWeight::get().writes(1_u64))732 .saturating_add(RocksDbWeight::get().writes(1_u64))
722 }733 }
730 // Proof Size summary in bytes:741 // Proof Size summary in bytes:
731 // Measured: `495`742 // Measured: `495`
732 // Estimated: `6118`743 // Estimated: `6118`
733 // Minimum execution time: 19_554_000 picoseconds.744 // Minimum execution time: 13_150_000 picoseconds.
734 Weight::from_parts(20_031_000, 6118)745 Weight::from_parts(13_600_000, 6118)
735 .saturating_add(RocksDbWeight::get().reads(4_u64))746 .saturating_add(RocksDbWeight::get().reads(4_u64))
736 .saturating_add(RocksDbWeight::get().writes(3_u64))747 .saturating_add(RocksDbWeight::get().writes(3_u64))
737 }748 }
749 // Proof Size summary in bytes:760 // Proof Size summary in bytes:
750 // Measured: `471`761 // Measured: `471`
751 // Estimated: `6118`762 // Estimated: `6118`
752 // Minimum execution time: 21_338_000 picoseconds.763 // Minimum execution time: 14_280_000 picoseconds.
753 Weight::from_parts(21_803_000, 6118)764 Weight::from_parts(14_680_000, 6118)
754 .saturating_add(RocksDbWeight::get().reads(5_u64))765 .saturating_add(RocksDbWeight::get().reads(5_u64))
755 .saturating_add(RocksDbWeight::get().writes(5_u64))766 .saturating_add(RocksDbWeight::get().writes(5_u64))
756 }767 }
768 // Proof Size summary in bytes:779 // Proof Size summary in bytes:
769 // Measured: `586`780 // Measured: `586`
770 // Estimated: `6118`781 // Estimated: `6118`
771 // Minimum execution time: 24_179_000 picoseconds.782 // Minimum execution time: 16_110_000 picoseconds.
772 Weight::from_parts(24_647_000, 6118)783 Weight::from_parts(16_710_000, 6118)
773 .saturating_add(RocksDbWeight::get().reads(5_u64))784 .saturating_add(RocksDbWeight::get().reads(5_u64))
774 .saturating_add(RocksDbWeight::get().writes(5_u64))785 .saturating_add(RocksDbWeight::get().writes(5_u64))
775 }786 }
787 // Proof Size summary in bytes:798 // Proof Size summary in bytes:
788 // Measured: `471`799 // Measured: `471`
789 // Estimated: `6118`800 // Estimated: `6118`
790 // Minimum execution time: 24_008_000 picoseconds.801 // Minimum execution time: 16_130_000 picoseconds.
791 Weight::from_parts(24_545_000, 6118)802 Weight::from_parts(16_680_000, 6118)
792 .saturating_add(RocksDbWeight::get().reads(6_u64))803 .saturating_add(RocksDbWeight::get().reads(6_u64))
793 .saturating_add(RocksDbWeight::get().writes(7_u64))804 .saturating_add(RocksDbWeight::get().writes(7_u64))
794 }805 }
810 // Proof Size summary in bytes:821 // Proof Size summary in bytes:
811 // Measured: `471`822 // Measured: `471`
812 // Estimated: `3570`823 // Estimated: `3570`
813 // Minimum execution time: 27_907_000 picoseconds.824 // Minimum execution time: 18_380_000 picoseconds.
814 Weight::from_parts(28_489_000, 3570)825 Weight::from_parts(18_870_000, 3570)
815 .saturating_add(RocksDbWeight::get().reads(5_u64))826 .saturating_add(RocksDbWeight::get().reads(5_u64))
816 .saturating_add(RocksDbWeight::get().writes(7_u64))827 .saturating_add(RocksDbWeight::get().writes(7_u64))
817 }828 }
822 // Proof Size summary in bytes:833 // Proof Size summary in bytes:
823 // Measured: `314`834 // Measured: `314`
824 // Estimated: `20191`835 // Estimated: `20191`
825 // Minimum execution time: 1_460_000 picoseconds.836 // Minimum execution time: 580_000 picoseconds.
826 Weight::from_parts(1_564_000, 20191)837 Weight::from_parts(660_000, 20191)
827 // Standard Error: 14_117838 // Standard Error: 29_964
828 .saturating_add(Weight::from_parts(8_196_214, 0).saturating_mul(b.into()))839 .saturating_add(Weight::from_parts(6_251_766, 0).saturating_mul(b.into()))
829 .saturating_add(RocksDbWeight::get().reads(1_u64))840 .saturating_add(RocksDbWeight::get().reads(1_u64))
830 .saturating_add(RocksDbWeight::get().writes(1_u64))841 .saturating_add(RocksDbWeight::get().writes(1_u64))
831 }842 }
840 // Proof Size summary in bytes:851 // Proof Size summary in bytes:
841 // Measured: `502 + b * (261 ±0)`852 // Measured: `502 + b * (261 ±0)`
842 // Estimated: `36269`853 // Estimated: `36269`
843 // Minimum execution time: 1_012_000 picoseconds.854 // Minimum execution time: 350_000 picoseconds.
844 Weight::from_parts(1_081_000, 36269)855 Weight::from_parts(2_269_806, 36269)
845 // Standard Error: 6_838856 // Standard Error: 7_751
846 .saturating_add(Weight::from_parts(5_801_181, 0).saturating_mul(b.into()))857 .saturating_add(Weight::from_parts(3_068_126, 0).saturating_mul(b.into()))
847 .saturating_add(RocksDbWeight::get().reads(3_u64))858 .saturating_add(RocksDbWeight::get().reads(3_u64))
848 .saturating_add(RocksDbWeight::get().writes(1_u64))859 .saturating_add(RocksDbWeight::get().writes(1_u64))
860 }
861 /// Storage: Refungible TokenProperties (r:1 w:0)
862 /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
863 fn load_token_properties() -> Weight {
864 // Proof Size summary in bytes:
865 // Measured: `120`
866 // Estimated: `36269`
867 // Minimum execution time: 1_010_000 picoseconds.
868 Weight::from_parts(1_080_000, 36269)
869 .saturating_add(RocksDbWeight::get().reads(1_u64))
849 }870 }
850 /// Storage: Refungible TokenProperties (r:0 w:1)871 /// Storage: Refungible TokenProperties (r:0 w:1)
851 /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)872 /// Proof: Refungible TokenProperties (max_values: None, max_size: Some(32804), added: 35279, mode: MaxEncodedLen)
852 /// The range of component `b` is `[0, 64]`.873 /// The range of component `b` is `[0, 64]`.
853 fn init_token_properties(b: u32, ) -> Weight {874 fn write_token_properties(b: u32, ) -> Weight {
854 // Proof Size summary in bytes:875 // Proof Size summary in bytes:
855 // Measured: `0`876 // Measured: `0`
856 // Estimated: `0`877 // Estimated: `0`
857 // Minimum execution time: 229_000 picoseconds.878 // Minimum execution time: 70_000 picoseconds.
858 Weight::from_parts(253_000, 0)879 Weight::from_parts(1_363_449, 0)
859 // Standard Error: 100_218880 // Standard Error: 8_964
860 .saturating_add(Weight::from_parts(12_632_221, 0).saturating_mul(b.into()))881 .saturating_add(Weight::from_parts(2_665_759, 0).saturating_mul(b.into()))
861 .saturating_add(RocksDbWeight::get().writes(1_u64))882 .saturating_add(RocksDbWeight::get().writes(1_u64))
862 }883 }
863 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)884 /// Storage: Common CollectionPropertyPermissions (r:1 w:0)
871 // Proof Size summary in bytes:892 // Proof Size summary in bytes:
872 // Measured: `561 + b * (33291 ±0)`893 // Measured: `561 + b * (33291 ±0)`
873 // Estimated: `36269`894 // Estimated: `36269`
874 // Minimum execution time: 1_014_000 picoseconds.895 // Minimum execution time: 320_000 picoseconds.
875 Weight::from_parts(1_065_000, 36269)896 Weight::from_parts(370_000, 36269)
876 // Standard Error: 39_536897 // Standard Error: 28_541
877 .saturating_add(Weight::from_parts(24_125_838, 0).saturating_mul(b.into()))898 .saturating_add(Weight::from_parts(9_863_065, 0).saturating_mul(b.into()))
878 .saturating_add(RocksDbWeight::get().reads(3_u64))899 .saturating_add(RocksDbWeight::get().reads(3_u64))
879 .saturating_add(RocksDbWeight::get().writes(1_u64))900 .saturating_add(RocksDbWeight::get().writes(1_u64))
880 }901 }
886 // Proof Size summary in bytes:907 // Proof Size summary in bytes:
887 // Measured: `288`908 // Measured: `288`
888 // Estimated: `3554`909 // Estimated: `3554`
889 // Minimum execution time: 10_315_000 picoseconds.910 // Minimum execution time: 6_320_000 picoseconds.
890 Weight::from_parts(10_601_000, 3554)911 Weight::from_parts(6_640_000, 3554)
891 .saturating_add(RocksDbWeight::get().reads(2_u64))912 .saturating_add(RocksDbWeight::get().reads(2_u64))
892 .saturating_add(RocksDbWeight::get().writes(2_u64))913 .saturating_add(RocksDbWeight::get().writes(2_u64))
893 }914 }
897 // Proof Size summary in bytes:918 // Proof Size summary in bytes:
898 // Measured: `288`919 // Measured: `288`
899 // Estimated: `6118`920 // Estimated: `6118`
900 // Minimum execution time: 4_898_000 picoseconds.921 // Minimum execution time: 2_520_000 picoseconds.
901 Weight::from_parts(5_136_000, 6118)922 Weight::from_parts(2_680_000, 6118)
902 .saturating_add(RocksDbWeight::get().reads(2_u64))923 .saturating_add(RocksDbWeight::get().reads(2_u64))
903 }924 }
904 /// Storage: Refungible CollectionAllowance (r:0 w:1)925 /// Storage: Refungible CollectionAllowance (r:0 w:1)
907 // Proof Size summary in bytes:928 // Proof Size summary in bytes:
908 // Measured: `0`929 // Measured: `0`
909 // Estimated: `0`930 // Estimated: `0`
910 // Minimum execution time: 4_146_000 picoseconds.931 // Minimum execution time: 2_070_000 picoseconds.
911 Weight::from_parts(4_337_000, 0)932 Weight::from_parts(2_230_000, 0)
912 .saturating_add(RocksDbWeight::get().writes(1_u64))933 .saturating_add(RocksDbWeight::get().writes(1_u64))
913 }934 }
914 /// Storage: Refungible CollectionAllowance (r:1 w:0)935 /// Storage: Refungible CollectionAllowance (r:1 w:0)
917 // Proof Size summary in bytes:938 // Proof Size summary in bytes:
918 // Measured: `4`939 // Measured: `4`
919 // Estimated: `3576`940 // Estimated: `3576`
920 // Minimum execution time: 2_170_000 picoseconds.941 // Minimum execution time: 1_270_000 picoseconds.
921 Weight::from_parts(2_301_000, 3576)942 Weight::from_parts(1_420_000, 3576)
922 .saturating_add(RocksDbWeight::get().reads(1_u64))943 .saturating_add(RocksDbWeight::get().reads(1_u64))
923 }944 }
924 /// Storage: Refungible TokenProperties (r:1 w:1)945 /// Storage: Refungible TokenProperties (r:1 w:1)
927 // Proof Size summary in bytes:948 // Proof Size summary in bytes:
928 // Measured: `120`949 // Measured: `120`
929 // Estimated: `36269`950 // Estimated: `36269`
930 // Minimum execution time: 2_098_000 picoseconds.951 // Minimum execution time: 1_010_000 picoseconds.
931 Weight::from_parts(2_251_000, 36269)952 Weight::from_parts(1_160_000, 36269)
932 .saturating_add(RocksDbWeight::get().reads(1_u64))953 .saturating_add(RocksDbWeight::get().reads(1_u64))
933 .saturating_add(RocksDbWeight::get().writes(1_u64))954 .saturating_add(RocksDbWeight::get().writes(1_u64))
934 }955 }
modifiedpallets/structure/src/lib.rsdiffbeforeafterboth
54#![cfg_attr(not(feature = "std"), no_std)]54#![cfg_attr(not(feature = "std"), no_std)]
5555
56use frame_support::{56use frame_support::{dispatch::DispatchResult, fail, pallet_prelude::*};
57 dispatch::{DispatchResult, DispatchResultWithPostInfo},
58 fail,
59 pallet_prelude::*,
60};
61use pallet_common::{57use pallet_common::{
62 dispatch::CollectionDispatch, erc::CrossAccountId, eth::is_collection,58 dispatch::CollectionDispatch, erc::CrossAccountId, eth::is_collection,
269 Err(<Error<T>>::DepthLimit.into())265 Err(<Error<T>>::DepthLimit.into())
270 }266 }
271
272 /// Burn token and all of it's nested tokens
273 ///
274 /// - `self_budget`: Limit for searching children in depth.
275 /// - `breadth_budget`: Limit of breadth of searching children.
276 pub fn burn_item_recursively(
277 from: T::CrossAccountId,
278 collection: CollectionId,
279 token: TokenId,
280 self_budget: &dyn Budget,
281 breadth_budget: &dyn Budget,
282 ) -> DispatchResultWithPostInfo {
283 let dispatch = T::CollectionDispatch::dispatch(collection)?;
284 let dispatch = dispatch.as_dyn();
285 dispatch.burn_item_recursively(from, token, self_budget, breadth_budget)
286 }
287267
288 /// Check if `token` indirectly owned by `user`268 /// Check if `token` indirectly owned by `user`
289 ///269 ///
modifiedpallets/unique/Cargo.tomldiffbeforeafterboth
31 'parity-scale-codec/std',31 'parity-scale-codec/std',
32 'sp-runtime/std',32 'sp-runtime/std',
33 'sp-std/std',33 'sp-std/std',
34 'up-common/std',
34 'up-data-structs/std',35 'up-data-structs/std',
36 'pallet-structure/std',
35]37]
36stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]38stubgen = ["evm-coder/stubgen", "pallet-common/stubgen"]
37try-runtime = ["frame-support/try-runtime"]39try-runtime = ["frame-support/try-runtime"]
53pallet-evm-coder-substrate = { workspace = true }55pallet-evm-coder-substrate = { workspace = true }
54pallet-nonfungible = { workspace = true }56pallet-nonfungible = { workspace = true }
55pallet-refungible = { workspace = true }57pallet-refungible = { workspace = true }
58pallet-structure = { workspace = true }
56scale-info = { workspace = true }59scale-info = { workspace = true }
57sp-core = { workspace = true }60sp-core = { workspace = true }
58sp-io = { workspace = true }61sp-io = { workspace = true }
59sp-runtime = { workspace = true }62sp-runtime = { workspace = true }
60sp-std = { workspace = true }63sp-std = { workspace = true }
64up-common = { workspace = true }
61up-data-structs = { workspace = true }65up-data-structs = { workspace = true }
6266
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
8484
85#[frame_support::pallet]85#[frame_support::pallet]
86pub mod pallet {86pub mod pallet {
87 use frame_support::{dispatch::DispatchResult, ensure, fail, storage::Key, BoundedVec};87 use frame_support::{
88 dispatch::{DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo},
89 ensure, fail,
90 storage::Key,
91 BoundedVec,
92 };
88 use frame_system::{ensure_root, ensure_signed};93 use frame_system::{ensure_root, ensure_signed};
89 use pallet_common::{94 use pallet_common::{
90 dispatch::{dispatch_tx, CollectionDispatch},95 dispatch::{dispatch_tx, CollectionDispatch},
91 CollectionHandle, CommonWeightInfo, Pallet as PalletCommon, RefungibleExtensionsWeightInfo,96 CollectionHandle, CommonCollectionOperations, CommonWeightInfo, Pallet as PalletCommon,
97 RefungibleExtensionsWeightInfo,
92 };98 };
93 use pallet_evm::account::CrossAccountId;99 use pallet_evm::account::CrossAccountId;
100 use pallet_structure::weights::WeightInfo as StructureWeightInfo;
94 use scale_info::TypeInfo;101 use scale_info::TypeInfo;
95 use sp_std::{vec, vec::Vec};102 use sp_std::{vec, vec::Vec};
96 use up_data_structs::{103 use up_data_structs::{
105112
106 use super::*;113 use super::*;
107114
108 /// A maximum number of levels of depth in the token nesting tree.
109 pub const NESTING_BUDGET: u32 = 5;
110
111 /// Errors for the common Unique transactions.115 /// Errors for the common Unique transactions.
112 #[pallet::error]116 #[pallet::error]
113 pub enum Error<T> {117 pub enum Error<T> {
128 /// Weight information for common pallet operations.132 /// Weight information for common pallet operations.
129 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;133 type CommonWeightInfo: CommonWeightInfo<Self::CrossAccountId>;
130134
135 type StructureWeightInfo: StructureWeightInfo;
136
131 /// Weight info information for extra refungible pallet operations.137 /// Weight info information for extra refungible pallet operations.
132 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;138 type RefungibleExtensionsWeightInfo: RefungibleExtensionsWeightInfo;
133 }139 }
264 impl<T: Config> Pallet<T> {270 impl<T: Config> Pallet<T> {
265 /// A maximum number of levels of depth in the token nesting tree.271 /// A maximum number of levels of depth in the token nesting tree.
266 fn nesting_budget() -> u32 {272 fn nesting_budget() -> u32 {
267 NESTING_BUDGET273 5
268 }274 }
269275
270 /// Maximal length of a collection name.276 /// Maximal length of a collection name.
666 /// * `owner`: Address of the initial owner of the item.672 /// * `owner`: Address of the initial owner of the item.
667 /// * `data`: Token data describing the item to store on chain.673 /// * `data`: Token data describing the item to store on chain.
668 #[pallet::call_index(11)]674 #[pallet::call_index(11)]
669 #[pallet::weight(T::CommonWeightInfo::create_item(data))]675 #[pallet::weight(T::CommonWeightInfo::create_item(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
670 pub fn create_item(676 pub fn create_item(
671 origin: OriginFor<T>,677 origin: OriginFor<T>,
672 collection_id: CollectionId,678 collection_id: CollectionId,
673 owner: T::CrossAccountId,679 owner: T::CrossAccountId,
674 data: CreateItemData,680 data: CreateItemData,
675 ) -> DispatchResultWithPostInfo {681 ) -> DispatchResultWithPostInfo {
676 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);682 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
677 let budget = budget::Value::new(NESTING_BUDGET);683 let budget = Self::structure_nesting_budget();
678684
679 dispatch_tx::<T, _>(collection_id, |d| {685 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
680 d.create_item(sender, owner, data, &budget)686 d.create_item(sender, owner, data, &budget)
681 })687 })
682 }688 }
700 /// * `owner`: Address of the initial owner of the tokens.706 /// * `owner`: Address of the initial owner of the tokens.
701 /// * `items_data`: Vector of data describing each item to be created.707 /// * `items_data`: Vector of data describing each item to be created.
702 #[pallet::call_index(12)]708 #[pallet::call_index(12)]
703 #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data))]709 #[pallet::weight(T::CommonWeightInfo::create_multiple_items(items_data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
704 pub fn create_multiple_items(710 pub fn create_multiple_items(
705 origin: OriginFor<T>,711 origin: OriginFor<T>,
706 collection_id: CollectionId,712 collection_id: CollectionId,
709 ) -> DispatchResultWithPostInfo {715 ) -> DispatchResultWithPostInfo {
710 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);716 ensure!(!items_data.is_empty(), Error::<T>::EmptyArgument);
711 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);717 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
712 let budget = budget::Value::new(NESTING_BUDGET);718 let budget = Self::structure_nesting_budget();
713719
714 dispatch_tx::<T, _>(collection_id, |d| {720 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
715 d.create_multiple_items(sender, owner, items_data, &budget)721 d.create_multiple_items(sender, owner, items_data, &budget)
716 })722 })
717 }723 }
791 /// * `properties`: Vector of key-value pairs stored as the token's metadata.797 /// * `properties`: Vector of key-value pairs stored as the token's metadata.
792 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.798 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
793 #[pallet::call_index(15)]799 #[pallet::call_index(15)]
794 #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32))]800 #[pallet::weight(T::CommonWeightInfo::set_token_properties(properties.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]
795 pub fn set_token_properties(801 pub fn set_token_properties(
796 origin: OriginFor<T>,802 origin: OriginFor<T>,
797 collection_id: CollectionId,803 collection_id: CollectionId,
801 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);807 ensure!(!properties.is_empty(), Error::<T>::EmptyArgument);
802808
803 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);809 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
804 let budget = budget::Value::new(NESTING_BUDGET);810 let budget = Self::structure_nesting_budget();
805811
806 dispatch_tx::<T, _>(collection_id, |d| {812 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
807 d.set_token_properties(sender, token_id, properties, &budget)813 d.set_token_properties(sender, token_id, properties, &budget)
808 })814 })
809 }815 }
824 /// * `property_keys`: Vector of keys of the properties to be deleted.830 /// * `property_keys`: Vector of keys of the properties to be deleted.
825 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.831 /// Keys support Latin letters, `-`, `_`, and `.` as symbols.
826 #[pallet::call_index(16)]832 #[pallet::call_index(16)]
827 #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32))]833 #[pallet::weight(T::CommonWeightInfo::delete_token_properties(property_keys.len() as u32) + <Pallet<T>>::nesting_budget_predispatch_weight())]
828 pub fn delete_token_properties(834 pub fn delete_token_properties(
829 origin: OriginFor<T>,835 origin: OriginFor<T>,
830 collection_id: CollectionId,836 collection_id: CollectionId,
834 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);840 ensure!(!property_keys.is_empty(), Error::<T>::EmptyArgument);
835841
836 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);842 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
837 let budget = budget::Value::new(NESTING_BUDGET);843 let budget = Self::structure_nesting_budget();
838844
839 dispatch_tx::<T, _>(collection_id, |d| {845 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
840 d.delete_token_properties(sender, token_id, property_keys, &budget)846 d.delete_token_properties(sender, token_id, property_keys, &budget)
841 })847 })
842 }848 }
888 /// * `collection_id`: ID of the collection to which the tokens would belong.894 /// * `collection_id`: ID of the collection to which the tokens would belong.
889 /// * `data`: Explicit item creation data.895 /// * `data`: Explicit item creation data.
890 #[pallet::call_index(18)]896 #[pallet::call_index(18)]
891 #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data))]897 #[pallet::weight(T::CommonWeightInfo::create_multiple_items_ex(data) + <Pallet<T>>::nesting_budget_predispatch_weight())]
892 pub fn create_multiple_items_ex(898 pub fn create_multiple_items_ex(
893 origin: OriginFor<T>,899 origin: OriginFor<T>,
894 collection_id: CollectionId,900 collection_id: CollectionId,
895 data: CreateItemExData<T::CrossAccountId>,901 data: CreateItemExData<T::CrossAccountId>,
896 ) -> DispatchResultWithPostInfo {902 ) -> DispatchResultWithPostInfo {
897 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);903 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
898 let budget = budget::Value::new(NESTING_BUDGET);904 let budget = Self::structure_nesting_budget();
899905
900 dispatch_tx::<T, _>(collection_id, |d| {906 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
901 d.create_multiple_items_ex(sender, data, &budget)907 d.create_multiple_items_ex(sender, data, &budget)
902 })908 })
903 }909 }
995 /// * Fungible Mode: The desired number of pieces to burn.1001 /// * Fungible Mode: The desired number of pieces to burn.
996 /// * Re-Fungible Mode: The desired number of pieces to burn.1002 /// * Re-Fungible Mode: The desired number of pieces to burn.
997 #[pallet::call_index(21)]1003 #[pallet::call_index(21)]
998 #[pallet::weight(T::CommonWeightInfo::burn_from())]1004 #[pallet::weight(T::CommonWeightInfo::burn_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]
999 pub fn burn_from(1005 pub fn burn_from(
1000 origin: OriginFor<T>,1006 origin: OriginFor<T>,
1001 collection_id: CollectionId,1007 collection_id: CollectionId,
1004 value: u128,1010 value: u128,
1005 ) -> DispatchResultWithPostInfo {1011 ) -> DispatchResultWithPostInfo {
1006 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1012 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1007 let budget = budget::Value::new(NESTING_BUDGET);1013 let budget = Self::structure_nesting_budget();
10081014
1009 dispatch_tx::<T, _>(collection_id, |d| {1015 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
1010 d.burn_from(sender, from, item_id, value, &budget)1016 d.burn_from(sender, from, item_id, value, &budget)
1011 })1017 })
1012 }1018 }
1033 /// * Fungible Mode: The desired number of pieces to transfer.1039 /// * Fungible Mode: The desired number of pieces to transfer.
1034 /// * Re-Fungible Mode: The desired number of pieces to transfer.1040 /// * Re-Fungible Mode: The desired number of pieces to transfer.
1035 #[pallet::call_index(22)]1041 #[pallet::call_index(22)]
1036 #[pallet::weight(T::CommonWeightInfo::transfer())]1042 #[pallet::weight(T::CommonWeightInfo::transfer() + <Pallet<T>>::nesting_budget_predispatch_weight())]
1037 pub fn transfer(1043 pub fn transfer(
1038 origin: OriginFor<T>,1044 origin: OriginFor<T>,
1039 recipient: T::CrossAccountId,1045 recipient: T::CrossAccountId,
1042 value: u128,1048 value: u128,
1043 ) -> DispatchResultWithPostInfo {1049 ) -> DispatchResultWithPostInfo {
1044 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1050 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1045 let budget = budget::Value::new(NESTING_BUDGET);1051 let budget = Self::structure_nesting_budget();
10461052
1047 dispatch_tx::<T, _>(collection_id, |d| {1053 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
1048 d.transfer(sender, recipient, item_id, value, &budget)1054 d.transfer(sender, recipient, item_id, value, &budget)
1049 })1055 })
1050 }1056 }
1138 /// * Fungible Mode: The desired number of pieces to transfer.1144 /// * Fungible Mode: The desired number of pieces to transfer.
1139 /// * Re-Fungible Mode: The desired number of pieces to transfer.1145 /// * Re-Fungible Mode: The desired number of pieces to transfer.
1140 #[pallet::call_index(25)]1146 #[pallet::call_index(25)]
1141 #[pallet::weight(T::CommonWeightInfo::transfer_from())]1147 #[pallet::weight(T::CommonWeightInfo::transfer_from() + <Pallet<T>>::nesting_budget_predispatch_weight())]
1142 pub fn transfer_from(1148 pub fn transfer_from(
1143 origin: OriginFor<T>,1149 origin: OriginFor<T>,
1144 from: T::CrossAccountId,1150 from: T::CrossAccountId,
1148 value: u128,1154 value: u128,
1149 ) -> DispatchResultWithPostInfo {1155 ) -> DispatchResultWithPostInfo {
1150 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);1156 let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
1151 let budget = budget::Value::new(NESTING_BUDGET);1157 let budget = Self::structure_nesting_budget();
11521158
1153 dispatch_tx::<T, _>(collection_id, |d| {1159 Self::dispatch_tx_with_nesting_budget(collection_id, &budget, |d| {
1154 d.transfer_from(sender, from, recipient, item_id, value, &budget)1160 d.transfer_from(sender, from, recipient, item_id, value, &budget)
1155 })1161 })
1156 }1162 }
1347 let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);1353 let _ = <RefungibleApproveBasket<T>>::clear_prefix((collection_id,), u32::MAX, None);
13481354
1349 Ok(())1355 Ok(())
1356 }
1357
1358 fn structure_nesting_budget() -> budget::Value {
1359 budget::Value::new(Self::nesting_budget())
1360 }
1361
1362 fn nesting_budget_weight(value: &budget::Value) -> Weight {
1363 T::StructureWeightInfo::find_parent().saturating_mul(value.remaining() as u64)
1364 }
1365
1366 fn nesting_budget_predispatch_weight() -> Weight {
1367 Self::nesting_budget_weight(&Self::structure_nesting_budget())
1368 }
1369
1370 pub fn dispatch_tx_with_nesting_budget<
1371 C: FnOnce(&dyn CommonCollectionOperations<T>) -> DispatchResultWithPostInfo,
1372 >(
1373 collection: CollectionId,
1374 budget: &budget::Value,
1375 call: C,
1376 ) -> DispatchResultWithPostInfo {
1377 let mut result = dispatch_tx::<T, _>(collection, call);
1378
1379 match &mut result {
1380 Ok(PostDispatchInfo {
1381 actual_weight: Some(weight),
1382 ..
1383 })
1384 | Err(DispatchErrorWithPostInfo {
1385 post_info: PostDispatchInfo {
1386 actual_weight: Some(weight),
1387 ..
1388 },
1389 ..
1390 }) => *weight += Self::nesting_budget_weight(budget),
1391 _ => {}
1392 }
1393
1394 result
1350 }1395 }
1351 }1396 }
1352}1397}
modifiedprimitives/common/src/constants.rsdiffbeforeafterboth

no syntactic changes

modifiedprimitives/data-structs/src/budget.rsdiffbeforeafterboth
1use core::cell::Cell;1use sp_std::cell::Cell;
22
3pub trait Budget {3pub trait Budget {
4 /// Returns true while not exceeded4 /// Returns true while not exceeded
22 pub fn new(v: u32) -> Self {22 pub fn new(v: u32) -> Self {
23 Self(Cell::new(v))23 Self(Cell::new(v))
24 }24 }
25 pub fn refund(self) -> u32 {25 pub fn remaining(&self) -> u32 {
26 self.0.get()26 self.0.get()
27 }27 }
28}28}
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
116impl pallet_unique::Config for Runtime {116impl pallet_unique::Config for Runtime {
117 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;117 type WeightInfo = pallet_unique::weights::SubstrateWeight<Self>;
118 type CommonWeightInfo = CommonWeights<Self>;118 type CommonWeightInfo = CommonWeights<Self>;
119 type StructureWeightInfo = pallet_structure::weights::SubstrateWeight<Self>;
119 type RefungibleExtensionsWeightInfo = CommonWeights<Self>;120 type RefungibleExtensionsWeightInfo = CommonWeights<Self>;
120}121}
121122
modifiedruntime/common/runtime_apis.rsdiffbeforeafterboth
84 }84 }
8585
86 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {86 fn topmost_token_owner(collection: CollectionId, token: TokenId) -> Result<Option<CrossAccountId>, DispatchError> {
87 let budget = up_data_structs::budget::Value::new(10);87 let budget = budget::Value::new(10);
8888
89 <pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)89 <pallet_structure::Pallet<Runtime>>::find_topmost_owner(collection, token, &budget)
90 }90 }
modifiedruntime/common/weights/mod.rsdiffbeforeafterboth
98 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))98 dispatch_weight::<T>() + max_weight_of!(set_token_properties(amount))
99 }99 }
100
101 fn delete_token_properties(amount: u32) -> Weight {
102 dispatch_weight::<T>() + max_weight_of!(delete_token_properties(amount))
103 }
104100
105 fn set_token_property_permissions(amount: u32) -> Weight {101 fn set_token_property_permissions(amount: u32) -> Weight {
106 dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))102 dispatch_weight::<T>() + max_weight_of!(set_token_property_permissions(amount))
126 dispatch_weight::<T>() + max_weight_of!(burn_from())122 dispatch_weight::<T>() + max_weight_of!(burn_from())
127 }123 }
128
129 fn burn_recursively_self_raw() -> Weight {
130 max_weight_of!(burn_recursively_self_raw())
131 }
132
133 fn burn_recursively_breadth_raw(amount: u32) -> Weight {
134 max_weight_of!(burn_recursively_breadth_raw(amount))
135 }
136
137 fn token_owner() -> Weight {
138 max_weight_of!(token_owner())
139 }
140124
141 fn set_allowance_for_all() -> Weight {125 fn set_allowance_for_all() -> Weight {
142 max_weight_of!(set_allowance_for_all())126 dispatch_weight::<T>() + max_weight_of!(set_allowance_for_all())
143 }127 }
144128
145 fn force_repair_item() -> Weight {129 fn force_repair_item() -> Weight {
146 max_weight_of!(force_repair_item())130 dispatch_weight::<T>() + max_weight_of!(force_repair_item())
147 }131 }
148}132}
149133