Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bounty module CLI commands #3102

Open
wants to merge 16 commits into
base: rhodes
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
generated BountyInputParameters & OracleJudgmentInputParameters schem…
…as for JSON input
  • Loading branch information
zeeshanakram3 committed Jan 28, 2022
commit 5855ab37080b4de48d3382f87ec3e69fc42a4f95
16 changes: 15 additions & 1 deletion cli/src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
IVideoCategoryMetadata,
IChannelCategoryMetadata,
IBountyMetadata,
IBountyWorkData,
} from '@joystream/metadata-protobuf'

// KeyringPair type extended with mandatory "meta.name"
Expand Down Expand Up @@ -198,11 +199,24 @@ export type BountyInputParameters = IBountyMetadata & {
cherry: number
entrantStake: number
// TODO: can this be improved?
fundingType: FundingTypeLimited & FundingTypePrepetual
fundingType: FundingTypeLimited | FundingTypePrepetual
workPeriod: number
judgementPeriod: number
}

export type BountyWorkDataInputParameters = IBountyWorkData

export type Winner = {
reward: number
}

export enum Rejected {}

export type OracleJudgmentInputParameters = {
entryId: number
judgment: Winner | Rejected
}[]

type AnyNonObject = string | number | boolean | any[] | Long

// JSONSchema utility types
Expand Down
191 changes: 168 additions & 23 deletions cli/src/json-schemas/Bounty.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,173 @@
import { BountyInputParameters, JsonSchema } from '../Types'
// schema are generated by Typescript JSON schema generator VSCode extension

export const BountyInputSchema: JsonSchema<BountyInputParameters> = {
type: 'object',
additionalProperties: false,
properties: {
title: { type: 'string' },
description: { type: 'string' },
discussionThread: { type: 'number' },
bannerImageUri: { type: 'string' },
oracle: { type: 'number' },
contractTypeInput: { type: 'array' },
cherry: { type: 'number' },
entrantStake: { type: 'number' },
fundingType: {
type: 'object',
additionalProperties: false,
properties: {
minFundingAmount: { type: 'number' },
maxFundingAmount: { type: 'number' },
fundingPeriod: { type: 'number' },
target: { type: 'number' },
export const BountyInputSchema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$ref': '#/definitions/BountyInputParameters',
'definitions': {
'BountyInputParameters': {
'type': 'object',
'additionalProperties': false,
'properties': {
'oracle': {
'type': 'number',
},
'contractTypeInput': {
'type': 'array',
'items': {
'type': 'string',
},
},
'cherry': {
'type': 'number',
},
'entrantStake': {
'type': 'number',
},
'fundingType': {
'anyOf': [
{
'$ref': '#/definitions/FundingTypeLimited',
},
{
'$ref': '#/definitions/FundingTypePrepetual',
},
],
},
'workPeriod': {
'type': 'number',
},
'judgementPeriod': {
'type': 'number',
},
'title': {
'type': ['string', 'null'],
},
'description': {
'type': ['string', 'null'],
},
'discussionThread': {
'anyOf': [
{
'$ref': '#/definitions/Long.Long',
},
{
'type': 'null',
},
],
},
'bannerImageUri': {
'type': ['string', 'null'],
},
},
'required': ['cherry', 'contractTypeInput', 'entrantStake', 'fundingType', 'judgementPeriod', 'workPeriod'],
},
'FundingTypeLimited': {
'type': 'object',
'properties': {
'minFundingAmount': {
'type': 'number',
},
'maxFundingAmount': {
'type': 'number',
},
'fundingPeriod': {
'type': 'number',
},
},
'required': ['minFundingAmount', 'maxFundingAmount', 'fundingPeriod'],
'additionalProperties': false,
},
'FundingTypePrepetual': {
'type': 'object',
'properties': {
'target': {
'type': 'number',
},
},
'required': ['target'],
'additionalProperties': false,
},
'Long.Long': {
'type': 'object',
'properties': {
'high': {
'type': 'number',
},
'low': {
'type': 'number',
},
'unsigned': {
'type': 'boolean',
},
},
'required': ['high', 'low', 'unsigned'],
'additionalProperties': false,
},
},
}

export const BountyWorkDataInputSchema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$ref': '#/definitions/BountyWorkDataInputParameters',
'definitions': {
'BountyWorkDataInputParameters': {
'$ref': '#/definitions/IBountyWorkData',
},
'IBountyWorkData': {
'type': 'object',
'properties': {
'title': {
'type': ['string', 'null'],
},
'description': {
'type': ['string', 'null'],
},
},
'additionalProperties': false,
},
},
}

export const OracleJudgmentInputSchema = {
'$schema': 'http://json-schema.org/draft-07/schema#',
'$ref': '#/definitions/OracleJudgmentInputParameters',
'definitions': {
'OracleJudgmentInputParameters': {
'type': 'array',
'items': {
'type': 'object',
'properties': {
'entryId': {
'type': 'number',
},
'judgment': {
'anyOf': [
{
'$ref': '#/definitions/Winner',
},
{
'$ref': '#/definitions/Rejected',
},
],
},
},
'required': ['entryId', 'judgment'],
'additionalProperties': false,
},
},
'Winner': {
'type': 'object',
'properties': {
'reward': {
'type': 'number',
},
},
'required': ['reward'],
'additionalProperties': false,
},
'Rejected': {
'type': [],
'enum': [],
},
workPeriod: { type: 'number' },
judgementPeriod: { type: 'number' },
},
}