fillOpening.ts 1.6 KB

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