-
Notifications
You must be signed in to change notification settings - Fork 115
/
updateRoleAccount.ts
41 lines (34 loc) · 1.38 KB
/
updateRoleAccount.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
import WorkingGroupsCommandBase from '../../base/WorkingGroupsCommandBase'
import { apiModuleByGroup } from '../../Api'
import { validateAddress } from '../../helpers/validation'
import chalk from 'chalk'
import ExitCodes from '../../ExitCodes'
export default class WorkingGroupsUpdateRoleAccount extends WorkingGroupsCommandBase {
static description = 'Updates the worker/lead role account. Requires member controller account to be selected'
static args = [
{
name: 'address',
required: false,
description: 'New role account address (if omitted, can be provided interactively)',
},
]
static flags = {
...WorkingGroupsCommandBase.flags,
}
async run(): Promise<void> {
let { address } = this.parse(WorkingGroupsUpdateRoleAccount).args
const worker = await this.getRequiredWorkerContext('MemberController')
if (!address) {
address = await this.promptForAnyAddress('Select new role account')
} else if (validateAddress(address) !== true) {
this.error('Invalid address', { exit: ExitCodes.InvalidInput })
}
await this.sendAndFollowNamedTx(
await this.getDecodedPair(worker.profile.membership.controllerAccount),
apiModuleByGroup[this.group],
'updateRoleAccount',
[worker.workerId, address]
)
this.log(chalk.green(`Successfully updated the role account to: ${chalk.magentaBright(address)})`))
}
}