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 id_repr_encoding : id_repr Mavryk_base.TzPervasives.Data_encoding.t
type id = id_repr option
type request = {
  1. method_ : string;
  2. parameters : Mavryk_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
}
val request_encoding : request Mavryk_base.TzPervasives.Data_encoding.t
type 'data error = {
  1. code : int;
  2. message : string;
  3. data : 'data option;
}

JSON-RPC Error representation.

{ "code" : <number>,
  "message": <string>,
  "data": <any value>
}
val error_encoding : 'a Mavryk_base.TzPervasives.Data_encoding.t -> 'a error Mavryk_base.TzPervasives.Data_encoding.t
type value = (Mavryk_base.TzPervasives.Data_encoding.json, Mavryk_base.TzPervasives.Data_encoding.json error) Stdlib.result
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.

val response_encoding : response Mavryk_base.TzPervasives.Data_encoding.t