-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathcancelOpening.ts
37 lines (30 loc) · 1.01 KB
/
cancelOpening.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
import { apiModuleByGroup } from '../../Api'
import chalk from 'chalk'
export default class WorkingGroupsCancelOpening extends WorkingGroupsCommandBase {
static description = 'Cancels (removes) an active opening'
static args = [
{
name: 'openingId',
required: true,
description: 'Opening ID',
},
]
static flags = {
...WorkingGroupsCommandBase.flags,
}
async run(): Promise<void> {
const { args } = this.parse(WorkingGroupsCancelOpening)
// Lead-only gate
const lead = await this.getRequiredLeadContext()
const openingId = parseInt(args.openingId)
await this.validateOpeningForLeadAction(openingId)
await this.sendAndFollowNamedTx(
await this.getDecodedPair(lead.roleAccount.toString()),
apiModuleByGroup[this.group],
'cancelOpening',
[openingId]
)
this.log(chalk.green(`Opening ${chalk.magentaBright(openingId.toString())} has been cancelled!`))
}
}