Sfoglia il codice sorgente

Content_dir: fix chain_spec & clean-up

iorveth 4 anni fa
parent
commit
cbd5e5ea40

+ 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,

+ 2 - 2
runtime-modules/content-directory/src/lib.rs

@@ -260,10 +260,10 @@ decl_storage! {
     trait Store for Module<T: Trait> as ContentDirectory {
 
         /// Map, representing ClassId -> Class relation
-        pub ClassById get(fn class_by_id): map hasher(blake2_128_concat) T::ClassId => Class<T::EntityId, T::ClassId, T::CuratorGroupId>;
+        pub ClassById get(fn class_by_id) config(): map hasher(blake2_128_concat) T::ClassId => Class<T::EntityId, T::ClassId, T::CuratorGroupId>;
 
         /// Map, representing EntityId -> Entity relation
-        pub EntityById get(fn entity_by_id): map hasher(blake2_128_concat) T::EntityId => Entity<T::ClassId, T::MemberId, T::Hash, T::EntityId, T::Nonce>;
+        pub EntityById get(fn entity_by_id) config(): map hasher(blake2_128_concat) T::EntityId => Entity<T::ClassId, T::MemberId, T::Hash, T::EntityId, T::Nonce>;
 
         /// Map, representing  CuratorGroupId -> CuratorGroup relation
         pub CuratorGroupById get(fn curator_group_by_id) config(): map hasher(blake2_128_concat) T::CuratorGroupId => CuratorGroup<T>;

+ 2 - 0
runtime-modules/content-directory/src/mock.rs

@@ -377,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,

+ 2 - 8
runtime-modules/content-directory/src/permissions.rs

@@ -106,8 +106,8 @@ pub fn ensure_is_lead<T: Trait>(origin: T::Origin) -> DispatchResult {
 }
 
 /// Enum, representing all possible `Actor`s
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Eq, PartialEq, Clone, Copy)]
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Eq, PartialEq, Clone, Copy, Debug)]
 pub enum Actor<
     CuratorGroupId: Default + Clone + Copy,
     CuratorId: Default + Clone + Copy,
@@ -128,9 +128,3 @@ impl<
         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)
-//     }
-// }

+ 2 - 8
runtime-modules/content-directory/src/permissions/entity.rs

@@ -1,8 +1,8 @@
 use super::*;
 
 /// Owner of an `Entity`.
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, PartialEq, Eq)]
+#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
+#[derive(Encode, Decode, Clone, PartialEq, Eq, Debug)]
 pub enum EntityController<MemberId: Default + PartialEq + Clone + Copy> {
     Maintainers,
     Member(MemberId),
@@ -26,12 +26,6 @@ impl<MemberId: Default + PartialEq + Clone + Copy> Default for EntityController<
     }
 }
 
-// impl<T: Trait> core::fmt::Debug for EntityController<MemberId> {
-//     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)]

+ 8 - 14
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,8 +26,8 @@ pub struct PropertyLockingPolicy {
 }
 
 /// Enum, used for `PropertyType` representation
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
+#[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,
@@ -71,8 +71,8 @@ impl<ClassId: Default + BaseArithmetic + Clone + Copy> Type<ClassId> {
 }
 
 /// Vector property type representation
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Default, Copy, PartialEq, Eq)]
+#[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
@@ -110,8 +110,8 @@ impl<ClassId: Default + BaseArithmetic + Clone + Copy> VecPropertyType<ClassId>
 }
 
 /// Enum, representing either `Type` or `VecPropertyType`
-#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Debug))]
-#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq)]
+#[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>),
@@ -190,12 +190,6 @@ impl<ClassId: Default + BaseArithmetic + Clone + Copy> Default for Property<Clas
     }
 }
 
-// impl<ClassId: Default + BaseArithmetic> core::fmt::Debug for Property<ClassId> {
-//     fn fmt(&self, formatter: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
-//         write!(formatter, "Property {:?}", self)
-//     }
-// }
-
 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 {