Browse Source

runtime: Continue to replace working group with working team.

Shamil Gadelshin 4 years ago
parent
commit
4bcbb38106

+ 2 - 2
Cargo.lock

@@ -4130,7 +4130,7 @@ dependencies = [
 
 [[package]]
 name = "pallet-service-discovery"
-version = "3.1.0"
+version = "4.0.0"
 dependencies = [
  "frame-support",
  "frame-system",
@@ -4238,7 +4238,7 @@ dependencies = [
 
 [[package]]
 name = "pallet-storage"
-version = "3.1.0"
+version = "4.0.0"
 dependencies = [
  "frame-support",
  "frame-system",

+ 2 - 32
runtime-modules/proposals/codex/src/lib.rs

@@ -92,7 +92,7 @@ const MAX_VALIDATOR_COUNT: u32 = 100;
 
 // Data container struct to fix linter warning 'too many arguments for the function' for the
 // create_proposal() function.
-struct CreateProposalParameters<T: Trait> {
+struct CreateProposalParameters<T: Trait + working_group::Trait> {
     pub origin: T::Origin,
     pub member_id: MemberId<T>,
     pub title: Vec<u8>,
@@ -113,6 +113,7 @@ pub trait Trait:
     + governance::election::Trait
     + hiring::Trait
     + staking::Trait
+    + working_group::Trait
 {
     /// Defines max allowed text proposal length.
     type TextProposalMaxLength: Get<u32>;
@@ -509,35 +510,6 @@ decl_module! {
             Self::create_proposal(params)?;
         }
 
-        /// Create 'Begin review working group leader applications' proposal type.
-        /// This proposal uses `begin_applicant_review()` extrinsic from the Joystream `working group` module.
-        #[weight = 10_000_000] // TODO: adjust weight
-        pub fn create_begin_review_working_group_leader_applications_proposal(
-            origin,
-            member_id: MemberId<T>,
-            title: Vec<u8>,
-            description: Vec<u8>,
-            staking_account_id: Option<T::AccountId>,
-            opening_id: working_group::OpeningId<T>,
-            working_group: WorkingGroup,
-            exact_execution_block: Option<T::BlockNumber>,
-        ) {
-            let proposal_details = ProposalDetails::BeginReviewWorkingGroupLeaderApplications(opening_id, working_group);
-            let params = CreateProposalParameters{
-                origin,
-                member_id,
-                title,
-                description,
-                staking_account_id,
-                proposal_details: proposal_details.clone(),
-                proposal_parameters: T::BeginReviewWorkingGroupApplicationsProposalParameters::get(),
-                proposal_code: T::ProposalEncoder::encode_proposal(proposal_details),
-                exact_execution_block,
-            };
-
-            Self::create_proposal(params)?;
-        }
-
         /// Create 'Fill working group leader opening' proposal type.
         /// This proposal uses `fill_opening()` extrinsic from the Joystream `working group` module.
         #[weight = 10_000_000] // TODO: adjust weight
@@ -548,8 +520,6 @@ decl_module! {
             description: Vec<u8>,
             staking_account_id: Option<T::AccountId>,
             fill_opening_parameters: FillOpeningParameters<
-                T::BlockNumber,
-                BalanceOfMint<T>,
                 working_group::OpeningId<T>,
                 working_group::ApplicationId<T>
             >,

+ 10 - 11
runtime-modules/proposals/codex/src/proposal_types/mod.rs

@@ -8,6 +8,8 @@ use sp_std::vec::Vec;
 use crate::ElectionParameters;
 use common::working_group::WorkingGroup;
 
+use working_group::{StakePolicy, RewardPolicy};
+
 /// Encodes proposal using its details information.
 pub trait ProposalEncoder<T: crate::Trait> {
     /// Encodes proposal using its details information.
@@ -86,7 +88,7 @@ pub enum ProposalDetails<
 
     /// Fill opening for the working group leader position.
     FillWorkingGroupLeaderOpening(
-        FillOpeningParameters<BlockNumber, MintedBalance, OpeningId, ApplicationId>,
+        FillOpeningParameters<OpeningId, ApplicationId>,
     ),
 
     /// Set working group mint capacity.
@@ -156,16 +158,13 @@ pub struct TerminateRoleParameters<WorkerId> {
 /// Parameters for the 'fill opening for the leader position' proposal.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Clone, PartialEq, Debug)]
-pub struct FillOpeningParameters<BlockNumber, Balance, OpeningId, ApplicationId> {
+pub struct FillOpeningParameters<OpeningId, ApplicationId> {
     /// Finalizing opening id.
     pub opening_id: OpeningId,
 
     /// Id of the selected application.
     pub successful_application_id: ApplicationId,
 
-    /// Position reward policy.
-    pub reward_policy: Option<working_group::RewardPolicy<Balance, BlockNumber>>,
-
     /// Defines working group with the open position.
     pub working_group: WorkingGroup,
 }
@@ -174,14 +173,14 @@ pub struct FillOpeningParameters<BlockNumber, Balance, OpeningId, ApplicationId>
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Clone, PartialEq, Debug)]
 pub struct AddOpeningParameters<BlockNumber, Balance> {
-    /// Activate opening at block.
-    pub activate_at: hiring::ActivateOpeningAt<BlockNumber>,
+    /// Opening description.
+    pub description: Vec<u8>,
 
-    /// Opening conditions.
-    pub commitment: working_group::OpeningPolicyCommitment<BlockNumber, Balance>,
+    /// Stake policy for the opening.
+    pub stake_policy: Option<StakePolicy<BlockNumber, Balance>>,
 
-    /// Opening description.
-    pub human_readable_text: Vec<u8>,
+    /// Reward policy for the opening.
+    pub reward_policy: Option<RewardPolicy<Balance>>,
 
     /// Defines working group with the open position.
     pub working_group: WorkingGroup,

+ 1 - 1
runtime-modules/service-discovery/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = 'pallet-service-discovery'
-version = '3.1.0'
+version = '4.0.0'
 authors = ['Joystream contributors']
 edition = '2018'
 

+ 1 - 4
runtime-modules/service-discovery/src/lib.rs

@@ -54,11 +54,8 @@ pub type Url = Vec<u8>;
 // The storage working group instance alias.
 pub(crate) type StorageWorkingGroupInstance = working_group::Instance2;
 
-// Alias for storage working group.
-pub(crate) type StorageWorkingGroup<T> = working_group::Module<T, StorageWorkingGroupInstance>;
-
 /// Storage provider is a worker from the  working_group module.
-pub type StorageProviderId<T> = working_group::GroupWorkerId<T>;
+pub type StorageProviderId<T> = working_group::WorkerId<T>;
 
 pub(crate) const MINIMUM_LIFETIME: u32 = 600; // 1hr assuming 6s block times
 pub(crate) const DEFAULT_LIFETIME: u32 = MINIMUM_LIFETIME * 24; // 24hr

+ 1 - 1
runtime-modules/storage/Cargo.toml

@@ -1,6 +1,6 @@
 [package]
 name = 'pallet-storage'
-version = '3.1.0'
+version = '4.0.0'
 authors = ['Joystream contributors']
 edition = '2018'
 

+ 7 - 4
runtime-modules/storage/src/data_directory.rs

@@ -36,9 +36,12 @@ use serde::{Deserialize, Serialize};
 use common::origin::ActorOriginValidator;
 pub(crate) use common::BlockAndTime;
 
+use working_group::ensure_worker_signed;
+
+
 use crate::data_object_type_registry;
 use crate::data_object_type_registry::IsActiveDataObjectType;
-use crate::{MemberId, StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance};
+use crate::{MemberId, StorageProviderId, StorageWorkingGroupInstance};
 
 /// The _Data directory_ main _Trait_.
 pub trait Trait:
@@ -208,7 +211,7 @@ decl_module! {
             size: u64,
             ipfs_content_id: Vec<u8>
         ) {
-            T::MemberOriginValidator::ensure_actor_origin(
+            <T as Trait>::MemberOriginValidator::ensure_actor_origin(
                 origin,
                 member_id,
             )?;
@@ -248,7 +251,7 @@ decl_module! {
             storage_provider_id: StorageProviderId<T>,
             content_id: T::ContentId
         ) {
-            <StorageWorkingGroup<T>>::ensure_worker_signed(origin, &storage_provider_id)?;
+            ensure_worker_signed::<T, StorageWorkingGroupInstance>(origin, &storage_provider_id)?;
 
             // == MUTATION SAFE ==
 
@@ -267,7 +270,7 @@ decl_module! {
             storage_provider_id: StorageProviderId<T>,
             content_id: T::ContentId
         ) {
-            <StorageWorkingGroup<T>>::ensure_worker_signed(origin, &storage_provider_id)?;
+            ensure_worker_signed::<T, StorageWorkingGroupInstance>(origin, &storage_provider_id)?;
 
             // == MUTATION SAFE ==
 

+ 5 - 3
runtime-modules/storage/src/data_object_storage_registry.rs

@@ -30,7 +30,9 @@ use sp_runtime::traits::{MaybeSerialize, Member};
 use sp_std::vec::Vec;
 
 use crate::data_directory::{self, ContentIdExists};
-use crate::{StorageProviderId, StorageWorkingGroup, StorageWorkingGroupInstance};
+use crate::{StorageProviderId, StorageWorkingGroupInstance};
+
+use working_group::ensure_worker_signed;
 
 const DEFAULT_FIRST_RELATIONSHIP_ID: u8 = 1;
 
@@ -144,7 +146,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn add_relationship(origin, storage_provider_id: StorageProviderId<T>, cid: T::ContentId) {
             // Origin should match storage provider.
-            <StorageWorkingGroup<T>>::ensure_worker_signed(origin, &storage_provider_id)?;
+            ensure_worker_signed::<T, StorageWorkingGroupInstance>(origin, &storage_provider_id)?;
 
             // Content ID must exist
             ensure!(T::ContentIdExists::has_content(&cid), Error::<T>::CidNotFound);
@@ -209,7 +211,7 @@ impl<T: Trait> Module<T> {
         id: T::DataObjectStorageRelationshipId,
         ready: bool,
     ) -> DispatchResult {
-        <StorageWorkingGroup<T>>::ensure_worker_signed(origin, &storage_provider_id)?;
+        ensure_worker_signed::<T, StorageWorkingGroupInstance>(origin, &storage_provider_id)?;
 
         // For that, we need to fetch the identified DOSR
         let mut dosr =

+ 7 - 5
runtime-modules/storage/src/data_object_type_registry.rs

@@ -30,7 +30,9 @@ use sp_arithmetic::traits::BaseArithmetic;
 use sp_runtime::traits::{MaybeSerialize, Member};
 use sp_std::vec::Vec;
 
-use crate::{StorageWorkingGroup, StorageWorkingGroupInstance};
+use crate::{StorageWorkingGroupInstance};
+
+use working_group::ensure_origin_is_active_leader;
 
 const DEFAULT_TYPE_DESCRIPTION: &str = "Default data object type for audio and video content.";
 const DEFAULT_FIRST_DATA_OBJECT_TYPE_ID: u8 = 1;
@@ -138,7 +140,7 @@ decl_module! {
         /// Registers the new data object type. Requires leader privileges.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn register_data_object_type(origin, data_object_type: DataObjectType) {
-            <StorageWorkingGroup<T>>::ensure_origin_is_active_leader(origin)?;
+            ensure_origin_is_active_leader::<T, StorageWorkingGroupInstance>(origin)?;
 
             let new_do_type_id = Self::next_data_object_type_id();
             let do_type: DataObjectType = DataObjectType {
@@ -159,7 +161,7 @@ decl_module! {
         /// Updates existing data object type. Requires leader privileges.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_data_object_type(origin, id: T::DataObjectTypeId, data_object_type: DataObjectType) {
-            <StorageWorkingGroup<T>>::ensure_origin_is_active_leader(origin)?;
+            ensure_origin_is_active_leader::<T, StorageWorkingGroupInstance>(origin)?;
 
             let mut do_type = Self::ensure_data_object_type(id)?;
 
@@ -178,7 +180,7 @@ decl_module! {
         /// Activates existing data object type. Requires leader privileges.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn activate_data_object_type(origin, id: T::DataObjectTypeId) {
-            <StorageWorkingGroup<T>>::ensure_origin_is_active_leader(origin)?;
+            ensure_origin_is_active_leader::<T, StorageWorkingGroupInstance>(origin)?;
 
             let mut do_type = Self::ensure_data_object_type(id)?;
 
@@ -196,7 +198,7 @@ decl_module! {
         /// Deactivates existing data object type. Requires leader privileges.
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn deactivate_data_object_type(origin, id: T::DataObjectTypeId) {
-            <StorageWorkingGroup<T>>::ensure_origin_is_active_leader(origin)?;
+            ensure_origin_is_active_leader::<T, StorageWorkingGroupInstance>(origin)?;
 
             let mut do_type = Self::ensure_data_object_type(id)?;
 

+ 1 - 4
runtime-modules/storage/src/lib.rs

@@ -10,11 +10,8 @@ mod tests;
 // The storage working group instance alias.
 pub type StorageWorkingGroupInstance = working_group::Instance2;
 
-// Alias for storage working group
-pub(crate) type StorageWorkingGroup<T> = working_group::Module<T, StorageWorkingGroupInstance>;
-
 // Alias for the member id.
 pub(crate) type MemberId<T> = <T as membership::Trait>::MemberId;
 
 /// Storage provider is a worker from the working group module.
-pub type StorageProviderId<T> = working_group::GroupWorkerId<T>;
+pub type StorageProviderId<T> = working_group::WorkerId<T>;

+ 49 - 49
runtime-modules/working-group/src/benchmarking.rs

@@ -39,7 +39,7 @@ fn add_opening_helper<T: Trait<I>, I: Instance>(
     id: u32,
     add_opening_origin: &T::Origin,
     staking_role: &StakingRole,
-    job_opening_type: &JobOpeningType,
+    job_opening_type: &OpeningType,
 ) -> T::OpeningId {
     let staking_policy = match staking_role {
         StakingRole::WithStakes => Some(StakePolicy {
@@ -116,7 +116,7 @@ fn add_opening_and_apply_with_multiple_ids<T: Trait<I>, I: Instance>(
     ids: &Vec<u32>,
     add_opening_origin: &T::Origin,
     staking_role: &StakingRole,
-    job_opening_type: &JobOpeningType,
+    job_opening_type: &OpeningType,
 ) -> (T::OpeningId, BTreeSet<T::ApplicationId>, Vec<T::AccountId>) {
     let opening_id =
         add_opening_helper::<T, I>(1, add_opening_origin, &staking_role, job_opening_type);
@@ -147,7 +147,7 @@ fn add_and_apply_opening<T: Trait<I>, I: Instance>(
     staking_role: &StakingRole,
     applicant_id: &T::AccountId,
     member_id: &T::MemberId,
-    job_opening_type: &JobOpeningType,
+    job_opening_type: &OpeningType,
 ) -> (T::OpeningId, T::ApplicationId) {
     let opening_id =
         add_opening_helper::<T, I>(id, add_opening_origin, staking_role, job_opening_type);
@@ -215,16 +215,16 @@ fn force_missed_reward<T: Trait<I>, I: Instance>() {
 
 fn insert_a_worker<T: Trait<I>, I: Instance>(
     staking_role: StakingRole,
-    job_opening_type: JobOpeningType,
+    job_opening_type: OpeningType,
     id: u32,
     lead_id: Option<T::AccountId>,
-) -> (T::AccountId, GroupWorkerId<T>)
+) -> (T::AccountId, WorkerId<T>)
 where
     WorkingGroup<T, I>: OnInitialize<T::BlockNumber>,
 {
     let add_worker_origin = match job_opening_type {
-        JobOpeningType::Leader => RawOrigin::Root,
-        JobOpeningType::Regular => RawOrigin::Signed(lead_id.clone().unwrap()),
+        OpeningType::Leader => RawOrigin::Root,
+        OpeningType::Regular => RawOrigin::Signed(lead_id.clone().unwrap()),
     };
 
     let (caller_id, member_id) = member_funded_account::<T>("member", id);
@@ -251,7 +251,7 @@ where
     // remaining reward
     force_missed_reward::<T, I>();
 
-    let worker_id = GroupWorkerId::<T>::from(id.try_into().unwrap());
+    let worker_id = WorkerId::<T>::from(id.try_into().unwrap());
 
     assert!(WorkerById::<T, I>::contains_key(worker_id));
 
@@ -266,7 +266,7 @@ benchmarks_instance! {
 
         let (lead_id, lead_worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );
@@ -276,7 +276,7 @@ benchmarks_instance! {
                 &(1..i).collect(),
                 &T::Origin::from(RawOrigin::Signed(lead_id.clone())),
                 &StakingRole::WithStakes,
-                &JobOpeningType::Regular
+                &OpeningType::Regular
             );
 
         WorkingGroup::<T, _>::fill_opening(
@@ -288,7 +288,7 @@ benchmarks_instance! {
         force_missed_reward::<T,I>();
 
         // Force all workers to leave (Including the lead)
-        // We should have every GroupWorkerId from 0 to i-1
+        // We should have every WorkerId from 0 to i-1
         // Corresponding to each account id
         let mut worker_id = Zero::zero();
         for id in application_account_id {
@@ -303,7 +303,7 @@ benchmarks_instance! {
         ).unwrap();
 
         for i in 1..successful_application_ids.len() {
-            let worker = GroupWorkerId::<T>::from(i.try_into().unwrap());
+            let worker = WorkerId::<T>::from(i.try_into().unwrap());
             assert!(WorkerById::<T, I>::contains_key(worker), "Not all workers added");
             assert_eq!(
                 WorkingGroup::<T, _>::worker_by_id(worker).started_leaving_at,
@@ -348,7 +348,7 @@ benchmarks_instance! {
 
         let (lead_id, _) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );
@@ -358,7 +358,7 @@ benchmarks_instance! {
                 &(1..i).collect(),
                 &T::Origin::from(RawOrigin::Signed(lead_id.clone())),
                 &StakingRole::WithStakes,
-                &JobOpeningType::Regular
+                &OpeningType::Regular
             );
 
         WorkingGroup::<T, _>::fill_opening(RawOrigin::Signed(lead_id.clone()).into(), opening_id,
@@ -366,7 +366,7 @@ benchmarks_instance! {
 
         for i in 1..successful_application_ids.len() {
             assert!(
-                WorkerById::<T, I>::contains_key(GroupWorkerId::<T>::from(i.try_into().unwrap())),
+                WorkerById::<T, I>::contains_key(WorkerId::<T>::from(i.try_into().unwrap())),
                 "Not all workers added"
             );
         }
@@ -410,7 +410,7 @@ benchmarks_instance! {
 
         let (lead_id, _) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );
@@ -420,7 +420,7 @@ benchmarks_instance! {
                 &(1..i).collect(),
                 &T::Origin::from(RawOrigin::Signed(lead_id.clone())),
                 &StakingRole::WithStakes,
-                &JobOpeningType::Regular
+                &OpeningType::Regular
             );
 
         WorkingGroup::<T, _>::fill_opening(RawOrigin::Signed(lead_id.clone()).into(), opening_id,
@@ -428,7 +428,7 @@ benchmarks_instance! {
 
         for i in 1..successful_application_ids.len() {
             assert!(
-                WorkerById::<T, I>::contains_key(GroupWorkerId::<T>::from(i.try_into().unwrap())),
+                WorkerById::<T, I>::contains_key(WorkerId::<T>::from(i.try_into().unwrap())),
                 "Not all workers added"
             );
         }
@@ -461,7 +461,7 @@ benchmarks_instance! {
 
         let (lead_id, _) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );
@@ -471,7 +471,7 @@ benchmarks_instance! {
                 &(1..i).collect(),
                 &T::Origin::from(RawOrigin::Signed(lead_id.clone())),
                 &StakingRole::WithStakes,
-                &JobOpeningType::Regular
+                &OpeningType::Regular
             );
 
         WorkingGroup::<T, _>::fill_opening(RawOrigin::Signed(lead_id.clone()).into(), opening_id,
@@ -479,7 +479,7 @@ benchmarks_instance! {
 
         for i in 1..successful_application_ids.len() {
             assert!(
-                WorkerById::<T, I>::contains_key(GroupWorkerId::<T>::from(i.try_into().unwrap())),
+                WorkerById::<T, I>::contains_key(WorkerId::<T>::from(i.try_into().unwrap())),
                 "Not all workers added"
             );
         }
@@ -519,7 +519,7 @@ benchmarks_instance! {
             0,
             &T::Origin::from(RawOrigin::Root),
             &StakingRole::WithStakes,
-            &JobOpeningType::Leader
+            &OpeningType::Leader
         );
 
         let apply_on_opening_params = ApplyOnOpeningParameters::<T, I> {
@@ -558,7 +558,7 @@ benchmarks_instance! {
             &StakingRole::WithoutStakes,
             &lead_account_id,
             &lead_member_id,
-            &JobOpeningType::Leader
+            &OpeningType::Leader
         );
 
         let mut successful_application_ids: BTreeSet<T::ApplicationId> = BTreeSet::new();
@@ -587,7 +587,7 @@ benchmarks_instance! {
         let i in 1 .. T::MaxWorkerNumberLimit::get();
         let (lead_id, lead_worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithoutStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );
@@ -597,7 +597,7 @@ benchmarks_instance! {
                 &(1..i).collect(),
                 &T::Origin::from(RawOrigin::Signed(lead_id.clone())),
                 &StakingRole::WithoutStakes,
-                &JobOpeningType::Regular
+                &OpeningType::Regular
             );
     }: fill_opening(
             RawOrigin::Signed(lead_id.clone()),
@@ -609,10 +609,10 @@ benchmarks_instance! {
 
         let mut application_id_to_worker_id = BTreeMap::new();
         for (i, application_id) in successful_application_ids.iter().enumerate() {
-            let worker_id = GroupWorkerId::<T>::from((i + 1).try_into().unwrap());
+            let worker_id = WorkerId::<T>::from((i + 1).try_into().unwrap());
             application_id_to_worker_id.insert(*application_id, worker_id);
             assert!(
-                WorkerById::<T, I>::contains_key(GroupWorkerId::<T>::from(i.try_into().unwrap())),
+                WorkerById::<T, I>::contains_key(WorkerId::<T>::from(i.try_into().unwrap())),
                 "Not all workers added"
             );
         }
@@ -625,7 +625,7 @@ benchmarks_instance! {
     update_role_account{
         let i in 0 .. 1;
         let (lead_id, lead_worker_id) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let new_account_id = account::<T::AccountId>("new_lead_account", 1, SEED);
     }: _ (RawOrigin::Signed(lead_id), lead_worker_id, new_account_id.clone())
     verify {
@@ -644,12 +644,12 @@ benchmarks_instance! {
         let i in 0 .. 1;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let opening_id = add_opening_helper::<T, I>(
             1,
             &T::Origin::from(RawOrigin::Signed(lead_id.clone())),
             &StakingRole::WithoutStakes,
-            &JobOpeningType::Regular
+            &OpeningType::Regular
         );
 
     }: _ (RawOrigin::Signed(lead_id.clone()), opening_id)
@@ -667,7 +667,7 @@ benchmarks_instance! {
             &StakingRole::WithStakes,
             &caller_id,
             &member_id,
-            &JobOpeningType::Leader
+            &OpeningType::Leader
         );
 
     }: _ (RawOrigin::Signed(caller_id.clone()), application_id)
@@ -682,10 +682,10 @@ benchmarks_instance! {
         let i in 0 .. MAX_BYTES;
 
         let (lead_id, lead_worker_id) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let (caller_id, worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Regular,
+            OpeningType::Regular,
             1,
             Some(lead_id.clone())
         );
@@ -703,10 +703,10 @@ benchmarks_instance! {
         let i in 0 .. MAX_BYTES;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let (caller_id, worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Regular,
+            OpeningType::Regular,
             1,
             Some(lead_id.clone())
         );
@@ -727,7 +727,7 @@ benchmarks_instance! {
         let i in 0 .. MAX_BYTES;
 
         let (_, lead_worker_id) =
-            insert_a_worker::<T, I>(StakingRole::WithStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithStakes, OpeningType::Leader, 0, None);
         let current_budget = BalanceOfCurrency::<T>::max_value();
         // To be able to pay unpaid reward
         WorkingGroup::<T, _>::set_budget(RawOrigin::Root.into(), current_budget).unwrap();
@@ -747,10 +747,10 @@ benchmarks_instance! {
         let i in 0 .. 1;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let (caller_id, worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Regular,
+            OpeningType::Regular,
             1,
             Some(lead_id.clone())
         );
@@ -770,10 +770,10 @@ benchmarks_instance! {
         let i in 0 .. 1;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let (_, worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Regular,
+            OpeningType::Regular,
             1,
             Some(lead_id.clone())
         );
@@ -790,7 +790,7 @@ benchmarks_instance! {
 
         let (lead_id, _) = insert_a_worker::<T, I>(
             StakingRole::WithoutStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );
@@ -809,10 +809,10 @@ benchmarks_instance! {
         let i in 0 .. 1;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let (_, worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithoutStakes,
-            JobOpeningType::Regular,
+            OpeningType::Regular,
             1,
             Some(lead_id.clone())
         );
@@ -835,7 +835,7 @@ benchmarks_instance! {
         let i in 0 .. MAX_BYTES;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let status_text = Some(vec![0u8; i.try_into().unwrap()]);
 
     }: _ (RawOrigin::Signed(lead_id), status_text.clone())
@@ -855,7 +855,7 @@ benchmarks_instance! {
         let i in 0 .. 1;
 
         let (caller_id, worker_id) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
         let new_id = account::<T::AccountId>("new_id", 1, 0);
 
     }: _ (RawOrigin::Signed(caller_id), worker_id, new_id.clone())
@@ -886,7 +886,7 @@ benchmarks_instance! {
         let i in 0 .. MAX_BYTES;
 
         let (lead_id, _) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
 
         let stake_policy = StakePolicy {
             stake_amount: BalanceOfCurrency::<T>::max_value(),
@@ -902,7 +902,7 @@ benchmarks_instance! {
     }: _(
             RawOrigin::Signed(lead_id),
             description,
-            JobOpeningType::Regular,
+            OpeningType::Regular,
             Some(stake_policy),
             Some(reward_policy)
         )
@@ -918,7 +918,7 @@ benchmarks_instance! {
         // could separate into new branch to tighten weight
         // Also, workers without stake can leave immediatly
         let (caller_id, lead_worker_id) =
-            insert_a_worker::<T, I>(StakingRole::WithoutStakes, JobOpeningType::Leader, 0, None);
+            insert_a_worker::<T, I>(StakingRole::WithoutStakes, OpeningType::Leader, 0, None);
 
         // To be able to pay unpaid reward
         WorkingGroup::<T, _>::set_budget(
@@ -941,7 +941,7 @@ benchmarks_instance! {
         // Workers with stake can't leave immediatly
         let (caller_id, caller_worker_id) = insert_a_worker::<T, I>(
             StakingRole::WithStakes,
-            JobOpeningType::Leader,
+            OpeningType::Leader,
             0,
             None
         );

+ 13 - 13
runtime-modules/working-group/src/checks.rs

@@ -1,6 +1,6 @@
 use crate::{
-    BalanceOf, Instance, JobOpening, JobOpeningType, MemberId, RewardPolicy, StakePolicy,
-    GroupWorker, GroupWorkerId, Trait,
+    BalanceOf, Instance, JobOpening, OpeningType, MemberId, RewardPolicy, StakePolicy,
+    GroupWorker, WorkerId, Trait,
 };
 
 use super::Error;
@@ -17,14 +17,14 @@ use crate::types::{ApplicationInfo, StakeParameters};
 // Check opening: verifies origin and opening type compatibility.
 pub(crate) fn ensure_origin_for_opening_type<T: Trait<I>, I: Instance>(
     origin: T::Origin,
-    opening_type: JobOpeningType,
+    opening_type: OpeningType,
 ) -> DispatchResult {
     match opening_type {
-        JobOpeningType::Regular => {
+        OpeningType::Regular => {
             // Ensure lead is set and is origin signer.
             ensure_origin_is_active_leader::<T, I>(origin)
         }
-        JobOpeningType::Leader => {
+        OpeningType::Leader => {
             // Council proposal.
             ensure_root(origin).map_err(|err| err.into())
         }
@@ -97,7 +97,7 @@ pub(crate) fn ensure_succesful_applications_exist<T: Trait<I>, I: Instance>(
 }
 
 // Check leader: ensures that group leader was hired.
-pub(crate) fn ensure_lead_is_set<T: Trait<I>, I: Instance>() -> Result<GroupWorkerId<T>, Error<T, I>>
+pub(crate) fn ensure_lead_is_set<T: Trait<I>, I: Instance>() -> Result<WorkerId<T>, Error<T, I>>
 {
     let leader_worker_id = <crate::CurrentLead<T, I>>::get();
 
@@ -123,8 +123,8 @@ fn ensure_is_lead_account<T: Trait<I>, I: Instance>(
     Ok(())
 }
 
-// Check leader: ensures origin is signed by the leader.
-pub(crate) fn ensure_origin_is_active_leader<T: Trait<I>, I: Instance>(
+/// Check leader: ensures origin is signed by the leader.
+pub fn ensure_origin_is_active_leader<T: Trait<I>, I: Instance>(
     origin: T::Origin,
 ) -> DispatchResult {
     // Ensure is signed
@@ -135,7 +135,7 @@ pub(crate) fn ensure_origin_is_active_leader<T: Trait<I>, I: Instance>(
 
 // Check worker: ensures the worker was already created.
 pub(crate) fn ensure_worker_exists<T: Trait<I>, I: Instance>(
-    worker_id: &GroupWorkerId<T>,
+    worker_id: &WorkerId<T>,
 ) -> Result<GroupWorker<T>, Error<T, I>> {
     ensure!(
         <crate::WorkerById::<T, I>>::contains_key(worker_id),
@@ -161,7 +161,7 @@ pub(crate) fn ensure_origin_signed_by_member<T: Trait<I>, I: Instance>(
 /// Check worker: ensures the origin contains signed account that belongs to existing worker.
 pub fn ensure_worker_signed<T: Trait<I>, I: Instance>(
     origin: T::Origin,
-    worker_id: &GroupWorkerId<T>,
+    worker_id: &WorkerId<T>,
 ) -> Result<GroupWorker<T>, DispatchError> {
     // Ensure that it is signed
     let signer_account = ensure_signed(origin)?;
@@ -181,14 +181,14 @@ pub fn ensure_worker_signed<T: Trait<I>, I: Instance>(
 // Check worker: verifies proper origin for the worker operation. Returns whether the origin is sudo.
 pub(crate) fn ensure_origin_for_worker_operation<T: Trait<I>, I: Instance>(
     origin: T::Origin,
-    worker_id: GroupWorkerId<T>,
+    worker_id: WorkerId<T>,
 ) -> Result<bool, DispatchError> {
     let leader_worker_id = ensure_lead_is_set::<T, I>()?;
 
     let (worker_opening_type, is_sudo) = if leader_worker_id == worker_id {
-        (JobOpeningType::Leader, true)
+        (OpeningType::Leader, true)
     } else {
-        (JobOpeningType::Regular, false)
+        (OpeningType::Regular, false)
     };
 
     ensure_origin_for_opening_type::<T, I>(origin, worker_opening_type)?;

+ 39 - 39
runtime-modules/working-group/src/lib.rs

@@ -50,11 +50,11 @@ use sp_std::vec::Vec;
 pub use errors::Error;
 use types::{ApplicationInfo, BalanceOf, MemberId, GroupWorker, WorkerInfo};
 pub use types::{
-    ApplyOnOpeningParameters, JobApplication, JobOpening, JobOpeningType, Penalty, RewardPolicy,
-    StakePolicy, GroupWorkerId
+    ApplyOnOpeningParameters, JobApplication, JobOpening, OpeningType, Penalty, RewardPolicy,
+    StakePolicy, WorkerId, ApplicationId, OpeningId
 };
 
-pub use checks::ensure_worker_signed;
+pub use checks::{ensure_worker_signed, ensure_origin_is_active_leader};
 
 use common::origin::ActorOriginValidator;
 use membership::staking_handler::StakingHandler;
@@ -108,8 +108,8 @@ decl_event!(
     where
        <T as Trait<I>>::OpeningId,
        <T as Trait<I>>::ApplicationId,
-       ApplicationIdToWorkerIdMap = BTreeMap<<T as Trait<I>>::ApplicationId, GroupWorkerId<T>>,
-       GroupWorkerId = GroupWorkerId<T>,
+       ApplicationIdToWorkerIdMap = BTreeMap<<T as Trait<I>>::ApplicationId, WorkerId<T>>,
+       WorkerId = WorkerId<T>,
        <T as frame_system::Trait>::AccountId,
        Balance = BalanceOf<T>,
     {
@@ -133,13 +133,13 @@ decl_event!(
         /// Emits on setting the group leader.
         /// Params:
         /// - Group worker id.
-        LeaderSet(GroupWorkerId),
+        LeaderSet(WorkerId),
 
         /// Emits on updating the role account of the worker.
         /// Params:
         /// - Id of the worker.
         /// - Role account id of the worker.
-        WorkerRoleAccountUpdated(GroupWorkerId, AccountId),
+        WorkerRoleAccountUpdated(WorkerId, AccountId),
 
         /// Emits on un-setting the leader.
         LeaderUnset(),
@@ -147,35 +147,35 @@ decl_event!(
         /// Emits on exiting the worker.
         /// Params:
         /// - worker id.
-        WorkerExited(GroupWorkerId),
+        WorkerExited(WorkerId),
 
         /// Emits on terminating the worker.
         /// Params:
         /// - worker id.
-        TerminatedWorker(GroupWorkerId),
+        TerminatedWorker(WorkerId),
 
         /// Emits on terminating the leader.
         /// Params:
         /// - leader worker id.
-        TerminatedLeader(GroupWorkerId),
+        TerminatedLeader(WorkerId),
 
         /// Emits on slashing the regular worker/lead stake.
         /// Params:
         /// - regular worker/lead id.
         /// - actual slashed balance.
-        StakeSlashed(GroupWorkerId, Balance),
+        StakeSlashed(WorkerId, Balance),
 
         /// Emits on decreasing the regular worker/lead stake.
         /// Params:
         /// - regular worker/lead id.
         /// - stake delta amount
-        StakeDecreased(GroupWorkerId, Balance),
+        StakeDecreased(WorkerId, Balance),
 
         /// Emits on increasing the regular worker/lead stake.
         /// Params:
         /// - regular worker/lead id.
         /// - stake delta amount
-        StakeIncreased(GroupWorkerId, Balance),
+        StakeIncreased(WorkerId, Balance),
 
         /// Emits on withdrawing the application for the regular worker/lead opening.
         /// Params:
@@ -196,13 +196,13 @@ decl_event!(
         /// Params:
         /// - Id of the worker.
         /// - Reward account id of the worker.
-        WorkerRewardAccountUpdated(GroupWorkerId, AccountId),
+        WorkerRewardAccountUpdated(WorkerId, AccountId),
 
         /// Emits on updating the reward amount of the worker.
         /// Params:
         /// - Id of the worker.
         /// - Reward per block
-        WorkerRewardAmountUpdated(GroupWorkerId, Option<Balance>),
+        WorkerRewardAmountUpdated(WorkerId, Option<Balance>),
 
         /// Emits on updating the status text of the working group.
         /// Params:
@@ -236,14 +236,14 @@ decl_storage! {
         pub NextApplicationId get(fn next_application_id) : T::ApplicationId;
 
         /// Next identifier for a new worker.
-        pub NextWorkerId get(fn next_worker_id) : GroupWorkerId<T>;
+        pub NextWorkerId get(fn next_worker_id) : WorkerId<T>;
 
         /// Maps identifier to corresponding worker.
         pub WorkerById get(fn worker_by_id) : map hasher(blake2_128_concat)
-            GroupWorkerId<T> => GroupWorker<T>;
+            WorkerId<T> => GroupWorker<T>;
 
         /// Current group lead.
-        pub CurrentLead get(fn current_lead) : Option<GroupWorkerId<T>>;
+        pub CurrentLead get(fn current_lead) : Option<WorkerId<T>>;
 
         /// Budget for the working group.
         pub Budget get(fn budget) : BalanceOf<T>;
@@ -287,7 +287,7 @@ decl_module! {
         pub fn add_opening(
             origin,
             description: Vec<u8>,
-            opening_type: JobOpeningType,
+            opening_type: OpeningType,
             stake_policy: Option<StakePolicy<T::BlockNumber, BalanceOf<T>>>,
             reward_policy: Option<RewardPolicy<BalanceOf<T>>>
         ){
@@ -406,14 +406,14 @@ decl_module! {
             );
 
             // Cannot hire a lead when another leader exists.
-            if matches!(opening.opening_type, JobOpeningType::Leader) {
+            if matches!(opening.opening_type, OpeningType::Leader) {
                 ensure!(!<CurrentLead<T,I>>::exists(), Error::<T, I>::CannotHireLeaderWhenLeaderExists);
             }
 
             let checked_applications_info = checks::ensure_succesful_applications_exist::<T, I>(&successful_application_ids)?;
 
             // Check for a single application for a leader.
-            if matches!(opening.opening_type, JobOpeningType::Leader) {
+            if matches!(opening.opening_type, OpeningType::Leader) {
                 ensure!(successful_application_ids.len() == 1, Error::<T, I>::CannotHireMultipleLeaders);
             }
 
@@ -438,7 +438,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_role_account(
             origin,
-            worker_id: GroupWorkerId<T>,
+            worker_id: WorkerId<T>,
             new_role_account_id: T::AccountId
         ) {
             // Ensuring worker actually exists
@@ -467,7 +467,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn leave_role(
             origin,
-            worker_id: GroupWorkerId<T>,
+            worker_id: WorkerId<T>,
         ) {
             // Ensure there is a signer which matches role account of worker corresponding to provided id.
             let worker = checks::ensure_worker_signed::<T, I>(origin, &worker_id)?;
@@ -493,7 +493,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn terminate_role(
             origin,
-            worker_id: GroupWorkerId<T>,
+            worker_id: WorkerId<T>,
             penalty: Option<Penalty<BalanceOf<T>>>,
         ) {
             // Ensure lead is set or it is the council terminating the leader.
@@ -534,7 +534,7 @@ decl_module! {
         /// If slashing balance greater than the existing stake - stake is slashed to zero.
         /// Requires signed leader origin or the root (to slash the leader stake).
         #[weight = 10_000_000] // TODO: adjust weight
-        pub fn slash_stake(origin, worker_id: GroupWorkerId<T>, penalty: Penalty<BalanceOf<T>>) {
+        pub fn slash_stake(origin, worker_id: WorkerId<T>, penalty: Penalty<BalanceOf<T>>) {
             // Ensure lead is set or it is the council slashing the leader.
             checks::ensure_origin_for_worker_operation::<T,I>(origin, worker_id)?;
 
@@ -566,7 +566,7 @@ decl_module! {
         /// Accepts the stake amount to decrease.
         /// Requires signed leader origin or the root (to decrease the leader stake).
         #[weight = 10_000_000] // TODO: adjust weight
-        pub fn decrease_stake(origin, worker_id: GroupWorkerId<T>, stake_balance_delta: BalanceOf<T>) {
+        pub fn decrease_stake(origin, worker_id: WorkerId<T>, stake_balance_delta: BalanceOf<T>) {
             // Ensure lead is set or it is the council decreasing the leader's stake.
             checks::ensure_origin_for_worker_operation::<T,I>(origin, worker_id)?;
 
@@ -617,7 +617,7 @@ decl_module! {
         /// Increases the regular worker/lead stake, demands a worker origin.
         /// Locks tokens from the worker staking_account_id equal to new stake. No limits on the stake.
         #[weight = 10_000_000] // TODO: adjust weight
-        pub fn increase_stake(origin, worker_id: GroupWorkerId<T>, stake_balance_delta: BalanceOf<T>) {
+        pub fn increase_stake(origin, worker_id: WorkerId<T>, stake_balance_delta: BalanceOf<T>) {
             // Checks worker origin and worker existence.
             let worker = checks::ensure_worker_signed::<T, I>(origin, &worker_id)?;
 
@@ -737,7 +737,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_reward_account(
             origin,
-            worker_id: GroupWorkerId<T>,
+            worker_id: WorkerId<T>,
             new_reward_account_id: T::AccountId
         ) {
             // Ensure there is a signer which matches role account of worker corresponding to provided id.
@@ -764,7 +764,7 @@ decl_module! {
         #[weight = 10_000_000] // TODO: adjust weight
         pub fn update_reward_amount(
             origin,
-            worker_id: GroupWorkerId<T>,
+            worker_id: WorkerId<T>,
             reward_per_block: Option<BalanceOf<T>>
         ) {
             // Ensure lead is set or it is the council setting the leader's reward.
@@ -870,7 +870,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
     fn fulfill_successful_applications(
         opening: &JobOpening<T::BlockNumber, BalanceOf<T>>,
         successful_applications_info: Vec<ApplicationInfo<T, I>>,
-    ) -> BTreeMap<T::ApplicationId, GroupWorkerId<T>> {
+    ) -> BTreeMap<T::ApplicationId, WorkerId<T>> {
         let mut application_id_to_worker_id = BTreeMap::new();
 
         successful_applications_info
@@ -881,7 +881,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
                 application_id_to_worker_id.insert(application_info.application_id, new_worker_id);
 
                 // Sets a leader on successful opening when opening is for leader.
-                if matches!(opening.opening_type, JobOpeningType::Leader) {
+                if matches!(opening.opening_type, OpeningType::Leader) {
                     Self::set_lead(new_worker_id);
                 }
             });
@@ -893,7 +893,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
     fn create_worker_by_application(
         opening: &JobOpening<T::BlockNumber, BalanceOf<T>>,
         application_info: &ApplicationInfo<T, I>,
-    ) -> GroupWorkerId<T> {
+    ) -> WorkerId<T> {
         // Get worker id.
         let new_worker_id = <NextWorkerId<T, I>>::get();
 
@@ -916,7 +916,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
         Self::increase_active_worker_counter();
 
         // Update the next worker id.
-        <NextWorkerId<T, I>>::mutate(|id| *id += <GroupWorkerId<T> as One>::one());
+        <NextWorkerId<T, I>>::mutate(|id| *id += <WorkerId<T> as One>::one());
 
         // Remove an application.
         <ApplicationById<T, I>>::remove(application_info.application_id);
@@ -925,7 +925,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
     }
 
     // Set worker id as a leader id.
-    pub(crate) fn set_lead(worker_id: GroupWorkerId<T>) {
+    pub(crate) fn set_lead(worker_id: WorkerId<T>) {
         // Update current lead
         <CurrentLead<T, I>>::put(worker_id);
 
@@ -945,7 +945,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
 
     // Fires the worker. Unsets the leader if necessary. Decreases active worker counter.
     // Deposits an event.
-    fn remove_worker(worker_id: &GroupWorkerId<T>, worker: &GroupWorker<T>, event: Event<T, I>) {
+    fn remove_worker(worker_id: &WorkerId<T>, worker: &GroupWorker<T>, event: Event<T, I>) {
         // Unset lead if the leader is leaving.
         let leader_worker_id = <CurrentLead<T, I>>::get();
         if let Some(leader_worker_id) = leader_worker_id {
@@ -969,7 +969,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
 
     // Slash the stake.
     fn slash(
-        worker_id: GroupWorkerId<T>,
+        worker_id: WorkerId<T>,
         staking_account_id: &T::AccountId,
         balance: Option<BalanceOf<T>>,
     ) {
@@ -978,7 +978,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
     }
 
     // Reward a worker using reward presets and working group budget.
-    fn reward_worker(worker_id: &GroupWorkerId<T>, worker: &GroupWorker<T>) {
+    fn reward_worker(worker_id: &WorkerId<T>, worker: &GroupWorker<T>) {
         // If reward period is not set.
         let mut rewarding_period: u32 = T::RewardPeriod::get();
         if rewarding_period == 0u32 {
@@ -1023,7 +1023,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
     }
 
     // Tries to pay missed reward if the reward is enabled for worker and there is enough of group budget.
-    fn try_to_pay_missed_reward(worker_id: &GroupWorkerId<T>, worker: &GroupWorker<T>) {
+    fn try_to_pay_missed_reward(worker_id: &WorkerId<T>, worker: &GroupWorker<T>) {
         if let Some(missed_reward) = worker.missed_reward {
             let (could_be_paid_reward, insufficient_amount) =
                 Self::calculate_possible_payment(missed_reward);
@@ -1048,7 +1048,7 @@ impl<T: Trait<I>, I: Instance> Module<T, I> {
 
     // Saves missed reward for a worker.
     fn save_missed_reward(
-        worker_id: &GroupWorkerId<T>,
+        worker_id: &WorkerId<T>,
         worker: &GroupWorker<T>,
         reward: BalanceOf<T>,
     ) {

+ 7 - 7
runtime-modules/working-group/src/tests/fixtures.rs

@@ -9,7 +9,7 @@ use super::hiring_workflow::HiringWorkflow;
 use super::mock::{Balances, LockId, Membership, System, Test, TestEvent, TestWorkingGroup};
 use crate::types::StakeParameters;
 use crate::{
-    ApplyOnOpeningParameters, DefaultInstance, JobApplication, JobOpening, JobOpeningType, Penalty,
+    ApplyOnOpeningParameters, DefaultInstance, JobApplication, JobOpening, OpeningType, Penalty,
     RawEvent, RewardPolicy, StakePolicy, GroupWorker,
 };
 
@@ -37,7 +37,7 @@ impl EventFixture {
 pub struct AddOpeningFixture {
     origin: RawOrigin<u64>,
     description: Vec<u8>,
-    opening_type: JobOpeningType,
+    opening_type: OpeningType,
     starting_block: u64,
     stake_policy: Option<StakePolicy<u64, u64>>,
     reward_policy: Option<RewardPolicy<u64>>,
@@ -48,7 +48,7 @@ impl Default for AddOpeningFixture {
         Self {
             origin: RawOrigin::Signed(1),
             description: b"human_text".to_vec(),
-            opening_type: JobOpeningType::Regular,
+            opening_type: OpeningType::Regular,
             starting_block: 0,
             stake_policy: None,
             reward_policy: None,
@@ -100,7 +100,7 @@ impl AddOpeningFixture {
         Ok(saved_opening_next_id)
     }
 
-    pub fn with_opening_type(self, opening_type: JobOpeningType) -> Self {
+    pub fn with_opening_type(self, opening_type: OpeningType) -> Self {
         Self {
             opening_type,
             ..self
@@ -410,7 +410,7 @@ impl HireLeadFixture {
     pub fn hire_lead(self) -> u64 {
         HiringWorkflow::default()
             .with_setup_environment(self.setup_environment)
-            .with_opening_type(JobOpeningType::Leader)
+            .with_opening_type(OpeningType::Leader)
             .with_stake_policy(self.stake_policy)
             .with_reward_policy(self.reward_policy)
             .add_application(b"leader".to_vec())
@@ -421,7 +421,7 @@ impl HireLeadFixture {
     pub fn expect(self, error: DispatchError) {
         HiringWorkflow::default()
             .with_setup_environment(self.setup_environment)
-            .with_opening_type(JobOpeningType::Leader)
+            .with_opening_type(OpeningType::Leader)
             .with_stake_policy(self.stake_policy)
             .with_reward_policy(self.reward_policy)
             .add_application(b"leader".to_vec())
@@ -463,7 +463,7 @@ impl HireRegularWorkerFixture {
     pub fn hire(self) -> u64 {
         HiringWorkflow::default()
             .with_setup_environment(self.setup_environment)
-            .with_opening_type(JobOpeningType::Regular)
+            .with_opening_type(OpeningType::Regular)
             .with_stake_policy(self.stake_policy)
             .with_reward_policy(self.reward_policy)
             .add_application(b"worker".to_vec())

+ 7 - 7
runtime-modules/working-group/src/tests/hiring_workflow.rs

@@ -6,7 +6,7 @@ use crate::tests::fixtures::{
 };
 use crate::tests::mock::TestWorkingGroup;
 use crate::types::StakeParameters;
-use crate::{JobOpeningType, RewardPolicy, StakePolicy};
+use crate::{OpeningType, RewardPolicy, StakePolicy};
 
 #[derive(Clone)]
 struct HiringWorkflowApplication {
@@ -17,7 +17,7 @@ struct HiringWorkflowApplication {
 }
 
 pub struct HiringWorkflow {
-    opening_type: JobOpeningType,
+    opening_type: OpeningType,
     expected_result: DispatchResult,
     stake_policy: Option<StakePolicy<u64, u64>>,
     reward_policy: Option<RewardPolicy<u64>>,
@@ -28,7 +28,7 @@ pub struct HiringWorkflow {
 impl Default for HiringWorkflow {
     fn default() -> Self {
         Self {
-            opening_type: JobOpeningType::Regular,
+            opening_type: OpeningType::Regular,
             expected_result: Ok(()),
             stake_policy: None,
             reward_policy: None,
@@ -67,7 +67,7 @@ impl HiringWorkflow {
         }
     }
 
-    pub fn with_opening_type(self, opening_type: JobOpeningType) -> Self {
+    pub fn with_opening_type(self, opening_type: OpeningType) -> Self {
         Self {
             opening_type,
             ..self
@@ -115,7 +115,7 @@ impl HiringWorkflow {
     }
 
     fn setup_environment(&self) {
-        if matches!(self.opening_type, JobOpeningType::Regular) {
+        if matches!(self.opening_type, OpeningType::Regular) {
             HireLeadFixture::default().hire_lead();
         } else {
             setup_members(6);
@@ -138,8 +138,8 @@ impl HiringWorkflow {
 
     fn fill_worker_position(&self) -> Result<u64, DispatchError> {
         let origin = match self.opening_type {
-            JobOpeningType::Leader => RawOrigin::Root,
-            JobOpeningType::Regular => {
+            OpeningType::Leader => RawOrigin::Root,
+            OpeningType::Regular => {
                 let leader_worker_id = TestWorkingGroup::current_lead().unwrap();
                 let leader = TestWorkingGroup::worker_by_id(leader_worker_id);
                 let lead_account_id = leader.role_account_id;

+ 5 - 5
runtime-modules/working-group/src/tests/mod.rs

@@ -18,7 +18,7 @@ use crate::tests::mock::{
 };
 use crate::types::StakeParameters;
 use crate::{
-    DefaultInstance, Error, JobOpeningType, Penalty, RawEvent, RewardPolicy, StakePolicy,
+    DefaultInstance, Error, OpeningType, Penalty, RawEvent, RewardPolicy, StakePolicy,
     GroupWorker,
 };
 use fixtures::{
@@ -61,7 +61,7 @@ fn add_opening_succeeded() {
 fn add_opening_fails_with_bad_origin() {
     build_test_externalities().execute_with(|| {
         let add_opening_fixture = AddOpeningFixture::default()
-            .with_opening_type(JobOpeningType::Leader)
+            .with_opening_type(OpeningType::Leader)
             .with_origin(RawOrigin::None);
 
         add_opening_fixture.call_and_assert(Err(DispatchError::BadOrigin));
@@ -128,7 +128,7 @@ fn add_opening_fails_with_incorrect_unstaking_period() {
 fn add_leader_opening_fails_with_incorrect_origin_for_opening_type() {
     build_test_externalities().execute_with(|| {
         let add_opening_fixture =
-            AddOpeningFixture::default().with_opening_type(JobOpeningType::Leader);
+            AddOpeningFixture::default().with_opening_type(OpeningType::Leader);
 
         add_opening_fixture.call_and_assert(Err(DispatchError::BadOrigin));
     });
@@ -409,7 +409,7 @@ fn cannot_hire_muptiple_leaders() {
     build_test_externalities().execute_with(|| {
         HiringWorkflow::default()
             .with_setup_environment(true)
-            .with_opening_type(JobOpeningType::Leader)
+            .with_opening_type(OpeningType::Leader)
             .add_default_application()
             .add_application_full(b"leader2".to_vec(), RawOrigin::Signed(2), 2, Some(2))
             .expect(Err(
@@ -1120,7 +1120,7 @@ fn leave_worker_works_immediately_stake_is_zero() {
 
         let worker_id = HiringWorkflow::default()
             .with_setup_environment(true)
-            .with_opening_type(JobOpeningType::Regular)
+            .with_opening_type(OpeningType::Regular)
             //    .with_stake_policy(stake_policy.clone())
             .add_application_full(b"worker".to_vec(), RawOrigin::Signed(1), 1, None)
             .execute()

+ 13 - 7
runtime-modules/working-group/src/types.rs

@@ -13,7 +13,13 @@ pub type JobApplication<T> = Application<<T as frame_system::Trait>::AccountId,
 pub type MemberId<T> = <T as membership::Trait>::MemberId;
 
 /// Type identifier for a worker role, which must be same as membership actor identifier.
-pub type GroupWorkerId<T> = <T as membership::Trait>::ActorId;
+pub type WorkerId<T> = <T as membership::Trait>::ActorId;
+
+/// Type alias for an application id.
+pub type ApplicationId<T> = <T as crate::Trait>::ApplicationId;
+
+/// Type alias for an opening id.
+pub type OpeningId<T> = <T as crate::Trait>::OpeningId;
 
 // ApplicationId - JobApplication - helper struct.
 pub(crate) struct ApplicationInfo<T: crate::Trait<I>, I: crate::Instance> {
@@ -23,14 +29,14 @@ pub(crate) struct ApplicationInfo<T: crate::Trait<I>, I: crate::Instance> {
 
 // WorkerId - GroupWorker - helper struct.
 pub(crate) struct WorkerInfo<T: membership::Trait + frame_system::Trait + balances::Trait> {
-    pub worker_id: GroupWorkerId<T>,
+    pub worker_id: WorkerId<T>,
     pub worker: GroupWorker<T>,
 }
 
 impl<T: membership::Trait + frame_system::Trait + balances::Trait>
-    From<(GroupWorkerId<T>, GroupWorker<T>)> for WorkerInfo<T>
+    From<(WorkerId<T>, GroupWorker<T>)> for WorkerInfo<T>
 {
-    fn from((worker_id, worker): (GroupWorkerId<T>, GroupWorker<T>)) -> Self {
+    fn from((worker_id, worker): (WorkerId<T>, GroupWorker<T>)) -> Self {
         WorkerInfo { worker_id, worker }
     }
 }
@@ -52,7 +58,7 @@ pub type BalanceOf<T> = <T as balances::Trait>::Balance;
 #[derive(Encode, Decode, Debug, Default, Clone, PartialEq, Eq)]
 pub struct JobOpening<BlockNumber: Ord, Balance> {
     /// Defines opening type: Leader or worker.
-    pub opening_type: JobOpeningType,
+    pub opening_type: OpeningType,
 
     /// Block at which opening was added.
     pub created: BlockNumber,
@@ -70,7 +76,7 @@ pub struct JobOpening<BlockNumber: Ord, Balance> {
 /// Defines type of the opening: regular working group fellow or group leader.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Debug, Clone, PartialEq, Eq, Copy)]
-pub enum JobOpeningType {
+pub enum OpeningType {
     /// Group leader.
     Leader,
 
@@ -80,7 +86,7 @@ pub enum JobOpeningType {
 
 /// Must be default constructible because it indirectly is a value in a storage map.
 /// ***SHOULD NEVER ACTUALLY GET CALLED, IS REQUIRED TO DUE BAD STORAGE MODEL IN SUBSTRATE***
-impl Default for JobOpeningType {
+impl Default for OpeningType {
     fn default() -> Self {
         Self::Regular
     }