Client: cosmetic updates in voting commands

This commit is contained in:
Benjamin Canou 2019-01-02 17:25:10 +01:00 committed by Marco Stronati
parent cacd3826e4
commit 618082ed18
2 changed files with 18 additions and 17 deletions

View File

@ -437,7 +437,7 @@ type ballots_info = {
(* Should be moved to src/proto_alpha/lib_protocol/src/vote_storage.ml *) (* Should be moved to src/proto_alpha/lib_protocol/src/vote_storage.ml *)
let ballot_list_encoding = let ballot_list_encoding =
Data_encoding.(list (obj2 Data_encoding.(list (obj2
(req "pkh" Signature.Public_key_hash.encoding) (req "delegate" Signature.Public_key_hash.encoding)
(req "ballot" Vote.ballot_encoding))) (req "ballot" Vote.ballot_encoding)))
let get_ballots_info let get_ballots_info

View File

@ -643,15 +643,16 @@ let commands version () =
return_unit return_unit
end ; end ;
command ~group ~desc: "Submit protocol proposals." command ~group ~desc: "Submit protocol proposals"
no_options no_options
(prefixes [ "submit" ; "proposals" ; "for" ] (prefixes [ "submit" ; "proposals" ; "for" ]
@@ ContractAlias.destination_param @@ ContractAlias.destination_param
~name: "src" ~desc: "name of the source contract" ~name: "delegate"
~desc: "the delegate who makes the proposal"
@@ seq_of_param @@ seq_of_param
(param (param
~name:"proposal" ~name:"proposal"
~desc:"Proposal to be submitted" ~desc:"the protocol hash proposal to be submitted"
(parameter (parameter
(fun _ x -> (fun _ x ->
match Protocol_hash.of_b58check_opt x with match Protocol_hash.of_b58check_opt x with
@ -686,14 +687,15 @@ let commands version () =
return_unit return_unit
end ; end ;
command ~group ~desc: "Submit a ballot." command ~group ~desc: "Submit a ballot"
no_options no_options
(prefixes [ "submit" ; "ballot" ; "for" ] (prefixes [ "submit" ; "ballot" ; "for" ]
@@ ContractAlias.destination_param @@ ContractAlias.destination_param
~name: "src" ~desc: "name of the source contract" ~name: "delegate"
~desc: "the delegate who votes"
@@ param @@ param
~name:"proposal" ~name:"proposal"
~desc:"Proposal" ~desc:"the protocol hash proposal to vote for"
(parameter (parameter
(fun _ x -> (fun _ x ->
match Protocol_hash.of_b58check_opt x with match Protocol_hash.of_b58check_opt x with
@ -701,16 +703,15 @@ let commands version () =
| Some hash -> return hash)) | Some hash -> return hash))
@@ param @@ param
~name:"ballot" ~name:"ballot"
~desc:"Ballot(yay/nay/pass)" ~desc:"the ballot value (yay, nay or pass)"
(parameter (parameter
(fun _ s -> ~autocomplete: (fun _ -> return [ "yea" ; "nay" ; "pass" ])
let fail () = failwith "Invalid ballot: '%s'" s in (fun _ s -> (* We should have [Vote.of_string]. *)
match Data_encoding.Json.from_string ("\"" ^ s ^ "\"") with match String.lowercase_ascii s with
| Error _ -> fail () | "yay" | "yea" -> return Vote.Yay
| Ok j -> | "nay" -> return Vote.Nay
match Data_encoding.Json.destruct Vote.ballot_encoding j with | "pass" -> return Vote.Pass
| exception _ -> fail () | s -> failwith "Invalid ballot: '%s'" s))
| b -> return b))
@@ stop) @@ stop)
begin fun () (_name, source) proposal ballot (cctxt : Proto_alpha.full) -> begin fun () (_name, source) proposal ballot (cctxt : Proto_alpha.full) ->
get_period_info ~chain:`Main ~block:cctxt#block cctxt >>=? fun info -> get_period_info ~chain:`Main ~block:cctxt#block cctxt >>=? fun info ->
@ -726,7 +727,7 @@ let commands version () =
return_unit return_unit
end ; end ;
command ~group ~desc: "Summarize the current voting period." command ~group ~desc: "Summarize the current voting period"
no_options no_options
(fixed [ "show" ; "voting" ; "period" ]) (fixed [ "show" ; "voting" ; "period" ])
begin fun () (cctxt : Proto_alpha.full) -> begin fun () (cctxt : Proto_alpha.full) ->