Browse Source

Merge pull request #1542 from iorveth/update_class_permissions_extrinsic_fix

Update class permissions extrinsic fix
Mokhtar Naamani 4 years ago
parent
commit
e9f50ab816
27 changed files with 844 additions and 633 deletions
  1. 2 0
      node/src/chain_spec/mod.rs
  2. 50 51
      runtime-modules/content-directory/src/class.rs
  3. 49 38
      runtime-modules/content-directory/src/entity.rs
  4. 3 0
      runtime-modules/content-directory/src/errors.rs
  5. 21 15
      runtime-modules/content-directory/src/helpers.rs
  6. 257 124
      runtime-modules/content-directory/src/lib.rs
  7. 63 52
      runtime-modules/content-directory/src/mock.rs
  8. 14 11
      runtime-modules/content-directory/src/permissions.rs
  9. 13 64
      runtime-modules/content-directory/src/permissions/class.rs
  10. 16 0
      runtime-modules/content-directory/src/permissions/curator_group.rs
  11. 27 28
      runtime-modules/content-directory/src/permissions/entity.rs
  12. 3 3
      runtime-modules/content-directory/src/schema/convert.rs
  13. 78 39
      runtime-modules/content-directory/src/schema/output.rs
  14. 111 123
      runtime-modules/content-directory/src/schema/property.rs
  15. 11 8
      runtime-modules/content-directory/src/tests.rs
  16. 9 9
      runtime-modules/content-directory/src/tests/add_class_schema.rs
  17. 38 38
      runtime-modules/content-directory/src/tests/add_schema_support_to_entity.rs
  18. 3 3
      runtime-modules/content-directory/src/tests/clear_entity_property_vector.rs
  19. 2 2
      runtime-modules/content-directory/src/tests/create_entity.rs
  20. 9 9
      runtime-modules/content-directory/src/tests/insert_at_entity_property_vector.rs
  21. 3 3
      runtime-modules/content-directory/src/tests/remove_at_entity_property_vector.rs
  22. 1 1
      runtime-modules/content-directory/src/tests/remove_entity.rs
  23. 1 1
      runtime-modules/content-directory/src/tests/transaction.rs
  24. 2 2
      runtime-modules/content-directory/src/tests/transfer_entity_ownership.rs
  25. 51 2
      runtime-modules/content-directory/src/tests/update_class_permissions.rs
  26. 1 1
      runtime-modules/content-directory/src/tests/update_entity_creation_voucher.rs
  27. 6 6
      runtime-modules/content-directory/src/tests/update_entity_property_values.rs

+ 2 - 0
node/src/chain_spec/mod.rs

@@ -330,6 +330,8 @@ pub fn testnet_genesis(
         }),
         content_directory: Some({
             ContentDirectoryConfig {
+                class_by_id: vec![],
+                entity_by_id: vec![],
                 curator_group_by_id: vec![],
                 next_class_id: 1,
                 next_entity_id: 1,

+ 50 - 51
runtime-modules/content-directory/src/class.rs

@@ -1,14 +1,18 @@
 use super::*;
 
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Eq, PartialEq, Clone)]
-pub struct Class<T: Trait> {
+#[derive(Encode, Decode, Eq, PartialEq, Default, Clone)]
+pub struct Class<
+    EntityId: Default + BaseArithmetic + Clone + Copy,
+    ClassId: Default + BaseArithmetic + Clone + Copy,
+    CuratorGroupId: Ord + Default,
+> {
     /// Permissions for an instance of a Class.
-    class_permissions: ClassPermissions<T>,
+    class_permissions: ClassPermissions<CuratorGroupId>,
     /// All properties that have been used on this class across different class schemas.
     /// Unlikely to be more than roughly 20 properties per class, often less.
     /// For Person, think "height", "weight", etc.
-    properties: Vec<Property<T>>,
+    properties: Vec<Property<ClassId>>,
 
     /// All schemas that are available for this class, think v0.0 Person, v.1.0 Person, etc.
     schemas: Vec<Schema>,
@@ -18,38 +22,28 @@ pub struct Class<T: Trait> {
     description: Vec<u8>,
 
     /// The maximum number of entities which can be created.
-    maximum_entities_count: T::EntityId,
+    maximum_entities_count: EntityId,
 
     /// The current number of entities which exist.
-    current_number_of_entities: T::EntityId,
+    current_number_of_entities: EntityId,
 
     /// How many entities a given controller may create at most.
-    default_entity_creation_voucher_upper_bound: T::EntityId,
+    default_entity_creation_voucher_upper_bound: EntityId,
 }
 
-impl<T: Trait> Default for Class<T> {
-    fn default() -> Self {
-        Self {
-            class_permissions: ClassPermissions::<T>::default(),
-            properties: vec![],
-            schemas: vec![],
-            name: vec![],
-            description: vec![],
-            maximum_entities_count: T::EntityId::default(),
-            current_number_of_entities: T::EntityId::default(),
-            default_entity_creation_voucher_upper_bound: T::EntityId::default(),
-        }
-    }
-}
-
-impl<T: Trait> Class<T> {
+impl<
+        EntityId: Default + BaseArithmetic + Clone + Copy,
+        ClassId: Default + BaseArithmetic + Clone + Copy,
+        CuratorGroupId: Ord + Default,
+    > Class<EntityId, ClassId, CuratorGroupId>
+{
     /// Create new `Class` with provided parameters
     pub fn new(
-        class_permissions: ClassPermissions<T>,
+        class_permissions: ClassPermissions<CuratorGroupId>,
         name: Vec<u8>,
         description: Vec<u8>,
-        maximum_entities_count: T::EntityId,
-        default_entity_creation_voucher_upper_bound: T::EntityId,
+        maximum_entities_count: EntityId,
+        default_entity_creation_voucher_upper_bound: EntityId,
     ) -> Self {
         Self {
             class_permissions,
@@ -58,7 +52,7 @@ impl<T: Trait> Class<T> {
             name,
             description,
             maximum_entities_count,
-            current_number_of_entities: T::EntityId::zero(),
+            current_number_of_entities: EntityId::zero(),
             default_entity_creation_voucher_upper_bound,
         }
     }
@@ -87,7 +81,7 @@ impl<T: Trait> Class<T> {
     }
 
     /// Used to update `Class` permissions
-    pub fn update_permissions(&mut self, permissions: ClassPermissions<T>) {
+    pub fn update_permissions(&mut self, permissions: ClassPermissions<CuratorGroupId>) {
         self.class_permissions = permissions
     }
 
@@ -103,72 +97,75 @@ impl<T: Trait> Class<T> {
 
     /// Increment number of entities, associated with this class
     pub fn increment_entities_count(&mut self) {
-        self.current_number_of_entities += T::EntityId::one();
+        self.current_number_of_entities += EntityId::one();
     }
 
     /// Decrement number of entities, associated with this class
     pub fn decrement_entities_count(&mut self) {
-        self.current_number_of_entities -= T::EntityId::one();
+        self.current_number_of_entities -= EntityId::one();
     }
 
     /// Retrieve `ClassPermissions` by mutable reference
-    pub fn get_permissions_mut(&mut self) -> &mut ClassPermissions<T> {
+    pub fn get_permissions_mut(&mut self) -> &mut ClassPermissions<CuratorGroupId> {
         &mut self.class_permissions
     }
 
     /// Retrieve `ClassPermissions` by reference
-    pub fn get_permissions_ref(&self) -> &ClassPermissions<T> {
+    pub fn get_permissions_ref(&self) -> &ClassPermissions<CuratorGroupId> {
         &self.class_permissions
     }
 
     /// Retrieve `ClassPermissions` by value
-    pub fn get_permissions(self) -> ClassPermissions<T> {
+    pub fn get_permissions(self) -> ClassPermissions<CuratorGroupId> {
         self.class_permissions
     }
 
     /// Retrieve `Class` properties by value  
-    pub fn get_properties(self) -> Vec<Property<T>> {
+    pub fn get_properties(self) -> Vec<Property<ClassId>> {
         self.properties
     }
 
     /// Replace `Class` properties with updated_class_properties
-    pub fn set_properties(&mut self, updated_class_properties: Vec<Property<T>>) {
+    pub fn set_properties(&mut self, updated_class_properties: Vec<Property<ClassId>>) {
         self.properties = updated_class_properties;
     }
 
     /// Get per controller `Class`- specific limit
-    pub fn get_default_entity_creation_voucher_upper_bound(&self) -> T::EntityId {
+    pub fn get_default_entity_creation_voucher_upper_bound(&self) -> EntityId {
         self.default_entity_creation_voucher_upper_bound
     }
 
     /// Retrive the maximum entities count, which can be created for given `Class`
-    pub fn get_maximum_entities_count(&self) -> T::EntityId {
+    pub fn get_maximum_entities_count(&self) -> EntityId {
         self.maximum_entities_count
     }
 
     /// Set per controller `Class`- specific limit
     pub fn set_default_entity_creation_voucher_upper_bound(
         &mut self,
-        new_default_entity_creation_voucher_upper_bound: T::EntityId,
+        new_default_entity_creation_voucher_upper_bound: EntityId,
     ) {
         self.default_entity_creation_voucher_upper_bound =
             new_default_entity_creation_voucher_upper_bound;
     }
 
     /// Set the maximum entities count, which can be created for given `Class`
-    pub fn set_maximum_entities_count(&mut self, maximum_entities_count: T::EntityId) {
+    pub fn set_maximum_entities_count(&mut self, maximum_entities_count: EntityId) {
         self.maximum_entities_count = maximum_entities_count;
     }
 
     /// Ensure `Class` `Schema` under given index exist, return corresponding `Schema`
-    pub fn ensure_schema_exists(&self, schema_index: SchemaId) -> Result<&Schema, Error<T>> {
+    pub fn ensure_schema_exists<T: Trait>(
+        &self,
+        schema_index: SchemaId,
+    ) -> Result<&Schema, Error<T>> {
         self.schemas
             .get(schema_index as usize)
             .ok_or(Error::<T>::UnknownClassSchemaId)
     }
 
     /// Ensure `schema_id` is a valid index of `Class` schemas vector
-    pub fn ensure_schema_id_exists(&self, schema_id: SchemaId) -> Result<(), Error<T>> {
+    pub fn ensure_schema_id_exists<T: Trait>(&self, schema_id: SchemaId) -> Result<(), Error<T>> {
         ensure!(
             schema_id < self.schemas.len() as SchemaId,
             Error::<T>::UnknownClassSchemaId
@@ -177,7 +174,7 @@ impl<T: Trait> Class<T> {
     }
 
     /// Ensure `Schema`s limit per `Class` not reached
-    pub fn ensure_schemas_limit_not_reached(&self) -> Result<(), Error<T>> {
+    pub fn ensure_schemas_limit_not_reached<T: Trait>(&self) -> Result<(), Error<T>> {
         ensure!(
             (self.schemas.len() as MaxNumber) < T::MaxNumberOfSchemasPerClass::get(),
             Error::<T>::ClassSchemasLimitReached
@@ -186,9 +183,9 @@ impl<T: Trait> Class<T> {
     }
 
     /// Ensure properties limit per `Schema` not reached
-    pub fn ensure_properties_limit_not_reached(
+    pub fn ensure_properties_limit_not_reached<T: Trait>(
         &self,
-        new_properties: &[Property<T>],
+        new_properties: &[Property<ClassId>],
     ) -> Result<(), Error<T>> {
         ensure!(
             T::MaxNumberOfPropertiesPerSchema::get()
@@ -199,7 +196,9 @@ impl<T: Trait> Class<T> {
     }
 
     /// Ensure `Class` specific entities limit not reached
-    pub fn ensure_maximum_entities_count_limit_not_reached(&self) -> Result<(), Error<T>> {
+    pub fn ensure_maximum_entities_count_limit_not_reached<T: Trait>(
+        &self,
+    ) -> Result<(), Error<T>> {
         ensure!(
             self.current_number_of_entities < self.maximum_entities_count,
             Error::<T>::NumberOfEntitiesPerClassLimitReached
@@ -209,11 +208,11 @@ impl<T: Trait> Class<T> {
 
     /// Ensure `Property` under given `PropertyId` is unlocked from actor with given `EntityAccessLevel`
     /// return corresponding `Property` by value
-    pub fn ensure_class_property_type_unlocked_from(
-        &self,
+    pub fn ensure_class_property_type_unlocked_from<T: Trait>(
+        self,
         in_class_schema_property_id: PropertyId,
         entity_access_level: EntityAccessLevel,
-    ) -> Result<Property<T>, Error<T>> {
+    ) -> Result<Property<ClassId>, Error<T>> {
         // Ensure property values were not locked on Class level
         self.ensure_property_values_unlocked()?;
 
@@ -226,13 +225,13 @@ impl<T: Trait> Class<T> {
             .ok_or(Error::<T>::ClassPropertyNotFound)?;
 
         // Ensure Property is unlocked from Actor with given EntityAccessLevel
-        class_property.ensure_unlocked_from(entity_access_level)?;
+        class_property.ensure_unlocked_from::<T>(entity_access_level)?;
 
-        Ok(class_property.to_owned())
+        Ok(class_property.clone())
     }
 
     /// Ensure property values were not locked on `Class` level
-    pub fn ensure_property_values_unlocked(&self) -> Result<(), Error<T>> {
+    pub fn ensure_property_values_unlocked<T: Trait>(&self) -> Result<(), Error<T>> {
         ensure!(
             !self
                 .get_permissions_ref()

+ 49 - 38
runtime-modules/content-directory/src/entity.rs

@@ -2,13 +2,19 @@ use super::*;
 
 /// Represents `Entity`, related to a specific `Class`
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, PartialEq, Eq)]
-pub struct Entity<T: Trait> {
+#[derive(Encode, Decode, Default, Clone, PartialEq, Eq)]
+pub struct Entity<
+    ClassId: Default + BaseArithmetic + Clone + Copy,
+    MemberId: Default + PartialEq + Clone + Copy,
+    Hashed: Default + Clone + Codec,
+    EntityId: Default + Clone + Copy + Codec,
+    Nonce: Default + BaseArithmetic + Clone + Copy,
+> {
     /// Permissions for an instance of an Entity.
-    entity_permissions: EntityPermissions<T>,
+    entity_permissions: EntityPermissions<MemberId>,
 
     /// The class id of this entity.
-    class_id: T::ClassId,
+    class_id: ClassId,
 
     /// What schemas under which entity of the respective class is available, think
     /// v.2.0 Person schema for John, v3.0 Person schema for John
@@ -18,34 +24,29 @@ pub struct Entity<T: Trait> {
 
     /// Values for properties on class that are used by some schema used by this entity
     /// Length is no more than Class.properties.
-    values: BTreeMap<PropertyId, StoredPropertyValue<T>>,
+    values: BTreeMap<PropertyId, StoredPropertyValue<Hashed, EntityId, Nonce>>,
 
     /// Number of property values referencing current entity
     reference_counter: InboundReferenceCounter,
 }
 
-impl<T: Trait> Default for Entity<T> {
-    fn default() -> Self {
-        Self {
-            entity_permissions: EntityPermissions::<T>::default(),
-            class_id: T::ClassId::default(),
-            supported_schemas: BTreeSet::new(),
-            values: BTreeMap::new(),
-            reference_counter: InboundReferenceCounter::default(),
-        }
-    }
-}
-
-impl<T: Trait> Entity<T> {
+impl<
+        ClassId: Default + BaseArithmetic + Clone + Copy,
+        MemberId: Default + PartialEq + Clone + Copy,
+        Hashed: Default + Clone + Codec,
+        EntityId: Default + Clone + Copy + Codec,
+        Nonce: Default + BaseArithmetic + Clone + Copy,
+    > Entity<ClassId, MemberId, Hashed, EntityId, Nonce>
+{
     /// Create new `Entity` instance, related to a given `class_id` with provided parameters,  
     pub fn new(
-        controller: EntityController<T>,
-        class_id: T::ClassId,
+        controller: EntityController<MemberId>,
+        class_id: ClassId,
         supported_schemas: BTreeSet<SchemaId>,
-        values: BTreeMap<PropertyId, StoredPropertyValue<T>>,
+        values: BTreeMap<PropertyId, StoredPropertyValue<Hashed, EntityId, Nonce>>,
     ) -> Self {
         Self {
-            entity_permissions: EntityPermissions::<T>::default_with_controller(controller),
+            entity_permissions: EntityPermissions::<MemberId>::default_with_controller(controller),
             class_id,
             supported_schemas,
             values,
@@ -54,7 +55,7 @@ impl<T: Trait> Entity<T> {
     }
 
     /// Get `class_id` of this `Entity`
-    pub fn get_class_id(&self) -> T::ClassId {
+    pub fn get_class_id(&self) -> ClassId {
         self.class_id
     }
 
@@ -64,54 +65,64 @@ impl<T: Trait> Entity<T> {
     }
 
     /// Get `Entity` values by value
-    pub fn get_values(self) -> BTreeMap<PropertyId, StoredPropertyValue<T>> {
+    pub fn get_values(self) -> BTreeMap<PropertyId, StoredPropertyValue<Hashed, EntityId, Nonce>> {
         self.values
     }
 
     /// Get `Entity` values by reference
-    pub fn get_values_ref(&self) -> &BTreeMap<PropertyId, StoredPropertyValue<T>> {
+    pub fn get_values_ref(
+        &self,
+    ) -> &BTreeMap<PropertyId, StoredPropertyValue<Hashed, EntityId, Nonce>> {
         &self.values
     }
 
     /// Get `Entity` values by mutable reference
-    pub fn get_values_mut(&mut self) -> &mut BTreeMap<PropertyId, StoredPropertyValue<T>> {
+    pub fn get_values_mut(
+        &mut self,
+    ) -> &mut BTreeMap<PropertyId, StoredPropertyValue<Hashed, EntityId, Nonce>> {
         &mut self.values
     }
 
     /// Get mutable reference to `Entity` values
-    pub fn set_values(&mut self, new_values: BTreeMap<PropertyId, StoredPropertyValue<T>>) {
+    pub fn set_values(
+        &mut self,
+        new_values: BTreeMap<PropertyId, StoredPropertyValue<Hashed, EntityId, Nonce>>,
+    ) {
         self.values = new_values;
     }
 
     /// Get mutable `EntityPermissions` reference, related to given `Entity`
-    pub fn get_permissions_mut(&mut self) -> &mut EntityPermissions<T> {
+    pub fn get_permissions_mut(&mut self) -> &mut EntityPermissions<MemberId> {
         &mut self.entity_permissions
     }
 
     /// Get `EntityPermissions` reference, related to given `Entity`
-    pub fn get_permissions_ref(&self) -> &EntityPermissions<T> {
+    pub fn get_permissions_ref(&self) -> &EntityPermissions<MemberId> {
         &self.entity_permissions
     }
 
     /// Get `EntityPermissions`, related to given `Entity` by value
-    pub fn get_permissions(self) -> EntityPermissions<T> {
+    pub fn get_permissions(self) -> EntityPermissions<MemberId> {
         self.entity_permissions
     }
 
     /// Update existing `EntityPermissions` with newly provided
-    pub fn update_permissions(&mut self, permissions: EntityPermissions<T>) {
+    pub fn update_permissions(&mut self, permissions: EntityPermissions<MemberId>) {
         self.entity_permissions = permissions
     }
 
     /// Ensure `Schema` under given id is not added to given `Entity` yet
-    pub fn ensure_schema_id_is_not_added(&self, schema_id: SchemaId) -> Result<(), Error<T>> {
+    pub fn ensure_schema_id_is_not_added<T: Trait>(
+        &self,
+        schema_id: SchemaId,
+    ) -> Result<(), Error<T>> {
         let schema_not_added = !self.supported_schemas.contains(&schema_id);
         ensure!(schema_not_added, Error::<T>::SchemaAlreadyAddedToTheEntity);
         Ok(())
     }
 
     /// Ensure provided `property_values` are not added to the `Entity` `values` map yet
-    pub fn ensure_property_values_are_not_added(
+    pub fn ensure_property_values_are_not_added<T: Trait>(
         &self,
         property_values: &BTreeMap<PropertyId, InputPropertyValue<T>>,
     ) -> Result<(), Error<T>> {
@@ -125,23 +136,23 @@ impl<T: Trait> Entity<T> {
     }
 
     /// Ensure InputPropertyValue under given `in_class_schema_property_id` is Vector
-    pub fn ensure_property_value_is_vec(
+    pub fn ensure_property_value_is_vec<T: Trait>(
         &self,
         in_class_schema_property_id: PropertyId,
-    ) -> Result<VecStoredPropertyValue<T>, Error<T>> {
+    ) -> Result<VecStoredPropertyValue<Hashed, EntityId, Nonce>, Error<T>> {
         self.values
             .get(&in_class_schema_property_id)
             // Throw an error if a property was not found on entity
             // by an in-class index of a property.
             .ok_or(Error::<T>::UnknownEntityPropertyId)?
             .as_vec_property_value()
-            .map(|property_value_vec| property_value_vec.to_owned())
+            .cloned()
             // Ensure prop value under given class schema property id is vector
             .ok_or(Error::<T>::PropertyValueUnderGivenIndexIsNotAVector)
     }
 
     /// Ensure any `InputPropertyValue` from external entity does not point to the given `Entity`
-    pub fn ensure_rc_is_zero(&self) -> Result<(), Error<T>> {
+    pub fn ensure_rc_is_zero<T: Trait>(&self) -> Result<(), Error<T>> {
         ensure!(
             self.reference_counter.is_total_equal_to_zero(),
             Error::<T>::EntityRcDoesNotEqualToZero
@@ -150,7 +161,7 @@ impl<T: Trait> Entity<T> {
     }
 
     /// Ensure any inbound `InputPropertyValue` with `same_owner` flag set points to the given `Entity`
-    pub fn ensure_inbound_same_owner_rc_is_zero(&self) -> Result<(), Error<T>> {
+    pub fn ensure_inbound_same_owner_rc_is_zero<T: Trait>(&self) -> Result<(), Error<T>> {
         ensure!(
             self.reference_counter.is_same_owner_equal_to_zero(),
             Error::<T>::EntityInboundSameOwnerRcDoesNotEqualToZero

+ 3 - 0
runtime-modules/content-directory/src/errors.rs

@@ -164,6 +164,9 @@ decl_error! {
         /// Curator under provided curator id is not a member of curaror group under given id
         CuratorIsNotAMemberOfGivenCuratorGroup,
 
+        /// Curator under provided curator id is already a member of curaror group under given id
+        CuratorIsAlreadyAMemberOfGivenCuratorGroup,
+
         /// Given curator group does not exist
         CuratorGroupDoesNotExist,
 

+ 21 - 15
runtime-modules/content-directory/src/helpers.rs

@@ -2,16 +2,19 @@ use crate::*;
 use core::ops::{Deref, DerefMut};
 
 /// Wrapper for existing `InputPropertyValue` and its respective `Class` `Property`
-pub struct InputValueForExistingProperty<'a, T: Trait>(&'a Property<T>, &'a InputPropertyValue<T>);
+pub struct InputValueForExistingProperty<'a, T: Trait>(
+    &'a Property<T::ClassId>,
+    &'a InputPropertyValue<T>,
+);
 
 impl<'a, T: Trait> InputValueForExistingProperty<'a, T> {
     /// Create single instance of `InputValueForExistingProperty` from provided `property` and `value`
-    fn new(property: &'a Property<T>, value: &'a InputPropertyValue<T>) -> Self {
+    fn new(property: &'a Property<T::ClassId>, value: &'a InputPropertyValue<T>) -> Self {
         Self(property, value)
     }
 
     /// Retrieve `Property` reference
-    pub fn get_property(&self) -> &Property<T> {
+    pub fn get_property(&self) -> &Property<T::ClassId> {
         self.0
     }
 
@@ -21,7 +24,7 @@ impl<'a, T: Trait> InputValueForExistingProperty<'a, T> {
     }
 
     /// Retrieve `Property` and `InputPropertyValue` references
-    pub fn unzip(&self) -> (&Property<T>, &InputPropertyValue<T>) {
+    pub fn unzip(&self) -> (&Property<T::ClassId>, &InputPropertyValue<T>) {
         (self.0, self.1)
     }
 }
@@ -55,7 +58,7 @@ impl<'a, T: Trait> InputValuesForExistingProperties<'a, T> {
     /// Create `InputValuesForExistingProperties` helper structure from provided `property_values` and their corresponding `Class` properties.
     /// Throws an error, when `Class` `Property` under `property_id`, corresponding to provided `property_value` not found
     pub fn from(
-        properties: &'a [Property<T>],
+        properties: &'a [Property<T::ClassId>],
         property_values: &'a BTreeMap<PropertyId, InputPropertyValue<T>>,
     ) -> Result<Self, Error<T>> {
         let mut values_for_existing_properties = InputValuesForExistingProperties::<T>::default();
@@ -74,35 +77,36 @@ impl<'a, T: Trait> InputValuesForExistingProperties<'a, T> {
 
 /// Wrapper for existing `StoredPropertyValue` and its respective `Class` `Property`
 pub struct StoredValueForExistingProperty<'a, T: Trait>(
-    &'a Property<T>,
-    &'a StoredPropertyValue<T>,
+    &'a Property<T::ClassId>,
+    &'a StoredPropertyValueOf<T>,
 );
 
 impl<'a, T: Trait> StoredValueForExistingProperty<'a, T> {
     /// Create single instance of `StoredValueForExistingProperty` from provided `property` and `value`
-    pub fn new(property: &'a Property<T>, value: &'a StoredPropertyValue<T>) -> Self {
+    pub fn new(property: &'a Property<T::ClassId>, value: &'a StoredPropertyValueOf<T>) -> Self {
         Self(property, value)
     }
 
     /// Retrieve `Property` reference
-    pub fn get_property(&self) -> &Property<T> {
+    pub fn get_property(&self) -> &Property<T::ClassId> {
         self.0
     }
 
     /// Retrieve `StoredPropertyValue` reference
-    pub fn get_value(&self) -> &StoredPropertyValue<T> {
+    pub fn get_value(&self) -> &StoredPropertyValueOf<T> {
         self.1
     }
 
     /// Retrieve `Property` and `StoredPropertyValue` references
-    pub fn unzip(&self) -> (&Property<T>, &StoredPropertyValue<T>) {
+    pub fn unzip(&self) -> (&Property<T::ClassId>, &StoredPropertyValueOf<T>) {
         (self.0, self.1)
     }
 
     /// Check if Property is default and non `required`
     pub fn is_default(&self) -> bool {
         let (property, property_value) = self.unzip();
-        !property.required && *property_value == StoredPropertyValue::<T>::default()
+        !property.required
+            && *property_value == StoredPropertyValue::<T::Hash, T::EntityId, T::Nonce>::default()
     }
 }
 
@@ -134,8 +138,8 @@ impl<'a, T: Trait> DerefMut for StoredValuesForExistingProperties<'a, T> {
 impl<'a, T: Trait> StoredValuesForExistingProperties<'a, T> {
     /// Create `StoredValuesForExistingProperties` helper structure from provided `property_values` and their corresponding `Class` properties.
     pub fn from(
-        properties: &'a [Property<T>],
-        property_values: &'a BTreeMap<PropertyId, StoredPropertyValue<T>>,
+        properties: &'a [Property<T::ClassId>],
+        property_values: &'a BTreeMap<PropertyId, StoredPropertyValueOf<T>>,
     ) -> Result<Self, Error<T>> {
         let mut values_for_existing_properties = StoredValuesForExistingProperties::<T>::default();
 
@@ -162,7 +166,9 @@ impl<'a, T: Trait> StoredValuesForExistingProperties<'a, T> {
             .map(|(&property_id, property_value)| {
                 (
                     property_id,
-                    property_value.get_value().compute_unique_hash(property_id),
+                    property_value
+                        .get_value()
+                        .compute_unique_hash::<T>(property_id),
                 )
             })
             .collect()

File diff suppressed because it is too large
+ 257 - 124
runtime-modules/content-directory/src/lib.rs


+ 63 - 52
runtime-modules/content-directory/src/mock.rs

@@ -17,13 +17,14 @@ use std::cell::RefCell;
 
 /// Runtime Types
 
-type ClassId = <Runtime as Trait>::ClassId;
-type EntityId = <Runtime as Trait>::EntityId;
-type Nonce = <Runtime as Trait>::Nonce;
+pub type ClassId = <Runtime as Trait>::ClassId;
+pub type EntityId = <Runtime as Trait>::EntityId;
+pub type Nonce = <Runtime as Trait>::Nonce;
+pub type Hashed = <Runtime as system::Trait>::Hash;
 
-type CuratorId = <Runtime as ActorAuthenticator>::CuratorId;
+pub type CuratorId = <Runtime as ActorAuthenticator>::CuratorId;
 pub type CuratorGroupId = <Runtime as ActorAuthenticator>::CuratorGroupId;
-type MemberId = <Runtime as ActorAuthenticator>::MemberId;
+pub type MemberId = <Runtime as ActorAuthenticator>::MemberId;
 
 /// Origins
 
@@ -376,6 +377,8 @@ impl ExtBuilder {
 
 fn default_content_directory_genesis_config() -> GenesisConfig<Runtime> {
     GenesisConfig {
+        class_by_id: vec![],
+        entity_by_id: vec![],
         curator_group_by_id: vec![],
         next_class_id: 1,
         next_entity_id: 1,
@@ -404,7 +407,7 @@ pub fn generate_text(len: usize) -> Vec<u8> {
     vec![b'x'; len]
 }
 
-impl<T: Trait> Property<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> Property<ClassId> {
     pub fn required(mut self) -> Self {
         self.required = true;
         self
@@ -423,10 +426,10 @@ type RawTestEvent = RawEvent<
     CuratorId,
     ClassId,
     EntityId,
-    EntityController<Runtime>,
+    EntityController<MemberId>,
     EntityCreationVoucher<Runtime>,
     bool,
-    Actor<Runtime>,
+    Actor<CuratorGroupId, CuratorId, MemberId>,
     Nonce,
     Option<ReferenceCounterSideEffects<Runtime>>,
     Option<(EntityId, EntityReferenceCounterSideEffect)>,
@@ -581,7 +584,7 @@ pub fn create_simple_class(lead_origin: u64, class_type: ClassType) -> DispatchR
     )
 }
 
-pub fn create_class_with_default_permissions() -> Class<Runtime> {
+pub fn create_class_with_default_permissions() -> Class<EntityId, ClassId, CuratorGroupId> {
     Class::new(
         ClassPermissions::default(),
         generate_text(ClassNameLengthConstraint::get().max() as usize),
@@ -633,7 +636,7 @@ pub fn add_class_schema(
     lead_origin: u64,
     class_id: ClassId,
     existing_properties: BTreeSet<PropertyId>,
-    new_properties: Vec<Property<Runtime>>,
+    new_properties: Vec<Property<ClassId>>,
 ) -> DispatchResult {
     TestModule::add_class_schema(
         Origin::signed(lead_origin),
@@ -656,7 +659,7 @@ pub fn next_class_id() -> ClassId {
     TestModule::next_class_id()
 }
 
-pub fn class_by_id(class_id: ClassId) -> Class<Runtime> {
+pub fn class_by_id(class_id: ClassId) -> Class<EntityId, ClassId, CuratorGroupId> {
     TestModule::class_by_id(class_id)
 }
 
@@ -669,7 +672,7 @@ pub fn class_exists(class_id: ClassId) -> bool {
 pub fn update_entity_creation_voucher(
     lead_origin: u64,
     class_id: ClassId,
-    controller: EntityController<Runtime>,
+    controller: EntityController<MemberId>,
     maximum_entities_count: EntityId,
 ) -> DispatchResult {
     TestModule::update_entity_creation_voucher(
@@ -682,14 +685,14 @@ pub fn update_entity_creation_voucher(
 
 pub fn entity_creation_vouchers(
     class_id: ClassId,
-    entity_controller: &EntityController<Runtime>,
+    entity_controller: &EntityController<MemberId>,
 ) -> EntityCreationVoucher<Runtime> {
     TestModule::entity_creation_vouchers(class_id, entity_controller)
 }
 
 pub fn entity_creation_voucher_exists(
     class_id: ClassId,
-    entity_controller: &EntityController<Runtime>,
+    entity_controller: &EntityController<MemberId>,
 ) -> bool {
     EntityCreationVouchers::<Runtime>::contains_key(class_id, entity_controller)
 }
@@ -700,7 +703,7 @@ pub fn entity_exists(entity_id: EntityId) -> bool {
     EntityById::<Runtime>::contains_key(entity_id)
 }
 
-pub fn entity_by_id(entity_id: EntityId) -> Entity<Runtime> {
+pub fn entity_by_id(entity_id: EntityId) -> Entity<ClassId, MemberId, Hashed, EntityId, Nonce> {
     TestModule::entity_by_id(entity_id)
 }
 
@@ -708,11 +711,19 @@ pub fn next_entity_id() -> EntityId {
     TestModule::next_entity_id()
 }
 
-pub fn create_entity(origin: u64, class_id: ClassId, actor: Actor<Runtime>) -> DispatchResult {
+pub fn create_entity(
+    origin: u64,
+    class_id: ClassId,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
+) -> DispatchResult {
     TestModule::create_entity(Origin::signed(origin), class_id, actor)
 }
 
-pub fn remove_entity(origin: u64, actor: Actor<Runtime>, entity_id: EntityId) -> DispatchResult {
+pub fn remove_entity(
+    origin: u64,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
+    entity_id: EntityId,
+) -> DispatchResult {
     TestModule::remove_entity(Origin::signed(origin), actor, entity_id)
 }
 
@@ -732,7 +743,7 @@ pub fn update_entity_permissions(
 
 pub fn add_schema_support_to_entity(
     origin: u64,
-    actor: Actor<Runtime>,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
     entity_id: EntityId,
     schema_id: SchemaId,
     new_property_values: BTreeMap<PropertyId, InputPropertyValue<Runtime>>,
@@ -748,7 +759,7 @@ pub fn add_schema_support_to_entity(
 
 pub fn update_entity_property_values(
     origin: u64,
-    actor: Actor<Runtime>,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
     entity_id: EntityId,
     new_property_values: BTreeMap<PropertyId, InputPropertyValue<Runtime>>,
 ) -> DispatchResult {
@@ -762,7 +773,7 @@ pub fn update_entity_property_values(
 
 pub fn clear_entity_property_vector(
     origin: u64,
-    actor: Actor<Runtime>,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
     entity_id: EntityId,
     in_class_schema_property_id: PropertyId,
 ) -> DispatchResult {
@@ -776,7 +787,7 @@ pub fn clear_entity_property_vector(
 
 pub fn insert_at_entity_property_vector(
     origin: u64,
-    actor: Actor<Runtime>,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
     entity_id: EntityId,
     in_class_schema_property_id: PropertyId,
     index_in_property_vector: VecMaxLength,
@@ -796,7 +807,7 @@ pub fn insert_at_entity_property_vector(
 
 pub fn remove_at_entity_property_vector(
     origin: u64,
-    actor: Actor<Runtime>,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
     entity_id: EntityId,
     in_class_schema_property_id: PropertyId,
     index_in_property_vector: VecMaxLength,
@@ -815,7 +826,7 @@ pub fn remove_at_entity_property_vector(
 pub fn transfer_entity_ownership(
     origin: u64,
     entity_id: EntityId,
-    new_controller: EntityController<Runtime>,
+    new_controller: EntityController<MemberId>,
     new_property_value_references_with_same_owner_flag_set: BTreeMap<
         PropertyId,
         InputPropertyValue<Runtime>,
@@ -833,7 +844,7 @@ pub fn transfer_entity_ownership(
 
 pub fn transaction(
     origin: u64,
-    actor: Actor<Runtime>,
+    actor: Actor<CuratorGroupId, CuratorId, MemberId>,
     operations: Vec<OperationType<Runtime>>,
 ) -> DispatchResult {
     TestModule::transaction(Origin::signed(origin), actor, operations)
@@ -849,20 +860,20 @@ pub enum InvalidPropertyType {
     VecIsTooLong,
 }
 
-impl<T: Trait> Property<T> {
+impl Property<ClassId> {
     pub fn default_with_name(name_len: usize) -> Self {
         let name = generate_text(name_len);
         let description = generate_text(PropertyDescriptionLengthConstraint::get().min() as usize);
         Self {
             name,
             description,
-            ..Property::<T>::default()
+            ..Property::<ClassId>::default()
         }
     }
 
     pub fn with_name_and_type(
         name_len: usize,
-        property_type: PropertyType<T>,
+        property_type: PropertyType<ClassId>,
         required: bool,
         unique: bool,
     ) -> Self {
@@ -874,12 +885,12 @@ impl<T: Trait> Property<T> {
             property_type,
             required,
             unique,
-            ..Property::<T>::default()
+            ..Property::<ClassId>::default()
         }
     }
 
-    pub fn invalid(invalid_property_type: InvalidPropertyType) -> Property<Runtime> {
-        let mut default_property = Property::<Runtime>::default_with_name(
+    pub fn invalid(invalid_property_type: InvalidPropertyType) -> Property<ClassId> {
+        let mut default_property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().min() as usize,
         );
         match invalid_property_type {
@@ -901,16 +912,16 @@ impl<T: Trait> Property<T> {
             }
             InvalidPropertyType::TextIsTooLong => {
                 default_property.property_type =
-                    PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get() + 1);
+                    PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get() + 1);
             }
             InvalidPropertyType::TextHashIsTooLong => {
                 if let Some(hashed_text_max_len) = HashedTextMaxLengthConstraint::get() {
                     default_property.property_type =
-                        PropertyType::<Runtime>::single_text_hash(Some(hashed_text_max_len + 1));
+                        PropertyType::<ClassId>::single_text_hash(Some(hashed_text_max_len + 1));
                 }
             }
             InvalidPropertyType::VecIsTooLong => {
-                default_property.property_type = PropertyType::<Runtime>::vec_reference(
+                default_property.property_type = PropertyType::<ClassId>::vec_reference(
                     FIRST_CLASS_ID,
                     true,
                     VecMaxLengthConstraint::get() + 1,
@@ -921,43 +932,43 @@ impl<T: Trait> Property<T> {
     }
 }
 
-impl<T: Trait> PropertyType<T> {
+impl PropertyType<ClassId> {
     pub fn vec_reference(
         class_id: ClassId,
         same_controller: bool,
         max_length: VecMaxLength,
-    ) -> PropertyType<Runtime> {
-        let vec_type = Type::<Runtime>::Reference(class_id, same_controller);
-        let vec_reference = VecPropertyType::<Runtime>::new(vec_type, max_length);
-        PropertyType::<Runtime>::Vector(vec_reference)
+    ) -> PropertyType<ClassId> {
+        let vec_type = Type::<ClassId>::Reference(class_id, same_controller);
+        let vec_reference = VecPropertyType::<ClassId>::new(vec_type, max_length);
+        PropertyType::<ClassId>::Vector(vec_reference)
     }
 
     pub fn vec_text(
         text_max_len: TextMaxLength,
         vec_max_length: VecMaxLength,
-    ) -> PropertyType<Runtime> {
-        let vec_type = Type::<Runtime>::Text(text_max_len);
-        let vec_text = VecPropertyType::<Runtime>::new(vec_type, vec_max_length);
-        PropertyType::<Runtime>::Vector(vec_text)
+    ) -> PropertyType<ClassId> {
+        let vec_type = Type::<ClassId>::Text(text_max_len);
+        let vec_text = VecPropertyType::<ClassId>::new(vec_type, vec_max_length);
+        PropertyType::<ClassId>::Vector(vec_text)
     }
 
-    pub fn single_text(text_max_len: TextMaxLength) -> PropertyType<Runtime> {
-        let text_type = Type::<Runtime>::Text(text_max_len);
-        PropertyType::<Runtime>::Single(text_type)
+    pub fn single_text(text_max_len: TextMaxLength) -> PropertyType<ClassId> {
+        let text_type = Type::<ClassId>::Text(text_max_len);
+        PropertyType::<ClassId>::Single(text_type)
     }
 
-    pub fn single_text_hash(text_hash_max_len: HashedTextMaxLength) -> PropertyType<Runtime> {
-        let text_type = Type::<Runtime>::Hash(text_hash_max_len);
-        PropertyType::<Runtime>::Single(text_type)
+    pub fn single_text_hash(text_hash_max_len: HashedTextMaxLength) -> PropertyType<ClassId> {
+        let text_type = Type::<ClassId>::Hash(text_hash_max_len);
+        PropertyType::<ClassId>::Single(text_type)
     }
 
     pub fn vec_text_hash(
         text_hash_max_len: HashedTextMaxLength,
         vec_max_length: VecMaxLength,
-    ) -> PropertyType<Runtime> {
-        let vec_type = Type::<Runtime>::Hash(text_hash_max_len);
-        let vec_text_hash = VecPropertyType::<Runtime>::new(vec_type, vec_max_length);
-        PropertyType::<Runtime>::Vector(vec_text_hash)
+    ) -> PropertyType<ClassId> {
+        let vec_type = Type::<ClassId>::Hash(text_hash_max_len);
+        let vec_text_hash = VecPropertyType::<ClassId>::new(vec_type, vec_max_length);
+        PropertyType::<ClassId>::Vector(vec_text_hash)
     }
 }
 

+ 14 - 11
runtime-modules/content-directory/src/permissions.rs

@@ -107,21 +107,24 @@ pub fn ensure_is_lead<T: Trait>(origin: T::Origin) -> DispatchResult {
 
 /// Enum, representing all possible `Actor`s
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Eq, PartialEq, Clone, Copy)]
-pub enum Actor<T: Trait> {
-    Curator(T::CuratorGroupId, T::CuratorId),
-    Member(T::MemberId),
+#[derive(Encode, Decode, Eq, PartialEq, Clone, Copy, Debug)]
+pub enum Actor<
+    CuratorGroupId: Default + Clone + Copy,
+    CuratorId: Default + Clone + Copy,
+    MemberId: Default + Clone + Copy,
+> {
+    Curator(CuratorGroupId, CuratorId),
+    Member(MemberId),
     Lead,
 }
 
-impl<T: Trait> Default for Actor<T> {
+impl<
+        CuratorGroupId: Default + Clone + Copy,
+        CuratorId: Default + Clone + Copy,
+        MemberId: Default + Clone + Copy,
+    > Default for Actor<CuratorGroupId, CuratorId, MemberId>
+{
     fn default() -> Self {
         Self::Lead
     }
 }
-
-impl<T: Trait> core::fmt::Debug for Actor<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "Actor {:?}", self)
-    }
-}

+ 13 - 64
runtime-modules/content-directory/src/permissions/class.rs

@@ -2,8 +2,8 @@ use super::*;
 
 /// Permissions for an instance of a `Class` in the versioned store.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Eq, PartialEq, Clone)]
-pub struct ClassPermissions<T: Trait> {
+#[derive(Encode, Decode, Eq, PartialEq, Clone, Debug, Default)]
+pub struct ClassPermissions<CuratorGroupId: Ord + Default> {
     /// For this permission, the individual member is allowed to create the entity and become controller.
     any_member: bool,
 
@@ -20,27 +20,10 @@ pub struct ClassPermissions<T: Trait> {
     all_entity_property_values_locked: bool,
 
     /// Current class maintainer curator groups
-    maintainers: BTreeSet<T::CuratorGroupId>,
+    maintainers: BTreeSet<CuratorGroupId>,
 }
 
-impl<T: Trait> core::fmt::Debug for ClassPermissions<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "ClassPermissions {:?}", self)
-    }
-}
-
-impl<T: Trait> Default for ClassPermissions<T> {
-    fn default() -> Self {
-        Self {
-            any_member: false,
-            entity_creation_blocked: false,
-            all_entity_property_values_locked: false,
-            maintainers: BTreeSet::new(),
-        }
-    }
-}
-
-impl<T: Trait> ClassPermissions<T> {
+impl<CuratorGroupId: Ord + Default> ClassPermissions<CuratorGroupId> {
     /// Retieve `all_entity_property_values_locked` status
     pub fn all_entity_property_values_locked(&self) -> bool {
         self.all_entity_property_values_locked
@@ -52,17 +35,17 @@ impl<T: Trait> ClassPermissions<T> {
     }
 
     /// Check if given `curator_group_id` is maintainer of current `Class`
-    pub fn is_maintainer(&self, curator_group_id: &T::CuratorGroupId) -> bool {
+    pub fn is_maintainer(&self, curator_group_id: &CuratorGroupId) -> bool {
         self.maintainers.contains(curator_group_id)
     }
 
     /// Get `Class` maintainers by reference
-    pub fn get_maintainers(&self) -> &BTreeSet<T::CuratorGroupId> {
+    pub fn get_maintainers(&self) -> &BTreeSet<CuratorGroupId> {
         &self.maintainers
     }
 
     /// Get `Class` maintainers by mutable reference
-    pub fn get_maintainers_mut(&mut self) -> &mut BTreeSet<T::CuratorGroupId> {
+    pub fn get_maintainers_mut(&mut self) -> &mut BTreeSet<CuratorGroupId> {
         &mut self.maintainers
     }
 
@@ -85,46 +68,12 @@ impl<T: Trait> ClassPermissions<T> {
     }
 
     /// Update `maintainers` set with provided one
-    pub fn set_maintainers(&mut self, maintainers: BTreeSet<T::CuratorGroupId>) {
+    pub fn set_maintainers(&mut self, maintainers: BTreeSet<CuratorGroupId>) {
         self.maintainers = maintainers
     }
 
-    /// Ensure provided actor can create entities of current `Class`
-    pub fn ensure_can_create_entities(
-        &self,
-        account_id: &T::AccountId,
-        actor: &Actor<T>,
-    ) -> Result<(), Error<T>> {
-        let can_create = match &actor {
-            Actor::Lead => {
-                // Ensure lead authorization performed succesfully
-                ensure_lead_auth_success::<T>(account_id)?;
-                true
-            }
-            Actor::Member(member_id) if self.any_member => {
-                // Ensure member authorization performed succesfully
-                ensure_member_auth_success::<T>(member_id, account_id)?;
-                true
-            }
-            Actor::Curator(curator_group_id, curator_id)
-                if self.maintainers.contains(curator_group_id) =>
-            {
-                // Authorize curator, performing all checks to ensure curator can act
-                CuratorGroup::<T>::perform_curator_in_group_auth(
-                    curator_id,
-                    curator_group_id,
-                    account_id,
-                )?;
-                true
-            }
-            _ => false,
-        };
-        ensure!(can_create, Error::<T>::ActorCanNotCreateEntities);
-        Ok(())
-    }
-
     /// Ensure entities creation is not blocked on `Class` level
-    pub fn ensure_entity_creation_not_blocked(&self) -> Result<(), Error<T>> {
+    pub fn ensure_entity_creation_not_blocked<T: Trait>(&self) -> Result<(), Error<T>> {
         ensure!(
             !self.entity_creation_blocked,
             Error::<T>::EntitiesCreationBlocked
@@ -133,9 +82,9 @@ impl<T: Trait> ClassPermissions<T> {
     }
 
     /// Ensure maintainer, associated with given `curator_group_id` is already added to `maintainers` set
-    pub fn ensure_maintainer_exists(
+    pub fn ensure_maintainer_exists<T: Trait>(
         &self,
-        curator_group_id: &T::CuratorGroupId,
+        curator_group_id: &CuratorGroupId,
     ) -> Result<(), Error<T>> {
         ensure!(
             self.maintainers.contains(curator_group_id),
@@ -145,9 +94,9 @@ impl<T: Trait> ClassPermissions<T> {
     }
 
     /// Ensure maintainer, associated with given `curator_group_id` is not yet added to `maintainers` set
-    pub fn ensure_maintainer_does_not_exist(
+    pub fn ensure_maintainer_does_not_exist<T: Trait>(
         &self,
-        curator_group_id: &T::CuratorGroupId,
+        curator_group_id: &CuratorGroupId,
     ) -> Result<(), Error<T>> {
         ensure!(
             !self.maintainers.contains(curator_group_id),

+ 16 - 0
runtime-modules/content-directory/src/permissions/curator_group.rs

@@ -36,6 +36,10 @@ impl<T: Trait> CuratorGroup<T> {
         self.active
     }
 
+    pub fn get_number_of_classes_maintained(&self) -> u32 {
+        self.number_of_classes_maintained
+    }
+
     /// Set `CuratorGroup` status as provided
     pub fn set_status(&mut self, is_active: bool) {
         self.active = is_active
@@ -91,6 +95,18 @@ impl<T: Trait> CuratorGroup<T> {
         Ok(())
     }
 
+    /// Ensure curator under given `curator_id` does not exist yet in `CuratorGroup`
+    pub fn ensure_curator_in_group_does_not_exist(
+        &self,
+        curator_id: &T::CuratorId,
+    ) -> Result<(), Error<T>> {
+        ensure!(
+            !self.get_curators().contains(curator_id),
+            Error::<T>::CuratorIsAlreadyAMemberOfGivenCuratorGroup
+        );
+        Ok(())
+    }
+
     /// Authorize curator, performing all checks to ensure curator can act
     pub fn perform_curator_in_group_auth(
         curator_id: &T::CuratorId,

+ 27 - 28
runtime-modules/content-directory/src/permissions/entity.rs

@@ -2,16 +2,16 @@ use super::*;
 
 /// Owner of an `Entity`.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
-pub enum EntityController<T: Trait> {
+#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)]
+pub enum EntityController<MemberId: Default + PartialEq + Clone + Copy> {
     Maintainers,
-    Member(T::MemberId),
+    Member(MemberId),
     Lead,
 }
 
-impl<T: Trait> EntityController<T> {
+impl<MemberId: Default + PartialEq + Clone + Copy> EntityController<MemberId> {
     /// Create `EntityController` enum representation, using provided `Actor`
-    pub fn from_actor(actor: &Actor<T>) -> Self {
+    pub fn from_actor<T: Trait>(actor: &Actor<T::CuratorGroupId, T::CuratorId, MemberId>) -> Self {
         match &actor {
             Actor::Lead => Self::Lead,
             Actor::Member(member_id) => Self::Member(*member_id),
@@ -20,24 +20,18 @@ impl<T: Trait> EntityController<T> {
     }
 }
 
-impl<T: Trait> Default for EntityController<T> {
+impl<MemberId: Default + PartialEq + Clone + Copy> Default for EntityController<MemberId> {
     fn default() -> Self {
         Self::Lead
     }
 }
 
-impl<T: Trait> core::fmt::Debug for EntityController<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "EntityController {:?}", self)
-    }
-}
-
 /// Permissions for a given entity.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
 #[derive(Encode, Decode, Clone, PartialEq, Eq)]
-pub struct EntityPermissions<T: Trait> {
+pub struct EntityPermissions<MemberId: Default + PartialEq + Clone + Copy> {
     /// Current controller, which is initially set based on who created entity
-    pub controller: EntityController<T>,
+    pub controller: EntityController<MemberId>,
 
     /// Forbid groups to mutate any property value.
     /// Can be useful to use in concert with some curation censorship policy
@@ -49,19 +43,19 @@ pub struct EntityPermissions<T: Trait> {
     pub referenceable: bool,
 }
 
-impl<T: Trait> Default for EntityPermissions<T> {
+impl<MemberId: Default + PartialEq + Clone + Copy> Default for EntityPermissions<MemberId> {
     fn default() -> Self {
         Self {
-            controller: EntityController::<T>::default(),
+            controller: EntityController::<MemberId>::default(),
             frozen: false,
             referenceable: true,
         }
     }
 }
 
-impl<T: Trait> EntityPermissions<T> {
+impl<MemberId: Default + PartialEq + Clone + Copy> EntityPermissions<MemberId> {
     /// Create an instance of `EntityPermissions` with `EntityController` equal to provided one
-    pub fn default_with_controller(controller: EntityController<T>) -> Self {
+    pub fn default_with_controller(controller: EntityController<MemberId>) -> Self {
         Self {
             controller,
             ..EntityPermissions::default()
@@ -69,12 +63,15 @@ impl<T: Trait> EntityPermissions<T> {
     }
 
     /// Set current `controller` as provided
-    pub fn set_conroller(&mut self, controller: EntityController<T>) {
+    pub fn set_conroller(&mut self, controller: EntityController<MemberId>) {
         self.controller = controller
     }
 
     /// Check if inner `controller` is equal to the provided one
-    pub fn controller_is_equal_to(&self, new_entity_controller: &EntityController<T>) -> bool {
+    pub fn controller_is_equal_to(
+        &self,
+        new_entity_controller: &EntityController<MemberId>,
+    ) -> bool {
         self.controller == *new_entity_controller
     }
 
@@ -94,12 +91,14 @@ impl<T: Trait> EntityPermissions<T> {
     }
 
     /// Get current `controller` by reference
-    pub fn get_controller(&self) -> &EntityController<T> {
+    pub fn get_controller(&self) -> &EntityController<MemberId> {
         &self.controller
     }
 
     /// Ensure actor with given `EntityAccessLevel` can remove entity
-    pub fn ensure_group_can_remove_entity(access_level: EntityAccessLevel) -> Result<(), Error<T>> {
+    pub fn ensure_group_can_remove_entity<T: Trait>(
+        access_level: EntityAccessLevel,
+    ) -> Result<(), Error<T>> {
         match access_level {
             EntityAccessLevel::EntityController => Ok(()),
             EntityAccessLevel::EntityControllerAndMaintainer => Ok(()),
@@ -108,9 +107,9 @@ impl<T: Trait> EntityPermissions<T> {
     }
 
     /// Ensure provided new_entity_controller is not equal to current one
-    pub fn ensure_controllers_are_not_equal(
+    pub fn ensure_controllers_are_not_equal<T: Trait>(
         &self,
-        new_entity_controller: &EntityController<T>,
+        new_entity_controller: &EntityController<MemberId>,
     ) -> Result<(), Error<T>> {
         ensure!(
             !self.controller_is_equal_to(new_entity_controller),
@@ -138,11 +137,11 @@ impl EntityAccessLevel {
     /// Derives the `EntityAccessLevel` for the actor, attempting to act.
     pub fn derive<T: Trait>(
         account_id: &T::AccountId,
-        entity_permissions: &EntityPermissions<T>,
-        class_permissions: &ClassPermissions<T>,
-        actor: &Actor<T>,
+        entity_permissions: &EntityPermissions<T::MemberId>,
+        class_permissions: &ClassPermissions<T::CuratorGroupId>,
+        actor: &Actor<T::CuratorGroupId, T::CuratorId, T::MemberId>,
     ) -> Result<Self, Error<T>> {
-        let controller = EntityController::<T>::from_actor(actor);
+        let controller = EntityController::<T::MemberId>::from_actor::<T>(actor);
         match actor {
             Actor::Lead if entity_permissions.controller_is_equal_to(&controller) => {
                 // Ensure lead authorization performed succesfully

+ 3 - 3
runtime-modules/content-directory/src/schema/convert.rs

@@ -1,7 +1,7 @@
 use super::*;
 use sp_runtime::traits::Hash;
 
-impl<T: Trait> From<InputPropertyValue<T>> for StoredPropertyValue<T> {
+impl<T: Trait> From<InputPropertyValue<T>> for StoredPropertyValueOf<T> {
     fn from(input_property_value: InputPropertyValue<T>) -> Self {
         match input_property_value {
             InputPropertyValue::Single(input_value) => {
@@ -16,7 +16,7 @@ impl<T: Trait> From<InputPropertyValue<T>> for StoredPropertyValue<T> {
     }
 }
 
-impl<T: Trait> From<InputValue<T>> for StoredValue<T> {
+impl<T: Trait> From<InputValue<T>> for StoredValue<T::Hash, T::EntityId> {
     fn from(input_value: InputValue<T>) -> Self {
         match input_value {
             InputValue::Bool(value) => StoredValue::Bool(value),
@@ -37,7 +37,7 @@ impl<T: Trait> From<InputValue<T>> for StoredValue<T> {
     }
 }
 
-impl<T: Trait> From<VecInputValue<T>> for VecStoredValue<T> {
+impl<T: Trait> From<VecInputValue<T>> for VecStoredValue<T::Hash, T::EntityId> {
     fn from(vec_input_value: VecInputValue<T>) -> Self {
         match vec_input_value {
             VecInputValue::Bool(vec_value) => VecStoredValue::Bool(vec_value),

+ 78 - 39
runtime-modules/content-directory/src/schema/output.rs

@@ -4,14 +4,23 @@ use sp_runtime::traits::Hash;
 /// Enum, representing either `StoredValue` or `VecStoredPropertyValue`
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
 #[derive(Encode, Decode, Clone, PartialEq, Eq)]
-pub enum StoredPropertyValue<T: Trait> {
-    Single(StoredValue<T>),
-    Vector(VecStoredPropertyValue<T>),
+pub enum StoredPropertyValue<
+    Hashed: Default + Clone + Codec,
+    EntityId: Default + Clone + Copy + Codec,
+    Nonce: Default + BaseArithmetic + Clone + Copy,
+> {
+    Single(StoredValue<Hashed, EntityId>),
+    Vector(VecStoredPropertyValue<Hashed, EntityId, Nonce>),
 }
 
-impl<T: Trait> StoredPropertyValue<T> {
+impl<
+        Hashed: Default + Clone + Codec,
+        EntityId: Default + Clone + Copy + Codec,
+        Nonce: Default + BaseArithmetic + Clone + Copy,
+    > StoredPropertyValue<Hashed, EntityId, Nonce>
+{
     /// Returns single property value by reference if `StoredPropertyValue` is Single
-    pub fn as_single_value(&self) -> Option<&StoredValue<T>> {
+    pub fn as_single_value(&self) -> Option<&StoredValue<Hashed, EntityId>> {
         if let StoredPropertyValue::Single(single_value) = self {
             Some(single_value)
         } else {
@@ -20,7 +29,9 @@ impl<T: Trait> StoredPropertyValue<T> {
     }
 
     /// Returns vector property value by reference if `StoredPropertyValue` is Single
-    pub fn as_vec_property_value(&self) -> Option<&VecStoredPropertyValue<T>> {
+    pub fn as_vec_property_value(
+        &self,
+    ) -> Option<&VecStoredPropertyValue<Hashed, EntityId, Nonce>> {
         if let StoredPropertyValue::Vector(vec_property_value) = self {
             Some(vec_property_value)
         } else {
@@ -29,7 +40,9 @@ impl<T: Trait> StoredPropertyValue<T> {
     }
 
     /// Returns vector property value by mutable reference if `StoredPropertyValue` is Single
-    pub fn as_vec_property_value_mut(&mut self) -> Option<&mut VecStoredPropertyValue<T>> {
+    pub fn as_vec_property_value_mut(
+        &mut self,
+    ) -> Option<&mut VecStoredPropertyValue<Hashed, EntityId, Nonce>> {
         if let StoredPropertyValue::Vector(vec_property_value) = self {
             Some(vec_property_value)
         } else {
@@ -49,7 +62,7 @@ impl<T: Trait> StoredPropertyValue<T> {
     }
 
     /// Retrieve all involved `entity_id`'s, if current `StoredPropertyValue` is reference
-    pub fn get_involved_entities(&self) -> Option<Vec<T::EntityId>> {
+    pub fn get_involved_entities(&self) -> Option<Vec<EntityId>> {
         match self {
             StoredPropertyValue::Single(single_property_value) => {
                 if let Some(entity_id) = single_property_value.get_involved_entity() {
@@ -65,19 +78,24 @@ impl<T: Trait> StoredPropertyValue<T> {
     }
 
     /// Compute hash from unique property value and its respective property_id
-    pub fn compute_unique_hash(&self, property_id: PropertyId) -> T::Hash {
+    pub fn compute_unique_hash<T: Trait>(&self, property_id: PropertyId) -> T::Hash {
         match self {
             StoredPropertyValue::Single(output_value) => {
                 (property_id, output_value).using_encoded(<T as system::Trait>::Hashing::hash)
             }
             StoredPropertyValue::Vector(vector_output_value) => {
-                vector_output_value.compute_unique_hash(property_id)
+                vector_output_value.compute_unique_hash::<T>(property_id)
             }
         }
     }
 }
 
-impl<T: Trait> Default for StoredPropertyValue<T> {
+impl<
+        Hashed: Default + Clone + Codec,
+        EntityId: Default + Clone + Copy + Codec,
+        Nonce: Default + BaseArithmetic + Clone + Copy,
+    > Default for StoredPropertyValue<Hashed, EntityId, Nonce>
+{
     fn default() -> Self {
         StoredPropertyValue::Single(StoredValue::default())
     }
@@ -85,8 +103,8 @@ impl<T: Trait> Default for StoredPropertyValue<T> {
 
 /// StoredValue enum representation, related to corresponding `SingleStoredPropertyValue` structure
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Hash, Clone, PartialEq, PartialOrd, Ord, Eq)]
-pub enum StoredValue<T: Trait> {
+#[derive(Encode, Decode, Clone, PartialEq, PartialOrd, Ord, Eq)]
+pub enum StoredValue<Hashed: Default + Clone + Codec, EntityId: Default + Clone + Copy + Codec> {
     Bool(bool),
     Uint16(u16),
     Uint32(u32),
@@ -95,19 +113,23 @@ pub enum StoredValue<T: Trait> {
     Int32(i32),
     Int64(i64),
     Text(Vec<u8>),
-    Hash(T::Hash),
-    Reference(T::EntityId),
+    Hash(Hashed),
+    Reference(EntityId),
 }
 
-impl<T: Trait> Default for StoredValue<T> {
-    fn default() -> StoredValue<T> {
+impl<Hashed: Default + Clone + Codec, EntityId: Default + Clone + Copy + Codec> Default
+    for StoredValue<Hashed, EntityId>
+{
+    fn default() -> StoredValue<Hashed, EntityId> {
         Self::Bool(false)
     }
 }
 
-impl<T: Trait> StoredValue<T> {
+impl<Hashed: Default + Clone + Codec, EntityId: Default + Clone + Copy + Codec>
+    StoredValue<Hashed, EntityId>
+{
     /// Retrieve involved `entity_id`, if current `StoredValue` is reference
-    pub fn get_involved_entity(&self) -> Option<T::EntityId> {
+    pub fn get_involved_entity(&self) -> Option<EntityId> {
         if let StoredValue::Reference(entity_id) = self {
             Some(*entity_id)
         } else {
@@ -119,36 +141,45 @@ impl<T: Trait> StoredValue<T> {
 /// Consists of `VecStoredPropertyValue` enum representation and `nonce`, used to avoid vector data race update conditions
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq)]
-pub struct VecStoredPropertyValue<T: Trait> {
-    vec_value: VecStoredValue<T>,
-    nonce: T::Nonce,
+pub struct VecStoredPropertyValue<
+    Hashed: Default + Clone + Codec,
+    EntityId: Default + Clone + Copy + Codec,
+    Nonce: Default + BaseArithmetic + Clone + Copy,
+> {
+    vec_value: VecStoredValue<Hashed, EntityId>,
+    nonce: Nonce,
 }
 
-impl<T: Trait> VecStoredPropertyValue<T> {
+impl<
+        Hashed: Default + Clone + Codec,
+        EntityId: Default + Clone + Copy + Codec,
+        Nonce: Default + BaseArithmetic + Clone + Copy,
+    > VecStoredPropertyValue<Hashed, EntityId, Nonce>
+{
     /// Compute hash from unique vec property value and its respective property_id
-    pub fn compute_unique_hash(&self, property_id: PropertyId) -> T::Hash {
+    pub fn compute_unique_hash<T: Trait>(&self, property_id: PropertyId) -> T::Hash {
         // Do not hash nonce
         (property_id, &self.vec_value).using_encoded(<T as system::Trait>::Hashing::hash)
     }
 
     /// Increase nonce by 1
-    fn increment_nonce(&mut self) -> T::Nonce {
-        self.nonce += T::Nonce::one();
+    fn increment_nonce(&mut self) -> Nonce {
+        self.nonce += Nonce::one();
         self.nonce
     }
 
     /// Create new `VecStoredPropertyValue` from `vec value` provided and `nonce`
-    pub fn new(vec_value: VecStoredValue<T>, nonce: T::Nonce) -> Self {
+    pub fn new(vec_value: VecStoredValue<Hashed, EntityId>, nonce: Nonce) -> Self {
         Self { vec_value, nonce }
     }
 
     /// Retrieve `VecStoredValue`
-    pub fn get_vec_value(self) -> VecStoredValue<T> {
+    pub fn get_vec_value(self) -> VecStoredValue<Hashed, EntityId> {
         self.vec_value
     }
 
     /// Retrieve `VecStoredValue` by reference
-    pub fn get_vec_value_ref(&self) -> &VecStoredValue<T> {
+    pub fn get_vec_value_ref(&self) -> &VecStoredValue<Hashed, EntityId> {
         &self.vec_value
     }
 
@@ -208,7 +239,11 @@ impl<T: Trait> VecStoredPropertyValue<T> {
     }
 
     /// Insert provided `StoredValue` at given `index_in_property_vec`, increment `nonce`
-    pub fn insert_at(&mut self, index_in_property_vec: VecMaxLength, single_value: StoredValue<T>) {
+    pub fn insert_at(
+        &mut self,
+        index_in_property_vec: VecMaxLength,
+        single_value: StoredValue<Hashed, EntityId>,
+    ) {
         fn insert_at<T>(vec: &mut Vec<T>, index_in_property_vec: VecMaxLength, value: T) {
             if (index_in_property_vec as usize) < vec.len() {
                 vec.insert(index_in_property_vec as usize, value);
@@ -253,7 +288,7 @@ impl<T: Trait> VecStoredPropertyValue<T> {
 
     /// Ensure `VecStoredPropertyValue` nonce is equal to the provided one.
     /// Used to to avoid possible data races, when performing vector specific operations
-    pub fn ensure_nonce_equality(&self, new_nonce: T::Nonce) -> Result<(), Error<T>> {
+    pub fn ensure_nonce_equality<T: Trait>(&self, new_nonce: Nonce) -> Result<(), Error<T>> {
         ensure!(
             self.nonce == new_nonce,
             Error::<T>::PropertyValueVecNoncesDoesNotMatch
@@ -262,7 +297,7 @@ impl<T: Trait> VecStoredPropertyValue<T> {
     }
 
     /// Ensure, provided `index_in_property_vec` is valid index of `VecStoredValue`
-    pub fn ensure_index_in_property_vector_is_valid(
+    pub fn ensure_index_in_property_vector_is_valid<T: Trait>(
         &self,
         index_in_property_vec: VecMaxLength,
     ) -> Result<(), Error<T>> {
@@ -277,8 +312,8 @@ impl<T: Trait> VecStoredPropertyValue<T> {
 
 /// Vector value enum representation, related to corresponding `VecStoredPropertyValue` structure
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)]
-pub enum VecStoredValue<T: Trait> {
+#[derive(Encode, Decode, Clone, PartialEq, Eq, PartialOrd, Ord)]
+pub enum VecStoredValue<Hashed: Default + Clone + Codec, EntityId: Default + Clone + Copy + Codec> {
     Bool(Vec<bool>),
     Uint16(Vec<u16>),
     Uint32(Vec<u32>),
@@ -286,20 +321,24 @@ pub enum VecStoredValue<T: Trait> {
     Int16(Vec<i16>),
     Int32(Vec<i32>),
     Int64(Vec<i64>),
-    Hash(Vec<T::Hash>),
+    Hash(Vec<Hashed>),
     Text(Vec<Vec<u8>>),
-    Reference(Vec<T::EntityId>),
+    Reference(Vec<EntityId>),
 }
 
-impl<T: Trait> Default for VecStoredValue<T> {
+impl<Hashed: Default + Clone + Codec, EntityId: Default + Clone + Copy + Codec> Default
+    for VecStoredValue<Hashed, EntityId>
+{
     fn default() -> Self {
         Self::Bool(vec![])
     }
 }
 
-impl<T: Trait> VecStoredValue<T> {
+impl<Hashed: Default + Clone + Codec, EntityId: Default + Clone + Copy + Codec>
+    VecStoredValue<Hashed, EntityId>
+{
     /// Retrieve all involved `entity_id`'s, if current `VecStoredValue` is reference
-    pub fn get_involved_entities(&self) -> Option<Vec<T::EntityId>> {
+    pub fn get_involved_entities(&self) -> Option<Vec<EntityId>> {
         if let Self::Reference(entity_ids) = self {
             Some(entity_ids.to_owned())
         } else {

+ 111 - 123
runtime-modules/content-directory/src/schema/property.rs

@@ -16,8 +16,8 @@ pub type HashedTextMaxLength = Option<u16>;
 type SameController = bool;
 
 /// Locking policy, representing `Property` locking status for both controller and maintainer
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Default, Decode, Clone, Copy, PartialEq, Eq)]
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Default, Decode, Clone, Copy, PartialEq, Eq, Debug)]
 pub struct PropertyLockingPolicy {
     /// If property is locked from maintainer
     pub is_locked_from_maintainer: bool,
@@ -26,9 +26,9 @@ pub struct PropertyLockingPolicy {
 }
 
 /// Enum, used for `PropertyType` representation
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
-pub enum Type<T: Trait> {
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug)]
+pub enum Type<ClassId: Default + BaseArithmetic + Clone + Copy> {
     Bool,
     Uint16,
     Uint32,
@@ -40,18 +40,18 @@ pub enum Type<T: Trait> {
     Text(TextMaxLength),
     Hash(HashedTextMaxLength),
     /// Can reference only specific class id entities
-    Reference(T::ClassId, SameController),
+    Reference(ClassId, SameController),
 }
 
-impl<T: Trait> Default for Type<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> Default for Type<ClassId> {
     fn default() -> Self {
         Self::Bool
     }
 }
 
-impl<T: Trait> Type<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> Type<ClassId> {
     /// Ensure `Type` specific `TextMaxLengthConstraint` or `HashedTextMaxLengthConstraint` satisfied
-    pub fn ensure_property_type_size_is_valid(&self) -> Result<(), Error<T>> {
+    pub fn ensure_property_type_size_is_valid<T: Trait>(&self) -> Result<(), Error<T>> {
         if let Type::Text(text_max_len) = self {
             ensure!(
                 *text_max_len <= T::TextMaxLengthConstraint::get(),
@@ -71,26 +71,17 @@ impl<T: Trait> Type<T> {
 }
 
 /// Vector property type representation
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
-pub struct VecPropertyType<T: Trait> {
-    vec_type: Type<T>,
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Clone, Default, Copy, PartialEq, Eq, Debug)]
+pub struct VecPropertyType<ClassId: Default + BaseArithmetic + Clone + Copy> {
+    vec_type: Type<ClassId>,
     /// Max length of vector, corresponding to a given type
     max_length: VecMaxLength,
 }
 
-impl<T: Trait> Default for VecPropertyType<T> {
-    fn default() -> Self {
-        Self {
-            vec_type: Type::default(),
-            max_length: 0,
-        }
-    }
-}
-
-impl<T: Trait> VecPropertyType<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> VecPropertyType<ClassId> {
     /// Create new `VecPropertyType` from provided `type` and `max_length`
-    pub fn new(vec_type: Type<T>, max_length: VecMaxLength) -> Self {
+    pub fn new(vec_type: Type<ClassId>, max_length: VecMaxLength) -> Self {
         Self {
             vec_type,
             max_length,
@@ -98,7 +89,7 @@ impl<T: Trait> VecPropertyType<T> {
     }
 
     /// Ensure `Type` specific `TextMaxLengthConstraint` & `VecMaxLengthConstraint` satisfied
-    fn ensure_property_type_size_is_valid(&self) -> Result<(), Error<T>> {
+    fn ensure_property_type_size_is_valid<T: Trait>(&self) -> Result<(), Error<T>> {
         // Ensure Type specific TextMaxLengthConstraint or HashedTextMaxLengthConstraint satisfied
         self.vec_type.ensure_property_type_size_is_valid()?;
 
@@ -109,7 +100,7 @@ impl<T: Trait> VecPropertyType<T> {
         Ok(())
     }
 
-    fn get_vec_type(&self) -> &Type<T> {
+    fn get_vec_type(&self) -> &Type<ClassId> {
         &self.vec_type
     }
 
@@ -119,21 +110,21 @@ impl<T: Trait> VecPropertyType<T> {
 }
 
 /// Enum, representing either `Type` or `VecPropertyType`
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
-pub enum PropertyType<T: Trait> {
-    Single(Type<T>),
-    Vector(VecPropertyType<T>),
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, Debug)]
+pub enum PropertyType<ClassId: Default + BaseArithmetic + Clone + Copy> {
+    Single(Type<ClassId>),
+    Vector(VecPropertyType<ClassId>),
 }
 
-impl<T: Trait> Default for PropertyType<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> Default for PropertyType<ClassId> {
     fn default() -> Self {
         Self::Single(Type::default())
     }
 }
 
-impl<T: Trait> PropertyType<T> {
-    fn as_single_value_type(&self) -> Option<&Type<T>> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> PropertyType<ClassId> {
+    fn as_single_value_type(&self) -> Option<&Type<ClassId>> {
         if let PropertyType::Single(single_value_property_type) = self {
             Some(single_value_property_type)
         } else {
@@ -141,7 +132,7 @@ impl<T: Trait> PropertyType<T> {
         }
     }
 
-    pub fn as_vec_type(&self) -> Option<&VecPropertyType<T>> {
+    pub fn as_vec_type(&self) -> Option<&VecPropertyType<ClassId>> {
         if let PropertyType::Vector(vec_value_property_type) = self {
             Some(vec_value_property_type)
         } else {
@@ -149,7 +140,8 @@ impl<T: Trait> PropertyType<T> {
         }
     }
 
-    fn get_inner_type(&self) -> &Type<T> {
+    /// Get inner type of `PropertyType` enum wrapper
+    pub fn get_inner_type(&self) -> &Type<ClassId> {
         match self {
             PropertyType::Single(single_property_type) => single_property_type,
             PropertyType::Vector(vec_property_type) => vec_property_type.get_vec_type(),
@@ -169,10 +161,10 @@ impl<T: Trait> PropertyType<T> {
 
 /// `Property` representation, related to a given `Class`
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
-#[derive(Encode, Decode, Clone, PartialEq, Eq)]
-pub struct Property<T: Trait> {
+#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq)]
+pub struct Property<ClassId: Default + BaseArithmetic + Clone + Copy> {
     /// The type of `Property`
-    pub property_type: PropertyType<T>,
+    pub property_type: PropertyType<ClassId>,
     /// If property value can be skipped, when adding entity schema support
     pub required: bool,
     /// Used to enforce uniquness of a property across all entities that have this property
@@ -185,10 +177,10 @@ pub struct Property<T: Trait> {
     pub locking_policy: PropertyLockingPolicy,
 }
 
-impl<T: Trait> Default for Property<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> Default for Property<ClassId> {
     fn default() -> Self {
         Self {
-            property_type: PropertyType::<T>::default(),
+            property_type: PropertyType::<ClassId>::default(),
             required: false,
             unique: false,
             name: vec![],
@@ -198,13 +190,7 @@ impl<T: Trait> Default for Property<T> {
     }
 }
 
-impl<T: Trait> core::fmt::Debug for Property<T> {
-    fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-        write!(formatter, "Property {:?}", self)
-    }
-}
-
-impl<T: Trait> Property<T> {
+impl<ClassId: Default + BaseArithmetic + Clone + Copy> Property<ClassId> {
     /// Check if property is locked from actor with provided `EntityAccessLevel`
     pub fn is_locked_from(&self, access_level: EntityAccessLevel) -> bool {
         let is_locked_from_controller = self.locking_policy.is_locked_from_controller;
@@ -219,7 +205,10 @@ impl<T: Trait> Property<T> {
     }
 
     /// Ensure `Property` is unlocked from `Actor` with given `EntityAccessLevel`
-    pub fn ensure_unlocked_from(&self, access_level: EntityAccessLevel) -> Result<(), Error<T>> {
+    pub fn ensure_unlocked_from<T: Trait>(
+        &self,
+        access_level: EntityAccessLevel,
+    ) -> Result<(), Error<T>> {
         ensure!(
             !self.is_locked_from(access_level),
             Error::<T>::ClassPropertyTypeLockedForGivenActor
@@ -229,27 +218,31 @@ impl<T: Trait> Property<T> {
 
     /// Validate new `InputPropertyValue` against the type of this `Property`
     /// and check any additional constraints
-    pub fn ensure_property_value_to_update_is_valid(
-        &self,
+    pub fn ensure_property_value_to_update_is_valid<T: Trait>(
+        property: &Property<T::ClassId>,
         value: &InputPropertyValue<T>,
-        current_entity_controller: &EntityController<T>,
+        current_entity_controller: &EntityController<T::MemberId>,
     ) -> Result<(), Error<T>> {
         // Ensure provided InputPropertyValue matches its Type
-        self.ensure_property_value_matches_its_type(value)?;
+        property.ensure_property_value_matches_its_type(value)?;
 
         // Perform all required checks to ensure provided InputPropertyValue is valid, when current PropertyType is Reference
-        self.ensure_property_value_is_valid_reference(value, current_entity_controller)?;
+        Self::ensure_property_value_is_valid_reference(
+            &property,
+            value,
+            current_entity_controller,
+        )?;
 
         // Ensure text property does not exceed its max length
-        self.validate_max_len_if_text_property(value)?;
+        property.validate_max_len_if_text_property(value)?;
 
         // Ensure vector property does not exceed its max length
-        self.validate_max_len_if_vec_property(value)?;
+        property.validate_max_len_if_vec_property(value)?;
         Ok(())
     }
 
     /// Ensure property vector length after value inserted is valid
-    fn validate_property_vector_length_after_value_insert<V>(
+    fn validate_property_vector_length_after_value_insert<T: Trait, V>(
         vec: &[V],
         max_len: VecMaxLength,
     ) -> Result<(), Error<T>> {
@@ -262,17 +255,17 @@ impl<T: Trait> Property<T> {
 
     /// Ensure `SingleInputPropertyValue` type is equal to the `VecInputPropertyValue` type
     /// and check all constraints
-    pub fn ensure_property_value_can_be_inserted_at_property_vector(
-        &self,
+    pub fn ensure_property_value_can_be_inserted_at_property_vector<T: Trait>(
+        property: &Property<T::ClassId>,
         single_value: &InputValue<T>,
-        vec_value: &VecStoredPropertyValue<T>,
+        vec_value: &VecStoredPropertyValue<T::Hash, T::EntityId, T::Nonce>,
         index_in_property_vec: VecMaxLength,
-        current_entity_controller: &EntityController<T>,
+        current_entity_controller: &EntityController<T::MemberId>,
     ) -> Result<(), Error<T>> {
         // Ensure, provided index_in_property_vec is valid index of VecInputValue
         vec_value.ensure_index_in_property_vector_is_valid(index_in_property_vec)?;
 
-        let property_type_vec = self
+        let property_type_vec = property
             .property_type
             .as_vec_type()
             .ok_or(Error::<T>::PropertyValueTypeDoesNotMatchInternalVectorType)?;
@@ -286,29 +279,35 @@ impl<T: Trait> Property<T> {
         ) {
             // Single values
             (InputValue::Bool(_), VecStoredValue::Bool(vec), Type::Bool) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, bool>(
+                    vec,
+                    max_vec_len,
+                )
             }
             (InputValue::Uint16(_), VecStoredValue::Uint16(vec), Type::Uint16) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, u16>(vec, max_vec_len)
             }
             (InputValue::Uint32(_), VecStoredValue::Uint32(vec), Type::Uint32) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, u32>(vec, max_vec_len)
             }
             (InputValue::Uint64(_), VecStoredValue::Uint64(vec), Type::Uint64) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, u64>(vec, max_vec_len)
             }
             (InputValue::Int16(_), VecStoredValue::Int16(vec), Type::Int16) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, i16>(vec, max_vec_len)
             }
             (InputValue::Int32(_), VecStoredValue::Int32(vec), Type::Int32) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, i32>(vec, max_vec_len)
             }
             (InputValue::Int64(_), VecStoredValue::Int64(vec), Type::Int64) => {
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, i64>(vec, max_vec_len)
             }
             (InputValue::Text(text_item), VecStoredValue::Text(vec), Type::Text(text_max_len)) => {
                 Self::validate_max_len_of_text(text_item, *text_max_len)?;
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, Vec<u8>>(
+                    vec,
+                    max_vec_len,
+                )
             }
             (
                 InputValue::TextToHash(text_item),
@@ -318,7 +317,10 @@ impl<T: Trait> Property<T> {
                 if let Some(text_max_len) = text_max_len {
                     Self::validate_max_len_of_text_to_be_hashed(text_item, *text_max_len)?;
                 }
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, T::Hash>(
+                    vec,
+                    max_vec_len,
+                )
             }
             (
                 InputValue::Reference(entity_id),
@@ -328,21 +330,25 @@ impl<T: Trait> Property<T> {
                 // Ensure class_id of Entity under provided entity_id references Entity,
                 // which class_id is equal to class_id, declared in corresponding PropertyType
                 // Retrieve corresponding Entity
-                let entity = Self::ensure_referenced_entity_match_its_class(*entity_id, *class_id)?;
+                let entity =
+                    Self::ensure_referenced_entity_match_its_class::<T>(*entity_id, *class_id)?;
                 // Ensure Entity can be referenced.
                 Self::ensure_entity_can_be_referenced(
                     entity,
                     *same_controller_status,
                     current_entity_controller,
                 )?;
-                Self::validate_property_vector_length_after_value_insert(vec, max_vec_len)
+                Self::validate_property_vector_length_after_value_insert::<T, T::EntityId>(
+                    vec,
+                    max_vec_len,
+                )
             }
             _ => Err(Error::<T>::PropertyValueTypeDoesNotMatchInternalVectorType),
         }
     }
 
     /// Ensure text property does not exceed its max len
-    pub fn validate_max_len_if_text_property(
+    pub fn validate_max_len_if_text_property<T: Trait>(
         &self,
         value: &InputPropertyValue<T>,
     ) -> Result<(), Error<T>> {
@@ -363,7 +369,10 @@ impl<T: Trait> Property<T> {
         }
     }
 
-    fn validate_max_len_of_text(text: &[u8], text_max_len: TextMaxLength) -> Result<(), Error<T>> {
+    fn validate_max_len_of_text<T: Trait>(
+        text: &[u8],
+        text_max_len: TextMaxLength,
+    ) -> Result<(), Error<T>> {
         ensure!(
             text.len() <= text_max_len as usize,
             Error::<T>::TextPropertyTooLong
@@ -371,7 +380,7 @@ impl<T: Trait> Property<T> {
         Ok(())
     }
 
-    fn validate_max_len_of_text_to_be_hashed(
+    fn validate_max_len_of_text_to_be_hashed<T: Trait>(
         text_to_be_hashed: &[u8],
         text_to_be_hashed_max_len: u16,
     ) -> Result<(), Error<T>> {
@@ -382,7 +391,7 @@ impl<T: Trait> Property<T> {
         Ok(())
     }
 
-    fn validate_vec_len<V>(vec: &[V], max_len: VecMaxLength) -> Result<(), Error<T>> {
+    fn validate_vec_len<V, T: Trait>(vec: &[V], max_len: VecMaxLength) -> Result<(), Error<T>> {
         ensure!(
             vec.len() <= max_len as usize,
             Error::<T>::VecPropertyTooLong
@@ -391,7 +400,7 @@ impl<T: Trait> Property<T> {
     }
 
     /// Ensure `VecInputValue` does not exceed its max len
-    pub fn validate_max_len_if_vec_property(
+    pub fn validate_max_len_if_vec_property<T: Trait>(
         &self,
         value: &InputPropertyValue<T>,
     ) -> Result<(), Error<T>> {
@@ -441,7 +450,7 @@ impl<T: Trait> Property<T> {
     }
 
     /// Ensure provided `InputPropertyValue` matches its `Type`
-    pub fn ensure_property_value_matches_its_type(
+    pub fn ensure_property_value_matches_its_type<T: Trait>(
         &self,
         value: &InputPropertyValue<T>,
     ) -> Result<(), Error<T>> {
@@ -453,7 +462,7 @@ impl<T: Trait> Property<T> {
     }
 
     /// Check if provided `InputPropertyValue` matches its `Type`
-    pub fn does_prop_value_match_type(&self, value: &InputPropertyValue<T>) -> bool {
+    pub fn does_prop_value_match_type<T: Trait>(&self, value: &InputPropertyValue<T>) -> bool {
         // A non required property can be updated to Bool(false):
         if !self.required && *value == InputPropertyValue::default() {
             return true;
@@ -462,7 +471,7 @@ impl<T: Trait> Property<T> {
             (
                 InputPropertyValue::Single(single_property_value),
                 PropertyType::Single(ref single_property_type),
-            ) => match (single_property_value, single_property_type.deref()) {
+            ) => matches!((single_property_value, single_property_type.deref()),
                 (InputValue::Bool(_), Type::Bool)
                 | (InputValue::Uint16(_), Type::Uint16)
                 | (InputValue::Uint32(_), Type::Uint32)
@@ -472,13 +481,11 @@ impl<T: Trait> Property<T> {
                 | (InputValue::Int64(_), Type::Int64)
                 | (InputValue::Text(_), Type::Text(_))
                 | (InputValue::TextToHash(_), Type::Hash(_))
-                | (InputValue::Reference(_), Type::Reference(_, _)) => true,
-                _ => false,
-            },
+                | (InputValue::Reference(_), Type::Reference(_, _))),
             (
                 InputPropertyValue::Vector(vec_value),
                 PropertyType::Vector(ref vec_property_type),
-            ) => match (vec_value, vec_property_type.get_vec_type()) {
+            ) => matches!((vec_value, vec_property_type.get_vec_type()),
                 (VecInputValue::Bool(_), Type::Bool)
                 | (VecInputValue::Uint16(_), Type::Uint16)
                 | (VecInputValue::Uint32(_), Type::Uint32)
@@ -488,21 +495,19 @@ impl<T: Trait> Property<T> {
                 | (VecInputValue::Int64(_), Type::Int64)
                 | (VecInputValue::Text(_), Type::Text(_))
                 | (VecInputValue::TextToHash(_), Type::Hash(_))
-                | (VecInputValue::Reference(_), Type::Reference(_, _)) => true,
-                _ => false,
-            },
+                | (VecInputValue::Reference(_), Type::Reference(_, _))),
             _ => false,
         }
     }
 
     /// Perform all required checks to ensure provided `InputPropertyValue` is valid,
     /// when current `PropertyType` is `Reference`
-    pub fn ensure_property_value_is_valid_reference(
-        &self,
+    pub fn ensure_property_value_is_valid_reference<T: Trait>(
+        property: &Property<T::ClassId>,
         value: &InputPropertyValue<T>,
-        current_entity_controller: &EntityController<T>,
+        current_entity_controller: &EntityController<T::MemberId>,
     ) -> Result<(), Error<T>> {
-        match (value, &self.property_type) {
+        match (value, &property.property_type) {
             (
                 InputPropertyValue::Single(single_property_value),
                 PropertyType::Single(single_property_type),
@@ -516,7 +521,7 @@ impl<T: Trait> Property<T> {
                     // which class_id is equal to class_id, declared in corresponding PropertyType
                     // Retrieve corresponding Entity
                     let entity =
-                        Self::ensure_referenced_entity_match_its_class(*entity_id, *class_id)?;
+                        Self::ensure_referenced_entity_match_its_class::<T>(*entity_id, *class_id)?;
 
                     // Ensure Entity can be referenced.
                     Self::ensure_entity_can_be_referenced(
@@ -536,8 +541,9 @@ impl<T: Trait> Property<T> {
                         // Ensure class_id of Entity under provided entity_id references Entity,
                         // which class_id is equal to class_id, declared in corresponding PropertyType
                         // Retrieve corresponding Entity
-                        let entity =
-                            Self::ensure_referenced_entity_match_its_class(*entity_id, *class_id)?;
+                        let entity = Self::ensure_referenced_entity_match_its_class::<T>(
+                            *entity_id, *class_id,
+                        )?;
 
                         // Ensure Entity can be referenced.
                         Self::ensure_entity_can_be_referenced(
@@ -556,26 +562,25 @@ impl<T: Trait> Property<T> {
     /// Ensure `class_id` of `Entity` under provided `entity_id` references `Entity`, which `class_id` is equal to `class_id`,
     /// declared in corresponding `PropertyType`.
     /// Returns  corresponding `Entity` instance
-    pub fn ensure_referenced_entity_match_its_class(
+    pub fn ensure_referenced_entity_match_its_class<T: Trait>(
         entity_id: T::EntityId,
         class_id: T::ClassId,
-    ) -> Result<Entity<T>, Error<T>> {
+    ) -> Result<EntityOf<T>, Error<T>> {
         // Ensure Entity under given id exists
-        Module::<T>::ensure_known_entity_id(entity_id)?;
+        let entity = Module::<T>::ensure_known_entity_id(entity_id)?;
 
-        let entity = Module::<T>::entity_by_id(entity_id);
         ensure!(
-            entity.get_class_id() == class_id,
+            class_id == entity.get_class_id(),
             Error::<T>::ReferencedEntityDoesNotMatchItsClass
         );
         Ok(entity)
     }
 
     /// Ensure `Entity` can be referenced.
-    pub fn ensure_entity_can_be_referenced(
-        entity: Entity<T>,
+    pub fn ensure_entity_can_be_referenced<T: Trait>(
+        entity: EntityOf<T>,
         same_controller_status: bool,
-        current_entity_controller: &EntityController<T>,
+        current_entity_controller: &EntityController<T::MemberId>,
     ) -> Result<(), Error<T>> {
         let entity_permissions = entity.get_permissions();
 
@@ -596,7 +601,7 @@ impl<T: Trait> Property<T> {
     }
 
     /// Ensure `PropertyNameLengthConstraint` satisfied
-    pub fn ensure_name_is_valid(&self) -> Result<(), Error<T>> {
+    pub fn ensure_name_is_valid<T: Trait>(&self) -> Result<(), Error<T>> {
         T::PropertyNameLengthConstraint::get().ensure_valid(
             self.name.len(),
             Error::<T>::PropertyNameTooShort,
@@ -605,7 +610,7 @@ impl<T: Trait> Property<T> {
     }
 
     /// Ensure `PropertyDescriptionLengthConstraint` satisfied
-    pub fn ensure_description_is_valid(&self) -> Result<(), Error<T>> {
+    pub fn ensure_description_is_valid<T: Trait>(&self) -> Result<(), Error<T>> {
         T::PropertyDescriptionLengthConstraint::get().ensure_valid(
             self.description.len(),
             Error::<T>::PropertyDescriptionTooShort,
@@ -614,7 +619,7 @@ impl<T: Trait> Property<T> {
     }
 
     /// Ensure `Type` specific constraints satisfied
-    pub fn ensure_property_type_size_is_valid(&self) -> Result<(), Error<T>> {
+    pub fn ensure_property_type_size_is_valid<T: Trait>(&self) -> Result<(), Error<T>> {
         match &self.property_type {
             PropertyType::Single(single_property_type) => {
                 // Ensure Type specific TextMaxLengthConstraint satisfied
@@ -626,21 +631,4 @@ impl<T: Trait> Property<T> {
             }
         }
     }
-
-    /// Ensure refers to existing `class_id`, if If `Property` `Type` is `Reference`,
-    pub fn ensure_property_type_reference_is_valid(&self) -> Result<(), Error<T>> {
-        let has_unknown_reference =
-            if let Type::Reference(other_class_id, _) = self.property_type.get_inner_type() {
-                !<ClassById<T>>::contains_key(other_class_id)
-            } else {
-                false
-            };
-
-        ensure!(
-            !has_unknown_reference,
-            Error::<T>::ClassSchemaRefersUnknownClass
-        );
-
-        Ok(())
-    }
 }

+ 11 - 8
runtime-modules/content-directory/src/tests.rs

@@ -25,7 +25,10 @@ use super::*;
 use crate::mock::*;
 use core::iter::FromIterator;
 
-pub fn add_entity_schemas_support() -> (Entity<Runtime>, Entity<Runtime>) {
+pub fn add_entity_schemas_support() -> (
+    Entity<ClassId, MemberId, Hashed, EntityId, Nonce>,
+    Entity<ClassId, MemberId, Hashed, EntityId, Nonce>,
+) {
     // Create first class with default permissions
     assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
@@ -46,12 +49,12 @@ pub fn add_entity_schemas_support() -> (Entity<Runtime>, Entity<Runtime>) {
 
     // Create first property
     let first_property =
-        Property::<Runtime>::default_with_name(PropertyNameLengthConstraint::get().max() as usize);
+        Property::<ClassId>::default_with_name(PropertyNameLengthConstraint::get().max() as usize);
 
     // Create second property
-    let second_property_type = PropertyType::<Runtime>::vec_reference(SECOND_CLASS_ID, true, 5);
+    let second_property_type = PropertyType::<ClassId>::vec_reference(SECOND_CLASS_ID, true, 5);
 
-    let second_property = Property::<Runtime>::with_name_and_type(
+    let second_property = Property::<ClassId>::with_name_and_type(
         (PropertyNameLengthConstraint::get().max() - 1) as usize,
         second_property_type,
         true,
@@ -162,7 +165,7 @@ pub enum EntityAccessStateFailureType {
 
 pub fn emulate_entity_access_state_for_failure_case(
     entity_access_level_failure_type: EntityAccessStateFailureType,
-) -> Actor<Runtime> {
+) -> Actor<CuratorGroupId, CuratorId, MemberId> {
     // Create class with default permissions
     assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
@@ -305,9 +308,9 @@ pub fn emulate_entity_access_state_for_failure_case(
 pub fn add_unique_class_reference_schema() {
     // Create property
     let property_type =
-        PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, VecMaxLengthConstraint::get());
+        PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, VecMaxLengthConstraint::get());
 
-    let property = Property::<Runtime>::with_name_and_type(
+    let property = Property::<ClassId>::with_name_and_type(
         (PropertyNameLengthConstraint::get().max() - 1) as usize,
         property_type,
         true,
@@ -325,7 +328,7 @@ pub fn add_unique_class_reference_schema() {
 
 ///  Create class reference schema and add corresponding schema support to the Entity
 pub fn add_unique_class_reference_schema_and_entity_schema_support(
-    actor: &Actor<Runtime>,
+    actor: &Actor<CuratorGroupId, CuratorId, MemberId>,
     origin: u64,
 ) {
     add_unique_class_reference_schema();

+ 9 - 9
runtime-modules/content-directory/src/tests/add_class_schema.rs

@@ -303,7 +303,7 @@ fn add_class_schema_property_name_too_long() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::NameTooLong);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::NameTooLong);
 
         // Make an attempt to add class schema, providing property with name, which length exceeds PropertyNameLengthConstraint
         let add_class_schema_result =
@@ -329,7 +329,7 @@ fn add_class_schema_property_name_too_short() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::NameTooShort);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::NameTooShort);
 
         // Make an attempt to add class schema, providing property with name, which length is less than min value of PropertyNameLengthConstraint
         let add_class_schema_result =
@@ -355,7 +355,7 @@ fn add_class_schema_property_description_too_long() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::DescriptionTooLong);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::DescriptionTooLong);
 
         // Make an attempt to add class schema, providing property with description, which length exceeds PropertyDescriptionLengthConstraint
         let add_class_schema_result =
@@ -381,7 +381,7 @@ fn add_class_schema_property_description_too_short() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::DescriptionTooShort);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::DescriptionTooShort);
 
         // Make an attempt to add class schema, providing property with description, which length is less than min value of PropertyDescriptionLengthConstraint
         let add_class_schema_result =
@@ -407,7 +407,7 @@ fn add_class_schema_text_property_is_too_long() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::TextIsTooLong);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::TextIsTooLong);
 
         // Make an attempt to add class schema, providing property with Text type, which TextMaxLength exceeds corresponding TextMaxLengthConstraint
         let add_class_schema_result =
@@ -433,7 +433,7 @@ fn add_class_schema_text_hash_property_is_too_long() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::TextHashIsTooLong);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::TextHashIsTooLong);
 
         // Make an attempt to add class schema, providing property with Hash type,
         // which HashedTextMaxLength exceeds corresponding HashedTextMaxLengthConstraint
@@ -460,7 +460,7 @@ fn add_class_schema_property_vec_property_is_too_long() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let property = Property::<Runtime>::invalid(InvalidPropertyType::VecIsTooLong);
+        let property = Property::<ClassId>::invalid(InvalidPropertyType::VecIsTooLong);
 
         // Make an attempt to add class schema, providing Vector property, which VecMaxLength exceeds corresponding VecMaxLengthConstraint
         let add_class_schema_result =
@@ -486,12 +486,12 @@ fn add_class_schema_property_refers_unknown_class() {
         // Events number before tested calls
         let number_of_events_before_call = System::events().len();
 
-        let reference_vec_type = PropertyType::<Runtime>::vec_reference(
+        let reference_vec_type = PropertyType::<ClassId>::vec_reference(
             UNKNOWN_CLASS_ID,
             true,
             VecMaxLengthConstraint::get(),
         );
-        let property = Property::<Runtime>::with_name_and_type(1, reference_vec_type, true, true);
+        let property = Property::<ClassId>::with_name_and_type(1, reference_vec_type, true, true);
 
         // Make an attempt to add class schema, providing property with Type::Reference, which refers to unknown ClassId
         let add_class_schema_result =

+ 38 - 38
runtime-modules/content-directory/src/tests/add_schema_support_to_entity.rs

@@ -22,7 +22,7 @@ fn add_schema_support_to_non_existent_entity() {
         );
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -68,7 +68,7 @@ fn add_schema_support_lead_auth_failed() {
         );
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -114,7 +114,7 @@ fn add_schema_support_member_auth_failed() {
         );
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -167,7 +167,7 @@ fn add_schema_support_curator_group_is_not_active() {
         ));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -213,7 +213,7 @@ fn add_schema_support_curator_auth_failed() {
         );
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -260,7 +260,7 @@ fn add_schema_support_curator_not_found_in_curator_group() {
         );
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -307,7 +307,7 @@ fn add_schema_support_access_denied() {
         );
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -391,7 +391,7 @@ fn add_schema_support_to_entity_class_property_not_found() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -442,7 +442,7 @@ fn add_schema_support_already_added_to_the_entity() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -501,7 +501,7 @@ fn add_schema_support_already_contains_given_property_id() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create first property
-        let first_property = Property::<Runtime>::default_with_name(
+        let first_property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -515,8 +515,8 @@ fn add_schema_support_already_contains_given_property_id() {
 
         // Create second property
         let second_property_type =
-            PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
-        let second_property = Property::<Runtime>::with_name_and_type(
+            PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
+        let second_property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize - 1,
             second_property_type,
             true,
@@ -583,7 +583,7 @@ fn add_schema_support_is_not_active() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -642,7 +642,7 @@ fn add_schema_support_does_not_contain_provided_property_id() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create first property
-        let first_property = Property::<Runtime>::default_with_name(
+        let first_property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -655,7 +655,7 @@ fn add_schema_support_does_not_contain_provided_property_id() {
         ));
 
         // Create second property
-        let second_property = Property::<Runtime>::default_with_name(
+        let second_property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize - 1,
         );
 
@@ -706,14 +706,14 @@ fn add_schema_support_missing_required_property() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create first property
-        let first_property = Property::<Runtime>::default_with_name(
+        let first_property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
         // Create second property
         let second_property_type =
-            PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
-        let second_property = Property::<Runtime>::with_name_and_type(
+            PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
+        let second_property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize - 1,
             second_property_type,
             true,
@@ -766,8 +766,8 @@ fn add_schema_support_dont_match_type() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
-        let property = Property::<Runtime>::with_name_and_type(
+        let property_type = PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize - 1,
             property_type,
             true,
@@ -836,9 +836,9 @@ fn add_schema_support_referenced_entity_does_not_match_class() {
         ));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -898,9 +898,9 @@ fn add_schema_support_referenced_entity_does_not_exist() {
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.to_owned()));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(SECOND_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(SECOND_CLASS_ID, true, 5);
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -970,9 +970,9 @@ fn add_schema_support_entity_can_not_be_referenced() {
         ));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -1046,9 +1046,9 @@ fn add_schema_support_same_controller_constraint_violation() {
         ));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -1105,9 +1105,9 @@ fn add_schema_support_text_property_is_too_long() {
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.to_owned()));
 
         // Create text property
-        let property_type = PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
+        let property_type = PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,
@@ -1168,9 +1168,9 @@ fn add_schema_support_text_hash_property_is_too_long() {
 
         // Create hash property
         let property_type =
-            PropertyType::<Runtime>::single_text_hash(hashed_text_max_length_constraint);
+            PropertyType::<ClassId>::single_text_hash(hashed_text_max_length_constraint);
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,
@@ -1239,13 +1239,13 @@ fn add_schema_support_vec_property_is_too_long() {
         ));
 
         // Create vec property
-        let property_type = PropertyType::<Runtime>::vec_reference(
+        let property_type = PropertyType::<ClassId>::vec_reference(
             SECOND_CLASS_ID,
             true,
             VecMaxLengthConstraint::get(),
         );
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -1306,11 +1306,11 @@ fn add_schema_support_property_should_be_unique() {
         // Create second entity
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.to_owned()));
 
-        let property_type = PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
+        let property_type = PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
 
         // Create text property
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,
@@ -1382,11 +1382,11 @@ fn add_schema_support_properties_should_be_unique() {
         // Create third entity
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.to_owned()));
 
-        let property_type = PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
+        let property_type = PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
 
         // Create text property
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,

+ 3 - 3
runtime-modules/content-directory/src/tests/clear_entity_property_vector.rs

@@ -359,9 +359,9 @@ fn clear_entity_property_vector_is_locked_for_given_actor() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let mut property = Property::<Runtime>::with_name_and_type(
+        let mut property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -457,7 +457,7 @@ fn clear_entity_property_vector_value_under_given_index_is_not_a_vector() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 

+ 2 - 2
runtime-modules/content-directory/src/tests/create_entity.rs

@@ -47,7 +47,7 @@ fn create_entity_success() {
             EntityCreationVoucher::new(class.get_default_entity_creation_voucher_upper_bound());
         entity_voucher.increment_created_entities_count();
 
-        let entity_controller = EntityController::from_actor(&actor);
+        let entity_controller = EntityController::<MemberId>::from_actor::<Runtime>(&actor);
 
         assert_eq!(
             entity_creation_vouchers(FIRST_CLASS_ID, &entity_controller),
@@ -55,7 +55,7 @@ fn create_entity_success() {
         );
 
         // Ensure new entity created
-        let entity = Entity::<Runtime>::new(
+        let entity = Entity::<ClassId, MemberId, Hashed, EntityId, Nonce>::new(
             entity_controller,
             FIRST_CLASS_ID,
             BTreeSet::new(),

+ 9 - 9
runtime-modules/content-directory/src/tests/insert_at_entity_property_vector.rs

@@ -456,9 +456,9 @@ fn insert_at_entity_property_vector_is_locked_for_given_actor() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let mut property = Property::<Runtime>::with_name_and_type(
+        let mut property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -579,7 +579,7 @@ fn insert_at_entity_property_vector_value_under_given_index_is_not_a_vector() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 
@@ -818,12 +818,12 @@ fn insert_at_entity_property_vector_text_prop_is_too_long() {
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone()));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_text(
+        let property_type = PropertyType::<ClassId>::vec_text(
             TextMaxLengthConstraint::get(),
             VecMaxLengthConstraint::get(),
         );
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -898,12 +898,12 @@ fn insert_at_entity_property_vector_hashed_text_prop_is_too_long() {
         let hashed_text_max_length_constraint = HashedTextMaxLengthConstraint::get();
 
         // Create vec text hash property
-        let property_type = PropertyType::<Runtime>::vec_text_hash(
+        let property_type = PropertyType::<ClassId>::vec_text_hash(
             hashed_text_max_length_constraint,
             VecMaxLengthConstraint::get(),
         );
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,
@@ -977,12 +977,12 @@ fn insert_at_entity_property_vector_prop_type_does_not_match_internal_vec_proper
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.clone()));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_text(
+        let property_type = PropertyType::<ClassId>::vec_text(
             TextMaxLengthConstraint::get(),
             VecMaxLengthConstraint::get(),
         );
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,

+ 3 - 3
runtime-modules/content-directory/src/tests/remove_at_entity_property_vector.rs

@@ -430,9 +430,9 @@ fn remove_at_entity_property_vector_is_locked_for_given_actor() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let mut property = Property::<Runtime>::with_name_and_type(
+        let mut property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -549,7 +549,7 @@ fn remove_at_entity_property_vector_value_under_given_index_is_not_a_vector() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property = Property::<Runtime>::default_with_name(
+        let property = Property::<ClassId>::default_with_name(
             PropertyNameLengthConstraint::get().max() as usize,
         );
 

+ 1 - 1
runtime-modules/content-directory/src/tests/remove_entity.rs

@@ -27,7 +27,7 @@ fn remove_entity_success() {
         // Ensure number of entities_created under respective entity creation voucher decremented succesfully.
         let entity_voucher = EntityCreationVoucher::new(IndividualEntitiesCreationLimit::get());
 
-        let entity_controller = EntityController::from_actor(&actor);
+        let entity_controller = EntityController::<MemberId>::from_actor::<Runtime>(&actor);
 
         assert_eq!(
             entity_creation_vouchers(FIRST_CLASS_ID, &entity_controller),

+ 1 - 1
runtime-modules/content-directory/src/tests/transaction.rs

@@ -8,7 +8,7 @@ fn transaction_success() {
 
         // Create single reference property
         let property_type_reference = Type::Reference(FIRST_CLASS_ID, true);
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             PropertyType::Single(property_type_reference),
             true,

+ 2 - 2
runtime-modules/content-directory/src/tests/transfer_entity_ownership.rs

@@ -616,13 +616,13 @@ fn transfer_entity_ownership_unique_constraint_violation() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create unique reference property with same_controller flag set
-        let property_type = PropertyType::<Runtime>::vec_reference(
+        let property_type = PropertyType::<ClassId>::vec_reference(
             FIRST_CLASS_ID,
             true,
             VecMaxLengthConstraint::get(),
         );
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,

+ 51 - 2
runtime-modules/content-directory/src/tests/update_class_permissions.rs

@@ -17,15 +17,28 @@ fn update_class_permissions_success() {
         let mut class_permissions = ClassPermissions::default();
 
         // Ensure class permissions of newly created Class are equal to default ones
+
         assert_eq!(
             class_by_id(FIRST_CLASS_ID).get_permissions(),
             class_permissions
         );
 
+        // Ensure curator groups maintain no classes.
+
+        assert_eq!(
+            curator_group_by_id(FIRST_CURATOR_GROUP_ID).get_number_of_classes_maintained(),
+            0
+        );
+
+        assert_eq!(
+            curator_group_by_id(SECOND_CURATOR_GROUP_ID).get_number_of_classes_maintained(),
+            0
+        );
+
         // Events number before tested call
         let number_of_events_before_call = System::events().len();
 
-        let maintainers =
+        let mut maintainers =
             BTreeSet::from_iter(vec![FIRST_CURATOR_GROUP_ID, SECOND_CURATOR_GROUP_ID]);
 
         // Update class permissions
@@ -53,10 +66,46 @@ fn update_class_permissions_success() {
         let class_permissions_updated_event =
             get_test_event(RawEvent::ClassPermissionsUpdated(FIRST_CLASS_ID));
 
+        // Ensure number of classes maintained by curator groups updated succesfully.
+
+        assert_eq!(
+            curator_group_by_id(FIRST_CURATOR_GROUP_ID).get_number_of_classes_maintained(),
+            1
+        );
+
+        assert_eq!(
+            curator_group_by_id(SECOND_CURATOR_GROUP_ID).get_number_of_classes_maintained(),
+            1
+        );
+
+        maintainers = BTreeSet::from_iter(vec![SECOND_CURATOR_GROUP_ID]);
+
+        // Update class permissions
+        assert_ok!(update_class_permissions(
+            LEAD_ORIGIN,
+            FIRST_CLASS_ID,
+            None,
+            Some(true),
+            None,
+            Some(maintainers.clone())
+        ));
+
+        // Ensure number of classes maintained by curator groups updated succesfully.
+
+        assert_eq!(
+            curator_group_by_id(FIRST_CURATOR_GROUP_ID).get_number_of_classes_maintained(),
+            0
+        );
+
+        assert_eq!(
+            curator_group_by_id(SECOND_CURATOR_GROUP_ID).get_number_of_classes_maintained(),
+            1
+        );
+
         // Event checked
         assert_event_success(
             class_permissions_updated_event,
-            number_of_events_before_call + 1,
+            number_of_events_before_call + 2,
         );
     })
 }

+ 1 - 1
runtime-modules/content-directory/src/tests/update_entity_creation_voucher.rs

@@ -65,7 +65,7 @@ fn update_entity_creation_voucher_success() {
             None
         ));
 
-        let entity_controller = EntityController::from_actor(&actor);
+        let entity_controller = EntityController::<MemberId>::from_actor::<Runtime>(&actor);
 
         // Create entity
         assert_ok!(create_entity(FIRST_MEMBER_ORIGIN, FIRST_CLASS_ID, actor));

+ 6 - 6
runtime-modules/content-directory/src/tests/update_entity_property_values.rs

@@ -391,9 +391,9 @@ fn update_entity_property_values_is_locked_for_given_actor() {
         assert_ok!(create_simple_class(LEAD_ORIGIN, ClassType::Valid));
 
         // Create property
-        let property_type = PropertyType::<Runtime>::vec_reference(FIRST_CLASS_ID, true, 5);
+        let property_type = PropertyType::<ClassId>::vec_reference(FIRST_CLASS_ID, true, 5);
 
-        let mut property = Property::<Runtime>::with_name_and_type(
+        let mut property = Property::<ClassId>::with_name_and_type(
             (PropertyNameLengthConstraint::get().max() - 1) as usize,
             property_type,
             true,
@@ -605,9 +605,9 @@ fn update_entity_property_values_text_prop_is_too_long() {
         assert_ok!(create_entity(LEAD_ORIGIN, FIRST_CLASS_ID, actor.to_owned()));
 
         // Create text property
-        let property_type = PropertyType::<Runtime>::single_text(TextMaxLengthConstraint::get());
+        let property_type = PropertyType::<ClassId>::single_text(TextMaxLengthConstraint::get());
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,
@@ -682,9 +682,9 @@ fn update_entity_property_values_hashed_text_prop_is_too_long() {
 
         // Create hash property
         let property_type =
-            PropertyType::<Runtime>::single_text_hash(hashed_text_max_length_constraint);
+            PropertyType::<ClassId>::single_text_hash(hashed_text_max_length_constraint);
 
-        let property = Property::<Runtime>::with_name_and_type(
+        let property = Property::<ClassId>::with_name_and_type(
             PropertyNameLengthConstraint::get().max() as usize,
             property_type,
             true,

Some files were not shown because too many files changed in this diff