Skip to content

Commit

Permalink
refactor: property writer / fix set_token_props weight
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshiposha committed Oct 5, 2023
1 parent bce2cc1 commit c064a0a
Showing 14 changed files with 408 additions and 295 deletions.
21 changes: 5 additions & 16 deletions pallets/common/src/benchmarking.rs
Original file line number Diff line number Diff line change
@@ -17,14 +17,13 @@
#![allow(missing_docs)]

use sp_std::vec::Vec;
use crate::{Config, CollectionHandle, Pallet};
use crate::{Config, CollectionHandle, Pallet, BenchmarkPropertyWriter};
use pallet_evm::account::CrossAccountId;
use frame_benchmarking::{benchmarks, account};
use up_data_structs::{
CollectionMode, CreateCollectionData, CollectionId, Property, PropertyKey, PropertyValue,
CollectionPermissions, NestingPermissions, AccessMode, PropertiesPermissionMap,
MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
MAX_PROPERTIES_PER_ITEM,
CollectionPermissions, NestingPermissions, AccessMode, MAX_COLLECTION_NAME_LENGTH,
MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, MAX_PROPERTIES_PER_ITEM,
};
use frame_support::{
traits::{Get, fungible::Balanced, Imbalance, tokens::Precision},
@@ -124,16 +123,6 @@ fn create_collection<T: Config>(
)
}

pub fn load_is_admin_and_property_permissions<T: Config>(
collection: &CollectionHandle<T>,
sender: &T::CrossAccountId,
) -> (bool, PropertiesPermissionMap) {
(
collection.is_owner_or_admin(sender),
<Pallet<T>>::property_permissions(collection.id),
)
}

/// Helper macros, which handles all benchmarking preparation in semi-declarative way
///
/// `name` is a substrate account
@@ -227,11 +216,11 @@ benchmarks! {

}: {collection_handle.check_allowlist(&sender)?;}

init_token_properties_common {
property_writer_load_collection_info {
bench_init!{
owner: sub; collection: collection(owner);
sender: sub;
sender: cross_from_sub(sender);
};
}: {load_is_admin_and_property_permissions(&collection, &sender);}
}: {<BenchmarkPropertyWriter<T>>::load_collection_info(&&collection, &sender);}
}
Loading

0 comments on commit c064a0a

Please sign in to comment.