123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)openProtocol_client_contextopenProtocolopenAlpha_contexttypeerror+=Bad_tez_argofstring*string(* Arg_name * value *)typeerror+=Bad_max_priorityofstringtypeerror+=Bad_minimal_feesofstringtypeerror+=Bad_max_waiting_timeofstringtypeerror+=Bad_preserved_levelsofstringtypeerror+=Forbidden_Negative_intofstringlet()=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));register_error_kind`Permanent~id:"badMaxPriorityArg"~title:"Bad -max-priority arg"~description:"invalid priority in -max-priority"~pp:(funppfliteral->Format.fprintfppf"invalid priority '%s' in -max-priority"literal)Data_encoding.(obj1(req"parameter"string))(functionBad_max_priorityparameter->Someparameter|_->None)(funparameter->Bad_max_priorityparameter);register_error_kind`Permanent~id:"badMinimalFeesArg"~title:"Bad -minimal-fees arg"~description:"invalid fee threshold in -fee-threshold"~pp:(funppfliteral->Format.fprintfppf"invalid minimal fees '%s'"literal)Data_encoding.(obj1(req"parameter"string))(functionBad_minimal_feesparameter->Someparameter|_->None)(funparameter->Bad_minimal_feesparameter);register_error_kind`Permanent~id:"badMaxWaitingTimeArg"~title:"Bad -max-waiting-time arg"~description:"invalid duration in -max-waiting-time"~pp:(funppfliteral->Format.fprintfppf"Bad argument value for -max-waiting-time. Expected an integer, but \
given '%s'"literal)Data_encoding.(obj1(req"parameter"string))(functionBad_max_waiting_timeparameter->Someparameter|_->None)(funparameter->Bad_max_waiting_timeparameter);register_error_kind`Permanent~id:"badPreservedLevelsArg"~title:"Bad -preserved-levels arg"~description:"invalid number of levels in -preserved-levels"~pp:(funppfliteral->Format.fprintfppf"Bad argument value for -preserved_levels. Expected a positive \
integer, but given '%s'"literal)Data_encoding.(obj1(req"parameter"string))(functionBad_preserved_levelsparameter->Someparameter|_->None)(funparameter->Bad_preserved_levelsparameter);register_error_kind`Permanent~id:"ForbiddenNegativeInt"~title:"Forbidden negative int"~description:"invalid number, must a non negative natural "Data_encoding.(obj1(req"invalid_natural"string))~pp:(funppfliteral->Format.fprintfppf"Bad argument value for natural. Expected a non negative integer, but \
given '%s'"literal)(functionForbidden_Negative_intstr->Somestr|_->None)(funstr->Forbidden_Negative_intstr)letstring_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun_x->returnx)letint_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)p->tryreturn(int_of_stringp)with_->cctxt#error"Cannot read int")letz_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)p->tryreturn(Z.of_stringp)with_->cctxt#error"Cannot read integer")leturi_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun_x->return(Uri.of_stringx))letbytes_of_prefixed_string(cctxt:#Client_context.full)s=letopenLwt_result_syntaxinmatchifString.lengths<2||s.[0]<>'0'||s.[1]<>'x'thenNoneelseHex.to_bytes(`Hex(String.subs2(String.lengths-2)))with|Somes->returns|None->cctxt#error"Invalid bytes, expecting hexadecimal notation (e.g. 0x1234abcd)"letbytes_parameter=Tezos_clic.parameterbytes_of_prefixed_stringtype'afile_or_text=Fileof{path:string;content:'a}|Textof'aletcontent_of_file_or_text=function|File{content;_}|Textcontent->contentletparse_file~from_text~read_file~path=letopenLwt_result_syntaxinlet*content=read_filepathinfrom_textcontentletfile_or_text~from_text~read_file=letopenLwt_result_syntaxinClient_aliases.parse_alternatives[("file",funpath->let*content=parse_file~from_text~read_file~pathinreturn(File{path;content}));("text",funtext->let*content=from_texttextinreturn(Textcontent));]letfile_or_text_with_origin_parameter~from_text()=Tezos_clic.parameter(fun(cctxt:#Client_context.full)->file_or_text~from_text:(from_textcctxt)~read_file:cctxt#read_file)letfile_or_text_parameter~from_text()=file_or_text_with_origin_parameter~from_text()|>Tezos_clic.map_parameter~f:content_of_file_or_textletjson_with_origin_parameter=letopenLwt_result_syntaxinletfrom_text(cctxt:#Client_context.full)s=matchData_encoding.Json.from_stringswith|Okjson->returnjson|Errorerr->cctxt#error"'%s' is not a valid JSON-encoded value: %s"serrinfile_or_text_with_origin_parameter~from_text()letjson_parameter=Tezos_clic.map_parameter~f:content_of_file_or_textjson_with_origin_parameterletdata_parameter=letfrom_text(_cctxt:#Client_context.full)input=Lwt.return@@Tezos_micheline.Micheline_parser.no_parsing_error@@Michelson_v1_parser.parse_expressioninputinfile_or_text_parameter~from_text()letsafe_decode_json(cctxt:#Client_context.full)~name?(pp_error=fun_jsonfmtexn->Data_encoding.Json.print_errorfmtexn)encodingjson=letopenLwt_result_syntaxinmatchData_encoding.Json.destructencodingjsonwith|exception(Data_encoding.Json.Cannot_destruct_asexn)->cctxt#error"@[<v 2>could not decode %s JSON:@,%a@]"name(pp_errorjson)exn|exception((Stack_overflow|Out_of_memory)asexc)->raiseexc|exceptionexc->cctxt#error"could not decode json (%s)"(Printexc.to_stringexc)|expr->returnexprletjson_encoded_with_origin_parameter~name?pp_errorencoding=letopenLwt_result_syntaxinTezos_clic.map_es_parameter~f:(fun(cctxt:#Client_context.full)json_with_origin->matchjson_with_originwith|File{path;content}->let+content=safe_decode_json~name?pp_errorcctxtencodingcontentinFile{path;content}|Textcontent->let+content=safe_decode_json~namecctxtencodingcontentinTextcontent)json_with_origin_parameterletjson_encoded_parameter~name?pp_errorencoding=Tezos_clic.map_parameter~f:content_of_file_or_text(json_encoded_with_origin_parameter~name?pp_errorencoding)letjson_encoded_param~name~desc?pp_errorencoding=Tezos_clic.param~name~desc(json_encoded_parameter~name?pp_errorencoding)letbinary_encoded_parameter~nameencoding=letopenLwt_result_syntaxinletfrom_text(cctxt:#Client_context.full)s=matchData_encoding.Binary.of_bytes_optencoding(Bytes.of_strings)with|None->cctxt#error"Invalid %s parameter"name|Somex->returnxinfile_or_text_parameter~from_text()letparse_micheline_parametersource=Lwt.return@@Tezos_micheline.Micheline_parser.no_parsing_error@@Michelson_v1_parser.expand_expressionsourceletmicheline_parameter=Tezos_clic.parameter(fun(_:full)source->parse_micheline_parametersource)letentrypoint_parameter=Tezos_clic.parameter(fun_str->Lwt.return@@Environment.wrap_tzresult@@Entrypoint.of_string_laxstr)letinit_arg=Tezos_clic.default_arg~long:"init"~placeholder:"data"~doc:"initial value of the contract's storage"~default:"Unit"string_parameterletother_contracts_parameter=Tezos_clic.parameter(fun_source->letopenLwt_result_syntaxinlet*parsed=parse_micheline_parametersourceinlet*?l=Michelson_v1_stack.parse_other_contractsparsedinreturnl)letother_contracts_arg=Tezos_clic.arg~doc:{|types and addresses of extra contracts, formatted as {Contract "KT1..." <ty1>; Contract "KT1..." <ty2>; ...}|}~long:"other-contracts"~placeholder:"contracts"other_contracts_parameterletextra_big_maps_parameter=Tezos_clic.parameter(fun_source->letopenLwt_result_syntaxinlet*parsed=parse_micheline_parametersourceinlet*?l=Michelson_v1_stack.parse_extra_big_mapsparsedinreturnl)letextra_big_maps_arg=Tezos_clic.arg~doc:{|identifier and content of extra big maps, formatted as {Big_map <index> <key_type> <value_type> {Elt <key1> <value1>; Elt <key2> <value2>; ...}}|}~long:"extra-big-maps"~placeholder:"big maps"extra_big_maps_parameterletglobal_constant_param~name~descnext=Tezos_clic.param~name~descstring_parameternextletarg_arg=Tezos_clic.arg~long:"arg"~placeholder:"data"~doc:"argument passed to the contract's script, if needed"string_parameterletdefault_arg_arg=Tezos_clic.arg~long:"default-arg"~placeholder:"data"~doc:"default argument passed to each contract's script, if needed"string_parameterletdelegate_arg=Client_keys.Public_key_hash.source_arg~long:"delegate"~placeholder:"address"~doc:"delegate of the contract\nMust be a known address."()letsource_arg=Tezos_clic.arg~long:"source"~placeholder:"address"~doc:"source of the deposits to be paid\nMust be a known address."string_parameterletentrypoint_arg=Tezos_clic.arg~long:"entrypoint"~placeholder:"name"~doc:"entrypoint of the smart contract"entrypoint_parameterletdefault_entrypoint_arg=Tezos_clic.arg~long:"default-entrypoint"~placeholder:"name"~doc:"default entrypoint of the smart contracts"entrypoint_parameterletforce_switch=Tezos_clic.switch~long:"force"~short:'f'~doc:"disables the node's injection checks\n\
Force the injection of branch-invalid operation or force the injection \
of block without a fitness greater than the current head."()letminimal_timestamp_switch=Tezos_clic.switch~long:"minimal-timestamp"~doc:"Use the minimal timestamp instead of the current date as timestamp of \
the baked block."()lettez_format="Text format: `DDDDDDD.DDDDDD`.\n\
Tez and mutez and separated by a period sign. Trailing and pending zeroes \
are allowed."lettez_parameterparam=letopenLwt_result_syntaxinTezos_clic.parameter(fun_s->matchTez.of_stringswith|Sometez->returntez|None->tzfail(Bad_tez_arg(param,s)))leteverything_tez_parameterparam=letopenLwt_result_syntaxinTezos_clic.parameter(fun_s->matchswith|"everything"->returnTez.max_mutez|_->tzfail(Bad_tez_arg(param,s)))leteverything_or_tez_parameterparam=Tezos_clic.compose_parameters(tez_parameterparam)(everything_tez_parameterparam)lettez_arg~default~parameter~doc=Tezos_clic.default_arg~long:parameter~placeholder:"amount"~doc~default(tez_parameter("--"^parameter))lettez_opt_arg~parameter~doc=Tezos_clic.arg~long:parameter~placeholder:"amount"~doc(tez_parameter("--"^parameter))lettez_param~name~descnext=Tezos_clic.param~name~desc:(desc^" in \xEA\x9C\xA9\n"^tez_format)(tez_parametername)nextleteverything_or_tez_param~name~descnext=Tezos_clic.param~name~desc:(desc^" in \xEA\x9C\xA9 (or everything)\n"^tez_format)(everything_or_tez_parametername)nextletnon_negative_z_parser(cctxt:#Client_context.io)s=matchZ.of_stringswith|exceptionInvalid_argument_->cctxt#error"Expected number"|vwhenCompare.Z.(v<Z.zero)->cctxt#error"Invalid number, must be a non negative number."|v->Lwt_result_syntax.returnvletnon_negative_z_parameter()=Tezos_clic.parameternon_negative_z_parserletnon_negative_z_param~name~descnext=Tezos_clic.param~name~desc(non_negative_z_parameter())nextletcounter_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->matchManager_counter.Internal_for_injection.of_stringswith|None->cctxt#error"Invalid counter, must be a non-negative number."|Somec->returnc)letnon_negative_parser(cctxt:#Client_context.io)s=letopenLwt_result_syntaxinmatchint_of_string_optswith|Someiwheni>=0->returni|_->cctxt#error"Parameter should be a non-negative integer literal"letnon_negative_parameter()=Tezos_clic.parameternon_negative_parserletnon_negative_param~name~descnext=Tezos_clic.param~name~desc(non_negative_parameter())nextletpositive_int_parser(cctxt:#Client_context.io)s=letopenLwt_result_syntaxinmatchint_of_string_optswith|Someiwheni>0->returni|_->cctxt#error"Parameter should be a positive integer literal"letpositive_int_parameter()=Tezos_clic.parameterpositive_int_parserletpositive_int_param~name~descnext=Tezos_clic.param~name~desc(positive_int_parameter())nextletfee_arg=Tezos_clic.arg~long:"fee"~placeholder:"amount"~doc:"fee in \xEA\x9C\xA9 to pay to the baker"(tez_parameter"--fee")letdefault_fee_arg=Tezos_clic.arg~long:"default-fee"~placeholder:"amount"~doc:"default fee in \xEA\x9C\xA9 to pay to the baker for each transaction"(tez_parameter"--default-fee")letlevel_kind=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->matchOption.bind(Script_int.of_strings)Script_int.is_natwith|Somen->returnn|None->cctxt#error"invalid level (must be a positive number)")letlevel_arg=Tezos_clic.arg~long:"level"~placeholder:"level"~doc:"Set the level to be returned by the LEVEL instruction"level_kindletraw_level_parser(cctxt:#Client_context.io)s=matchInt32.of_string_optswith|Someiwheni>=0l->Lwt.return@@Environment.wrap_tzresult(Raw_level.of_int32i)|_->cctxt#error"'%s' is not a valid level (should be a non-negative int32 value)"sletraw_level_parameter()=Tezos_clic.parameterraw_level_parserletraw_level_param~name~descnext=Tezos_clic.param~name~desc(raw_level_parameter())nextlettimestamp_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->matchScript_timestamp.of_stringswith|Sometime->returntime|None->cctxt#error"invalid timestamp, must be either a RFC 3339 string or a number \
of seconds since epoch.")letnow_arg=Tezos_clic.arg~long:"now"~placeholder:"timestamp"~doc:"Set the timestamp to be returned by the NOW instruction. Allowed format \
are RFC 3339 (YYYY-MM-DDTHH:MM:SSZ) or number of seconds since epoch."timestamp_parameterletgas_limit_kind=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->tryletv=Z.of_stringsinreturn(Gas.Arith.integral_exnv)with_->cctxt#error"invalid gas limit (must be a positive number)")letgas_limit_arg=Tezos_clic.arg~long:"gas-limit"~short:'G'~placeholder:"amount"~doc:"Set the gas limit of the transaction instead of letting the client \
decide based on a simulation"gas_limit_kindletdefault_gas_limit_arg=Tezos_clic.arg~long:"default-gas-limit"~short:'G'~placeholder:"amount"~doc:"Set the default gas limit for each transaction instead of letting the \
client decide based on a simulation"gas_limit_kindletsafety_guard_arg=Tezos_clic.arg~long:"safety-guard"~placeholder:"extra_gas"~doc:"Amount of gas to add to value computed by simulation. The gas safety \
guard allows operations that consume a little more gas than expected to \
be successful"gas_limit_kindletrun_gas_limit_arg=Tezos_clic.arg~long:"gas"~short:'G'~doc:"Initial quantity of gas for typechecking and execution"~placeholder:"gas"gas_limit_kindletunlimited_gas_arg=Tezos_clic.switch~long:"unlimited-gas"~doc:"Allows interpretation with virtually unlimited gas"()letstorage_limit_kind=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->tryletv=Z.of_stringsinassert(Compare.Z.(v>=Z.zero));returnvwith_->cctxt#error"invalid storage limit (must be a positive number of bytes)")letstorage_limit_arg=Tezos_clic.arg~long:"storage-limit"~short:'S'~placeholder:"amount"~doc:"Set the storage limit of the transaction instead of letting the client \
decide based on a simulation"storage_limit_kindletdefault_storage_limit_arg=Tezos_clic.arg~long:"default-storage-limit"~short:'S'~placeholder:"amount"~doc:"Set the default storage limit for each transaction instead of letting \
the client decide based on a simulation"storage_limit_kindletcounter_arg=Tezos_clic.arg~long:"counter"~short:'C'~placeholder:"counter"~doc:"Set the counter to be used by the transaction"counter_parameterletmax_priority_arg=letopenLwt_result_syntaxinTezos_clic.arg~long:"max-priority"~placeholder:"slot"~doc:"maximum allowed baking slot"(Tezos_clic.parameter(fun_s->tryreturn(int_of_strings)with_->tzfail(Bad_max_prioritys)))lettimelock_locked_value_arg=Tezos_clic.arg~long:"timelock-locked-valuec"~placeholder:"timelock-locked"~doc:"Timelock RSA group modulus"string_parameterletdefault_minimal_fees=matchTez.of_mutez100LwithNone->assertfalse|Somet->tletdefault_minimal_nanotez_per_gas_unit=Q.of_int100letdefault_minimal_nanotez_per_byte=Q.of_int1000letminimal_fees_arg=letopenLwt_result_syntaxinTezos_clic.default_arg~long:"minimal-fees"~placeholder:"amount"~doc:"exclude operations with fees lower than this threshold (in tez)"~default:(Tez.to_stringdefault_minimal_fees)(Tezos_clic.parameter(fun_s->matchTez.of_stringswith|Somet->returnt|None->tzfail(Bad_minimal_feess)))letminimal_nanotez_per_gas_unit_arg=letopenLwt_result_syntaxinTezos_clic.default_arg~long:"minimal-nanotez-per-gas-unit"~placeholder:"amount"~doc:"exclude operations with fees per gas lower than this threshold (in \
nanotez)"~default:(Q.to_stringdefault_minimal_nanotez_per_gas_unit)(Tezos_clic.parameter(fun_s->tryreturn(Q.of_strings)with_->tzfail(Bad_minimal_feess)))letminimal_nanotez_per_byte_arg=letopenLwt_result_syntaxinTezos_clic.default_arg~long:"minimal-nanotez-per-byte"~placeholder:"amount"~default:(Q.to_stringdefault_minimal_nanotez_per_byte)~doc:"exclude operations with fees per byte lower than this threshold (in \
nanotez)"(Tezos_clic.parameter(fun_s->tryreturn(Q.of_strings)with_->tzfail(Bad_minimal_feess)))letreplace_by_fees_arg=Tezos_clic.switch~long:"replace"~doc:"Replace an existing pending transaction from the same source, if any, \
with another one with higher fees. There are no guarantees that the \
first operation will not be included or that the second one will be. \
But, only one of the operations at most will end in a block (in \
precheck mode)."()letsuccessor_level_arg=Tezos_clic.switch~long:"simulate-successor-level"~doc:"Make the simulate on the successor level of the current head."()letpreserved_levels_arg=letopenLwt_result_syntaxinTezos_clic.default_arg~long:"preserved-levels"~placeholder:"threshold"~doc:"Number of effective levels kept in the accuser's memory"~default:"200"(Tezos_clic.parameter(fun_s->tryletpreserved_levels=int_of_stringsinifpreserved_levels<0thentzfail(Bad_preserved_levelss)elsereturnpreserved_levelswith_->tzfail(Bad_preserved_levelss)))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."()letno_confirmation=Tezos_clic.switch~long:"no-confirmation"~doc:"don't print wait for the operation to be confirmed."()letsignature_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->matchSignature.of_b58check_optswith|Somes->returns|None->cctxt#error"Not given a valid signature")letunparsing_mode_parameter=letopenLwt_result_syntaxinTezos_clic.parameter~autocomplete:(fun_cctxt->return["Readable";"Optimized";"Optimized_legacy"])(fun(cctxt:#Client_context.full)s->matchswith|"Readable"->returnScript_ir_unparser.Readable|"Optimized"->returnScript_ir_unparser.Optimized|"Optimized_legacy"->returnScript_ir_unparser.Optimized_legacy|_->cctxt#error"Unknown unparsing mode %s"s)letunparsing_mode_arg~default=Tezos_clic.default_arg~long:"unparsing-mode"~placeholder:"mode"~doc:"Unparsing mode to use\n\
One of \"Readable\", \"Optimized\", or \"Optimized_legacy\".\n\
This option affects the way the values of the following Michelson types \
are represented:\n\
- timestamp: the Readable representation is a RFC3339 string, the \
Optimized and Optimized_legacy representations are the number of \
seconds since Epoch\n\
- key, signature, key_hash, address, contract, chain_id: the Readable \
representation is a Base58Check string, the Optimized and \
Optimized_legacy representations are byte sequences\n\
- nested pairs: in Readable mode, the Pair constructor is used even \
with arity bigger than 2 such as in Pair 0 1 2; in Optimized_legacy \
mode, the Pair constructor is always use with arity 2 such as in Pair 0 \
(Pair 1 2); in Optimized mode, a sequence is used if there are at least \
4 elements and the behavior is the same as in Optimized_legacy mode \
otherwise.\n"~defaultunparsing_mode_parameterletenforce_indentation_flag=Tezos_clic.switch~long:"enforce-indentation"~doc:"Check that the Micheline expression passed to this command is \
well-indented."()letdisplay_names_flag=Tezos_clic.switch~long:"display-names"~doc:"Print names of scripts passed to this command"()letfixed_point_parameter=letopenLwt_result_syntaxinletrecremove_trailing_zeroes~decimals~righti=ifi<decimalsthenSome(String.subright0decimals)elseifright.[i]<>'0'thenNoneelse(remove_trailing_zeroes[@ocaml.tailcall])~decimals~right(i-1)inletparse~decimalsp=letopenOption_syntaxinlet*left,right=matchString.split_on_char'.'pwith|[left;right]->Some(left,right)|[left]->Some(left,"")|_->Noneinlet*right=ifString.lengthright>decimalsthenremove_trailing_zeroes~decimals~right(String.lengthright-1)elseSome(right^String.make(decimals-String.lengthright)'0')inint_of_string_opt(left^right)inletparse~decimalsp=ifdecimals>=2&&String.lengthp>0&&p.[String.lengthp-1]='%'thenparse~decimals:(decimals-2)(String.subp0(String.lengthp-1))elseparse~decimalspinfun~decimals->ifdecimals<0thenraise(Invalid_argument"fixed_point_parameter: negative decimals")elsefun~name->Tezos_clic.parameter(fun(cctxt:#Client_context.full)p->matchparse~decimalspwith|Someres->returnres|None->cctxt#error"Cannot read %s parameter: expecting a fixed point number with \
at most %d decimals, or a fixed point number with at most %d \
decimals followed by a %% sign."namedecimals(decimals-2))letlimit_of_staking_over_baking_millionth_arg=Tezos_clic.arg~long:"limit-of-staking-over-baking"~placeholder:"limit"~doc:"Limits the total amount of stake for the source's delegators as a \
proportion of the source's own stake. Any amount exceeding this limit \
is considered as delegation in the stake of the delegate. The value \
should be between 0 and 5 (default 0 if not set). If this parameter is \
0, as is the default, any staking operation from the source's \
delegators are forbidden and will fail (unstaking operations are still \
allowed)."((* TODO #6162: should we check it's between 0 and 5 million? *)fixed_point_parameter~decimals:6~name:"limit of staking over baking")letedge_of_baking_over_staking_billionth_arg=Tezos_clic.arg~long:"edge-of-baking-over-staking"~placeholder:"edge"~doc:"Sets the portion of the delegate's stakers rewards that goes to the \
delegate. This edge, taken from the staker's rewards, is accrued to the \
delegate's own frozen balance. This value must be between 0 and 1 (e.g. \
0.05 for the delegate to receive 5% of the staker's rewards). Default \
value is 1 (delegate receives all staker's rewards)."((* TODO #6162: check it's between 0 and 1 billion *)fixed_point_parameter~decimals:9~name:"edge of baking over staking")moduleSc_rollup_params=structletrollup_kind_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)name->matchSc_rollup.Kind.of_stringnamewith|None->cctxt#error"Parameter '%s' is not a valid rollup name (must be one of %s)"name(String.concat", "Sc_rollup.Kind.(List.mapto_stringall))|Somek->returnk)letboot_sector_parameter=letopenLwt_result_syntaxinletfrom_text(cctxt:#Client_context.full)s=return(fun(Sc_rollup.PVM.Packed(moduleR))->R.parse_boot_sectors|>function|None->cctxt#error"Invalid kernel"|Someboot_sector->returnboot_sector)infile_or_text_parameter~from_text()letmessages_parameter=letopenLwt_result_syntaxinletfrom_json(cctxt:#Client_context.full)text=trymatchEzjsonm.from_stringtextwith|`Amessages->return(`Json(`A(`String"raw"::messages)))|_->cctxt#error"Expecting a list of string"withEzjsonm.Parse_error_->cctxt#error"Given text is not valid JSON: '%s'"textinletfrom_json_hex(cctxt:#Client_context.full)text=trymatchEzjsonm.from_stringtextwith|`Amessages->return(`Json(`A(`String"hex"::messages)))|_->cctxt#error"Expecting a list of hex-encoded string"withEzjsonm.Parse_error_->cctxt#error"Given text is not valid JSON: '%s'"textinletfrom_bin_file(cctxt:#Client_context.full)path=let*bin=cctxt#read_filepathinreturn(`Binbin)inletfrom_json_file(cctxt:#Client_context.full)path=let*json_string=cctxt#read_filepathinfrom_jsoncctxtjson_stringinTezos_clic.parameter(fun(cctxt:#Client_context.full)p->Client_aliases.parse_alternatives[("text",from_jsoncctxt);("hex",from_json_hexcctxt);("file",from_json_filecctxt);("bin",from_bin_filecctxt);]p)letcommitment_hash_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)commitment_hash->matchSc_rollup.Commitment.Hash.of_b58check_optcommitment_hashwith|None->cctxt#error"Parameter '%s' is not a valid B58-encoded rollup commitment hash"commitment_hash|Somehash->returnhash)letunchecked_payload_parameter=letopenLwt_result_syntaxinfile_or_text_parameter~from_text:(fun_cctxt->return)()letcompressed_state_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)state_hash->matchSc_rollup.State_hash.of_b58check_optstate_hashwith|None->cctxt#error"Parameter '%s' is not a valid B58-encoded compressed state"state_hash|Somehash->returnhash)letnumber_of_ticks_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)nb_of_ticks->matchInt64.of_string_optnb_of_tickswith|Somenb_of_ticks->(matchSc_rollup.Number_of_ticks.of_valuenb_of_tickswith|None->cctxt#error"Parameter '%Ld' is out of bounds, it should be between %Ld \
and %Ld"nb_of_ticksSc_rollup.Number_of_ticks.min_valueSc_rollup.Number_of_ticks.max_value|Somenb_of_ticks->returnnb_of_ticks)|None->cctxt#error"'%s' is not valid, should be a int64 value"nb_of_ticks)letwhitelist=json_encoded_parameter~name:"Whitelist for private rollups"Sc_rollup.Whitelist.encodingendletwhitelist_arg=Tezos_clic.arg~long:"whitelist"~short:'W'~placeholder:"whitelist"~doc:"Whitelist for private rollups. Members of the whitelist are stakers \
that are allowed to publish commitments."Sc_rollup_params.whitelistmoduleZk_rollup_params=structletaddress_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)s->matchZk_rollup.Address.of_b58check_optswith|Somec->returnc|None->cctxt#error"Parameter '%s' is an invalid Epoxy address"s)letplonk_public_parameters_parameter=binary_encoded_parameter~name:"PlonK public"Plonk.Main_protocol.verifier_public_parameters_encodingletupdate_parameter=binary_encoded_parameter~name:"Epoxy Update"Zk_rollup.Update.encodingletoperations_parameter=binary_encoded_parameter~name:"Epoxy Operations"Data_encoding.(list@@tup2Zk_rollup.Operation.encoding(optionZk_rollup.Ticket.encoding))letstate_parameter=binary_encoded_parameter~name:"Epoxy State"Zk_rollup.State.encodingletcircuits_info_parameter=binary_encoded_parameter~name:"Epoxy Circuits_info map"Zk_rollup.Account.circuits_info_encodingendmoduleDal=structletcommitment_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)commitment_hash->matchDal_slot_repr.Commitment.of_b58check_optcommitment_hashwith|None->cctxt#error"Parameter '%s' is not a valid B58-encoded DAL commitment"commitment_hash|Somecommitment->returncommitment)letcommitment_proof_parameter=letopenLwt_result_syntaxinTezos_clic.parameter(fun(cctxt:#Client_context.full)commitment_proof_hex->matchHex.to_string(`Hexcommitment_proof_hex)with|None->cctxt#error"Commitment proof parameter '%s' is not a valid hexadecimal \
string"commitment_proof_hex|Somecommitment_proof_bin->(matchData_encoding.Binary.of_string_optDal_slot_repr.Commitment_proof.encodingcommitment_proof_binwith|None->cctxt#error"Commitment proof parameter '%s' is not a valid DAL \
commitment proof"commitment_proof_hex|Somecommitment_proof->returncommitment_proof))endletfee_parameter_args=letopenTezos_clicinletopenLwt_result_syntaxinletforce_low_fee_arg=switch~long:"force-low-fee"~doc:"Don't check that the fee is lower than the estimated default value"()inletfee_cap_arg=default_arg~long:"fee-cap"~placeholder:"amount"~default:"1.0"~doc:"Set the fee cap"(parameter(fun(cctxt:#Client_context.full)s->matchTez.of_stringswith|Somet->returnt|None->cctxt#error"Bad fee cap"))inletburn_cap_arg=default_arg~long:"burn-cap"~placeholder:"amount"~default:"0"~doc:"Set the burn cap"(parameter(fun(cctxt:#Client_context.full)s->matchTez.of_stringswith|Somet->returnt|None->cctxt#error"Bad burn cap"))inTezos_clic.map_arg~f:(fun_cctxt(minimal_fees,minimal_nanotez_per_byte,minimal_nanotez_per_gas_unit,force_low_fee,fee_cap,burn_cap)->return{Injection.minimal_fees;minimal_nanotez_per_byte;minimal_nanotez_per_gas_unit;force_low_fee;fee_cap;burn_cap;})(Tezos_clic.aggregate(Tezos_clic.args6minimal_fees_argminimal_nanotez_per_byte_argminimal_nanotez_per_gas_unit_argforce_low_fee_argfee_cap_argburn_cap_arg))