From 8ff7aac5a645dc3a039855ae54d4d027e20d25c0 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Tue, 26 Jun 2018 00:44:23 +0200 Subject: [PATCH] Client: add disclaimer banners --- src/bin_client/main_client.ml | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/src/bin_client/main_client.ml b/src/bin_client/main_client.ml index e56f5507c..8f622966e 100644 --- a/src/bin_client/main_client.ml +++ b/src/bin_client/main_client.ml @@ -9,6 +9,69 @@ open Client_config +let display_warning_banner ctxt = + let default () = + Format.eprintf + "@[@{@{Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ Use your fundraiser keys @{<warning>AT YOUR OWN RISK@}.@,\ + All transactions happening on the Betanet @{<warning>are expected to be valid in the Mainnet@}.@,\ + \ In doubt, we recommend that you wait for the lunch of the Mainnet.@]@\n@." ; + Lwt.return () in + Shell_services.P2p.versions ctxt >>= function + | Error _ -> default () + | Ok versions -> + match String.split_on_char '_' (List.hd versions).name with + | "TEZOS" :: "ZERONET" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running on the@,\ + \ @{<warning>Tezos Zeronet DEVELOPMENT NETWORK@}.@,\ + \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ + Zeronet is a testing network, with free tokens and frequent resets.@]@\n@." ; + Lwt.return () + | "TEZOS" :: "ALPHANET" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running on the@,\ + \ @{<warning>Tezos Alphanet DEVELOPMENT NETWORK.@}@,\ + \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ + \ Alphanet is a testing network, with free tokens.@]@\n@." ; + Lwt.return () + | "TEZOS" :: "BETANET" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running on the@,\ + \ @{<warning>Tezos Betanet EXPERIMENTAL NETWORK@}.@,\ + \ Betanet is a pre-release experimental network and comes with no warranty.@,\ + \ Use your fundraiser keys on this network @{<warning>AT YOUR OWN RISK@}.@,\ + \ All transactions happening on the Betanet @{<warning>are expected to be valid in the Mainnet@}.@,\ + \ If in doubt, we recommend that you wait for the Mainnet lunch.@]@\n@." ; + Lwt.return () + | "TEZOS" :: _date :: [] -> + Format.eprintf + "@[<v 2>@{<warning>@{<title>Warning@}@}@,@,\ + \ This is @{<warning>NOT@} the Tezos Mainnet.@,\ + \ The Tezos Mainnet is not yet released.@,\ + @,\ + \ The node you are connecting to claims to be running in a@,\ + \ @{<warning>Tezos TEST SANDBOX@}.@,\ + \ Do @{<warning>NOT@} use your fundraiser keys on this network.@,\ + You should not see this message if you are not a developer.@]@\n@." ; + Lwt.return () + | _ -> default () + let get_commands_for_version ctxt block protocol = Shell_services.Blocks.protocols ctxt ~block () >>= function | Ok { next_protocol = version } -> begin @@ -40,6 +103,7 @@ let get_commands_for_version ctxt block protocol = end let select_commands ctxt { block ; protocol } = + display_warning_banner ctxt >>= fun () -> get_commands_for_version ctxt block protocol >>|? fun (_, commands_for_version) -> Client_rpc_commands.commands @ List.map