Browse Source

Content cli: add ChannelCreationParameters protobuf, init content cli commands

iorveth 4 years ago
parent
commit
f44a0e0264

+ 1 - 0
cli/5GKqhpFCPjojQoXewiwYyndZx519NF7jAkvXAW3ir9tTBA79.json

@@ -0,0 +1 @@
+{"address":"5GKqhpFCPjojQoXewiwYyndZx519NF7jAkvXAW3ir9tTBA79","encoded":"UkZszWozSH6M2q8QaU6VVd+D7aapciI4IJWpXvcy1jwAgAAAAQAAAAgAAABhBmMPZUPsRj1RDTWx8QcacFtNPxVK1Df8/d6Z/wls33/8I/+7kxlA0cos0C6DfP0PTINS9z6dnHFZelgkY4A/UHr/F7Br0qHQbKFoIyI2KDU0hn6alyTLktHMIF/bNbs/Lob9HJA4MssUTB2qahlYPd0o9IAuYaVWw22PM+RcIL2D9peMLoD85c/AVo4574i61Xt9hOcEVyKjcUCJ","encoding":{"content":["pkcs8","sr25519"],"type":["scrypt","xsalsa20-poly1305"],"version":"3"},"meta":{"name":"iorveth","tags":[],"whenCreated":1614341535516}}

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

@@ -57,17 +57,14 @@ export default abstract class ContentDirectoryCommandBase extends RolesCommandBa
     await this.getRequiredLead()
   }
 
-  async getCuratorContext(classNames: string[] = []): Promise<Actor> {
+  async getCuratorContext(): Promise<Actor> {
     const curator = await this.getRequiredWorker()
-    const classes = await Promise.all(classNames.map(async (cName) => (await this.classEntryByNameOrId(cName))[1]))
-    const classMaintainers = classes.map(({ class_permissions: permissions }) => permissions.maintainers.toArray())
 
     const groups = await this.getApi().availableCuratorGroups()
     const availableGroupIds = groups
       .filter(
-        ([groupId, group]) =>
+        ([_, group]) =>
           group.active.valueOf() &&
-          classMaintainers.every((maintainers) => maintainers.some((m) => m.eq(groupId))) &&
           group.curators.toArray().some((curatorId) => curatorId.eq(curator.workerId))
       )
       .map(([id]) => id)
@@ -75,8 +72,7 @@ export default abstract class ContentDirectoryCommandBase extends RolesCommandBa
     let groupId: number
     if (!availableGroupIds.length) {
       this.error(
-        'You do not have the required maintainer access to at least one of the following classes: ' +
-          classNames.join(', '),
+        'You do not have the curator access!',
         { exit: ExitCodes.AccessDenied }
       )
     } else if (availableGroupIds.length === 1) {

+ 35 - 0
cli/src/commands/content/createChannel.ts

@@ -0,0 +1,35 @@
+import ContentDirectoryCommandBase from '../../base/ContentDirectoryCommandBase'
+import CreateClassSchema from '@joystream/cd-schemas/schemas/extrinsics/CreateClass.schema.json'
+import { CreateClass } from '@joystream/cd-schemas/types/extrinsics/CreateClass'
+import { InputParser } from '@joystream/cd-schemas'
+import { JSONSchema } from '@apidevtools/json-schema-ref-parser'
+import { IOFlags, getInputJson, saveOutputJson } from '../../helpers/InputOutput'
+
+export default class CreateChannelCommand extends ContentDirectoryCommandBase {
+  static description = 'Create channel inside content directory.'
+  static flags = {
+    context: ContentDirectoryCommandBase.contextFlag,
+    ...IOFlags,
+  }
+
+  async run() {
+    let { context, input, output } = this.parse(CreateChannelCommand).flags
+
+    if (!context) {
+      context = await this.promptForContext()
+    }
+
+
+    // let inputJson = await getInputJson<CreateClass>(input, CreateClassSchema as JSONSchema)
+
+    // this.jsonPrettyPrint(JSON.stringify(inputJson))
+    // const confirmed = await this.simplePrompt({ type: 'confirm', message: 'Do you confirm the provided input?' })
+
+    // if (confirmed) {
+    //   saveOutputJson(output, `${inputJson.name}Class.json`, inputJson)
+    //   this.log('Sending the extrinsic...')
+    //   const inputParser = new InputParser(this.getOriginalApi())
+    //   await this.sendAndFollowTx(account, inputParser.parseCreateClassExtrinsic(inputJson))
+    // }
+  }
+}

+ 38 - 0
content-metadata-protobuf/proto/ChannelCreationParameters.proto

@@ -0,0 +1,38 @@
+syntax = "proto2";
+
+/// Content parameters for the asset to be uploaded
+message Upload {    
+    optional uint64 content_id = 1;
+    optional uint64 type_id = 1;
+    optional uint64 size = 1;
+    optional bytes ipfs_content_id = 1;
+}
+
+/// Represents multiple urls
+message Urls {
+    repeated bytes urls = 1;
+}
+
+/// Specifies how a new asset will be provided on creating and updating
+message NewAssetMetadata {
+    oneof new_asset {
+        /// Upload to the storage system
+        Upload upload = 1;
+        /// Multiple url strings pointing at an asset
+        Urls urls = 2;
+    }
+}
+
+/// Represents an array of new assets metadata
+message AssetsMetadata {
+    repeated NewAssetMetadata new_asset = 1;
+}
+
+message ChannelCreationParametersMetadata {
+    /// Assets referenced by metadata
+    optional AssetsMetadata assets = 1;
+    /// Metadata about the channel.
+    optional bytes meta = 2;
+    /// Metadata about the channel.
+    optional bytes reward_account = 3;
+}