fillOpening.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
  2. import { OpeningStatus } from '../../Types'
  3. import { apiModuleByGroup } from '../../Api'
  4. import chalk from 'chalk'
  5. import { createParamOptions } from '../../helpers/promptOptions'
  6. import { JoyBTreeSet } from '@joystream/types/common'
  7. import { registry } from '@joystream/types'
  8. import { ApplicationId } from '@joystream/types/hiring'
  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>`, createParamOptions('RewardPolicy'))
  30. await this.requestAccountDecoding(account)
  31. await this.sendAndFollowNamedTx(account, apiModuleByGroup[this.group], 'fillOpening', [
  32. openingId,
  33. new (JoyBTreeSet(ApplicationId))(registry, applicationIds),
  34. rewardPolicyOpt,
  35. ])
  36. this.log(chalk.green(`Opening ${chalk.magentaBright(openingId)} successfully filled!`))
  37. this.log(
  38. chalk.green('Accepted working group application IDs: ') +
  39. chalk.magentaBright(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
  40. )
  41. }
  42. }