-
Notifications
You must be signed in to change notification settings - Fork 115
/
leaveRole.ts
33 lines (28 loc) · 1.03 KB
/
leaveRole.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
import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
import { apiModuleByGroup } from '../../Api'
import chalk from 'chalk'
import { flags } from '@oclif/command'
export default class WorkingGroupsLeaveRole extends WorkingGroupsCommandBase {
static description = 'Leave the worker or lead role associated with currently selected account.'
static flags = {
...WorkingGroupsCommandBase.flags,
rationale: flags.string({
name: 'Optional rationale',
required: false,
}),
}
async run(): Promise<void> {
// Worker-only gate
const worker = await this.getRequiredWorkerContext()
const {
flags: { rationale },
} = this.parse(WorkingGroupsLeaveRole)
await this.sendAndFollowNamedTx(
await this.getDecodedPair(worker.roleAccount.toString()),
apiModuleByGroup[this.group],
'leaveRole',
[worker.workerId, rationale || null]
)
this.log(chalk.green(`Successfully left the role! (worker id: ${chalk.magentaBright(worker.workerId.toString())})`))
}
}