Client refactor: Proto_alpha.Environment -> Alpha_environment

This commit is contained in:
Grégoire Henry 2018-02-11 19:17:39 +01:00
parent 91143452e3
commit 6a5a235d42
15 changed files with 30 additions and 30 deletions

View File

@ -9,7 +9,6 @@
open Proto_alpha open Proto_alpha
open Tezos_context open Tezos_context
open Environment
val list_contract_labels : val list_contract_labels :
#Client_commands.full_context -> #Client_commands.full_context ->

View File

@ -16,7 +16,7 @@ module ContractEntity = struct
let of_source s = let of_source s =
match Contract.of_b58check s with match Contract.of_b58check s with
| Error _ as err -> | Error _ as err ->
Lwt.return (Environment.wrap_error err) Lwt.return (Alpha_environment.wrap_error err)
|> trace (failure "bad contract notation") |> trace (failure "bad contract notation")
| Ok s -> return s | Ok s -> return s
let to_source s = return (Contract.to_b58check s) let to_source s = return (Contract.to_b58check s)

View File

@ -130,7 +130,7 @@ let print_typecheck_result
if emacs then if emacs then
let type_map, errs = match res with let type_map, errs = match res with
| Ok type_map -> type_map, [] | Ok type_map -> type_map, []
| Error (Environment.Ecoproto_error | Error (Alpha_environment.Ecoproto_error
(Script_tc_errors.Ill_typed_contract (_, type_map ) :: _) (Script_tc_errors.Ill_typed_contract (_, type_map ) :: _)
:: _ as errs) -> :: _ as errs) ->
type_map, errs type_map, errs

View File

@ -99,8 +99,8 @@ let report_errors ppf (parsed, errs) =
fst (List.assoc oloc parsed.expansion_table) in fst (List.assoc oloc parsed.expansion_table) in
let errs, loc = let errs, loc =
match err with match err with
| Environment.Ecoproto_error (top :: errs) -> | Alpha_environment.Ecoproto_error (top :: errs) ->
[ Environment.Ecoproto_error (top :: errs) ], [ Alpha_environment.Ecoproto_error (top :: errs) ],
begin match top with begin match top with
| Ill_typed_contract (expr, _) | Ill_typed_contract (expr, _)
| Ill_typed_data (_, expr, _) -> | Ill_typed_data (_, expr, _) ->

View File

@ -368,13 +368,14 @@ let report_errors ~details ~show_source ?parsed ppf errs =
print_ty (None, tyb) print_ty (None, tyb)
| Reject _ -> Format.fprintf ppf "Script reached FAIL instruction" | Reject _ -> Format.fprintf ppf "Script reached FAIL instruction"
| Overflow _ -> Format.fprintf ppf "Unexpected arithmetic overflow" | Overflow _ -> Format.fprintf ppf "Unexpected arithmetic overflow"
| err -> Format.fprintf ppf "%a" Environment.Error_monad.pp err | err -> Format.fprintf ppf "%a" Alpha_environment.Error_monad.pp err
end ; end ;
if rest <> [] then Format.fprintf ppf "@," ; if rest <> [] then Format.fprintf ppf "@," ;
print_trace locations rest in print_trace locations rest in
Format.fprintf ppf "@[<v 0>%a@]" Format.fprintf ppf "@[<v 0>%a@]"
(Format.pp_print_list (Format.pp_print_list
(fun ppf -> function (fun ppf -> function
| Environment.Ecoproto_error errs -> print_trace (fun _ -> None) errs | Alpha_environment.Ecoproto_error errs ->
print_trace (fun _ -> None) errs
| err -> pp ppf err)) | err -> pp ppf err))
errs errs

View File

@ -67,7 +67,7 @@ let expand_all source ast errors =
(l, (ploc, elocs))) (l, (ploc, elocs)))
(List.sort compare loc_table) (List.sort compare loc_table)
(List.sort compare grouped) in (List.sort compare grouped) in
match Environment.wrap_error (Michelson_v1_primitives.prims_of_strings expanded) with match Alpha_environment.wrap_error (Michelson_v1_primitives.prims_of_strings expanded) with
| Ok expanded -> | Ok expanded ->
{ source ; unexpanded ; expanded ; { source ; unexpanded ; expanded ;
expansion_table ; unexpansion_table }, expansion_table ; unexpansion_table },

View File

@ -8,5 +8,5 @@
(**************************************************************************) (**************************************************************************)
module Name = struct let name = "alpha" end module Name = struct let name = "alpha" end
module Environment = Tezos_protocol_environment_client.Fake.Make(Name)() module Alpha_environment = Tezos_protocol_environment_client.Fake.Make(Name)()
include Tezos_protocol_alpha.Functor.Make(Environment) include Tezos_protocol_alpha.Functor.Make(Alpha_environment)

View File

@ -313,7 +313,7 @@ module Assert = struct
equal_pkh ~msg expected_delegate actual_delegate equal_pkh ~msg expected_delegate actual_delegate
let ecoproto_error f = function let ecoproto_error f = function
| Environment.Ecoproto_error errors -> | Alpha_environment.Ecoproto_error errors ->
List.exists f errors List.exists f errors
| _ -> false | _ -> false
@ -451,7 +451,7 @@ module Baking = struct
let endorsement_reward block = let endorsement_reward block =
Client_proto_rpcs.Header.priority !rpc_ctxt block >>=? fun prio -> Client_proto_rpcs.Header.priority !rpc_ctxt block >>=? fun prio ->
Baking.endorsement_reward ~block_priority:prio >|= Baking.endorsement_reward ~block_priority:prio >|=
Environment.wrap_error >>|? Alpha_environment.wrap_error >>|?
Tez.to_mutez Tez.to_mutez
end end

View File

@ -166,12 +166,12 @@ module Assert : sig
val failed_to_preapply: val failed_to_preapply:
msg:string -> msg:string ->
?op:Tezos_base.Operation.t -> ?op:Tezos_base.Operation.t ->
(Environment.Error_monad.error -> (Alpha_environment.Error_monad.error ->
bool) -> bool) ->
'a tzresult -> unit 'a tzresult -> unit
val ecoproto_error: val ecoproto_error:
(Environment.Error_monad.error -> bool) -> (Alpha_environment.Error_monad.error -> bool) ->
error -> bool error -> bool
val generic_economic_error : msg:string -> 'a tzresult -> unit val generic_economic_error : msg:string -> 'a tzresult -> unit

View File

@ -40,7 +40,7 @@ module Assert = struct
end end
let wrap_result = Proto_alpha.Environment.wrap_error let wrap_result = Alpha_environment.wrap_error
let wrap = fun x -> Lwt.return @@ wrap_result x let wrap = fun x -> Lwt.return @@ wrap_result x
@ -135,7 +135,7 @@ let equal_cents_balance ~tc ?msg (contract, cents_balance) =
(contract, Helpers_cast.cents_of_int cents_balance) (contract, Helpers_cast.cents_of_int cents_balance)
let ecoproto_error f = function let ecoproto_error f = function
| Proto_alpha.Environment.Ecoproto_error errors -> | Alpha_environment.Ecoproto_error errors ->
List.exists f errors List.exists f errors
| _ -> false | _ -> false

View File

@ -16,11 +16,11 @@ val sourced : sourced_operations -> proto_operation
val manager : val manager :
Helpers_account.t -> ?fee:Tez.tez -> manager_operation list -> Helpers_account.t -> ?fee:Tez.tez -> manager_operation list ->
Proto_alpha.Environment.Context.t -> sourced_operations proto_tzresult Lwt.t Alpha_environment.Context.t -> sourced_operations proto_tzresult Lwt.t
val manager_full : val manager_full :
Helpers_account.t -> ?fee:Tez.tez -> manager_operation list -> Helpers_account.t -> ?fee:Tez.tez -> manager_operation list ->
Proto_alpha.Environment.Context.t -> proto_operation proto_tzresult Lwt.t Alpha_environment.Context.t -> proto_operation proto_tzresult Lwt.t
val transaction : val transaction :
?parameters:Script.expr -> Tez.t -> Contract.contract -> ?parameters:Script.expr -> Tez.t -> Contract.contract ->
@ -33,21 +33,21 @@ val origination :
val delegation : public_key_hash -> manager_operation val delegation : public_key_hash -> manager_operation
val delegation_full : val delegation_full :
?fee:Tez.tez -> Helpers_account.t -> public_key_hash -> Proto_alpha.Environment.Context.t -> ?fee:Tez.tez -> Helpers_account.t -> public_key_hash -> Alpha_environment.Context.t ->
proto_operation proto_tzresult Lwt.t proto_operation proto_tzresult Lwt.t
val script_origination_full : val script_origination_full :
Script.t option -> Helpers_account.t -> Tez.t -> Proto_alpha.Environment.Context.t -> Script.t option -> Helpers_account.t -> Tez.t -> Alpha_environment.Context.t ->
proto_operation proto_tzresult Lwt.t proto_operation proto_tzresult Lwt.t
val origination_full : val origination_full :
?spendable:bool -> ?delegatable:bool -> ?fee:Tez.tez -> ?spendable:bool -> ?delegatable:bool -> ?fee:Tez.tez ->
Helpers_account.t -> Tez.t -> Proto_alpha.Environment.Context.t -> Helpers_account.t -> Tez.t -> Alpha_environment.Context.t ->
proto_operation proto_tzresult Lwt.t proto_operation proto_tzresult Lwt.t
val transaction_full : val transaction_full :
?fee:Tez.tez -> ?parameters:Proto_alpha.Tezos_context.Script.expr -> Helpers_account.t -> Contract.contract -> Tez.t -> ?fee:Tez.tez -> ?parameters:Proto_alpha.Tezos_context.Script.expr -> Helpers_account.t -> Contract.contract -> Tez.t ->
Proto_alpha.Environment.Context.t -> proto_operation proto_tzresult Lwt.t Alpha_environment.Context.t -> proto_operation proto_tzresult Lwt.t
val delegate : val delegate :
Helpers_account.t -> delegate_operation list -> sourced_operations Helpers_account.t -> delegate_operation list -> sourced_operations

View File

@ -38,7 +38,7 @@ module Shorthands = struct
~fitness:res.validation.fitness ~fitness:res.validation.fitness
let get_balance_res (account:Account.t) (result:Block.result) = let get_balance_res (account:Account.t) (result:Block.result) =
let open Proto_alpha.Environment.Error_monad in let open Alpha_environment.Error_monad in
get_tc_full result >>=? fun tc -> get_tc_full result >>=? fun tc ->
Tezos_context.Contract.get_balance tc account.contract Tezos_context.Contract.get_balance tc account.contract

View File

@ -12,11 +12,11 @@ module Context =
Tezos_protocol_environment_client.Mem_context Tezos_protocol_environment_client.Mem_context
module Updater = module Updater =
Tezos_protocol_environment_client.Fake_updater.Make(Context) Tezos_protocol_environment_client.Fake_updater.Make(Context)
module Environment = module Alpha_environment =
Tezos_base.Protocol_environment.MakeV1(Name)(Context)(Updater)() Tezos_base.Protocol_environment.MakeV1(Name)(Context)(Updater)()
include Tezos_protocol_alpha.Functor.Make(Environment) include Tezos_protocol_alpha.Functor.Make(Alpha_environment)
module Error_monad = Environment.Error_monad module Error_monad = Alpha_environment.Error_monad
type proto_error = Error_monad.error type proto_error = Error_monad.error
type 'a proto_tzresult = 'a Error_monad.tzresult type 'a proto_tzresult = 'a Error_monad.tzresult

View File

@ -8,5 +8,5 @@
(**************************************************************************) (**************************************************************************)
module Name = struct let name = "genesis-alpha" end module Name = struct let name = "genesis-alpha" end
module Environment = Tezos_protocol_environment_client.Fake.Make(Name)() module Alpha_environment = Tezos_protocol_environment_client.Fake.Make(Name)()
include Tezos_protocol_alpha.Functor.Make(Environment) include Tezos_protocol_alpha.Functor.Make(Alpha_environment)

View File

@ -8,5 +8,5 @@
(**************************************************************************) (**************************************************************************)
module Name = struct let name = "genesis" end module Name = struct let name = "genesis" end
module Environment = Tezos_protocol_environment_client.Fake.Make(Name)() module Genesis_environment = Tezos_protocol_environment_client.Fake.Make(Name)()
include Tezos_protocol_genesis.Functor.Make(Environment) include Tezos_protocol_genesis.Functor.Make(Genesis_environment)