From 95ccd3486484a33585c80d28179672844b48975a Mon Sep 17 00:00:00 2001 From: Vincent Bernardoff Date: Tue, 5 Dec 2017 15:09:36 +0100 Subject: [PATCH] Client: remove useless argument --- src/lib_client_base/client_aliases.ml | 29 +++++++------------ src/lib_client_base/client_aliases.mli | 16 +++------- src/lib_client_base/client_keys.ml | 20 ++++++------- src/lib_client_base/client_tags.ml | 6 ++-- .../client_proto_context_commands.ml | 4 +-- .../lib_client/client_proto_contracts.ml | 6 ++-- .../lib_client/client_proto_programs.ml | 4 +-- .../client_proto_programs_commands.ml | 2 +- 8 files changed, 35 insertions(+), 52 deletions(-) diff --git a/src/lib_client_base/client_aliases.ml b/src/lib_client_base/client_aliases.ml index 69216ae2f..7b16fd6e3 100644 --- a/src/lib_client_base/client_aliases.ml +++ b/src/lib_client_base/client_aliases.ml @@ -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 "@[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 diff --git a/src/lib_client_base/client_aliases.mli b/src/lib_client_base/client_aliases.mli index 18d5c4893..7c165ee88 100644 --- a/src/lib_client_base/client_aliases.mli +++ b/src/lib_client_base/client_aliases.mli @@ -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 -> diff --git a/src/lib_client_base/client_keys.ml b/src/lib_client_base/client_keys.ml index 6b14c6a5a..9e20f65b4 100644 --- a/src/lib_client_base/client_keys.ml +++ b/src/lib_client_base/client_keys.ml @@ -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 ()) ; diff --git a/src/lib_client_base/client_tags.ml b/src/lib_client_base/client_tags.ml index 45f4f887a..ae2b55529 100644 --- a/src/lib_client_base/client_tags.ml +++ b/src/lib_client_base/client_tags.ml @@ -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 = diff --git a/src/proto_alpha/lib_client/client_proto_context_commands.ml b/src/proto_alpha/lib_client/client_proto_context_commands.ml index dd941467c..a9ce7a2e3 100644 --- a/src/proto_alpha/lib_client/client_proto_context_commands.ml +++ b/src/proto_alpha/lib_client/client_proto_context_commands.ml @@ -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 () diff --git a/src/proto_alpha/lib_client/client_proto_contracts.ml b/src/proto_alpha/lib_client/client_proto_contracts.ml index 6110d0ae9..7b0281fa2 100644 --- a/src/proto_alpha/lib_client/client_proto_contracts.ml +++ b/src/proto_alpha/lib_client/client_proto_contracts.ml @@ -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)) diff --git a/src/proto_alpha/lib_client/client_proto_programs.ml b/src/proto_alpha/lib_client/client_proto_programs.ml index c292a1112..596031325 100644 --- a/src/proto_alpha/lib_client/client_proto_programs.ml +++ b/src/proto_alpha/lib_client/client_proto_programs.ml @@ -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) diff --git a/src/proto_alpha/lib_client/client_proto_programs_commands.ml b/src/proto_alpha/lib_client/client_proto_programs_commands.ml index 13065a4c7..e56990b0b 100644 --- a/src/proto_alpha/lib_client/client_proto_programs_commands.ml +++ b/src/proto_alpha/lib_client/client_proto_programs_commands.ml @@ -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 ()) ;