iorveth 4 years ago
parent
commit
13ac5d3f34

+ 0 - 1
cli/examples/content/CreateChannel.json

@@ -14,4 +14,3 @@
     "category": 1
   }
 }
-

+ 0 - 1
cli/examples/content/UpdateChannel.json

@@ -14,4 +14,3 @@
     "category": 1
   }
 }
-

+ 3 - 1
cli/src/base/ContentDirectoryCommandBase.ts

@@ -41,7 +41,9 @@ export default abstract class ContentDirectoryCommandBase extends RolesCommandBa
     })
   }
 
-  async promptForOwnerContext(message = 'Choose in which context you wish to execute the command'): Promise<OwnerContext> {
+  async promptForOwnerContext(
+    message = 'Choose in which context you wish to execute the command'
+  ): Promise<OwnerContext> {
     return this.simplePrompt({
       message,
       type: 'list',

+ 2 - 2
cli/src/commands/content/channels.ts

@@ -14,12 +14,12 @@ export default class ChannelsCommand extends ContentDirectoryCommandBase {
           'ID': id.toString(),
           'Owner': JSON.stringify(c.owner.toJSON()),
           'IsCensored': c.is_censored.toString(),
-          'RewardAccount': c.reward_account? c.reward_account.toString() : 'NONE'
+          'RewardAccount': c.reward_account ? c.reward_account.toString() : 'NONE',
         })),
         3
       )
     } else {
-        this.log('There are no channels yet')
+      this.log('There are no channels yet')
     }
   }
 }

+ 14 - 15
cli/src/commands/content/createChannel.ts

@@ -1,28 +1,28 @@
 import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
 import { IOFlags, getInputJson } from '../../helpers/InputOutput'
-import { NewAsset} from '@joystream/types/content'
-import {ChannelMetadata} from '@joystream/content-metadata-protobuf'
-import { Vec, Option} from '@polkadot/types';
-import AccountId from '@polkadot/types/generic/AccountId';
-import { Bytes } from '@polkadot/types/primitive';
+import { NewAsset } from '@joystream/types/content'
+import { ChannelMetadata } from '@joystream/content-metadata-protobuf'
+import { Vec, Option } from '@polkadot/types'
+import AccountId from '@polkadot/types/generic/AccountId'
+import { Bytes } from '@polkadot/types/primitive'
 
 type ChannelCreationParametersInput = {
-  assets: Vec<NewAsset>,
-  meta: ChannelMetadata.AsObject,
-  reward_account: Option<AccountId>,
+  assets: Vec<NewAsset>
+  meta: ChannelMetadata.AsObject
+  reward_account: Option<AccountId>
 }
 
 type ChannelCreationParameters = {
-  assets: Vec<NewAsset>,
-  meta: Bytes,
-  reward_account: Option<AccountId>,
+  assets: Vec<NewAsset>
+  meta: Bytes
+  reward_account: Option<AccountId>
 }
 
 export default class CreateChannelCommand extends ContentDirectoryCommandBase {
   static description = 'Create channel inside content directory.'
   static flags = {
     context: ContentDirectoryCommandBase.ownerContextFlag,
-    input: IOFlags.input
+    input: IOFlags.input,
   }
 
   async run() {
@@ -51,7 +51,7 @@ export default class CreateChannelCommand extends ContentDirectoryCommandBase {
       channelMetadata.setAvatarPhoto(channelCreationParametersInput.meta.avatarPhoto!)
       channelMetadata.setCategory(channelCreationParametersInput.meta.category!)
 
-      const serialized = channelMetadata.serializeBinary();
+      const serialized = channelMetadata.serializeBinary()
 
       const meta = this.createType('Bytes', '0x' + Buffer.from(serialized).toString('hex'))
 
@@ -67,11 +67,10 @@ export default class CreateChannelCommand extends ContentDirectoryCommandBase {
 
       const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
 
-      if (confirmed)  {
+      if (confirmed) {
         this.log('Sending the extrinsic...')
 
         await this.sendAndFollowNamedTx(currentAccount, 'content', 'createChannel', [actor, channelCreationParameters])
-
       }
     } else {
       this.error('Input invalid or was not provided...')

+ 20 - 18
cli/src/commands/content/updateChannel.ts

@@ -1,28 +1,28 @@
 import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
-import { IOFlags, getInputJson,  } from '../../helpers/InputOutput'
-import { NewAsset} from '@joystream/types/content'
-import {ChannelMetadata} from '@joystream/content-metadata-protobuf'
-import { Vec, Option} from '@polkadot/types';
-import AccountId from '@polkadot/types/generic/AccountId';
-import { Bytes } from '@polkadot/types/primitive';
+import { IOFlags, getInputJson } from '../../helpers/InputOutput'
+import { NewAsset } from '@joystream/types/content'
+import { ChannelMetadata } from '@joystream/content-metadata-protobuf'
+import { Vec, Option } from '@polkadot/types'
+import AccountId from '@polkadot/types/generic/AccountId'
+import { Bytes } from '@polkadot/types/primitive'
 
 type ChannelUpdateParametersInput = {
-  assets: Option<Vec<NewAsset>>,
-  new_meta: ChannelMetadata.AsObject,
-  reward_account: Option<AccountId>,
+  assets: Option<Vec<NewAsset>>
+  new_meta: ChannelMetadata.AsObject
+  reward_account: Option<AccountId>
 }
 
 type ChannelUpdateParameters = {
-  assets: Option<Vec<NewAsset>>,
-  new_meta: Bytes,
-  reward_account: Option<AccountId>,
+  assets: Option<Vec<NewAsset>>
+  new_meta: Bytes
+  reward_account: Option<AccountId>
 }
 
 export default class UpdateChannelCommand extends ContentDirectoryCommandBase {
   static description = 'Update existing content directory channel.'
   static flags = {
     context: ContentDirectoryCommandBase.contextFlag,
-    input: IOFlags.input
+    input: IOFlags.input,
   }
 
   static args = [
@@ -34,7 +34,6 @@ export default class UpdateChannelCommand extends ContentDirectoryCommandBase {
   ]
 
   async run() {
-
     let { context, input } = this.parse(UpdateChannelCommand).flags
 
     const { channelId } = this.parse(UpdateChannelCommand).args
@@ -60,7 +59,7 @@ export default class UpdateChannelCommand extends ContentDirectoryCommandBase {
       channelMetadata.setAvatarPhoto(channelUpdateParametersInput.new_meta.avatarPhoto!)
       channelMetadata.setCategory(channelUpdateParametersInput.new_meta.category!)
 
-      const serialized = channelMetadata.serializeBinary();
+      const serialized = channelMetadata.serializeBinary()
 
       const meta = this.createType('Bytes', '0x' + Buffer.from(serialized).toString('hex'))
 
@@ -77,11 +76,14 @@ export default class UpdateChannelCommand extends ContentDirectoryCommandBase {
       this.jsonPrettyPrint(JSON.stringify(channelUpdateParameters))
       const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
 
-      if (confirmed)  {
+      if (confirmed) {
         this.log('Sending the extrinsic...')
 
-        await this.sendAndFollowNamedTx(currentAccount, 'content', 'updateChannel', [actor, channelId, channelUpdateParameters])
-
+        await this.sendAndFollowNamedTx(currentAccount, 'content', 'updateChannel', [
+          actor,
+          channelId,
+          channelUpdateParameters,
+        ])
       }
     } else {
       this.error('Input invalid or was not provided...')