Module Rpc_encodings.JSONRPC

Encodings for the JSON-RPC standard. See https://www.jsonrpc.org/specification.

val version : string

Constant being `2.0`.

type id_repr =
  1. | Id_string of string
  2. | Id_float of float

Ids in the JSON-RPC specification can be either a string, a number or NULL (which is represented by the option type). Note that MetaMask uses ids that only fit in 64 bits, which is not supported by Data_encoding.

val random_id : ?seed:Stdlib.Random.State.t -> unit -> id_repr
type id = id_repr option
type request = {
  1. method_ : string;
  2. parameters : Tezos_base.TzPervasives.Data_encoding.json option;
    (*

    `params` is optional.

    *)
  3. id : id;
    (*

    `id` is optional.

    *)
}

JSON-RPC Request object:

  { "jsonrpc" : "2.0",
  "method": <string>,
  "params": <array | object>, //optional
  "id": <string | number | NULL> //optional
  }
type error = {
  1. code : int;
  2. message : string;
  3. data : Tezos_base.TzPervasives.Data_encoding.json option;
}

JSON-RPC Error representation.

    { "code" : <number>,
      "message": <string>,
      "data": <any value>
    }
type return_value =
  1. | Direct of value
  2. | Lazy of value Lwt.t
type response = {
  1. value : value;
  2. id : id;
}

JSON-RPC Response object:

    { "jsonrpc": "2.0",
      "result": <any>,
      "error": <error object>,
      "id": <id>
    }

Note that `result` and `error` cannot appear at the same time, hence the choice of using the result type as representation.

type return_response = {
  1. return_value : return_value;
  2. id : id;
}