-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathfillOpening.ts
47 lines (39 loc) · 1.57 KB
/
fillOpening.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
38
39
40
41
42
43
44
45
46
47
import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
import { apiModuleByGroup } from '../../Api'
import chalk from 'chalk'
import { createType } from '@joystream/types'
import { flags } from '@oclif/command'
export default class WorkingGroupsFillOpening extends WorkingGroupsCommandBase {
static description = "Allows filling working group opening that's currently in review. Requires lead access."
static flags = {
openingId: flags.integer({
required: true,
description: 'Working Group Opening ID',
}),
applicationIds: flags.integer({
multiple: true,
description: 'Accepted application ids',
}),
...WorkingGroupsCommandBase.flags,
}
async run(): Promise<void> {
let { openingId, applicationIds } = this.parse(WorkingGroupsFillOpening).flags
// Lead-only gate
const lead = await this.getRequiredLeadContext()
const opening = await this.getOpeningForLeadAction(openingId)
if (!applicationIds || !applicationIds.length) {
applicationIds = await this.promptForApplicationsToAccept(opening)
}
await this.sendAndFollowNamedTx(
await this.getDecodedPair(lead.roleAccount),
apiModuleByGroup[this.group],
'fillOpening',
[openingId, createType('BTreeSet<u64>', applicationIds)]
)
this.log(chalk.green(`Opening ${chalk.magentaBright(openingId.toString())} successfully filled!`))
this.log(
chalk.green('Accepted working group application IDs: ') +
chalk.magentaBright(applicationIds.length ? applicationIds.join(chalk.green(', ')) : 'NONE')
)
}
}