terminateApplication.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
  2. import { apiModuleByGroup } from '../../Api'
  3. import { ApplicationStageKeys } from '@joystream/types/hiring'
  4. import chalk from 'chalk'
  5. export default class WorkingGroupsTerminateApplication extends WorkingGroupsCommandBase {
  6. static description = 'Terminates given working group application. Requires lead access.'
  7. static args = [
  8. {
  9. name: 'wgApplicationId',
  10. required: true,
  11. description: 'Working Group Application ID',
  12. },
  13. ]
  14. static flags = {
  15. ...WorkingGroupsCommandBase.flags,
  16. }
  17. async run() {
  18. const { args } = this.parse(WorkingGroupsTerminateApplication)
  19. const account = await this.getRequiredSelectedAccount()
  20. // Lead-only gate
  21. await this.getRequiredLead()
  22. const applicationId = parseInt(args.wgApplicationId)
  23. // We don't really need the application itself here, so this one is just for validation purposes
  24. await this.getApplicationForLeadAction(applicationId, ApplicationStageKeys.Active)
  25. await this.requestAccountDecoding(account)
  26. await this.sendAndFollowExtrinsic(account, apiModuleByGroup[this.group], 'terminateApplication', [applicationId])
  27. this.log(chalk.green(`Application ${chalk.white(applicationId)} has been succesfully terminated!`))
  28. }
  29. }