-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathmemberRemark.ts
45 lines (40 loc) · 1.41 KB
/
memberRemark.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
import { flags } from '@oclif/command'
import chalk from 'chalk'
import MembershipsCommandBase from '../../base/MembershipsCommandBase'
export default class MemberRemarkCommand extends MembershipsCommandBase {
static description = 'Member remarks'
static args = [
{
name: 'message',
required: true,
description: 'Remark message',
},
]
static flags = {
account: flags.string({
description: 'Account where JOY needs to be transferred',
dependsOn: ['amount'],
}),
amount: flags.string({
description: 'JOY amount to be transferred',
}),
...MembershipsCommandBase.flags,
}
async run(): Promise<void> {
const { message } = this.parse(MemberRemarkCommand).args
const { account, amount } = this.parse(MemberRemarkCommand).flags
const [memberId, controllerAccount, payment] = await this.getValidatedMemberRemarkParams(
amount ? { account, amount } : undefined
)
const keypair = await this.getDecodedPair(controllerAccount)
const result = await this.sendAndFollowNamedTx(keypair, 'members', 'memberRemark', [memberId, message, payment])
const [id, msg, optionalPayment] = this.getEvent(result, 'members', 'MemberRemarked').data
this.log(
chalk.green(
`Member ${id} remarked successfully with message: ${msg} ${
optionalPayment.isSome ? `and payment: ${optionalPayment.unwrap()}` : ''
}`
)
)
}
}