12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
- import { getInputJson } from '../../helpers/InputOutput'
- import { VideoCategoryInputParameters } from '../../Types'
- import { asValidatedMetadata, metadataToBytes } from '../../helpers/serialization'
- import { flags } from '@oclif/command'
- import { CreateInterface } from '@joystream/types'
- import { VideoCategoryUpdateParameters } from '@joystream/types/content'
- import { VideoCategoryInputSchema } from '../../schemas/ContentDirectory'
- import { VideoCategoryMetadata } from '@joystream/metadata-protobuf'
- export default class UpdateVideoCategoryCommand extends ContentDirectoryCommandBase {
- static description = 'Update video category inside content directory.'
- static flags = {
- context: ContentDirectoryCommandBase.categoriesContextFlag,
- input: flags.string({
- char: 'i',
- required: true,
- description: `Path to JSON file to use as input`,
- }),
- ...ContentDirectoryCommandBase.flags,
- }
- static args = [
- {
- name: 'videoCategoryId',
- required: true,
- description: 'ID of the Video Category',
- },
- ]
- async run(): Promise<void> {
- const { context, input } = this.parse(UpdateVideoCategoryCommand).flags
- const { videoCategoryId } = this.parse(UpdateVideoCategoryCommand).args
- const [actor, address] = context ? await this.getContentActor(context) : await this.getCategoryManagementActor()
- const videoCategoryInput = await getInputJson<VideoCategoryInputParameters>(input, VideoCategoryInputSchema)
- const meta = asValidatedMetadata(VideoCategoryMetadata, videoCategoryInput)
- const videoCategoryUpdateParameters: CreateInterface<VideoCategoryUpdateParameters> = {
- new_meta: metadataToBytes(VideoCategoryMetadata, meta),
- }
- this.jsonPrettyPrint(JSON.stringify(videoCategoryInput))
- await this.requireConfirmation('Do you confirm the provided input?', true)
- await this.sendAndFollowNamedTx(await this.getDecodedPair(address), 'content', 'updateVideoCategory', [
- actor,
- videoCategoryId,
- videoCategoryUpdateParameters,
- ])
- }
- }
|