fillOpening.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
  2. import { apiModuleByGroup } from '../../Api'
  3. import chalk from 'chalk'
  4. import { JoyBTreeSet } from '@joystream/types/common'
  5. import { ApplicationId } from '@joystream/types/working-group'
  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 args = [
  9. {
  10. name: 'wgOpeningId',
  11. required: true,
  12. description: 'Working Group Opening ID',
  13. },
  14. ]
  15. static flags = {
  16. ...WorkingGroupsCommandBase.flags,
  17. }
  18. async run() {
  19. const { args } = this.parse(WorkingGroupsFillOpening)
  20. // Lead-only gate
  21. const lead = await this.getRequiredLeadContext()
  22. const openingId = parseInt(args.wgOpeningId)
  23. const opening = await this.getOpeningForLeadAction(openingId)
  24. const applicationIds = await this.promptForApplicationsToAccept(opening)
  25. await this.sendAndFollowNamedTx(
  26. await this.getDecodedPair(lead.roleAccount.toString()),
  27. apiModuleByGroup[this.group],
  28. 'fillOpening',
  29. [openingId, new (JoyBTreeSet(ApplicationId))(this.getTypesRegistry(), applicationIds)]
  30. )
  31. this.log(chalk.green(`Opening ${chalk.magentaBright(openingId.toString())} succesfully filled!`))
  32. this.log(
  33. chalk.green('Accepted working group application IDs: ') +
  34. chalk.magentaBright(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
  35. )
  36. }
  37. }