Browse Source

Reusability fix

Leszek Wiesner 4 years ago
parent
commit
8d8786ef19

+ 1 - 1
cli/src/Api.ts

@@ -28,7 +28,7 @@ export const DEFAULT_API_URI = 'wss://rome-rpc-endpoint.joystream.org:9944/';
 const DEFAULT_DECIMALS = new u32(12);
 
 // Mapping of working group to api module
-const apiModuleByGroup: { [key in WorkingGroups]: string } = {
+export const apiModuleByGroup: { [key in WorkingGroups]: string } = {
     [WorkingGroups.StorageProviders]: 'storageWorkingGroup'
 };
 

+ 2 - 1
cli/src/base/WorkingGroupsCommandBase.ts

@@ -2,6 +2,7 @@ import ExitCodes from '../ExitCodes';
 import AccountsCommandBase from './AccountsCommandBase';
 import { flags } from '@oclif/command';
 import { WorkingGroups, AvailableGroups, NamedKeyringPair, GroupLeadWithProfile, GroupMember } from '../Types';
+import { apiModuleByGroup } from '../Api';
 import { CLIError } from '@oclif/errors';
 import inquirer from 'inquirer';
 import { ApiMethodInputArg } from './ApiCommandBase';
@@ -122,7 +123,7 @@ export default abstract class WorkingGroupsCommandBase extends AccountsCommandBa
     loadOpeningDraftParams(draftName: string) {
         const draftFilePath = this.getOpeningDraftPath(draftName);
         const params = this.extrinsicArgsFromDraft(
-            'storageBureaucracy',
+            apiModuleByGroup[this.group],
             'addWorkerOpening',
             draftFilePath
         );

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

@@ -4,6 +4,7 @@ import chalk from 'chalk';
 import { flags } from '@oclif/command';
 import { ApiMethodInputArg } from '../../base/ApiCommandBase';
 import { schemaValidator } from '@joystream/types/lib/hiring';
+import { apiModuleByGroup } from '../../Api';
 
 export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase {
     static description = 'Create working group opening (requires lead access)';
@@ -46,7 +47,7 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
         if (!flags.skipPrompts) {
             const params = await this.buildAndSendExtrinsic(
                 account,
-                'storageBureaucracy',
+                apiModuleByGroup[this.group],
                 'addWorkerOpening',
                 { 'human_readable_text': { struct: HRTStruct, schemaValidator } },
                 defaultValues
@@ -66,7 +67,7 @@ export default class WorkingGroupsCreateOpening extends WorkingGroupsCommandBase
         }
         else {
             this.log(chalk.white('Sending the extrinsic...'));
-            await this.sendExtrinsic(account, 'storageBureaucracy', 'addWorkerOpening', defaultValues!);
+            await this.sendExtrinsic(account, apiModuleByGroup[this.group], 'addWorkerOpening', defaultValues!);
             this.log(chalk.green('Opening succesfully created!'));
         }
     }