-
Notifications
You must be signed in to change notification settings - Fork 115
/
deleteForumPost.ts
44 lines (38 loc) · 1.4 KB
/
deleteForumPost.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
import FeeProfileCommandBase from '../../base/FeeProfileCommandBase'
import _ from 'lodash'
import { flags } from '@oclif/command'
import { createType } from '@joystream/types'
import chalk from 'chalk'
import { formatBalance } from '@polkadot/util'
const DEFAULT_RATIONALE_LENGTH = 0
export default class FeeProfileDeleteForumPost extends FeeProfileCommandBase {
static description = 'Create fee profile of forum.delete_posts extrinsic (single post case).'
static flags = {
rationaleLen: flags.integer({
char: 'r',
default: DEFAULT_RATIONALE_LENGTH,
description: 'Default rationale length to use for estimating tx fee',
}),
...super.flags,
}
async run(): Promise<void> {
const api = this.getOriginalApi()
const { postDeposit } = api.consts.forum
const { rationaleLen } = this.parse(FeeProfileDeleteForumPost).flags
this.log(`Post deposit: ${chalk.cyanBright(formatBalance(postDeposit))}`)
this.log('Parameters:')
this.jsonPrettyPrint(JSON.stringify({ rationaleLen }))
const tx = api.tx.forum.deletePosts(
0,
createType(
'BTreeMap<PalletForumExtendedPostIdObject, bool>',
new Map([[createType('PalletForumExtendedPostIdObject', { categoryId: 0, threadId: 0, postId: 0 }), true]])
),
_.repeat('x', rationaleLen)
)
const returns = {
postDeposit,
}
await this.profile(tx, undefined, returns)
}
}