Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file client_proto_context_commands.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019 Nomadic Labs <contact@nomadic-labs.com> *)(* Copyright (c) 2022 TriliTech <contact@trili.tech> *)(* *)(* 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. *)(* *)(*****************************************************************************)openProtocolopenAlpha_contextopenClient_proto_contextopenClient_proto_contractsopenClient_proto_rollupsopenClient_keys_v0openClient_proto_argsletsave_tx_rollup~force(cctxt:#Client_context.full)alias_namerollup~origination_level=TxRollupAlias.add~forcecctxtalias_name{rollup;origination_level}>>=?fun()->cctxt#message"Transaction rollup memorized as %s"alias_name>>=fun()->return_unitletdry_run_switch:(_,Protocol_client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"dry-run"~short:'D'~doc:"don't inject the operation, just display it"()letverbose_signing_switch:(_,Protocol_client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"verbose-signing"~doc:"display extra information before signing the operation"()letnormalize_types_switch=Tezos_clic.switch~long:"normalize-types"~doc:"Whether types should be normalized (annotations removed, combs \
flattened) or kept as they appeared in the original script."()letreport_michelson_errors?(no_print_source=false)~msg(cctxt:#Client_context.full)=function|Errorerrs->Michelson_v1_error_reporter.enrich_runtime_errorscctxt~chain:cctxt#chain~block:cctxt#block~parsed:Noneerrs>>=funerrs->cctxt#warning"%a"(Michelson_v1_error_reporter.report_errors~details:(notno_print_source)~show_source:(notno_print_source)?parsed:None)errs>>=fun()->cctxt#error"%s"msg>>=fun()->Lwt.return_none|Okdata->Lwt.return_somedataletparse_fileparsepath=Lwt_utils_unix.read_filepath>>=funcontents->parsecontentsletfile_or_text_parameter~from_text?(from_path=parse_file(from_text~heuristic:false))()=Tezos_clic.parameter@@fun_p->matchString.split~limit:1':'pwith|["text";text]->from_text~heuristic:falsetext|["file";path]->from_pathpath|_->ifSys.file_existspthenfrom_pathpelsefrom_text~heuristic:truepletjson_file_or_text_parameter:(_,Protocol_client_context.full)Tezos_clic.parameter=letfrom_text~heuristics=tryreturn(Ezjsonm.from_strings)withEzjsonm.Parse_error_whenheuristic->failwith"Neither an existing file nor valid JSON: '%s'"sinletfrom_path=Lwt_utils_unix.Json.read_fileinfile_or_text_parameter~from_text~from_path()letnon_negative_param=Tezos_clic.parameter(fun_s->matchint_of_string_optswith|Someiwheni>=0->returni|_->failwith"Parameter should be a non-negative integer literal")letgroup={Tezos_clic.name="context";title="Block contextual commands (see option -block)";}letalphanet={Tezos_clic.name="alphanet";title="Alphanet only commands"}letbinary_description={Tezos_clic.name="description";title="Binary Description"}lettez_of_string_exnindexfields=matchTez.of_stringswith|Somet->returnt|None->failwith"Invalid \xEA\x9C\xA9 notation at entry %i, field \"%s\": %s"indexfieldslettez_of_opt_string_exnindexfields=matchswith|None->returnNone|Somes->tez_of_string_exnindexfields>>=?funs->return(Somes)letcommands_ro()=letopenTezos_clicin[command~group~desc:"Access the timestamp of the block."(args1(switch~doc:"output time in seconds"~short:'s'~long:"seconds"()))(fixed["get";"timestamp"])(funseconds(cctxt:Protocol_client_context.full)->Shell_services.Blocks.Header.shell_headercctxt~chain:cctxt#chain~block:cctxt#block()>>=?fun{timestamp=v;_}->(ifsecondsthencctxt#message"%Ld"(Time.Protocol.to_secondsv)elsecctxt#message"%s"(Time.Protocol.to_notationv))>>=fun()->return_unit);command~group~desc:"Lists all non empty contracts of the block."no_options(fixed["list";"contracts"])(fun()(cctxt:Protocol_client_context.full)->list_contract_labelscctxt~chain:cctxt#chain~block:cctxt#block>>=?funcontracts->List.iter_s(fun(alias,hash,kind)->cctxt#message"%s%s%s"hashkindalias)contracts>>=fun()->return_unit);command~group~desc:"Lists cached contracts and their age in LRU ordering."no_options(prefixes["list";"cached";"contracts"]@@stop)(fun()(cctxt:Protocol_client_context.full)->cached_contractscctxt~chain:cctxt#chain~block:cctxt#block>>=?funkeys->List.iter_s(fun(key,size)->cctxt#message"%a %d"Alpha_context.Contract.ppkeysize)keys>>=fun()->return_unit);command~group~desc:"Get the key rank of a cache key."no_options(prefixes["get";"cached";"contract";"rank";"for"]@@Contract_alias.destination_param~name:"src"~desc:"contract"@@stop)(fun()(_,contract)(cctxt:Protocol_client_context.full)->contract_rankcctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=?funrank->matchrankwith|None->cctxt#error"Invalid contract: %a"Alpha_context.Contract.ppcontract>>=fun()->return_unit|Somerank->cctxt#message"%d"rank>>=fun()->return_unit);command~group~desc:"Get cache contract size."no_options(prefixes["get";"cache";"contract";"size"]@@stop)(fun()(cctxt:Protocol_client_context.full)->contract_cache_sizecctxt~chain:cctxt#chain~block:cctxt#block>>=?funt->cctxt#message"%d"t>>=fun()->return_unit);command~group~desc:"Get cache contract size limit."no_options(prefixes["get";"cache";"contract";"size";"limit"]@@stop)(fun()(cctxt:Protocol_client_context.full)->contract_cache_size_limitcctxt~chain:cctxt#chain~block:cctxt#block>>=?funt->cctxt#message"%d"t>>=fun()->return_unit);command~group~desc:"Get the balance of a contract."no_options(prefixes["get";"balance";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Protocol_client_context.full)->get_balancecctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=?funamount->cctxt#answer"%a %s"Tez.ppamountClient_proto_args.tez_sym>>=fun()->return_unit);command~group~desc:"Get the storage of a contract."(args1(unparsing_mode_arg~default:"Readable"))(prefixes["get";"contract";"storage";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fununparsing_mode(_,contract)(cctxt:Protocol_client_context.full)->get_storagecctxt~chain:cctxt#chain~block:cctxt#block~unparsing_modecontract>>=?function|None->cctxt#error"This is not a smart contract."|Somestorage->cctxt#answer"%a"Michelson_v1_printer.print_expr_unwrappedstorage>>=fun()->return_unit);command~group~desc:"Get the value associated to a key in the big map storage of a \
contract (deprecated)."no_options(prefixes["get";"big";"map";"value";"for"]@@Tezos_clic.param~name:"key"~desc:"the key to look for"data_parameter@@prefixes["of";"type"]@@Tezos_clic.param~name:"type"~desc:"type of the key"data_parameter@@prefix"in"@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()keykey_type(_,contract)(cctxt:Protocol_client_context.full)->get_contract_big_map_valuecctxt~chain:cctxt#chain~block:cctxt#blockcontract(key.expanded,key_type.expanded)>>=?function|None->cctxt#error"No value associated to this key."|Somevalue->cctxt#answer"%a"Michelson_v1_printer.print_expr_unwrappedvalue>>=fun()->return_unit);command~group~desc:"Get a value in a big map."(args1(unparsing_mode_arg~default:"Readable"))(prefixes["get";"element"]@@Tezos_clic.param~name:"key"~desc:"the key to look for"(Tezos_clic.parameter(fun_s->return(Script_expr_hash.of_b58check_exns)))@@prefixes["of";"big";"map"]@@Tezos_clic.param~name:"big_map"~desc:"identifier of the big_map"int_parameter@@stop)(fununparsing_modekeyid(cctxt:Protocol_client_context.full)->get_big_map_valuecctxt~chain:cctxt#chain~block:cctxt#block~unparsing_mode(Big_map.Id.parse_z(Z.of_intid))key>>=?funvalue->cctxt#answer"%a"Michelson_v1_printer.print_expr_unwrappedvalue>>=fun()->return_unit);command~group~desc:"Get the code of a contract."(args2(unparsing_mode_arg~default:"Readable")normalize_types_switch)(prefixes["get";"contract";"code";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun(unparsing_mode,normalize_types)(_,contract)(cctxt:Protocol_client_context.full)->get_scriptcctxt~chain:cctxt#chain~block:cctxt#block~unparsing_mode~normalize_typescontract>>=?function|None->cctxt#error"This is not a smart contract."|Some{code;storage=_}->(matchScript_repr.force_decodecodewith|Errorerrs->cctxt#error"%a"Environment.Error_monad.pp_traceerrs|Okcode->let{Michelson_v1_parser.source;_}=Michelson_v1_printer.unparse_toplevelcodeincctxt#answer"%s"source>>=return));command~group~desc:"Get the `BLAKE2B` script hash of a contract."no_options(prefixes["get";"contract";"script";"hash";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Protocol_client_context.full)->get_script_hashcctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=function|Errorerrs->cctxt#error"%a"pp_print_traceerrs|OkNone->cctxt#error"This is not a smart contract."|Ok(Somehash)->cctxt#answer"%a"Script_expr_hash.pphash>|=ok);command~group~desc:"Get the type of an entrypoint of a contract."(args1normalize_types_switch)(prefixes["get";"contract";"entrypoint";"type";"of"]@@Tezos_clic.param~name:"entrypoint"~desc:"the entrypoint to describe"entrypoint_parameter@@prefixes["for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(funnormalize_typesentrypoint(_,contract)(cctxt:Protocol_client_context.full)->Michelson_v1_entrypoints.contract_entrypoint_typecctxt~chain:cctxt#chain~block:cctxt#block~contract~entrypoint~normalize_types>>=Michelson_v1_entrypoints.print_entrypoint_typecctxt~emacs:false~contract~entrypoint);command~group~desc:"Get the entrypoint list of a contract."(args1normalize_types_switch)(prefixes["get";"contract";"entrypoints";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(funnormalize_types(_,contract)(cctxt:Protocol_client_context.full)->Michelson_v1_entrypoints.list_contract_entrypointscctxt~chain:cctxt#chain~block:cctxt#block~contract~normalize_types>>=Michelson_v1_entrypoints.print_entrypoints_listcctxt~emacs:false~contract);command~group~desc:"Get the list of unreachable paths in a contract's parameter type."no_options(prefixes["get";"contract";"unreachable";"paths";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Protocol_client_context.full)->Michelson_v1_entrypoints.list_contract_unreachablescctxt~chain:cctxt#chain~block:cctxt#block~contract>>=Michelson_v1_entrypoints.print_unreachablescctxt~emacs:false~contract);command~group~desc:"Get the delegate of a contract."no_options(prefixes["get";"delegate";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Protocol_client_context.full)->Client_proto_contracts.get_delegatecctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=?function|None->cctxt#message"none">>=fun()->return_unit|Somedelegate->Public_key_hash.rev_findcctxtdelegate>>=?funmn->Public_key_hash.to_sourcedelegate>>=?funm->cctxt#message"%s (%s)"m(matchmnwithNone->"unknown"|Somen->"known as "^n)>>=fun()->return_unit);command~desc:"Get receipt for past operation"(args1(default_arg~long:"check-previous"~placeholder:"num_blocks"~doc:"number of previous blocks to check"~default:"10"non_negative_param))(prefixes["get";"receipt";"for"]@@param~name:"operation"~desc:"Operation to be looked up"(parameter(fun_x->matchOperation_hash.of_b58check_optxwith|None->Error_monad.failwith"Invalid operation hash: '%s'"x|Somehash->returnhash))@@stop)(funpredecessorsoperation_hash(ctxt:Protocol_client_context.full)->display_receipt_for_operationctxt~chain:ctxt#chain~predecessorsoperation_hash>>=?fun_->return_unit);command~group~desc:"Summarize the current voting period"no_options(fixed["show";"voting";"period"])(fun()(cctxt:Protocol_client_context.full)->get_period_info~chain:cctxt#chain~block:cctxt#blockcctxt>>=?funinfo->cctxt#message"Current period: %a\nBlocks remaining until end of period: %ld"Data_encoding.Json.pp(Data_encoding.Json.constructAlpha_context.Voting_period.kind_encodinginfo.current_period_kind)info.remaining>>=fun()->Shell_services.Protocol.listcctxt>>=?funknown_protos->get_proposals~chain:cctxt#chain~block:cctxt#blockcctxt>>=?funprops->letranks=Environment.Protocol_hash.Map.bindingsprops|>List.sort(fun(_,v1)(_,v2)->Int64.(comparev2v1))inletprint_proposal=function|None->cctxt#message"The current proposal has already been cleared."(* The proposal is cleared on the last block of adoption period, and
also on the last block of the exploration and promotion
periods when the proposal is not approved *)|Someproposal->cctxt#message"Current proposal: %a"Protocol_hash.ppproposalinmatchinfo.current_period_kindwith|Proposal->(* the current proposals are cleared on the last block of the
proposal period *)ifinfo.remaining<>0lthencctxt#answer"Current proposals:%t"Format.(funppf->pp_print_cutppf();pp_open_vboxppf0;List.iter(fun(p,w)->fprintfppf"* %a %a %s (%sknown by the node)@."Protocol_hash.pppTez.pp(Tez.of_mutez_exnw)Client_proto_args.tez_sym(ifList.mem~equal:Protocol_hash.equalpknown_protosthen""else"not "))ranks;pp_close_boxppf())>>=fun()->return_unitelsecctxt#message"The proposals have already been cleared.">>=fun()->return_unit|Exploration|Promotion->print_proposalinfo.current_proposal>>=fun()->(* the ballots are cleared on the last block of these periods *)ifinfo.remaining<>0lthenget_ballots_info~chain:cctxt#chain~block:cctxt#blockcctxt>>=?funballots_info->cctxt#answer"@[<v>Ballots:@,\
\ Yay: %a %s@,\
\ Nay: %a %s@,\
\ Pass: %a %s@,\
Current participation %.2f%%, necessary quorum %.2f%%@,\
Current in favor %a %s, needed supermajority %a %s@]"Tez.pp(Tez.of_mutez_exnballots_info.ballots.yay)Client_proto_args.tez_symTez.pp(Tez.of_mutez_exnballots_info.ballots.nay)Client_proto_args.tez_symTez.pp(Tez.of_mutez_exnballots_info.ballots.pass)Client_proto_args.tez_sym(Int32.to_floatballots_info.participation/.100.)(Int32.to_floatballots_info.current_quorum/.100.)Tez.pp(Tez.of_mutez_exnballots_info.ballots.yay)Client_proto_args.tez_symTez.pp(Tez.of_mutez_exnballots_info.supermajority)Client_proto_args.tez_sym>>=fun()->return_unitelsecctxt#message"The ballots have already been cleared.">>=fun()->return_unit|Cooldown->print_proposalinfo.current_proposal>>=fun()->return_unit|Adoption->print_proposalinfo.current_proposal>>=fun()->return_unit);command~group:binary_description~desc:"Describe unsigned block header"no_options(fixed["describe";"unsigned";"block";"header"])(fun()(cctxt:Protocol_client_context.full)->cctxt#message"%a"Data_encoding.Binary_schema.pp(Data_encoding.Binary.describeAlpha_context.Block_header.unsigned_encoding)>>=fun()->return_unit);command~group:binary_description~desc:"Describe unsigned operation"no_options(fixed["describe";"unsigned";"operation"])(fun()(cctxt:Protocol_client_context.full)->cctxt#message"%a"Data_encoding.Binary_schema.pp(Data_encoding.Binary.describeAlpha_context.Operation.unsigned_encoding)>>=fun()->return_unit);command~group~desc:"Get the frozen deposits limit of a delegate."no_options(prefixes["get";"deposits";"limit";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source delegate"@@stop)(fun()(_,contract)(cctxt:Protocol_client_context.full)->matchContract.is_implicitcontractwith|None->cctxt#error"Cannot change deposits limit on contract %a. This operation is \
invalid on originated contracts."Contract.ppcontract|Somedelegate->(get_frozen_deposits_limitcctxt~chain:cctxt#chain~block:cctxt#blockdelegate>>=?function|None->cctxt#answer"unlimited">>=return|Somelimit->cctxt#answer"%a %s"Tez.pplimitClient_proto_args.tez_sym>>=return));]letcommands_network()=commands_ro()