2018-02-14 14:01:23 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
open Client_config
|
|
|
|
|
|
|
|
let get_commands_for_version ctxt block protocol =
|
2018-05-29 15:14:04 +04:00
|
|
|
Shell_services.Blocks.protocols ctxt ~block () >>= function
|
|
|
|
| Ok { next_protocol = version } -> begin
|
2018-02-14 14:01:23 +04:00
|
|
|
match protocol with
|
|
|
|
| None ->
|
|
|
|
return (Some version, Client_commands.commands_for_version version)
|
|
|
|
| Some given_version -> begin
|
|
|
|
if not (Protocol_hash.equal version given_version) then
|
|
|
|
Format.eprintf
|
2018-02-14 20:27:39 +04:00
|
|
|
"@[<v 2>@{<warning>@{<title>Warning@}@}@,\
|
2018-02-28 17:57:22 +04:00
|
|
|
The protocol provided via `--protocol` (%a)@,\
|
2018-02-14 14:01:23 +04:00
|
|
|
is not the one retrieved from the node (%a).@]@\n@."
|
|
|
|
Protocol_hash.pp_short given_version
|
|
|
|
Protocol_hash.pp_short version ;
|
|
|
|
return (Some version, Client_commands.commands_for_version given_version)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
| Error errs -> begin
|
|
|
|
match protocol with
|
|
|
|
| None -> begin
|
|
|
|
Format.eprintf
|
|
|
|
"@[<v 2>@{<warning>@{<title>Warning@}@}@,\
|
|
|
|
Failed to acquire the protocol version from the node@,%a@]@\n@."
|
|
|
|
(Format.pp_print_list pp) errs ;
|
|
|
|
return (None, [])
|
|
|
|
end
|
|
|
|
| Some version ->
|
|
|
|
return (Some version, Client_commands.commands_for_version version)
|
|
|
|
end
|
|
|
|
|
|
|
|
let select_commands ctxt { block ; protocol } =
|
|
|
|
get_commands_for_version ctxt block protocol >>|? fun (_, commands_for_version) ->
|
2018-02-14 18:20:03 +04:00
|
|
|
Client_rpc_commands.commands @
|
2018-05-26 12:52:34 +04:00
|
|
|
List.map
|
|
|
|
(Clic.map_command
|
|
|
|
(fun (o : Client_context.full) -> (o :> Client_context.io_wallet)))
|
2018-05-30 20:05:30 +04:00
|
|
|
(Tezos_signer_backends.Ledger.commands () @
|
|
|
|
Client_keys_commands.commands ()) @
|
2018-02-14 14:01:23 +04:00
|
|
|
Client_helpers_commands.commands () @
|
|
|
|
commands_for_version
|
|
|
|
|
|
|
|
let () = Client_main_run.run select_commands
|