123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019 Nomadic Labs <contact@nomadic-labs.com> *)(* *)(* Permission is hereby granted, free of charge, to any person obtaining a *)(* copy of this software and associated documentation files (the "Software"),*)(* to deal in the Software without restriction, including without limitation *)(* the rights to use, copy, modify, merge, publish, distribute, sublicense, *)(* and/or sell copies of the Software, and to permit persons to whom the *)(* Software is furnished to do so, subject to the following conditions: *)(* *)(* The above copyright notice and this permission notice shall be included *)(* in all copies or substantial portions of the Software. *)(* *)(* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*)(* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *)(* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *)(* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*)(* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *)(* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *)(* DEALINGS IN THE SOFTWARE. *)(* *)(*****************************************************************************)openAlpha_client_contextopenProtocolopenAlpha_contexttypeerror+=Bad_tez_argofstring*string(* Arg_name * value *)let()=register_error_kind`Permanent~id:"badTezArg"~title:"Bad Tez Arg"~description:"Invalid \xEA\x9C\xA9 notation in parameter."~pp:(funppf(arg_name,literal)->Format.fprintfppf"Invalid \xEA\x9C\xA9 notation in parameter %s: '%s'"arg_nameliteral)Data_encoding.(obj2(req"parameter"string)(req"literal"string))(function|Bad_tez_arg(parameter,literal)->Some(parameter,literal)|_->None)(fun(parameter,literal)->Bad_tez_arg(parameter,literal))lettez_sym="\xEA\x9C\xA9"letbytes_parameter=Tezos_clic.parameter(fun_s->matchifString.lengths<2||s.[0]<>'0'||s.[1]<>'x'thenNoneelseHex.to_bytes(`Hex(String.subs2(String.lengths-2)))with|Somes->returns|None->failwith"Invalid bytes, expecting hexadecimal notation (e.g. 0x1234abcd)")lettez_parameterparam=Tezos_clic.parameter(fun_s->matchTez.of_stringswith|Sometez->returntez|None->fail(Bad_tez_arg(param,s)))lettez_arg~default~parameter~doc=Tezos_clic.default_arg~long:parameter~placeholder:"amount"~doc~default(tez_parameter("--"^parameter))letno_print_source_flag=Tezos_clic.switch~long:"no-print-source"~short:'q'~doc:"don't print the source code\n\
If an error is encountered, the client will print the contract's source \
code by default.\n\
This option disables this behaviour."()