Client: remove useless argument

This commit is contained in:
Vincent Bernardoff 2017-12-05 15:09:36 +01:00 committed by Benjamin Canou
parent e03f842ece
commit 95ccd34864
8 changed files with 35 additions and 52 deletions

View File

@ -15,12 +15,8 @@ open Cli_entries
module type Entity = sig
type t
val encoding : t Data_encoding.t
val of_source :
#Client_commands.wallet ->
string -> t tzresult Lwt.t
val to_source :
#Client_commands.wallet ->
t -> string tzresult Lwt.t
val of_source : string -> t tzresult Lwt.t
val to_source : t -> string tzresult Lwt.t
val name : string
end
@ -59,12 +55,8 @@ module type Alias = sig
val update :
#Client_commands.wallet ->
string -> t -> unit tzresult Lwt.t
val of_source :
#Client_commands.wallet ->
string -> t tzresult Lwt.t
val to_source :
#Client_commands.wallet ->
t -> string tzresult Lwt.t
val of_source : string -> t tzresult Lwt.t
val to_source : t -> string tzresult Lwt.t
val alias_param :
?name:string ->
?desc:string ->
@ -107,7 +99,6 @@ module Alias = functor (Entity : Entity) -> struct
let set (wallet : #wallet) entries =
wallet#write Entity.name entries wallet_encoding
let autocomplete wallet =
load wallet >>= function
| Error _ -> return []
@ -204,9 +195,9 @@ module Alias = functor (Entity : Entity) -> struct
return ()
else
iter_s
(fun (n, _v) ->
(fun (n, v) ->
if n = s then
Entity.to_source wallet _v >>=? fun value ->
Entity.to_source v >>=? fun value ->
failwith
"@[<v 2>The %s alias %s already exists.@,\
The current value is %s.@,\
@ -247,13 +238,13 @@ module Alias = functor (Entity : Entity) -> struct
failwith
"cannot read file (%s)" (Printexc.to_string exn))
>>=? fun content ->
of_source cctxt content in
of_source content in
begin
match String.split ~limit:1 ':' s with
| [ "alias" ; alias ]->
find cctxt alias
| [ "text" ; text ] ->
of_source cctxt text
of_source text
| [ "file" ; path ] ->
read path
| _ ->
@ -263,7 +254,7 @@ module Alias = functor (Entity : Entity) -> struct
read s >>= function
| Ok v -> return v
| Error r_errs ->
of_source cctxt s >>= function
of_source s >>= function
| Ok v -> return v
| Error s_errs ->
let all_errs =
@ -278,7 +269,7 @@ module Alias = functor (Entity : Entity) -> struct
let name (wallet : #wallet) d =
rev_find wallet d >>=? function
| None -> Entity.to_source wallet d
| None -> Entity.to_source d
| Some name -> return name
end

View File

@ -11,12 +11,8 @@
module type Entity = sig
type t
val encoding : t Data_encoding.t
val of_source :
#Client_commands.wallet ->
string -> t tzresult Lwt.t
val to_source :
#Client_commands.wallet ->
t -> string tzresult Lwt.t
val of_source : string -> t tzresult Lwt.t
val to_source : t -> string tzresult Lwt.t
val name : string
end
@ -55,12 +51,8 @@ module type Alias = sig
val update :
#Client_commands.wallet ->
string -> t -> unit tzresult Lwt.t
val of_source :
#Client_commands.wallet ->
string -> t tzresult Lwt.t
val to_source :
#Client_commands.wallet ->
t -> string tzresult Lwt.t
val of_source : string -> t tzresult Lwt.t
val to_source : t -> string tzresult Lwt.t
val alias_param :
?name:string ->
?desc:string ->

View File

@ -10,24 +10,24 @@
module Public_key_hash = Client_aliases.Alias (struct
type t = Ed25519.Public_key_hash.t
let encoding = Ed25519.Public_key_hash.encoding
let of_source _ s = Lwt.return (Ed25519.Public_key_hash.of_b58check s)
let to_source _ p = return (Ed25519.Public_key_hash.to_b58check p)
let of_source s = Lwt.return (Ed25519.Public_key_hash.of_b58check s)
let to_source p = return (Ed25519.Public_key_hash.to_b58check p)
let name = "public key hash"
end)
module Public_key = Client_aliases.Alias (struct
type t = Ed25519.Public_key.t
let encoding = Ed25519.Public_key.encoding
let of_source _ s = Lwt.return (Ed25519.Public_key.of_b58check s)
let to_source _ p = return (Ed25519.Public_key.to_b58check p)
let of_source s = Lwt.return (Ed25519.Public_key.of_b58check s)
let to_source p = return (Ed25519.Public_key.to_b58check p)
let name = "public key"
end)
module Secret_key = Client_aliases.Alias (struct
type t = Ed25519.Secret_key.t
let encoding = Ed25519.Secret_key.encoding
let of_source _ s = Lwt.return (Ed25519.Secret_key.of_b58check s)
let to_source _ p = return (Ed25519.Secret_key.to_b58check p)
let of_source s = Lwt.return (Ed25519.Secret_key.of_b58check s)
let to_source p = return (Ed25519.Secret_key.to_b58check p)
let name = "secret key"
end)
@ -233,7 +233,7 @@ let commands () =
list_keys cctxt >>=? fun l ->
iter_s
(fun (name, pkh, pkm, pks) ->
Public_key_hash.to_source cctxt pkh >>=? fun v ->
Public_key_hash.to_source pkh >>=? fun v ->
cctxt#message "%s: %s%s%s" name v
(if pkm then " (public key known)" else "")
(if pks then " (secret key known)" else "") >>= fun () ->
@ -251,18 +251,18 @@ let commands () =
match key_info with
| None -> ok_lwt @@ cctxt#message "No keys found for identity"
| Some (hash, pub, priv) ->
Public_key_hash.to_source cctxt hash >>=? fun hash ->
Public_key_hash.to_source hash >>=? fun hash ->
ok_lwt @@ cctxt#message "Hash: %s" hash >>=? fun () ->
match pub with
| None -> return ()
| Some pub ->
Public_key.to_source cctxt pub >>=? fun pub ->
Public_key.to_source pub >>=? fun pub ->
ok_lwt @@ cctxt#message "Public Key: %s" pub >>=? fun () ->
if show_private then
match priv with
| None -> return ()
| Some priv ->
Secret_key.to_source cctxt priv >>=? fun priv ->
Secret_key.to_source priv >>=? fun priv ->
ok_lwt @@ cctxt#message "Secret Key: %s" priv
else return ()) ;

View File

@ -40,7 +40,7 @@ module Tags (Entity : Entity) = struct
let encoding = Tag.encoding
(* Split a string of tags separated by commas, and possibly spaces *)
let of_source _ tags_str =
let of_source tags_str =
let rec aux tags s =
try
let idx = String.index s ',' in
@ -53,7 +53,7 @@ module Tags (Entity : Entity) = struct
in
return (aux [] tags_str)
let to_source _ tags =
let to_source tags =
return (String.concat ", " tags)
let name = Entity.name ^ " tag"
@ -66,7 +66,7 @@ module Tags (Entity : Entity) = struct
^ "can be one or multiple tags separated by commas" in
Cli_entries.(
param ~name ~desc
(parameter (fun cctxt s -> of_source cctxt s))
(parameter (fun _ s -> of_source s))
next)
let rev_find_by_tag cctxt tag =

View File

@ -99,7 +99,7 @@ let commands () =
Client_proto_contracts.get_manager
cctxt cctxt#block contract >>=? fun manager ->
Public_key_hash.rev_find cctxt manager >>=? fun mn ->
Public_key_hash.to_source cctxt manager >>=? fun m ->
Public_key_hash.to_source manager >>=? fun m ->
cctxt#message "%s (%s)" m
(match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () ->
return ()
@ -114,7 +114,7 @@ let commands () =
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 cctxt delegate >>=? fun m ->
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 ()

View File

@ -13,13 +13,13 @@ open Tezos_context
module ContractEntity = struct
type t = Contract.t
let encoding = Contract.encoding
let of_source _ s =
let of_source s =
match Contract.of_b58check s with
| Error _ as err ->
Lwt.return (Environment.wrap_error err)
|> trace (failure "bad contract notation")
| Ok s -> return s
let to_source _ s = return (Contract.to_b58check s)
let to_source s = return (Contract.to_b58check s)
let name = "contract"
end
@ -96,7 +96,7 @@ module ContractAlias = struct
find cctxt s >>= function
| Ok v -> return v
| Error k_errs ->
ContractEntity.of_source cctxt s >>= function
ContractEntity.of_source s >>= function
| Ok v -> return (s, v)
| Error c_errs ->
Lwt.return (Error (k_errs @ c_errs))

View File

@ -20,9 +20,9 @@ module Program = Client_aliases.Alias (struct
(fun ({ Michelson_v1_parser.source }, _) -> source)
(fun source -> Michelson_v1_parser.parse_toplevel source)
Data_encoding.string
let of_source _cctxt source =
let of_source source =
return (Michelson_v1_parser.parse_toplevel source)
let to_source _ ({ Michelson_v1_parser.source }, _) = return source
let to_source ({ Michelson_v1_parser.source }, _) = return source
let name = "program"
end)

View File

@ -71,7 +71,7 @@ let commands () =
@@ Program.alias_param
@@ stop)
(fun () (_, program) (cctxt : Client_commands.full_context) ->
Program.to_source cctxt program >>=? fun source ->
Program.to_source program >>=? fun source ->
cctxt#message "%s\n" source >>= fun () ->
return ()) ;