Browse Source

Updates following runtime renames

Leszek Wiesner 4 years ago
parent
commit
a987d6af6a

+ 36 - 36
cli/src/Api.ts

@@ -24,10 +24,10 @@ import { CLIError } from '@oclif/errors';
 import ExitCodes from './ExitCodes';
 import {
     Worker, WorkerId,
-    Lead as WorkerLead,
-    WorkerRoleStakeProfile,
-    WorkerOpening, WorkerOpeningId,
-    WorkerApplication, WorkerApplicationId
+    Lead as WGLead,
+    RoleStakeProfile,
+    Opening as WGOpening,
+    Application as WGApplication
 } from '@joystream/types/lib/working-group';
 import {
     Opening,
@@ -205,7 +205,7 @@ export default class Api {
     }
 
     async groupLead(group: WorkingGroups): Promise<GroupLeadWithProfile | null> {
-        const optLead = (await this.workingGroupApiQuery(group).currentLead()) as Option<WorkerLead>;
+        const optLead = (await this.workingGroupApiQuery(group).currentLead()) as Option<WGLead>;
 
         if (!optLead.isSome) {
             return null;
@@ -228,7 +228,7 @@ export default class Api {
         return stake.value;
     }
 
-    protected async workerStake(stakeProfile: WorkerRoleStakeProfile): Promise<Balance> {
+    protected async workerStake(stakeProfile: RoleStakeProfile): Promise<Balance> {
         return this.stakeValue(stakeProfile.stake_id);
     }
 
@@ -243,7 +243,7 @@ export default class Api {
         id: WorkerId,
         worker: Worker
     ): Promise<GroupMember> {
-        const roleAccount = worker.role_account;
+        const roleAccount = worker.role_account_id;
         const memberId = worker.member_id;
 
         const profile = await this.memberProfileById(memberId);
@@ -295,7 +295,7 @@ export default class Api {
 
     async openingsByGroup(group: WorkingGroups): Promise<GroupOpening[]> {
         const openings: GroupOpening[] = [];
-        const nextId = (await this.workingGroupApiQuery(group).nextWorkerOpeningId()) as WorkerOpeningId;
+        const nextId = (await this.workingGroupApiQuery(group).nextOpeningId()) as OpeningId;
 
         // This is chain specfic, but if next id is still 0, it means no openings have been added yet
         if (!nextId.eq(0)) {
@@ -318,29 +318,29 @@ export default class Api {
         return this.singleLinkageResult<Application>(result);
     }
 
-    async workerApplicationById(group: WorkingGroups, workerApplicationId: number): Promise<WorkerApplication> {
-        const nextAppId = await this.workingGroupApiQuery(group).nextWorkerApplicationId() as WorkerApplicationId;
+    async wgApplicationById(group: WorkingGroups, wgApplicationId: number): Promise<WGApplication> {
+        const nextAppId = await this.workingGroupApiQuery(group).nextApplicationId() as ApplicationId;
 
-        if (workerApplicationId < 0 || workerApplicationId >= nextAppId.toNumber()) {
-            throw new CLIError('Invalid worker application ID!');
+        if (wgApplicationId < 0 || wgApplicationId >= nextAppId.toNumber()) {
+            throw new CLIError('Invalid working group application ID!');
         }
 
-        return this.singleLinkageResult<WorkerApplication>(
-            await this.workingGroupApiQuery(group).workerApplicationById(workerApplicationId) as LinkageResult
+        return this.singleLinkageResult<WGApplication>(
+            await this.workingGroupApiQuery(group).applicationById(wgApplicationId) as LinkageResult
         );
     }
 
-    protected async parseApplication(workerApplicationId: number, workerApplication: WorkerApplication) {
-        const appId = workerApplication.application_id;
+    protected async parseApplication(wgApplicationId: number, wgApplication: WGApplication): Promise<GroupApplication> {
+        const appId = wgApplication.application_id;
         const application = await this.hiringApplicationById(appId);
 
         const { active_role_staking_id: roleStakingId, active_application_staking_id: appStakingId } = application;
 
         return {
-            workerApplicationId,
+            wgApplicationId,
             applicationId: appId.toNumber(),
-            member: await this.memberProfileById(workerApplication.member_id),
-            roleAccout: workerApplication.role_account,
+            member: await this.memberProfileById(wgApplication.member_id),
+            roleAccout: wgApplication.role_account_id,
             stakes: {
                 application: appStakingId.isSome ? (await this.stakeValue(appStakingId.unwrap())).toNumber() : 0,
                 role: roleStakingId.isSome ? (await this.stakeValue(roleStakingId.unwrap())).toNumber() : 0
@@ -350,41 +350,41 @@ export default class Api {
         };
     }
 
-    async groupApplication(group: WorkingGroups, workerApplicationId: number): Promise<GroupApplication> {
-        const workerApplication = await this.workerApplicationById(group, workerApplicationId);
-        return await this.parseApplication(workerApplicationId, workerApplication);
+    async groupApplication(group: WorkingGroups, wgApplicationId: number): Promise<GroupApplication> {
+        const wgApplication = await this.wgApplicationById(group, wgApplicationId);
+        return await this.parseApplication(wgApplicationId, wgApplication);
     }
 
-    protected async groupOpeningApplications(group: WorkingGroups, workerOpeningId: number): Promise<GroupApplication[]> {
+    protected async groupOpeningApplications(group: WorkingGroups, wgOpeningId: number): Promise<GroupApplication[]> {
         const applications: GroupApplication[] = [];
 
-        const nextAppId = await this.workingGroupApiQuery(group).nextWorkerApplicationId() as WorkerApplicationId;
+        const nextAppId = await this.workingGroupApiQuery(group).nextApplicationId() as ApplicationId;
         for (let i = 0; i < nextAppId.toNumber(); i++) {
-            const workerApplication = await this.workerApplicationById(group, i);
-            if (workerApplication.worker_opening_id.toNumber() !== workerOpeningId) {
+            const wgApplication = await this.wgApplicationById(group, i);
+            if (wgApplication.opening_id.toNumber() !== wgOpeningId) {
                 continue;
             }
-            applications.push(await this.parseApplication(i, workerApplication));
+            applications.push(await this.parseApplication(i, wgApplication));
         }
 
 
         return applications;
     }
 
-    async groupOpening(group: WorkingGroups, workerOpeningId: number): Promise<GroupOpening> {
-        const nextId = ((await this.workingGroupApiQuery(group).nextWorkerOpeningId()) as WorkerOpeningId).toNumber();
+    async groupOpening(group: WorkingGroups, wgOpeningId: number): Promise<GroupOpening> {
+        const nextId = ((await this.workingGroupApiQuery(group).nextOpeningId()) as OpeningId).toNumber();
 
-        if (workerOpeningId < 0 || workerOpeningId >= nextId) {
-            throw new CLIError('Invalid group opening ID!');
+        if (wgOpeningId < 0 || wgOpeningId >= nextId) {
+            throw new CLIError('Invalid working group opening ID!');
         }
 
-        const groupOpening = this.singleLinkageResult<WorkerOpening>(
-            await this.workingGroupApiQuery(group).workerOpeningById(workerOpeningId) as LinkageResult
+        const groupOpening = this.singleLinkageResult<WGOpening>(
+            await this.workingGroupApiQuery(group).openingById(wgOpeningId) as LinkageResult
         );
 
-        const openingId = groupOpening.opening_id.toNumber();
+        const openingId = groupOpening.hiring_opening_id.toNumber();
         const opening = await this.hiringOpeningById(openingId);
-        const applications = await this.groupOpeningApplications(group, workerOpeningId);
+        const applications = await this.groupOpeningApplications(group, wgOpeningId);
         const stage = await this.parseOpeningStage(opening.stage);
         const stakes = {
             application: opening.application_staking_policy.unwrapOr(undefined),
@@ -392,7 +392,7 @@ export default class Api {
         }
 
         return ({
-            workerOpeningId,
+            wgOpeningId,
             openingId,
             opening,
             stage,

+ 3 - 3
cli/src/Types.ts

@@ -108,7 +108,7 @@ export type GroupMember = {
 }
 
 export type GroupApplication = {
-    workerApplicationId: number;
+    wgApplicationId: number;
     applicationId: number;
     member: Profile | null;
     roleAccout: AccountId;
@@ -141,7 +141,7 @@ export type GroupOpeningStakes = {
 }
 
 export type GroupOpening = {
-    workerOpeningId: number;
+    wgOpeningId: number;
     openingId: number;
     stage: GroupOpeningStage;
     opening: Opening;
@@ -149,7 +149,7 @@ export type GroupOpening = {
     applications: GroupApplication[];
 }
 
-// Some helper structs for generating human_readable_text in worker opening extrinsic
+// Some helper structs for generating human_readable_text in working group opening extrinsic
 // Note those types are not part of the runtime etc., we just use them to simplify prompting for values
 // (since there exists functionality that handles that for substrate types like: Struct, Vec etc.)
 interface WithJSONable<T> {

+ 1 - 1
cli/src/base/ApiCommandBase.ts

@@ -322,7 +322,7 @@ export default abstract class ApiCommandBase extends StateAwareCommandBase {
         account: KeyringPair,
         module: string,
         method: string,
-        jsonArgs?: JSONArgsMapping, // Special JSON arguments (ie. human_readable_text of worker opening)
+        jsonArgs?: JSONArgsMapping, // Special JSON arguments (ie. human_readable_text of working group opening)
         defaultValues?: ApiMethodInputArg[],
         warnOnly: boolean = false // If specified - only warning will be displayed (instead of error beeing thrown)
     ): Promise<ApiMethodInputArg[]> {

+ 3 - 3
cli/src/base/WorkingGroupsCommandBase.ts

@@ -80,8 +80,8 @@ export default abstract class WorkingGroupsCommandBase extends AccountsCommandBa
             message: 'Select succesful applicants',
             type: 'checkbox',
             choices: acceptableApplications.map(a => ({
-                name: ` ${a.workerApplicationId}: ${a.member?.handle.toString()}`,
-                value: a.workerApplicationId,
+                name: ` ${a.wgApplicationId}: ${a.member?.handle.toString()}`,
+                value: a.wgApplicationId,
             }))
         });
 
@@ -139,7 +139,7 @@ export default abstract class WorkingGroupsCommandBase extends AccountsCommandBa
         const draftFilePath = this.getOpeningDraftPath(draftName);
         const params = this.extrinsicArgsFromDraft(
             apiModuleByGroup[this.group],
-            'addWorkerOpening',
+            'addOpening',
             draftFilePath
         );
 

+ 5 - 5
cli/src/commands/working-groups/application.ts

@@ -4,12 +4,12 @@ import _ from 'lodash';
 import chalk from 'chalk';
 
 export default class WorkingGroupsApplication extends WorkingGroupsCommandBase {
-    static description = 'Shows an overview of given application by Worker Application ID';
+    static description = 'Shows an overview of given application by Working Group Application ID';
     static args = [
         {
-            name: 'workerApplicationId',
+            name: 'wgApplicationId',
             required: true,
-            description: 'Worker Application ID'
+            description: 'Working Group Application ID'
         },
     ]
     static flags = {
@@ -19,14 +19,14 @@ export default class WorkingGroupsApplication extends WorkingGroupsCommandBase {
     async run() {
         const { args } = this.parse(WorkingGroupsApplication);
 
-        const application = await this.getApi().groupApplication(this.group, parseInt(args.workerApplicationId));
+        const application = await this.getApi().groupApplication(this.group, parseInt(args.wgApplicationId));
 
         displayHeader('Human readable text');
         this.jsonPrettyPrint(application.humanReadableText);
 
         displayHeader(`Details`);
         const applicationRow = {
-            'Worker application ID': application.workerApplicationId,
+            'WG application ID': application.wgApplicationId,
             'Application ID': application.applicationId,
             'Member handle': application.member?.handle.toString() || chalk.red('NONE'),
             'Role account': application.roleAccout.toString(),

+ 2 - 2
cli/src/commands/working-groups/createOpening.ts

@@ -51,7 +51,7 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
 
         if (!flags.skipPrompts) {
             const module = apiModuleByGroup[this.group];
-            const method = 'addWorkerOpening';
+            const method = 'addOpening';
             const jsonArgsMapping = { 'human_readable_text': { struct: HRTStruct, schemaValidator } };
 
             let saveDraft = false, params: ApiMethodInputArg[];
@@ -89,7 +89,7 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
         else {
             await this.requestAccountDecoding(account); // Prompt for password
             this.log(chalk.white('Sending the extrinsic...'));
-            await this.sendExtrinsic(account, apiModuleByGroup[this.group], 'addWorkerOpening', defaultValues!);
+            await this.sendExtrinsic(account, apiModuleByGroup[this.group], 'addOpening', defaultValues!);
             this.log(chalk.green('Opening succesfully created!'));
         }
     }

+ 11 - 10
cli/src/commands/working-groups/fillOpening.ts

@@ -3,17 +3,18 @@ import _ from 'lodash';
 import { OpeningStatus } from '../../Types';
 import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
-import { WorkerOpeningId, WorkerApplicationIdSet } from '@joystream/types/lib/working-group';
+import { OpeningId } from '@joystream/types/lib/hiring';
+import { ApplicationIdSet } from '@joystream/types/lib/working-group';
 import { RewardPolicy } from '@joystream/types/lib/content-working-group';
 import chalk from 'chalk';
 
 export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
-    static description = 'Allows filling worker opening that\'s currently in review. Requires lead access.';
+    static description = 'Allows filling working group opening that\'s currently in review. Requires lead access.';
     static args = [
         {
-            name: 'workerOpeningId',
+            name: 'wgOpeningId',
             required: true,
-            description: 'Worker Opening ID'
+            description: 'Working Group Opening ID'
         },
     ]
     static flags = {
@@ -27,7 +28,7 @@ export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
         // Lead-only gate
         await this.getRequiredLead();
 
-        const opening = await this.getApi().groupOpening(this.group, parseInt(args.workerOpeningId));
+        const opening = await this.getApi().groupOpening(this.group, parseInt(args.wgOpeningId));
 
         if (opening.stage.status !== OpeningStatus.InReview) {
             this.error('This opening is not in the Review stage!', { exit: ExitCodes.InvalidInput });
@@ -41,17 +42,17 @@ export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
         await this.sendAndFollowExtrinsic(
             account,
             apiModuleByGroup[this.group],
-            'fillWorkerOpening',
+            'fillOpening',
             [
-                new WorkerOpeningId(opening.workerOpeningId),
-                new WorkerApplicationIdSet(applicationIds),
+                new OpeningId(opening.wgOpeningId),
+                new ApplicationIdSet(applicationIds),
                 rewardPolicyOpt
             ]
         );
 
-        this.log(chalk.green(`Opening ${chalk.white(opening.workerOpeningId)} succesfully filled!`));
+        this.log(chalk.green(`Opening ${chalk.white(opening.wgOpeningId)} succesfully filled!`));
         this.log(
-            chalk.green('Accepted worker application IDs: ') +
+            chalk.green('Accepted working group application IDs: ') +
             chalk.white(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
         );
     }

+ 6 - 6
cli/src/commands/working-groups/opening.ts

@@ -7,12 +7,12 @@ import { formatBalance } from '@polkadot/util';
 import chalk from 'chalk';
 
 export default class WorkingGroupsOpening extends WorkingGroupsCommandBase {
-    static description = 'Shows an overview of given working group opening by Worker Opening ID';
+    static description = 'Shows an overview of given working group opening by Working Group Opening ID';
     static args = [
         {
-            name: 'workerOpeningId',
+            name: 'wgOpeningId',
             required: true,
-            description: 'Worker Opening ID'
+            description: 'Working Group Opening ID'
         },
     ]
     static flags = {
@@ -49,14 +49,14 @@ export default class WorkingGroupsOpening extends WorkingGroupsCommandBase {
     async run() {
         const { args } = this.parse(WorkingGroupsOpening);
 
-        const opening = await this.getApi().groupOpening(this.group, parseInt(args.workerOpeningId));
+        const opening = await this.getApi().groupOpening(this.group, parseInt(args.wgOpeningId));
 
         displayHeader('Human readable text');
         this.jsonPrettyPrint(opening.opening.human_readable_text.toString());
 
         displayHeader('Opening details');
         const openingRow = {
-            'Worker Opening ID': opening.workerOpeningId,
+            'WG Opening ID': opening.wgOpeningId,
             'Opening ID': opening.openingId,
             ...this.stageColumns(opening.stage),
             ...this.stakeColumns(opening.stakes)
@@ -65,7 +65,7 @@ export default class WorkingGroupsOpening extends WorkingGroupsCommandBase {
 
         displayHeader(`Applications (${opening.applications.length})`);
         const applicationsRows = opening.applications.map(a => ({
-            'Worker appl. ID': a.workerApplicationId,
+            'WG appl. ID': a.wgApplicationId,
             'Appl. ID': a.applicationId,
             'Member': a.member?.handle.toString() || chalk.red('NONE'),
             'Stage': a.stage,

+ 1 - 1
cli/src/commands/working-groups/openings.ts

@@ -12,7 +12,7 @@ export default class WorkingGroupsOpenings extends WorkingGroupsCommandBase {
         const openings = await this.getApi().openingsByGroup(this.group);
 
         const openingsRows = openings.map(o => ({
-            'Worker Opening ID': o.workerOpeningId,
+            'WG Opening ID': o.wgOpeningId,
             'Opening ID': o.openingId,
             'Stage': `${_.startCase(o.stage.status)}${o.stage.block ? ` (#${o.stage.block})` : ''}`,
             'Applications': o.applications.length

+ 7 - 7
cli/src/commands/working-groups/startAcceptingApplications.ts

@@ -3,16 +3,16 @@ import _ from 'lodash';
 import { OpeningStatus } from '../../Types';
 import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
-import { WorkerOpeningId } from '@joystream/types/lib/working-group';
+import { OpeningId } from '@joystream/types/lib/hiring';
 import chalk from 'chalk';
 
 export default class WorkingGroupsStartAcceptingApplications extends WorkingGroupsCommandBase {
     static description = 'Changes the status of pending opening to "Accepting applications". Requires lead access.';
     static args = [
         {
-            name: 'workerOpeningId',
+            name: 'wgOpeningId',
             required: true,
-            description: 'Worker Opening ID'
+            description: 'Working Group Opening ID'
         },
     ]
     static flags = {
@@ -26,7 +26,7 @@ export default class WorkingGroupsStartAcceptingApplications extends WorkingGrou
         // Lead-only gate
         await this.getRequiredLead();
 
-        const opening = await this.getApi().groupOpening(this.group, parseInt(args.workerOpeningId));
+        const opening = await this.getApi().groupOpening(this.group, parseInt(args.wgOpeningId));
 
         if (opening.stage.status !== OpeningStatus.WaitingToBegin) {
             this.error('This opening is not in "Waiting To Begin" stage!', { exit: ExitCodes.InvalidInput });
@@ -37,10 +37,10 @@ export default class WorkingGroupsStartAcceptingApplications extends WorkingGrou
         await this.sendAndFollowExtrinsic(
             account,
             apiModuleByGroup[this.group],
-            'acceptWorkerApplications',
-            [ new WorkerOpeningId(opening.workerOpeningId) ]
+            'acceptApplications',
+            [ new OpeningId(opening.wgOpeningId) ]
         );
 
-        this.log(chalk.green(`Opening ${chalk.white(opening.workerOpeningId)} status changed to: ${ chalk.white('Accepting Applications') }`));
+        this.log(chalk.green(`Opening ${chalk.white(opening.wgOpeningId)} status changed to: ${ chalk.white('Accepting Applications') }`));
     }
 }

+ 7 - 7
cli/src/commands/working-groups/startReviewPeriod.ts

@@ -3,16 +3,16 @@ import _ from 'lodash';
 import { OpeningStatus } from '../../Types';
 import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
-import { WorkerOpeningId } from '@joystream/types/lib/working-group';
+import { OpeningId } from '@joystream/types/lib/hiring';
 import chalk from 'chalk';
 
 export default class WorkingGroupsStartReviewPeriod extends WorkingGroupsCommandBase {
     static description = 'Changes the status of active opening to "In review". Requires lead access.';
     static args = [
         {
-            name: 'workerOpeningId',
+            name: 'wgOpeningId',
             required: true,
-            description: 'Worker Opening ID'
+            description: 'Working Group Opening ID'
         },
     ]
     static flags = {
@@ -26,7 +26,7 @@ export default class WorkingGroupsStartReviewPeriod extends WorkingGroupsCommand
         // Lead-only gate
         await this.getRequiredLead();
 
-        const opening = await this.getApi().groupOpening(this.group, parseInt(args.workerOpeningId));
+        const opening = await this.getApi().groupOpening(this.group, parseInt(args.wgOpeningId));
 
         if (opening.stage.status !== OpeningStatus.AcceptingApplications) {
             this.error('This opening is not in "Accepting Applications" stage!', { exit: ExitCodes.InvalidInput });
@@ -37,10 +37,10 @@ export default class WorkingGroupsStartReviewPeriod extends WorkingGroupsCommand
         await this.sendAndFollowExtrinsic(
             account,
             apiModuleByGroup[this.group],
-            'beginWorkerApplicantReview',
-            [ new WorkerOpeningId(opening.workerOpeningId) ]
+            'beginApplicantReview',
+            [ new OpeningId(opening.wgOpeningId) ]
         );
 
-        this.log(chalk.green(`Opening ${chalk.white(opening.workerOpeningId)} status changed to: ${ chalk.white('In Review') }`));
+        this.log(chalk.green(`Opening ${chalk.white(opening.wgOpeningId)} status changed to: ${ chalk.white('In Review') }`));
     }
 }

+ 8 - 9
cli/src/commands/working-groups/terminateApplication.ts

@@ -2,17 +2,16 @@ import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase';
 import _ from 'lodash';
 import ExitCodes from '../../ExitCodes';
 import { apiModuleByGroup } from '../../Api';
-import { WorkerApplicationId } from '@joystream/types/lib/working-group';
-import { ApplicationStageKeys } from '@joystream/types/lib/hiring';
+import { ApplicationStageKeys, ApplicationId } from '@joystream/types/lib/hiring';
 import chalk from 'chalk';
 
 export default class WorkingGroupsTerminateApplication extends WorkingGroupsCommandBase {
-    static description = 'Terminates given worker application. Requires lead access.';
+    static description = 'Terminates given working group application. Requires lead access.';
     static args = [
         {
-            name: 'workerApplicationId',
+            name: 'wgApplicationId',
             required: true,
-            description: 'Worker Application ID'
+            description: 'Working Group Application ID'
         },
     ]
     static flags = {
@@ -26,7 +25,7 @@ export default class WorkingGroupsTerminateApplication extends WorkingGroupsComm
         // Lead-only gate
         await this.getRequiredLead();
 
-        const application = await this.getApi().groupApplication(this.group, parseInt(args.workerApplicationId));
+        const application = await this.getApi().groupApplication(this.group, parseInt(args.wgApplicationId));
 
         if (application.stage !== ApplicationStageKeys.Active) {
             this.error('This application is not active!', { exit: ExitCodes.InvalidInput });
@@ -37,10 +36,10 @@ export default class WorkingGroupsTerminateApplication extends WorkingGroupsComm
         await this.sendAndFollowExtrinsic(
             account,
             apiModuleByGroup[this.group],
-            'terminateWorkerApplication',
-            [new WorkerApplicationId(application.workerApplicationId)]
+            'terminateApplication',
+            [new ApplicationId(application.wgApplicationId)]
         );
 
-        this.log(chalk.green(`Application ${chalk.white(application.workerApplicationId)} has been succesfully terminated!`));
+        this.log(chalk.green(`Application ${chalk.white(application.wgApplicationId)} has been succesfully terminated!`));
     }
 }