{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://capp.local/schemas/capp.solana-edge.operation.v4.schema.json",
  "title": "capp.solana-edge.operation.v4",
  "type": "object",
  "required": [
    "protocol",
    "operationId",
    "requestDigest",
    "sender",
    "recipient",
    "mode",
    "network",
    "simulated",
    "state",
    "timeline",
    "approval",
    "asset",
    "amountAtomic"
  ],
  "properties": {
    "protocol": {
      "const": "capp.solana-edge.operation.v4"
    },
    "operationId": {
      "type": "string",
      "minLength": 1
    },
    "requestDigest": {
      "type": "string",
      "pattern": "^[a-f0-9]{64}$"
    },
    "sender": {
      "type": "string",
      "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
    },
    "recipient": {
      "type": "string",
      "pattern": "^[1-9A-HJ-NP-Za-km-z]{32,44}$"
    },
    "mode": {
      "const": "devnet"
    },
    "network": {
      "const": "devnet"
    },
    "simulated": {
      "const": false
    },
    "state": {
      "enum": [
        "preparing",
        "prepared",
        "preflighted",
        "authority-pending",
        "authorised",
        "submitting",
        "submitted",
        "unknown",
        "confirmed",
        "finalised",
        "failed",
        "blocked",
        "expired"
      ]
    },
    "timeline": {
      "type": "array"
    },
    "approval": {
      "type": "object"
    },
    "commitment": {
      "type": "object",
      "required": [
        "namespace",
        "sha256"
      ],
      "properties": {
        "namespace": {
          "type": "string",
          "pattern": "^[a-z][a-z0-9.-]{0,23}$"
        },
        "sha256": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$"
        }
      },
      "additionalProperties": false
    },
    "asset": {
      "allOf": [
        {
          "$ref": "https://capp.local/schemas/capp.solana-asset.v1.schema.json"
        },
        {
          "properties": {
            "kind": {
              "const": "spl-token"
            }
          }
        }
      ]
    },
    "amountAtomic": {
      "type": "string",
      "pattern": "^(0|[1-9][0-9]{0,19})$",
      "description": "Exact unsigned u64 atomic units. Runtime also enforces <= 18446744073709551615."
    },
    "previousOperationId": {
      "type": "string",
      "minLength": 1,
      "description": "The retained expired, never-submitted operation this explicit refresh replaces."
    },
    "replacementOperationId": {
      "type": "string",
      "minLength": 1,
      "description": "One durable successor; repeat refresh calls resume it."
    },
    "expiry": {
      "type": "object",
      "required": [
        "reason",
        "notSubmitted",
        "observedAt"
      ],
      "properties": {
        "reason": {
          "enum": [
            "blockhash",
            "payment-request"
          ]
        },
        "notSubmitted": {
          "const": true
        },
        "observedAt": {
          "type": "number"
        }
      },
      "additionalProperties": false
    }
  },
  "additionalProperties": true
}
