fillOpening.ts 1.8 KB

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