fillOpening.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
  2. import { apiModuleByGroup } from '../../Api'
  3. import chalk from 'chalk'
  4. import { createType } from '@joystream/types'
  5. export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
  6. static description = "Allows filling working group opening that's currently in review. Requires lead access."
  7. static args = [
  8. {
  9. name: 'wgOpeningId',
  10. required: true,
  11. description: 'Working Group Opening ID',
  12. },
  13. ]
  14. static flags = {
  15. ...WorkingGroupsCommandBase.flags,
  16. }
  17. async run(): Promise<void> {
  18. const { args } = this.parse(WorkingGroupsFillOpening)
  19. // Lead-only gate
  20. const lead = await this.getRequiredLeadContext()
  21. const openingId = parseInt(args.wgOpeningId)
  22. const opening = await this.getOpeningForLeadAction(openingId)
  23. const applicationIds = await this.promptForApplicationsToAccept(opening)
  24. await this.sendAndFollowNamedTx(
  25. await this.getDecodedPair(lead.roleAccount),
  26. apiModuleByGroup[this.group],
  27. 'fillOpening',
  28. [openingId, createType('BTreeSet<ApplicationId>', applicationIds)]
  29. )
  30. this.log(chalk.green(`Opening ${chalk.magentaBright(openingId.toString())} successfully filled!`))
  31. this.log(
  32. chalk.green('Accepted working group application IDs: ') +
  33. chalk.magentaBright(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
  34. )
  35. }
  36. }