Client: remove useless argument
This commit is contained in:
parent
e03f842ece
commit
95ccd34864
@ -15,12 +15,8 @@ open Cli_entries
|
|||||||
module type Entity = sig
|
module type Entity = sig
|
||||||
type t
|
type t
|
||||||
val encoding : t Data_encoding.t
|
val encoding : t Data_encoding.t
|
||||||
val of_source :
|
val of_source : string -> t tzresult Lwt.t
|
||||||
#Client_commands.wallet ->
|
val to_source : t -> string tzresult Lwt.t
|
||||||
string -> t tzresult Lwt.t
|
|
||||||
val to_source :
|
|
||||||
#Client_commands.wallet ->
|
|
||||||
t -> string tzresult Lwt.t
|
|
||||||
val name : string
|
val name : string
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -59,12 +55,8 @@ module type Alias = sig
|
|||||||
val update :
|
val update :
|
||||||
#Client_commands.wallet ->
|
#Client_commands.wallet ->
|
||||||
string -> t -> unit tzresult Lwt.t
|
string -> t -> unit tzresult Lwt.t
|
||||||
val of_source :
|
val of_source : string -> t tzresult Lwt.t
|
||||||
#Client_commands.wallet ->
|
val to_source : t -> string tzresult Lwt.t
|
||||||
string -> t tzresult Lwt.t
|
|
||||||
val to_source :
|
|
||||||
#Client_commands.wallet ->
|
|
||||||
t -> string tzresult Lwt.t
|
|
||||||
val alias_param :
|
val alias_param :
|
||||||
?name:string ->
|
?name:string ->
|
||||||
?desc:string ->
|
?desc:string ->
|
||||||
@ -107,7 +99,6 @@ module Alias = functor (Entity : Entity) -> struct
|
|||||||
let set (wallet : #wallet) entries =
|
let set (wallet : #wallet) entries =
|
||||||
wallet#write Entity.name entries wallet_encoding
|
wallet#write Entity.name entries wallet_encoding
|
||||||
|
|
||||||
|
|
||||||
let autocomplete wallet =
|
let autocomplete wallet =
|
||||||
load wallet >>= function
|
load wallet >>= function
|
||||||
| Error _ -> return []
|
| Error _ -> return []
|
||||||
@ -204,9 +195,9 @@ module Alias = functor (Entity : Entity) -> struct
|
|||||||
return ()
|
return ()
|
||||||
else
|
else
|
||||||
iter_s
|
iter_s
|
||||||
(fun (n, _v) ->
|
(fun (n, v) ->
|
||||||
if n = s then
|
if n = s then
|
||||||
Entity.to_source wallet _v >>=? fun value ->
|
Entity.to_source v >>=? fun value ->
|
||||||
failwith
|
failwith
|
||||||
"@[<v 2>The %s alias %s already exists.@,\
|
"@[<v 2>The %s alias %s already exists.@,\
|
||||||
The current value is %s.@,\
|
The current value is %s.@,\
|
||||||
@ -247,13 +238,13 @@ module Alias = functor (Entity : Entity) -> struct
|
|||||||
failwith
|
failwith
|
||||||
"cannot read file (%s)" (Printexc.to_string exn))
|
"cannot read file (%s)" (Printexc.to_string exn))
|
||||||
>>=? fun content ->
|
>>=? fun content ->
|
||||||
of_source cctxt content in
|
of_source content in
|
||||||
begin
|
begin
|
||||||
match String.split ~limit:1 ':' s with
|
match String.split ~limit:1 ':' s with
|
||||||
| [ "alias" ; alias ]->
|
| [ "alias" ; alias ]->
|
||||||
find cctxt alias
|
find cctxt alias
|
||||||
| [ "text" ; text ] ->
|
| [ "text" ; text ] ->
|
||||||
of_source cctxt text
|
of_source text
|
||||||
| [ "file" ; path ] ->
|
| [ "file" ; path ] ->
|
||||||
read path
|
read path
|
||||||
| _ ->
|
| _ ->
|
||||||
@ -263,7 +254,7 @@ module Alias = functor (Entity : Entity) -> struct
|
|||||||
read s >>= function
|
read s >>= function
|
||||||
| Ok v -> return v
|
| Ok v -> return v
|
||||||
| Error r_errs ->
|
| Error r_errs ->
|
||||||
of_source cctxt s >>= function
|
of_source s >>= function
|
||||||
| Ok v -> return v
|
| Ok v -> return v
|
||||||
| Error s_errs ->
|
| Error s_errs ->
|
||||||
let all_errs =
|
let all_errs =
|
||||||
@ -278,7 +269,7 @@ module Alias = functor (Entity : Entity) -> struct
|
|||||||
|
|
||||||
let name (wallet : #wallet) d =
|
let name (wallet : #wallet) d =
|
||||||
rev_find wallet d >>=? function
|
rev_find wallet d >>=? function
|
||||||
| None -> Entity.to_source wallet d
|
| None -> Entity.to_source d
|
||||||
| Some name -> return name
|
| Some name -> return name
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,12 +11,8 @@
|
|||||||
module type Entity = sig
|
module type Entity = sig
|
||||||
type t
|
type t
|
||||||
val encoding : t Data_encoding.t
|
val encoding : t Data_encoding.t
|
||||||
val of_source :
|
val of_source : string -> t tzresult Lwt.t
|
||||||
#Client_commands.wallet ->
|
val to_source : t -> string tzresult Lwt.t
|
||||||
string -> t tzresult Lwt.t
|
|
||||||
val to_source :
|
|
||||||
#Client_commands.wallet ->
|
|
||||||
t -> string tzresult Lwt.t
|
|
||||||
val name : string
|
val name : string
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -55,12 +51,8 @@ module type Alias = sig
|
|||||||
val update :
|
val update :
|
||||||
#Client_commands.wallet ->
|
#Client_commands.wallet ->
|
||||||
string -> t -> unit tzresult Lwt.t
|
string -> t -> unit tzresult Lwt.t
|
||||||
val of_source :
|
val of_source : string -> t tzresult Lwt.t
|
||||||
#Client_commands.wallet ->
|
val to_source : t -> string tzresult Lwt.t
|
||||||
string -> t tzresult Lwt.t
|
|
||||||
val to_source :
|
|
||||||
#Client_commands.wallet ->
|
|
||||||
t -> string tzresult Lwt.t
|
|
||||||
val alias_param :
|
val alias_param :
|
||||||
?name:string ->
|
?name:string ->
|
||||||
?desc:string ->
|
?desc:string ->
|
||||||
|
@ -10,24 +10,24 @@
|
|||||||
module Public_key_hash = Client_aliases.Alias (struct
|
module Public_key_hash = Client_aliases.Alias (struct
|
||||||
type t = Ed25519.Public_key_hash.t
|
type t = Ed25519.Public_key_hash.t
|
||||||
let encoding = Ed25519.Public_key_hash.encoding
|
let encoding = Ed25519.Public_key_hash.encoding
|
||||||
let of_source _ s = Lwt.return (Ed25519.Public_key_hash.of_b58check s)
|
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 to_source p = return (Ed25519.Public_key_hash.to_b58check p)
|
||||||
let name = "public key hash"
|
let name = "public key hash"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
module Public_key = Client_aliases.Alias (struct
|
module Public_key = Client_aliases.Alias (struct
|
||||||
type t = Ed25519.Public_key.t
|
type t = Ed25519.Public_key.t
|
||||||
let encoding = Ed25519.Public_key.encoding
|
let encoding = Ed25519.Public_key.encoding
|
||||||
let of_source _ s = Lwt.return (Ed25519.Public_key.of_b58check s)
|
let of_source s = Lwt.return (Ed25519.Public_key.of_b58check s)
|
||||||
let to_source _ p = return (Ed25519.Public_key.to_b58check p)
|
let to_source p = return (Ed25519.Public_key.to_b58check p)
|
||||||
let name = "public key"
|
let name = "public key"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
module Secret_key = Client_aliases.Alias (struct
|
module Secret_key = Client_aliases.Alias (struct
|
||||||
type t = Ed25519.Secret_key.t
|
type t = Ed25519.Secret_key.t
|
||||||
let encoding = Ed25519.Secret_key.encoding
|
let encoding = Ed25519.Secret_key.encoding
|
||||||
let of_source _ s = Lwt.return (Ed25519.Secret_key.of_b58check s)
|
let of_source s = Lwt.return (Ed25519.Secret_key.of_b58check s)
|
||||||
let to_source _ p = return (Ed25519.Secret_key.to_b58check p)
|
let to_source p = return (Ed25519.Secret_key.to_b58check p)
|
||||||
let name = "secret key"
|
let name = "secret key"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ let commands () =
|
|||||||
list_keys cctxt >>=? fun l ->
|
list_keys cctxt >>=? fun l ->
|
||||||
iter_s
|
iter_s
|
||||||
(fun (name, pkh, pkm, pks) ->
|
(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
|
cctxt#message "%s: %s%s%s" name v
|
||||||
(if pkm then " (public key known)" else "")
|
(if pkm then " (public key known)" else "")
|
||||||
(if pks then " (secret key known)" else "") >>= fun () ->
|
(if pks then " (secret key known)" else "") >>= fun () ->
|
||||||
@ -251,18 +251,18 @@ let commands () =
|
|||||||
match key_info with
|
match key_info with
|
||||||
| None -> ok_lwt @@ cctxt#message "No keys found for identity"
|
| None -> ok_lwt @@ cctxt#message "No keys found for identity"
|
||||||
| Some (hash, pub, priv) ->
|
| 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 () ->
|
ok_lwt @@ cctxt#message "Hash: %s" hash >>=? fun () ->
|
||||||
match pub with
|
match pub with
|
||||||
| None -> return ()
|
| None -> return ()
|
||||||
| Some pub ->
|
| 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 () ->
|
ok_lwt @@ cctxt#message "Public Key: %s" pub >>=? fun () ->
|
||||||
if show_private then
|
if show_private then
|
||||||
match priv with
|
match priv with
|
||||||
| None -> return ()
|
| None -> return ()
|
||||||
| Some priv ->
|
| 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
|
ok_lwt @@ cctxt#message "Secret Key: %s" priv
|
||||||
else return ()) ;
|
else return ()) ;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ module Tags (Entity : Entity) = struct
|
|||||||
let encoding = Tag.encoding
|
let encoding = Tag.encoding
|
||||||
|
|
||||||
(* Split a string of tags separated by commas, and possibly spaces *)
|
(* 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 =
|
let rec aux tags s =
|
||||||
try
|
try
|
||||||
let idx = String.index s ',' in
|
let idx = String.index s ',' in
|
||||||
@ -53,7 +53,7 @@ module Tags (Entity : Entity) = struct
|
|||||||
in
|
in
|
||||||
return (aux [] tags_str)
|
return (aux [] tags_str)
|
||||||
|
|
||||||
let to_source _ tags =
|
let to_source tags =
|
||||||
return (String.concat ", " tags)
|
return (String.concat ", " tags)
|
||||||
|
|
||||||
let name = Entity.name ^ " tag"
|
let name = Entity.name ^ " tag"
|
||||||
@ -66,7 +66,7 @@ module Tags (Entity : Entity) = struct
|
|||||||
^ "can be one or multiple tags separated by commas" in
|
^ "can be one or multiple tags separated by commas" in
|
||||||
Cli_entries.(
|
Cli_entries.(
|
||||||
param ~name ~desc
|
param ~name ~desc
|
||||||
(parameter (fun cctxt s -> of_source cctxt s))
|
(parameter (fun _ s -> of_source s))
|
||||||
next)
|
next)
|
||||||
|
|
||||||
let rev_find_by_tag cctxt tag =
|
let rev_find_by_tag cctxt tag =
|
||||||
|
@ -99,7 +99,7 @@ let commands () =
|
|||||||
Client_proto_contracts.get_manager
|
Client_proto_contracts.get_manager
|
||||||
cctxt cctxt#block contract >>=? fun manager ->
|
cctxt cctxt#block contract >>=? fun manager ->
|
||||||
Public_key_hash.rev_find cctxt manager >>=? fun mn ->
|
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
|
cctxt#message "%s (%s)" m
|
||||||
(match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () ->
|
(match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () ->
|
||||||
return ()
|
return ()
|
||||||
@ -114,7 +114,7 @@ let commands () =
|
|||||||
Client_proto_contracts.get_delegate
|
Client_proto_contracts.get_delegate
|
||||||
cctxt cctxt#block contract >>=? fun delegate ->
|
cctxt cctxt#block contract >>=? fun delegate ->
|
||||||
Public_key_hash.rev_find cctxt delegate >>=? fun mn ->
|
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
|
cctxt#message "%s (%s)" m
|
||||||
(match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () ->
|
(match mn with None -> "unknown" | Some n -> "known as " ^ n) >>= fun () ->
|
||||||
return ()
|
return ()
|
||||||
|
@ -13,13 +13,13 @@ open Tezos_context
|
|||||||
module ContractEntity = struct
|
module ContractEntity = struct
|
||||||
type t = Contract.t
|
type t = Contract.t
|
||||||
let encoding = Contract.encoding
|
let encoding = Contract.encoding
|
||||||
let of_source _ s =
|
let of_source s =
|
||||||
match Contract.of_b58check s with
|
match Contract.of_b58check s with
|
||||||
| Error _ as err ->
|
| Error _ as err ->
|
||||||
Lwt.return (Environment.wrap_error err)
|
Lwt.return (Environment.wrap_error err)
|
||||||
|> trace (failure "bad contract notation")
|
|> trace (failure "bad contract notation")
|
||||||
| Ok s -> return s
|
| 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"
|
let name = "contract"
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ module ContractAlias = struct
|
|||||||
find cctxt s >>= function
|
find cctxt s >>= function
|
||||||
| Ok v -> return v
|
| Ok v -> return v
|
||||||
| Error k_errs ->
|
| Error k_errs ->
|
||||||
ContractEntity.of_source cctxt s >>= function
|
ContractEntity.of_source s >>= function
|
||||||
| Ok v -> return (s, v)
|
| Ok v -> return (s, v)
|
||||||
| Error c_errs ->
|
| Error c_errs ->
|
||||||
Lwt.return (Error (k_errs @ c_errs))
|
Lwt.return (Error (k_errs @ c_errs))
|
||||||
|
@ -20,9 +20,9 @@ module Program = Client_aliases.Alias (struct
|
|||||||
(fun ({ Michelson_v1_parser.source }, _) -> source)
|
(fun ({ Michelson_v1_parser.source }, _) -> source)
|
||||||
(fun source -> Michelson_v1_parser.parse_toplevel source)
|
(fun source -> Michelson_v1_parser.parse_toplevel source)
|
||||||
Data_encoding.string
|
Data_encoding.string
|
||||||
let of_source _cctxt source =
|
let of_source source =
|
||||||
return (Michelson_v1_parser.parse_toplevel 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"
|
let name = "program"
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ let commands () =
|
|||||||
@@ Program.alias_param
|
@@ Program.alias_param
|
||||||
@@ stop)
|
@@ stop)
|
||||||
(fun () (_, program) (cctxt : Client_commands.full_context) ->
|
(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 () ->
|
cctxt#message "%s\n" source >>= fun () ->
|
||||||
return ()) ;
|
return ()) ;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user