12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052(*****************************************************************************)(* *)(* 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=Tezos_clic.parameter(fun_x->returnx)letint_parameter=Tezos_clic.parameter(fun(cctxt:#Client_context.full)p->tryreturn(int_of_stringp)with_->cctxt#error"Cannot read int")letz_parameter=Tezos_clic.parameter(fun(cctxt:#Client_context.full)p->tryreturn(Z.of_stringp)with_->cctxt#error"Cannot read integer")leturi_parameter=Tezos_clic.parameter(fun_x->return(Uri.of_stringx))letbytes_of_prefixed_string(cctxt:#Client_context.full)s=matchifString.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=letfrom_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=Tezos_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=matchint_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=matchint_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=Tezos_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=Tezos_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=Tezos_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_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=Tezos_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_cycles=int_of_stringsinifpreserved_cycles<0thentzfail(Bad_preserved_levelss)elsereturnpreserved_cycleswith_->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=Tezos_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=Tezos_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=letrecremove_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 rewards issued to the delegate that should be \
transfered to its liquid balance. The rest is issued to its stakers \
(itself included), proportionally to their stake. Value should be \
between 0 and 1. If not set, default value is 1: all rewards given to \
the source are issued to their liquid balance."((* 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=Tezos_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=letfrom_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=Tezos_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=file_or_text_parameter~from_text:(fun_cctxt->return)()letcompressed_state_parameter=Tezos_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=Tezos_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=Tezos_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=Tezos_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_clicinletforce_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))