-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathaddForumPost.ts
38 lines (32 loc) · 1.26 KB
/
addForumPost.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
import FeeProfileCommandBase from '../../base/FeeProfileCommandBase'
import { flags } from '@oclif/command'
import _ from 'lodash'
import { formatBalance } from '@polkadot/util'
import chalk from 'chalk'
const DEFAULT_POST_LENGTH = 200
export default class FeeProfileAddForumPost extends FeeProfileCommandBase {
static description = 'Create fee profile of forum.add_post extrinsic.'
static flags = {
postLen: flags.integer({
char: 'p',
default: DEFAULT_POST_LENGTH,
description: 'Post length to use for estimating tx fee',
}),
editable: flags.boolean({
char: 'e',
description: 'If specified - `editable` parameter is set to true when estimating the costs',
}),
...super.flags,
}
async run(): Promise<void> {
const api = this.getOriginalApi()
const { postLen, editable = false } = this.parse(FeeProfileAddForumPost).flags
const { postDeposit } = api.consts.forum
this.log(`Post deposit: ${chalk.cyanBright(formatBalance(postDeposit))}`)
this.log('Parameters:')
this.jsonPrettyPrint(JSON.stringify({ postLen, editable }))
const tx = api.tx.forum.addPost(0, 0, 0, _.repeat('x', postLen), editable)
const extraCosts = editable ? { postDeposit } : undefined
await this.profile(tx, extraCosts)
}
}