terminateApplication.ts 1.5 KB

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