|
@@ -7,60 +7,34 @@ import { RewardRelationshipId } from '../recurring-rewards';
|
|
import { StakeId } from '../stake';
|
|
import { StakeId } from '../stake';
|
|
import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring';
|
|
import { ApplicationId, OpeningId, ApplicationRationingPolicy, StakingPolicy } from '../hiring';
|
|
|
|
|
|
-export type ILead = {
|
|
|
|
- member_id: MemberId,
|
|
|
|
- role_account_id: AccountId
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-// This type is also defined in /content-workig-group (and those are incosistent), but here
|
|
|
|
-// it is beeing registered as "LeadOf" (which is an alias used by the runtime working-group module),
|
|
|
|
-// so it shouldn't cause any conflicts)
|
|
|
|
-export class Lead extends JoyStruct<ILead> {
|
|
|
|
- constructor (value?: ILead) {
|
|
|
|
- super({
|
|
|
|
- member_id: MemberId,
|
|
|
|
- role_account_id: "AccountId"
|
|
|
|
- }, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- get member_id(): MemberId {
|
|
|
|
- return this.getField<MemberId>('member_id')
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- get role_account_id(): AccountId {
|
|
|
|
- return this.getField<AccountId>('role_account_id')
|
|
|
|
- }
|
|
|
|
-};
|
|
|
|
-
|
|
|
|
-export class WorkerApplicationId extends ApplicationId { };
|
|
|
|
-
|
|
|
|
-export class WorkerOpeningId extends OpeningId { };
|
|
|
|
-
|
|
|
|
export class RationaleText extends Bytes { };
|
|
export class RationaleText extends Bytes { };
|
|
|
|
|
|
-export type IWorkerApplication = {
|
|
|
|
- role_account: AccountId,
|
|
|
|
- worker_opening_id: WorkerOpeningId,
|
|
|
|
|
|
+export type IApplication = {
|
|
|
|
+ role_account_id: AccountId,
|
|
|
|
+ opening_id: OpeningId,
|
|
member_id: MemberId,
|
|
member_id: MemberId,
|
|
application_id: ApplicationId
|
|
application_id: ApplicationId
|
|
};
|
|
};
|
|
|
|
|
|
-export class WorkerApplication extends JoyStruct<IWorkerApplication> {
|
|
|
|
- constructor (value?: IWorkerApplication) {
|
|
|
|
|
|
+// This type is also defined in /hiring (and those are incosistent), but here
|
|
|
|
+// it is beeing registered as "ApplicationOf" (which is an alias used by the runtime working-group module),
|
|
|
|
+// so it shouldn't cause any conflicts
|
|
|
|
+export class Application extends JoyStruct<IApplication> {
|
|
|
|
+ constructor (value?: IApplication) {
|
|
super({
|
|
super({
|
|
- role_account: "AccountId",
|
|
|
|
- worker_opening_id: WorkerOpeningId,
|
|
|
|
|
|
+ role_account_id: "AccountId",
|
|
|
|
+ opening_id: OpeningId,
|
|
member_id: MemberId,
|
|
member_id: MemberId,
|
|
application_id: ApplicationId
|
|
application_id: ApplicationId
|
|
}, value);
|
|
}, value);
|
|
}
|
|
}
|
|
|
|
|
|
- get role_account(): AccountId {
|
|
|
|
- return this.getField<AccountId>('role_account');
|
|
|
|
|
|
+ get role_account_id(): AccountId {
|
|
|
|
+ return this.getField<AccountId>('role_account_id');
|
|
}
|
|
}
|
|
|
|
|
|
- get worker_opening_id(): WorkerOpeningId {
|
|
|
|
- return this.getField<WorkerOpeningId>('worker_opening_id');
|
|
|
|
|
|
+ get opening_id(): OpeningId {
|
|
|
|
+ return this.getField<OpeningId>('opening_id');
|
|
}
|
|
}
|
|
|
|
|
|
get member_id(): MemberId {
|
|
get member_id(): MemberId {
|
|
@@ -76,19 +50,19 @@ export class WorkerId extends ActorId { };
|
|
|
|
|
|
export class StorageProviderId extends WorkerId { };
|
|
export class StorageProviderId extends WorkerId { };
|
|
|
|
|
|
-export class WorkerApplicationIdSet extends BTreeSet.with(WorkerApplicationId) { };
|
|
|
|
|
|
+export class ApplicationIdSet extends BTreeSet.with(ApplicationId) { };
|
|
|
|
|
|
-export class WorkerApplicationIdToWorkerIdMap extends BTreeMap.with(WorkerApplicationId, WorkerId) { };
|
|
|
|
|
|
+export class ApplicationIdToWorkerIdMap extends BTreeMap.with(ApplicationId, WorkerId) { };
|
|
|
|
|
|
|
|
|
|
-export type IWorkerRoleStakeProfile = {
|
|
|
|
|
|
+export type IRoleStakeProfile = {
|
|
stake_id: StakeId,
|
|
stake_id: StakeId,
|
|
termination_unstaking_period: Option<BlockNumber>,
|
|
termination_unstaking_period: Option<BlockNumber>,
|
|
exit_unstaking_period: Option<BlockNumber>,
|
|
exit_unstaking_period: Option<BlockNumber>,
|
|
};
|
|
};
|
|
|
|
|
|
-export class WorkerRoleStakeProfile extends JoyStruct<IWorkerRoleStakeProfile> {
|
|
|
|
- constructor (value?: IWorkerRoleStakeProfile) {
|
|
|
|
|
|
+export class RoleStakeProfile extends JoyStruct<IRoleStakeProfile> {
|
|
|
|
+ constructor (value?: IRoleStakeProfile) {
|
|
super({
|
|
super({
|
|
stake_id: StakeId,
|
|
stake_id: StakeId,
|
|
termination_unstaking_period: "Option<BlockNumber>",
|
|
termination_unstaking_period: "Option<BlockNumber>",
|
|
@@ -111,18 +85,18 @@ export class WorkerRoleStakeProfile extends JoyStruct<IWorkerRoleStakeProfile> {
|
|
|
|
|
|
export type IWorker = {
|
|
export type IWorker = {
|
|
member_id: MemberId,
|
|
member_id: MemberId,
|
|
- role_account: AccountId,
|
|
|
|
|
|
+ role_account_id: AccountId,
|
|
reward_relationship: Option<RewardRelationshipId>,
|
|
reward_relationship: Option<RewardRelationshipId>,
|
|
- role_stake_profile: Option<WorkerRoleStakeProfile>,
|
|
|
|
|
|
+ role_stake_profile: Option<RoleStakeProfile>,
|
|
}
|
|
}
|
|
|
|
|
|
export class Worker extends JoyStruct<IWorker> {
|
|
export class Worker extends JoyStruct<IWorker> {
|
|
constructor (value?: IWorker) {
|
|
constructor (value?: IWorker) {
|
|
super({
|
|
super({
|
|
member_id: MemberId,
|
|
member_id: MemberId,
|
|
- role_account: "AccountId",
|
|
|
|
|
|
+ role_account_id: "AccountId",
|
|
reward_relationship: Option.with(RewardRelationshipId),
|
|
reward_relationship: Option.with(RewardRelationshipId),
|
|
- role_stake_profile: Option.with(WorkerRoleStakeProfile),
|
|
|
|
|
|
+ role_stake_profile: Option.with(RoleStakeProfile),
|
|
}, value);
|
|
}, value);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -130,16 +104,16 @@ export class Worker extends JoyStruct<IWorker> {
|
|
return this.getField<MemberId>('member_id');
|
|
return this.getField<MemberId>('member_id');
|
|
}
|
|
}
|
|
|
|
|
|
- get role_account(): AccountId {
|
|
|
|
- return this.getField<AccountId>('role_account');
|
|
|
|
|
|
+ get role_account_id(): AccountId {
|
|
|
|
+ return this.getField<AccountId>('role_account_id');
|
|
}
|
|
}
|
|
|
|
|
|
get reward_relationship(): Option<RewardRelationshipId> {
|
|
get reward_relationship(): Option<RewardRelationshipId> {
|
|
return this.getField<Option<RewardRelationshipId>>('reward_relationship');
|
|
return this.getField<Option<RewardRelationshipId>>('reward_relationship');
|
|
}
|
|
}
|
|
|
|
|
|
- get role_stake_profile(): Option<WorkerRoleStakeProfile> {
|
|
|
|
- return this.getField<Option<WorkerRoleStakeProfile>>('role_stake_profile');
|
|
|
|
|
|
+ get role_stake_profile(): Option<RoleStakeProfile> {
|
|
|
|
+ return this.getField<Option<RoleStakeProfile>>('role_stake_profile');
|
|
}
|
|
}
|
|
|
|
|
|
get is_active(): boolean {
|
|
get is_active(): boolean {
|
|
@@ -185,20 +159,20 @@ export type IWorkingGroupOpeningPolicyCommitment = {
|
|
fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>,
|
|
fill_opening_successful_applicant_application_stake_unstaking_period: Option<BlockNumber>,
|
|
fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>,
|
|
fill_opening_failed_applicant_application_stake_unstaking_period: Option<BlockNumber>,
|
|
fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>,
|
|
fill_opening_failed_applicant_role_stake_unstaking_period: Option<BlockNumber>,
|
|
- terminate_worker_application_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
- terminate_worker_role_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
- exit_worker_role_application_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
- exit_worker_role_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
|
|
+ terminate_application_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
+ terminate_role_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
+ exit_role_application_stake_unstaking_period: Option<BlockNumber>,
|
|
|
|
+ exit_role_stake_unstaking_period: Option<BlockNumber>,
|
|
};
|
|
};
|
|
|
|
|
|
// This type represents OpeningPolicyCommitment defined inside the runtime's working-grpup module.
|
|
// This type represents OpeningPolicyCommitment defined inside the runtime's working-grpup module.
|
|
// The only difference between this and the one defined in /content-working-group is in the names of some fields.
|
|
// The only difference between this and the one defined in /content-working-group is in the names of some fields.
|
|
//
|
|
//
|
|
// There is also a minor issue here:
|
|
// There is also a minor issue here:
|
|
-// Because api metadata still says that ie. the "commitment" argument of "storageWorkingGroup.addWorkerOpening" extrinsic
|
|
|
|
|
|
+// Because api metadata still says that ie. the "commitment" argument of "storageWorkingGroup.addOpening" extrinsic
|
|
// is of type "OpeningPolicyCommitment" (not the "WorkingGroupOpeningPolicyCommitment" defined here), the CWG's OpeningPolicyCommitment
|
|
// is of type "OpeningPolicyCommitment" (not the "WorkingGroupOpeningPolicyCommitment" defined here), the CWG's OpeningPolicyCommitment
|
|
// type is used when sending this extrinsic (it has "terminate_curator_role_stake_unstaking_period" field insted
|
|
// type is used when sending this extrinsic (it has "terminate_curator_role_stake_unstaking_period" field insted
|
|
-// of "terminate_worker_role_stake_unstaking_period" etc.).
|
|
|
|
|
|
+// of "terminate_role_stake_unstaking_period" etc.).
|
|
// Since both those types are basically the same structs (only filed names are different) nothing seems to break, but it's
|
|
// Since both those types are basically the same structs (only filed names are different) nothing seems to break, but it's
|
|
// very fragile atm and any change to this type in working-group module could result in "unsolvable" inconsistencies
|
|
// very fragile atm and any change to this type in working-group module could result in "unsolvable" inconsistencies
|
|
// (this won't be an issue after CWG gets refactored to use the working-grpup module too)
|
|
// (this won't be an issue after CWG gets refactored to use the working-grpup module too)
|
|
@@ -213,10 +187,10 @@ export class WorkingGroupOpeningPolicyCommitment extends JoyStruct<IWorkingGroup
|
|
fill_opening_successful_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
fill_opening_successful_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
fill_opening_failed_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
fill_opening_failed_applicant_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
fill_opening_failed_applicant_role_stake_unstaking_period: "Option<BlockNumber>",
|
|
fill_opening_failed_applicant_role_stake_unstaking_period: "Option<BlockNumber>",
|
|
- terminate_worker_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
- terminate_worker_role_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
- exit_worker_role_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
- exit_worker_role_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
|
|
+ terminate_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
+ terminate_role_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
+ exit_role_application_stake_unstaking_period: "Option<BlockNumber>",
|
|
|
|
+ exit_role_stake_unstaking_period: "Option<BlockNumber>",
|
|
}, value);
|
|
}, value);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -252,67 +226,91 @@ export class WorkingGroupOpeningPolicyCommitment extends JoyStruct<IWorkingGroup
|
|
return this.getField<Option<BlockNumber>>('fill_opening_failed_applicant_role_stake_unstaking_period')
|
|
return this.getField<Option<BlockNumber>>('fill_opening_failed_applicant_role_stake_unstaking_period')
|
|
}
|
|
}
|
|
|
|
|
|
- get terminate_worker_application_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
- return this.getField<Option<BlockNumber>>('terminate_worker_application_stake_unstaking_period')
|
|
|
|
|
|
+ get terminate_application_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
+ return this.getField<Option<BlockNumber>>('terminate_application_stake_unstaking_period')
|
|
}
|
|
}
|
|
|
|
|
|
- get terminate_worker_role_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
- return this.getField<Option<BlockNumber>>('terminate_worker_role_stake_unstaking_period')
|
|
|
|
|
|
+ get terminate_role_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
+ return this.getField<Option<BlockNumber>>('terminate_role_stake_unstaking_period')
|
|
}
|
|
}
|
|
|
|
|
|
- get exit_worker_role_application_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
- return this.getField<Option<BlockNumber>>('exit_worker_role_application_stake_unstaking_period')
|
|
|
|
|
|
+ get exit_role_application_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
+ return this.getField<Option<BlockNumber>>('exit_role_application_stake_unstaking_period')
|
|
}
|
|
}
|
|
|
|
|
|
- get exit_worker_role_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
- return this.getField<Option<BlockNumber>>('exit_worker_role_stake_unstaking_period')
|
|
|
|
|
|
+ get exit_role_stake_unstaking_period(): Option<BlockNumber> {
|
|
|
|
+ return this.getField<Option<BlockNumber>>('exit_role_stake_unstaking_period')
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
-export type IWorkerOpening = {
|
|
|
|
- opening_id: OpeningId,
|
|
|
|
- worker_applications: BTreeSet<WorkerApplicationId>,
|
|
|
|
|
|
+export enum OpeningTypeKeys {
|
|
|
|
+ Leader = 'Leader',
|
|
|
|
+ Worker = 'Worker'
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export class OpeningType extends Enum {
|
|
|
|
+ constructor (value?: any, index?: number) {
|
|
|
|
+ super(
|
|
|
|
+ {
|
|
|
|
+ Leader: Null,
|
|
|
|
+ Worker: Null
|
|
|
|
+ },
|
|
|
|
+ value, index
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+export type IOpening = {
|
|
|
|
+ hiring_opening_id: OpeningId,
|
|
|
|
+ applications: BTreeSet<ApplicationId>,
|
|
policy_commitment: WorkingGroupOpeningPolicyCommitment,
|
|
policy_commitment: WorkingGroupOpeningPolicyCommitment,
|
|
|
|
+ opening_type: OpeningType
|
|
}
|
|
}
|
|
|
|
|
|
-export class WorkerOpening extends JoyStruct<IWorkerOpening> {
|
|
|
|
|
|
+// This type is also defined in /hiring (and those are incosistent), but here
|
|
|
|
+// it is beeing registered as "OpeningOf" (which is an alias used by the runtime working-group module),
|
|
|
|
+// so it shouldn't cause any conflicts
|
|
|
|
+export class Opening extends JoyStruct<IOpening> {
|
|
constructor (value?: IWorker) {
|
|
constructor (value?: IWorker) {
|
|
super({
|
|
super({
|
|
- opening_id: OpeningId,
|
|
|
|
- worker_applications: BTreeSet.with(WorkerApplicationId),
|
|
|
|
|
|
+ hiring_opening_id: OpeningId,
|
|
|
|
+ applications: BTreeSet.with(ApplicationId),
|
|
policy_commitment: WorkingGroupOpeningPolicyCommitment,
|
|
policy_commitment: WorkingGroupOpeningPolicyCommitment,
|
|
|
|
+ opening_type: OpeningType
|
|
}, value);
|
|
}, value);
|
|
}
|
|
}
|
|
|
|
|
|
- get opening_id(): OpeningId {
|
|
|
|
- return this.getField<OpeningId>('opening_id');
|
|
|
|
|
|
+ get hiring_opening_id(): OpeningId {
|
|
|
|
+ return this.getField<OpeningId>('hiring_opening_id');
|
|
}
|
|
}
|
|
|
|
|
|
- get worker_applications(): BTreeSet<WorkerApplicationId> {
|
|
|
|
- return this.getField<BTreeSet<WorkerApplicationId>>('worker_applications');
|
|
|
|
|
|
+ get applications(): BTreeSet<ApplicationId> {
|
|
|
|
+ return this.getField<BTreeSet<ApplicationId>>('applications');
|
|
}
|
|
}
|
|
|
|
|
|
get policy_commitment(): WorkingGroupOpeningPolicyCommitment {
|
|
get policy_commitment(): WorkingGroupOpeningPolicyCommitment {
|
|
return this.getField<WorkingGroupOpeningPolicyCommitment>('policy_commitment');
|
|
return this.getField<WorkingGroupOpeningPolicyCommitment>('policy_commitment');
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ get opening_type(): OpeningType {
|
|
|
|
+ return this.getField<OpeningType>('opening_type');
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
export function registerWorkingGroupTypes() {
|
|
export function registerWorkingGroupTypes() {
|
|
try {
|
|
try {
|
|
getTypeRegistry().register({
|
|
getTypeRegistry().register({
|
|
- // Note that it actually HAS TO be "LeadOf" in the runtime,
|
|
|
|
- // otherwise there would be conflicts with the current content-workig-group module
|
|
|
|
- LeadOf: Lead,
|
|
|
|
RationaleText,
|
|
RationaleText,
|
|
- WorkerApplication,
|
|
|
|
- WorkerApplicationId,
|
|
|
|
- WorkerApplicationIdSet,
|
|
|
|
- WorkerApplicationIdToWorkerIdMap,
|
|
|
|
|
|
+ ApplicationOf: Application,
|
|
|
|
+ ApplicationIdSet,
|
|
|
|
+ ApplicationIdToWorkerIdMap,
|
|
WorkerId,
|
|
WorkerId,
|
|
WorkerOf: Worker,
|
|
WorkerOf: Worker,
|
|
- WorkerOpening,
|
|
|
|
- WorkerOpeningId,
|
|
|
|
- StorageProviderId
|
|
|
|
|
|
+ OpeningOf: Opening,
|
|
|
|
+ StorageProviderId,
|
|
|
|
+ OpeningType,
|
|
|
|
+ /// Alias used by the runtime working-group module
|
|
|
|
+ HiringApplicationId: ApplicationId
|
|
});
|
|
});
|
|
} catch (err) {
|
|
} catch (err) {
|
|
console.error('Failed to register custom types of working-group module', err);
|
|
console.error('Failed to register custom types of working-group module', err);
|