From 7af7cb95e37b76a7642104b601bdada572bdebde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Henry?= Date: Mon, 12 Mar 2018 18:13:27 +0100 Subject: [PATCH] Alpha/Client: fix incorrect 'delegate' display. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Grégoire Henry --- .../lib_client/client_proto_contracts.ml | 10 +--------- .../lib_client/client_proto_contracts.mli | 2 +- .../client_proto_context_commands.ml | 16 ++++++++++------ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/proto_alpha/lib_client/client_proto_contracts.ml b/src/proto_alpha/lib_client/client_proto_contracts.ml index d6ca6dce1..bc273d55c 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.ml +++ b/src/proto_alpha/lib_client/client_proto_contracts.ml @@ -135,15 +135,7 @@ let get_manager cctxt block source = | None -> Alpha_services.Contract.manager cctxt block source let get_delegate cctxt block source = - match Contract.is_implicit source with - | Some hash -> return hash - | None -> - Alpha_services.Contract.delegate_opt cctxt - block source >>=? function - | Some delegate -> - return delegate - | None -> - Alpha_services.Contract.manager cctxt block source + Alpha_services.Contract.delegate_opt cctxt block source let may_check_key sourcePubKey sourcePubKeyHash = match sourcePubKey with diff --git a/src/proto_alpha/lib_client/client_proto_contracts.mli b/src/proto_alpha/lib_client/client_proto_contracts.mli index 0de327619..5a225ba62 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.mli +++ b/src/proto_alpha/lib_client/client_proto_contracts.mli @@ -51,7 +51,7 @@ val get_delegate: #Proto_alpha.rpc_context -> Block_services.block -> Contract.t -> - public_key_hash tzresult Lwt.t + public_key_hash option tzresult Lwt.t module Contract_tags : module type of Client_tags.Tags (struct let name = "contract" diff --git a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml index 5262912a7..e6af300bd 100644 --- a/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client_commands/client_proto_context_commands.ml @@ -112,12 +112,16 @@ let commands () = @@ stop) begin fun () (_, contract) (cctxt : Proto_alpha.full) -> Client_proto_contracts.get_delegate - cctxt cctxt#block contract >>=? fun delegate -> - Public_key_hash.rev_find cctxt delegate >>=? fun mn -> - Public_key_hash.to_source delegate >>=? fun m -> - cctxt#message "%s (%s)" m - (match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () -> - return () + cctxt cctxt#block contract >>=? function + | None -> + cctxt#message "none" >>= fun () -> + return () + | Some delegate -> + Public_key_hash.rev_find cctxt delegate >>=? fun mn -> + Public_key_hash.to_source delegate >>=? fun m -> + cctxt#message "%s (%s)" m + (match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () -> + return () end ; command ~group ~desc: "Set the delegate of a contract."