Bladeren bron

runtime: add merge code

- remove commented code
- remove DaoId
- add distribution staking handler
Shamil Gadelshin 3 jaren geleden
bovenliggende
commit
89ae46858d

+ 0 - 11
runtime-modules/common/src/lib.rs

@@ -66,17 +66,6 @@ pub trait StorageOwnership {
         + Ord
         + PartialEq;
 
-    /// Dao id representation.
-    type DaoId: Parameter
-        + Member
-        + BaseArithmetic
-        + Codec
-        + Default
-        + Copy
-        + MaybeSerialize
-        + Ord
-        + PartialEq;
-
     /// Content id representation.
     type ContentId: Parameter + Member + Codec + Default + Copy + MaybeSerialize + Ord + PartialEq;
 

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

@@ -1446,17 +1446,10 @@ impl<T: Trait> Module<T> {
         match actor {
             // Lead should use their member or curator role to create channels
             ContentActor::Lead => Err(Error::<T>::ActorCannotOwnChannel),
-            ContentActor::Curator(
-                curator_group_id,
-                _curator_id
-            ) => {
+            ContentActor::Curator(curator_group_id, _curator_id) => {
                 Ok(ChannelOwner::CuratorGroup(*curator_group_id))
             }
-            ContentActor::Member(member_id) => {
-                Ok(ChannelOwner::Member(*member_id))
-            }
-            // TODO:
-            // ContentActor::Dao(id) => Ok(ChannelOwner::Dao(id)),
+            ContentActor::Member(member_id) => Ok(ChannelOwner::Member(*member_id)),
         }
     }
 

+ 5 - 31
runtime-modules/content/src/permissions/mod.rs

@@ -11,7 +11,6 @@ use frame_support::{ensure, Parameter};
 pub use serde::{Deserialize, Serialize};
 use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerializeDeserialize, Member};
-// use frame_system::ensure_root;
 
 /// Model of authentication manager.
 pub trait ContentActorAuthenticator: frame_system::Trait + membership::Trait {
@@ -168,8 +167,6 @@ pub fn ensure_actor_authorized_to_update_channel<T: Trait>(
 
             Ok(())
         }
-        // TODO:
-        // ContentActor::Dao(_daoId) => ...,
     }
 }
 
@@ -198,7 +195,7 @@ pub fn ensure_actor_authorized_to_censor<T: Trait>(
         ContentActor::Lead => {
             let sender = ensure_signed(origin)?;
             ensure_lead_auth_success::<T>(&sender)
-        },
+        }
         ContentActor::Curator(curator_group_id, curator_id) => {
             let sender = ensure_signed(origin)?;
 
@@ -215,13 +212,11 @@ pub fn ensure_actor_authorized_to_censor<T: Trait>(
             } else {
                 Ok(())
             }
-        },
+        }
         ContentActor::Member(_) => {
             // Members cannot censore channels!
             Err(Error::<T>::ActorNotAuthorized.into())
         }
-        // TODO:
-        // ContentActor::Dao(_daoId) => ...,
     }
 }
 
@@ -234,40 +229,20 @@ pub fn ensure_actor_authorized_to_manage_categories<T: Trait>(
         ContentActor::Lead => {
             let sender = ensure_signed(origin)?;
             ensure_lead_auth_success::<T>(&sender)
-        },
+        }
         ContentActor::Curator(curator_group_id, curator_id) => {
             let sender = ensure_signed(origin)?;
 
             // Authorize curator, performing all checks to ensure curator can act
-            CuratorGroup::<T>::perform_curator_in_group_auth(
-                curator_id,
-                curator_group_id,
-                &sender,
-            )
-        },
+            CuratorGroup::<T>::perform_curator_in_group_auth(curator_id, curator_group_id, &sender)
+        }
         ContentActor::Member(_) => {
             // Members cannot censore channels!
             Err(Error::<T>::ActorNotAuthorized.into())
         }
-        // TODO:
-        // ContentActor::Dao(_daoId) => ...,
     }
 }
 
-// pub fn ensure_actor_authorized_to_delete_stale_assets<T: Trait>(
-//     origin: T::Origin,
-//     actor: &ContentActor<T::CuratorGroupId, T::CuratorId, T::MemberId>,
-// ) -> DispatchResult {
-//     // Only Lead and (sudo) can delete assets no longer associated with a channel or person.
-//     if let ContentActor::Lead = actor {
-//         let sender = ensure_signed(origin)?;
-//         ensure_lead_auth_success::<T>(&sender)
-//     } else {
-//         ensure_root(origin)?;
-//         Ok(())
-//     }
-// }
-
 /// Enum, representing all possible `Actor`s
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Eq, PartialEq, Clone, Copy, Debug)]
@@ -279,7 +254,6 @@ pub enum ContentActor<
     Curator(CuratorGroupId, CuratorId),
     Member(MemberId),
     Lead,
-    // Dao,
 }
 
 impl<

+ 0 - 1
runtime-modules/content/src/tests/mock.rs

@@ -125,7 +125,6 @@ impl common::MembershipTypes for Test {
 
 impl common::StorageOwnership for Test {
     type ChannelId = u64;
-    type DaoId = u64;
     type ContentId = u64;
     type DataObjectTypeId = u64;
 }

+ 12 - 3
runtime/src/integration/working_group.rs

@@ -2,9 +2,9 @@ use frame_support::StorageMap;
 use sp_std::marker::PhantomData;
 
 use crate::{
-    ContentWorkingGroupInstance, GatewayWorkingGroupInstance, OperationsWorkingGroupInstanceAlpha,
-    OperationsWorkingGroupInstanceBeta, OperationsWorkingGroupInstanceGamma,
-    StorageWorkingGroupInstance,
+    ContentWorkingGroupInstance, DistributionWorkingGroupInstance, GatewayWorkingGroupInstance,
+    OperationsWorkingGroupInstanceAlpha, OperationsWorkingGroupInstanceBeta,
+    OperationsWorkingGroupInstanceGamma, StorageWorkingGroupInstance,
 };
 use stake::{BalanceOf, NegativeImbalance};
 
@@ -78,6 +78,10 @@ pub struct GatewayWgStakingEventsHandler<T> {
     pub marker: PhantomData<T>,
 }
 
+pub struct DistributionWgStakingEventsHandler<T> {
+    pub marker: PhantomData<T>,
+}
+
 wg_staking_event_impl!(
     ContentWorkingGroupInstance,
     ContentDirectoryWgStakingEventsHandler<T>
@@ -107,3 +111,8 @@ wg_staking_event_impl!(
     OperationsWorkingGroupInstanceGamma,
     OperationsWgStakingEventsHandlerGamma<T>
 );
+
+wg_staking_event_impl!(
+    DistributionWorkingGroupInstance,
+    DistributionWgStakingEventsHandler<T>
+);

+ 11 - 13
runtime/src/lib.rs

@@ -471,25 +471,24 @@ impl stake::Trait for Runtime {
     type Currency = <Self as common::currency::GovernanceCurrency>::Currency;
     type StakePoolId = StakePoolId;
     type StakingEventsHandler = (
-        crate::integration::proposals::StakingEventsHandler<Self>,
         (
             (
+                crate::integration::proposals::StakingEventsHandler<Self>,
                 crate::integration::working_group::ContentDirectoryWgStakingEventsHandler<Self>,
+            ),
+            (
                 crate::integration::working_group::StorageWgStakingEventsHandler<Self>,
+                crate::integration::working_group::OperationsWgStakingEventsHandlerAlpha<Self>,
+            ),
+        ),
+        (
+            (
+                crate::integration::working_group::OperationsWgStakingEventsHandlerBeta<Self>,
+                crate::integration::working_group::OperationsWgStakingEventsHandlerGamma<Self>,
             ),
             (
-                (
-                    (
-                        crate::integration::working_group::OperationsWgStakingEventsHandlerAlpha<
-                            Self,
-                        >,
-                        crate::integration::working_group::OperationsWgStakingEventsHandlerBeta<
-                            Self,
-                        >,
-                    ),
-                    crate::integration::working_group::OperationsWgStakingEventsHandlerGamma<Self>,
-                ),
                 crate::integration::working_group::GatewayWgStakingEventsHandler<Self>,
+                crate::integration::working_group::DistributionWgStakingEventsHandler<Self>,
             ),
         ),
     );
@@ -508,7 +507,6 @@ impl common::MembershipTypes for Runtime {
 
 impl common::StorageOwnership for Runtime {
     type ChannelId = ChannelId;
-    type DaoId = DaoId;
     type ContentId = ContentId;
     type DataObjectTypeId = DataObjectTypeId;
 }

+ 0 - 3
runtime/src/primitives.rs

@@ -14,9 +14,6 @@ pub type TransactionPriority = u64;
 /// Alias for ContentId, used in various places.
 pub type ContentId = sp_core::H256;
 
-/// Alias for DaoId, used in various places.
-pub type DaoId = u64;
-
 /// Alias for DataObjectTypeId, used in various places.
 pub type DataObjectTypeId = u64;