{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://dasp-protocol.github.io/dasp/schemas/draft-01/examples/counter-authority.schema.json",
  "title": "Counter scope for proof of authority",
  "description": "Apply with the authority grant schema. Also require amount_min <= amount_max and enforce the scope against each command.",
  "allOf": [
    {
      "$ref": "https://dasp-protocol.github.io/dasp/schemas/draft-01/bindings/authority-grant.schema.json"
    },
    {
      "if": {
        "type": "object",
        "properties": {
          "kind": {
            "const": "standing"
          }
        },
        "required": [
          "kind"
        ]
      },
      "then": {
        "type": "object",
        "properties": {
          "scope": {
            "type": "object",
            "properties": {
              "profile": {
                "const": {
                  "id": "urn:example:dasp:counter",
                  "version": "1"
                }
              },
              "commands": {
                "type": "array",
                "minItems": 1,
                "maxItems": 1,
                "items": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "const": "counter.add"
                    },
                    "input_scope": {
                      "type": "object",
                      "properties": {
                        "amount_min": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 1000000
                        },
                        "amount_max": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 1000000
                        }
                      },
                      "required": [
                        "amount_min",
                        "amount_max"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "name",
                    "input_scope"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        }
      },
      "else": {
        "type": "object",
        "properties": {
          "target": {
            "type": "object",
            "properties": {
              "profile": {
                "const": {
                  "id": "urn:example:dasp:counter",
                  "version": "1"
                }
              },
              "name": {
                "const": "counter.add"
              },
              "input": {
                "$ref": "https://dasp-protocol.github.io/dasp/schemas/draft-01/examples/counter-profile.schema.json#/$defs/input"
              }
            }
          }
        }
      }
    }
  ]
}
