Alpha/Client: fix incorrect 'delegate' display.

Signed-off-by: Grégoire Henry <gregoire.henry@tezos.com>
This commit is contained in:
Grégoire Henry 2018-03-12 18:13:27 +01:00
parent 487fce8be1
commit 7af7cb95e3
3 changed files with 12 additions and 16 deletions

View File

@ -135,15 +135,7 @@ let get_manager cctxt block source =
| None -> Alpha_services.Contract.manager cctxt block source | None -> Alpha_services.Contract.manager cctxt block source
let get_delegate cctxt block source = let get_delegate cctxt block source =
match Contract.is_implicit source with Alpha_services.Contract.delegate_opt cctxt block source
| 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
let may_check_key sourcePubKey sourcePubKeyHash = let may_check_key sourcePubKey sourcePubKeyHash =
match sourcePubKey with match sourcePubKey with

View File

@ -51,7 +51,7 @@ val get_delegate:
#Proto_alpha.rpc_context -> #Proto_alpha.rpc_context ->
Block_services.block -> Block_services.block ->
Contract.t -> 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 module Contract_tags : module type of Client_tags.Tags (struct
let name = "contract" let name = "contract"

View File

@ -112,12 +112,16 @@ let commands () =
@@ stop) @@ stop)
begin fun () (_, contract) (cctxt : Proto_alpha.full) -> begin fun () (_, contract) (cctxt : Proto_alpha.full) ->
Client_proto_contracts.get_delegate Client_proto_contracts.get_delegate
cctxt cctxt#block contract >>=? fun delegate -> cctxt cctxt#block contract >>=? function
Public_key_hash.rev_find cctxt delegate >>=? fun mn -> | None ->
Public_key_hash.to_source delegate >>=? fun m -> cctxt#message "none" >>= fun () ->
cctxt#message "%s (%s)" m return ()
(match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () -> | Some delegate ->
return () 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 ; end ;
command ~group ~desc: "Set the delegate of a contract." command ~group ~desc: "Set the delegate of a contract."