2018-06-29 16:08:08 +04:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Open Source License *)
|
|
|
|
(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
2019-01-22 18:23:18 +04:00
|
|
|
(* Copyright (c) 2018 Nomadic Labs, <contact@nomadic-labs.com> *)
|
2018-06-29 16:08:08 +04:00
|
|
|
(* *)
|
|
|
|
(* Permission is hereby granted, free of charge, to any person obtaining a *)
|
|
|
|
(* copy of this software and associated documentation files (the "Software"),*)
|
|
|
|
(* to deal in the Software without restriction, including without limitation *)
|
|
|
|
(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)
|
|
|
|
(* and/or sell copies of the Software, and to permit persons to whom the *)
|
|
|
|
(* Software is furnished to do so, subject to the following conditions: *)
|
|
|
|
(* *)
|
|
|
|
(* The above copyright notice and this permission notice shall be included *)
|
|
|
|
(* in all copies or substantial portions of the Software. *)
|
|
|
|
(* *)
|
|
|
|
(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)
|
|
|
|
(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)
|
|
|
|
(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)
|
|
|
|
(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)
|
|
|
|
(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)
|
|
|
|
(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)
|
|
|
|
(* DEALINGS IN THE SOFTWARE. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
2018-02-14 18:20:03 +04:00
|
|
|
|
|
|
|
type ('a, 'b) lwt_format =
|
|
|
|
('a, Format.formatter, unit, 'b Lwt.t) format4
|
|
|
|
|
2018-02-16 21:10:18 +04:00
|
|
|
class type printer = object
|
2018-02-14 18:20:03 +04:00
|
|
|
method error : ('a, 'b) lwt_format -> 'a
|
|
|
|
method warning : ('a, unit) lwt_format -> 'a
|
|
|
|
method message : ('a, unit) lwt_format -> 'a
|
|
|
|
method answer : ('a, unit) lwt_format -> 'a
|
|
|
|
method log : string -> ('a, unit) lwt_format -> 'a
|
|
|
|
end
|
|
|
|
|
2018-02-16 21:10:18 +04:00
|
|
|
class type prompter = object
|
2018-05-26 13:12:36 +04:00
|
|
|
method prompt : ('a, string tzresult) lwt_format -> 'a
|
|
|
|
method prompt_password : ('a, MBytes.t tzresult) lwt_format -> 'a
|
2018-02-16 14:08:04 +04:00
|
|
|
end
|
|
|
|
|
2018-02-16 21:10:18 +04:00
|
|
|
class type io = object
|
|
|
|
inherit printer
|
|
|
|
inherit prompter
|
|
|
|
end
|
|
|
|
|
|
|
|
class simple_printer log =
|
2018-02-14 18:20:03 +04:00
|
|
|
let message =
|
|
|
|
(fun x ->
|
|
|
|
Format.kasprintf (fun msg -> log "stdout" msg) x) in
|
|
|
|
object
|
|
|
|
method error : type a b. (a, b) lwt_format -> a =
|
|
|
|
Format.kasprintf
|
|
|
|
(fun msg ->
|
|
|
|
Lwt.fail (Failure msg))
|
|
|
|
method warning : type a. (a, unit) lwt_format -> a =
|
|
|
|
Format.kasprintf
|
|
|
|
(fun msg -> log "stderr" msg)
|
|
|
|
method message : type a. (a, unit) lwt_format -> a = message
|
|
|
|
method answer : type a. (a, unit) lwt_format -> a = message
|
|
|
|
method log : type a. string -> (a, unit) lwt_format -> a =
|
|
|
|
fun name ->
|
|
|
|
Format.kasprintf
|
|
|
|
(fun msg -> log name msg)
|
|
|
|
end
|
|
|
|
|
|
|
|
class type wallet = object
|
2018-08-02 19:35:34 +04:00
|
|
|
method password_filename : string option
|
2018-06-13 07:15:22 +04:00
|
|
|
method with_lock : (unit -> 'a Lwt.t) -> 'a Lwt.t
|
2018-02-14 18:20:03 +04:00
|
|
|
method load : string -> default:'a -> 'a Data_encoding.encoding -> 'a tzresult Lwt.t
|
|
|
|
method write : string -> 'a -> 'a Data_encoding.encoding -> unit tzresult Lwt.t
|
|
|
|
end
|
|
|
|
|
|
|
|
class type block = object
|
2018-04-22 16:40:44 +04:00
|
|
|
method block : Shell_services.block
|
2018-04-21 13:31:19 +04:00
|
|
|
method confirmations : int option
|
2018-02-14 18:20:03 +04:00
|
|
|
end
|
|
|
|
|
2018-02-16 14:08:04 +04:00
|
|
|
class type io_wallet = object
|
2018-02-16 21:10:18 +04:00
|
|
|
inherit printer
|
|
|
|
inherit prompter
|
2018-02-14 18:20:03 +04:00
|
|
|
inherit wallet
|
|
|
|
end
|
|
|
|
|
2018-02-16 21:10:18 +04:00
|
|
|
class type io_rpcs = object
|
|
|
|
inherit printer
|
|
|
|
inherit prompter
|
2018-02-14 18:20:03 +04:00
|
|
|
inherit RPC_context.json
|
|
|
|
end
|
|
|
|
|
2018-02-16 21:10:18 +04:00
|
|
|
class type full = object
|
|
|
|
inherit printer
|
|
|
|
inherit prompter
|
2018-02-14 18:20:03 +04:00
|
|
|
inherit wallet
|
|
|
|
inherit RPC_context.json
|
|
|
|
inherit block
|
|
|
|
end
|
|
|
|
|
2018-02-16 21:10:18 +04:00
|
|
|
class proxy_context (obj : full) = object
|
2018-08-02 19:35:34 +04:00
|
|
|
method password_filename = obj#password_filename
|
2018-05-18 23:14:44 +04:00
|
|
|
method base = obj#base
|
2018-02-14 18:20:03 +04:00
|
|
|
method block = obj#block
|
2018-04-21 13:31:19 +04:00
|
|
|
method confirmations = obj#confirmations
|
2018-02-14 18:20:03 +04:00
|
|
|
method answer : type a. (a, unit) lwt_format -> a = obj#answer
|
|
|
|
method call_service :
|
|
|
|
'm 'p 'q 'i 'o.
|
|
|
|
([< Resto.meth ] as 'm, 'pr, 'p, 'q, 'i, 'o) RPC_service.t ->
|
|
|
|
'p -> 'q -> 'i -> 'o tzresult Lwt.t = obj#call_service
|
|
|
|
method call_streamed_service :
|
|
|
|
'm 'p 'q 'i 'o.
|
|
|
|
([< Resto.meth ] as 'm, 'pr, 'p, 'q, 'i, 'o) RPC_service.t ->
|
|
|
|
on_chunk: ('o -> unit) ->
|
|
|
|
on_close: (unit -> unit) ->
|
|
|
|
'p -> 'q -> 'i -> (unit -> unit) tzresult Lwt.t = obj#call_streamed_service
|
|
|
|
method error : type a b. (a, b) lwt_format -> a = obj#error
|
|
|
|
method generic_json_call = obj#generic_json_call
|
2018-06-13 07:15:22 +04:00
|
|
|
method with_lock : type a. (unit -> a Lwt.t) -> a Lwt.t = obj#with_lock
|
2018-02-14 18:20:03 +04:00
|
|
|
method load : type a. string -> default:a -> a Data_encoding.encoding -> a tzresult Lwt.t = obj#load
|
|
|
|
method log : type a. string -> (a, unit) lwt_format -> a = obj#log
|
|
|
|
method message : type a. (a, unit) lwt_format -> a = obj#message
|
|
|
|
method warning : type a. (a, unit) lwt_format -> a = obj#warning
|
|
|
|
method write : type a. string -> a -> a Data_encoding.encoding -> unit tzresult Lwt.t = obj#write
|
2018-05-26 13:12:36 +04:00
|
|
|
method prompt : type a. (a, string tzresult) lwt_format -> a = obj#prompt
|
|
|
|
method prompt_password : type a. (a, MBytes.t tzresult) lwt_format -> a = obj#prompt_password
|
2018-02-14 18:20:03 +04:00
|
|
|
end
|