{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "HandleMsg",
  "anyOf": [
    {
      "type": "object",
      "required": [
        "create"
      ],
      "properties": {
        "create": {
          "$ref": "#/definitions/CreateMsg"
        }
      }
    },
    {
      "description": "Adds all sent native tokens to the contract",
      "type": "object",
      "required": [
        "top_up"
      ],
      "properties": {
        "top_up": {
          "type": "object",
          "required": [
            "id"
          ],
          "properties": {
            "id": {
              "type": "string"
            }
          }
        }
      }
    },
    {
      "description": "Approve sends all tokens to the recipient. Only the arbiter can do this",
      "type": "object",
      "required": [
        "approve"
      ],
      "properties": {
        "approve": {
          "type": "object",
          "required": [
            "id"
          ],
          "properties": {
            "id": {
              "description": "id is a human-readable name for the escrow from create",
              "type": "string"
            }
          }
        }
      }
    },
    {
      "description": "Refund returns all remaining tokens to the original sender, The arbiter can do this any time, or anyone can do this after a timeout",
      "type": "object",
      "required": [
        "refund"
      ],
      "properties": {
        "refund": {
          "type": "object",
          "required": [
            "id"
          ],
          "properties": {
            "id": {
              "description": "id is a human-readable name for the escrow from create",
              "type": "string"
            }
          }
        }
      }
    },
    {
      "description": "This accepts a properly-encoded ReceiveMsg from a cw20 contract",
      "type": "object",
      "required": [
        "receive"
      ],
      "properties": {
        "receive": {
          "$ref": "#/definitions/Cw20ReceiveMsg"
        }
      }
    }
  ],
  "definitions": {
    "Binary": {
      "description": "Binary is a wrapper around Vec<u8> to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec<u8>",
      "type": "string"
    },
    "CreateMsg": {
      "type": "object",
      "required": [
        "arbiter",
        "id",
        "recipient"
      ],
      "properties": {
        "arbiter": {
          "description": "arbiter can decide to approve or refund the escrow",
          "allOf": [
            {
              "$ref": "#/definitions/HumanAddr"
            }
          ]
        },
        "cw20_whitelist": {
          "description": "Besides any possible tokens sent with the CreateMsg, this is a list of all cw20 token addresses that are accepted by the escrow during a top-up. This is required to avoid a DoS attack by topping-up with an invalid cw20 contract. See https://github.com/CosmWasm/cosmwasm-plus/issues/19",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "$ref": "#/definitions/HumanAddr"
          }
        },
        "end_height": {
          "description": "When end height set and block height exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint64",
          "minimum": 0.0
        },
        "end_time": {
          "description": "When end time (in seconds since epoch 00:00:00 UTC on 1 January 1970) is set and block time exceeds this value, the escrow is expired. Once an escrow is expired, it can be returned to the original funder (via \"refund\").",
          "type": [
            "integer",
            "null"
          ],
          "format": "uint64",
          "minimum": 0.0
        },
        "id": {
          "description": "id is a human-readable name for the escrow to use later 3-20 bytes of utf-8 text",
          "type": "string"
        },
        "recipient": {
          "description": "if approved, funds go to the recipient",
          "allOf": [
            {
              "$ref": "#/definitions/HumanAddr"
            }
          ]
        }
      }
    },
    "Cw20ReceiveMsg": {
      "description": "Cw20ReceiveMsg should be de/serialized under `Receive()` variant in a HandleMsg",
      "type": "object",
      "required": [
        "amount",
        "sender"
      ],
      "properties": {
        "amount": {
          "$ref": "#/definitions/Uint128"
        },
        "msg": {
          "anyOf": [
            {
              "$ref": "#/definitions/Binary"
            },
            {
              "type": "null"
            }
          ]
        },
        "sender": {
          "$ref": "#/definitions/HumanAddr"
        }
      }
    },
    "HumanAddr": {
      "type": "string"
    },
    "Uint128": {
      "type": "string"
    }
  }
}
