2016-09-08 21:13:10 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2017-11-14 03:36:14 +04:00
|
|
|
(* Copyright (c) 2014 - 2017. *)
|
2016-09-08 21:13:10 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
2016-11-14 20:28:37 +04:00
|
|
|
module Make(Param : sig val name: string end)() = struct
|
|
|
|
|
|
|
|
include Pervasives
|
|
|
|
module Pervasives = Pervasives
|
|
|
|
module Compare = Compare
|
|
|
|
module Array = Array
|
|
|
|
module List = List
|
2016-11-17 05:06:50 +04:00
|
|
|
module Bytes = struct
|
|
|
|
include Bytes
|
|
|
|
include EndianBytes.BigEndian
|
|
|
|
module LE = EndianBytes.LittleEndian
|
|
|
|
end
|
|
|
|
module String = struct
|
|
|
|
include String
|
|
|
|
include EndianString.BigEndian
|
|
|
|
module LE = EndianString.LittleEndian
|
|
|
|
end
|
2016-11-14 20:28:37 +04:00
|
|
|
module Set = Set
|
|
|
|
module Map = Map
|
|
|
|
module Int32 = Int32
|
|
|
|
module Int64 = Int64
|
|
|
|
module Nativeint = Nativeint
|
|
|
|
module Buffer = Buffer
|
|
|
|
module Format = Format
|
|
|
|
module Hex_encode = Hex_encode
|
2017-05-23 17:04:31 +04:00
|
|
|
module Z = Z
|
2016-11-14 20:28:37 +04:00
|
|
|
module Lwt_sequence = Lwt_sequence
|
|
|
|
module Lwt = Lwt
|
|
|
|
module Lwt_list = Lwt_list
|
|
|
|
module MBytes = MBytes
|
|
|
|
module Uri = Uri
|
|
|
|
module Data_encoding = Data_encoding
|
|
|
|
module Time = Time
|
|
|
|
module Ed25519 = Ed25519
|
2017-11-27 09:13:12 +04:00
|
|
|
module Hash = struct
|
|
|
|
include Tezos_crypto
|
|
|
|
include Tezos_crypto.S
|
|
|
|
module Make_minimal_Blake2B = Blake2B.Make_minimal
|
|
|
|
module Make_Blake2B = Blake2B.Make
|
|
|
|
end
|
|
|
|
module Blake2B = Blake2B
|
|
|
|
module Tezos_data = struct
|
|
|
|
module type DATA = Tezos_base.S.T
|
|
|
|
module type HASHABLE_DATA = Tezos_base.S.HASHABLE
|
|
|
|
module Fitness = Fitness
|
|
|
|
module Operation = Operation
|
|
|
|
module Block_header = Block_header
|
|
|
|
module Protocol = Protocol
|
|
|
|
end
|
2017-12-09 06:51:58 +04:00
|
|
|
module RPC_arg = RPC_arg
|
|
|
|
module RPC_path = RPC_path
|
|
|
|
module RPC_query = RPC_query
|
|
|
|
module RPC_service = RPC_service
|
|
|
|
module RPC_answer = RPC_answer
|
|
|
|
module RPC_directory = RPC_directory
|
2017-11-27 09:13:12 +04:00
|
|
|
module Micheline = Tezos_micheline.Micheline
|
2016-11-14 20:28:37 +04:00
|
|
|
module Fitness = Fitness
|
|
|
|
module Error_monad = struct
|
|
|
|
type error_category = [ `Branch | `Temporary | `Permanent ]
|
|
|
|
include Error_monad.Make()
|
|
|
|
end
|
2017-10-09 12:55:12 +04:00
|
|
|
module Updater = struct
|
|
|
|
include Updater
|
|
|
|
module type PROTOCOL =
|
|
|
|
RAW_PROTOCOL with type error := Error_monad.error
|
|
|
|
and type 'a tzresult := 'a Error_monad.tzresult
|
|
|
|
end
|
2016-11-14 20:28:37 +04:00
|
|
|
module Logging = Logging.Make(Param)
|
2017-02-19 21:22:32 +04:00
|
|
|
module Base58 = struct
|
|
|
|
include Base58
|
|
|
|
let simple_encode enc s = simple_encode enc s
|
|
|
|
let simple_decode enc s = simple_decode enc s
|
2016-11-14 20:28:37 +04:00
|
|
|
include Make(struct type context = Context.t end)
|
2017-02-19 21:22:32 +04:00
|
|
|
let decode s = decode s
|
2016-11-14 20:28:37 +04:00
|
|
|
end
|
|
|
|
module Context = struct
|
|
|
|
include Context
|
2017-02-19 21:22:32 +04:00
|
|
|
let register_resolver = Base58.register_resolver
|
|
|
|
let complete ctxt s = Base58.complete ctxt s
|
2016-11-14 20:28:37 +04:00
|
|
|
end
|
2017-10-27 20:53:07 +04:00
|
|
|
|
|
|
|
type error += Ecoproto_error of Error_monad.error list
|
|
|
|
|
|
|
|
let () =
|
|
|
|
let id = Format.asprintf "Ecoproto.%s" Param.name in
|
|
|
|
register_wrapped_error_kind
|
|
|
|
(fun ecoerrors -> Error_monad.classify_errors ecoerrors)
|
|
|
|
~id ~title:"Error returned by the protocol"
|
|
|
|
~description:"Wrapped error for the economic protocol."
|
|
|
|
~pp:(fun ppf ->
|
|
|
|
Format.fprintf ppf
|
|
|
|
"@[<v 2>Economic error:@ %a@]"
|
|
|
|
(Format.pp_print_list Error_monad.pp))
|
|
|
|
Data_encoding.(obj1 (req "ecoproto"
|
|
|
|
(list Error_monad.error_encoding)))
|
|
|
|
(function Ecoproto_error ecoerrors -> Some ecoerrors
|
|
|
|
| _ -> None )
|
|
|
|
(function ecoerrors -> Ecoproto_error ecoerrors)
|
|
|
|
|
|
|
|
let wrap_error = function
|
|
|
|
| Ok _ as ok -> ok
|
|
|
|
| Error errors -> Error [Ecoproto_error errors]
|
|
|
|
|
2016-09-08 21:13:10 +04:00
|
|
|
end
|