fillOpening.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase';
  2. import _ from 'lodash';
  3. import { OpeningStatus } from '../../Types';
  4. import { apiModuleByGroup } from '../../Api';
  5. import { OpeningId } from '@joystream/types/hiring';
  6. import { ApplicationIdSet, RewardPolicy } from '@joystream/types/working-group';
  7. import chalk from 'chalk';
  8. import { createParamOptions } from '../../helpers/promptOptions';
  9. export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
  10. static description = 'Allows filling working group opening that\'s currently in review. Requires lead access.';
  11. static args = [
  12. {
  13. name: 'wgOpeningId',
  14. required: true,
  15. description: 'Working Group Opening ID'
  16. },
  17. ]
  18. static flags = {
  19. ...WorkingGroupsCommandBase.flags,
  20. };
  21. async run() {
  22. const { args } = this.parse(WorkingGroupsFillOpening);
  23. const account = await this.getRequiredSelectedAccount();
  24. // Lead-only gate
  25. await this.getRequiredLead();
  26. const openingId = parseInt(args.wgOpeningId);
  27. const opening = await this.getOpeningForLeadAction(openingId, OpeningStatus.InReview);
  28. const applicationIds = await this.promptForApplicationsToAccept(opening);
  29. const rewardPolicyOpt = await this.promptForParam(`Option<${RewardPolicy.name}>`, createParamOptions('RewardPolicy'));
  30. await this.requestAccountDecoding(account);
  31. await this.sendAndFollowExtrinsic(
  32. account,
  33. apiModuleByGroup[this.group],
  34. 'fillOpening',
  35. [
  36. new OpeningId(openingId),
  37. new ApplicationIdSet(applicationIds),
  38. rewardPolicyOpt
  39. ]
  40. );
  41. this.log(chalk.green(`Opening ${chalk.white(openingId)} succesfully filled!`));
  42. this.log(
  43. chalk.green('Accepted working group application IDs: ') +
  44. chalk.white(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
  45. );
  46. }
  47. }