{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$id": "https://joystream.org/WorkingGroupOpening.schema.json",
  "title": "WorkingGroupOpening",
  "description": "JSON schema to describe Joystream working group opening",
  "type": "object",
  "additionalProperties": false,
  "required": ["activateAt", "maxReviewPeriodLength"],
  "properties": {
    "activateAt": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["ExactBlock"],
          "properties": {
            "ExactBlock": {
              "type": "integer",
              "minimum": 1,
              "description": "Exact block number"
            }
          }
        },
        {
          "type": "object",
          "additionalProperties": false,
          "required": ["CurrentBlock"],
          "properties": { "CurrentBlock": { "type": "null" } }
        }
      ]
    },
    "maxActiveApplicants": {
      "type": "integer",
      "description": "Max. number of active applicants",
      "minimum": 1,
      "default": 10
    },
    "maxReviewPeriodLength": {
      "type": "integer",
      "description": "Max. review period length in blocks",
      "minimum": 1,
      "default": 432000
    },
    "applicationStake": { "$ref": "#/definitions/StakingPolicy", "description": "Application stake properties" },
    "roleStake": { "$ref": "#/definitions/StakingPolicy", "description": "Role stake properties" },
    "terminateRoleUnstakingPeriod": { "$ref": "#/definitions/UnstakingPeriod" },
    "leaveRoleUnstakingPeriod": { "$ref": "#/definitions/UnstakingPeriod" }
  },
  "definitions": {
    "UnstakingPeriod": {
      "type": "integer",
      "minimum": 1,
      "default": 100800
    },
    "StakingPolicy": {
      "type": "object",
      "additionalProperties": false,
      "required": ["value", "mode"],
      "properties": {
        "mode": {
          "type": "string",
          "description": "Application stake mode (Exact/AtLeast)",
          "enum": ["Exact", "AtLeast"]
        },
        "value": {
          "type": "integer",
          "description": "Required stake value in JOY",
          "minimum": 1
        }
      }
    }
  }
}
