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
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

View File

@ -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"

View File

@ -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."