startAcceptingApplications.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
  2. import { OpeningStatus } from '../../Types'
  3. import { apiModuleByGroup } from '../../Api'
  4. import chalk from 'chalk'
  5. export default class WorkingGroupsStartAcceptingApplications extends WorkingGroupsCommandBase {
  6. static description = 'Changes the status of pending opening to "Accepting applications". 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(WorkingGroupsStartAcceptingApplications)
  19. // Lead-only gate
  20. const lead = await this.getRequiredLeadContext()
  21. const openingId = parseInt(args.wgOpeningId)
  22. await this.validateOpeningForLeadAction(openingId, OpeningStatus.WaitingToBegin)
  23. await this.sendAndFollowNamedTx(
  24. await this.getDecodedPair(lead.roleAccount),
  25. apiModuleByGroup[this.group],
  26. 'acceptApplications',
  27. [openingId]
  28. )
  29. this.log(
  30. chalk.green(
  31. `Opening ${chalk.magentaBright(openingId)} status changed to: ${chalk.magentaBright('Accepting Applications')}`
  32. )
  33. )
  34. }
  35. }