Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file client_proto_context_commands.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019-2022 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_keysopenClient_proto_argsletsave_zk_rollup~force(cctxt:#Client_context.full)alias_namerollup=letopenLwt_result_syntaxinlet*()=Epoxy_alias.add~forcecctxtalias_namerollupinlet*!()=cctxt#message"Epoxy rollup memorized as %s"alias_nameinreturn_unitletencrypted_switch:(_,Protocol_client_context.full)Tezos_clic.arg=Tezos_clic.switch~long:"encrypted"~doc:"encrypt the key on-disk"()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)=letopenLwt_syntaxinfunction|Errorerrs->let*errs=Michelson_v1_error_reporter.enrich_runtime_errorscctxt~chain:cctxt#chain~block:cctxt#block~parsed:Noneerrsinlet*()=cctxt#warning"%a"(Michelson_v1_error_reporter.report_errors~details:(notno_print_source)~show_source:(notno_print_source)?parsed:None)errsinlet*()=cctxt#error"%s"msginreturn_none|Okdata->return_somedataletgroup={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_exn(cctxt:#Client_context.full)indexfields=letopenLwt_result_syntaxinmatchTez.of_stringswith|Somet->returnt|None->cctxt#error"Invalid \xEA\x9C\xA9 notation at entry %i, field \"%s\": %s"indexfieldslettez_of_opt_string_exn(cctxt:#Client_context.full)indexfields=Option.map_es(tez_of_string_exncctxtindexfield)sletcheck_smart_contract=Managed_contract.check_smart_contractletcommands_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)->letopenLwt_result_syntaxinlet*{timestamp=v;_}=Shell_services.Blocks.Header.shell_headercctxt~chain:cctxt#chain~block:cctxt#block()inlet*!()=ifsecondsthencctxt#message"%Ld"(Time.Protocol.to_secondsv)elsecctxt#message"%s"(Time.Protocol.to_notationv)inreturn_unit);command~group~desc:"Lists all non empty contracts of the block."no_options(fixed["list";"contracts"])(fun()(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*contracts=list_contract_labelscctxt~chain:cctxt#chain~block:cctxt#blockinlet*!()=List.iter_s(fun(alias,hash,kind)->cctxt#message"%s%s%s"hashkindalias)contractsinreturn_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)->letopenLwt_result_syntaxinlet*keys=cached_contractscctxt~chain:cctxt#chain~block:cctxt#blockinlet*!()=List.iter_s(fun(key,size)->cctxt#message"%a %d"Contract_hash.ppkeysize)keysinreturn_unit);command~group~desc:"Get the key rank of a cache key."no_options(prefixes["get";"cached";"contract";"rank";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"contract"@@stop)(fun()contract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*rank=contract_rankcctxt~chain:cctxt#chain~block:cctxt#blockcontractinlet*!()=matchrankwith|None->cctxt#error"Invalid contract: %a"Contract_hash.ppcontract|Somerank->cctxt#message"%d"rankinreturn_unit);command~group~desc:"Get cache contract size."no_options(prefixes["get";"cache";"contract";"size"]@@stop)(fun()(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*t=contract_cache_sizecctxt~chain:cctxt#chain~block:cctxt#blockinlet*!()=cctxt#message"%d"tinreturn_unit);command~group~desc:"Get cache contract size limit."no_options(prefixes["get";"cache";"contract";"size";"limit"]@@stop)(fun()(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*t=contract_cache_size_limitcctxt~chain:cctxt#chain~block:cctxt#blockinlet*!()=cctxt#message"%d"tinreturn_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)->letopenLwt_result_syntaxinlet*amount=get_balancecctxt~chain:cctxt#chain~block:cctxt#blockcontractinlet*!()=cctxt#answer"%a %s"Tez.ppamountOperation_result.tez_syminreturn_unit);command~group~desc:"Get the storage of a contract."(args1(unparsing_mode_arg~default:"Readable"))(prefixes["get";"contract";"storage";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fununparsing_modecontract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*v=get_storagecctxt~chain:cctxt#chain~block:cctxt#block~unparsing_modecontractincheck_smart_contractcctxtv@@funstorage->let*!()=cctxt#answer"%a"Michelson_v1_printer.print_expr_unwrappedstorageinreturn_unit);command~group~desc:"Get the used storage space of a contract."no_options(prefixes["get";"contract";"used";"storage";"space";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()contract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*used_space=get_used_storage_spacecctxt~chain:cctxt#chain~block:cctxt#blockcontractincheck_smart_contractcctxtused_space@@funused_space->let*!()=cctxt#answer"%a"Z.pp_printused_spaceinreturn_unit);command~group~desc:"Get the paid storage space of a contract."no_options(prefixes["get";"contract";"paid";"storage";"space";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()contract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*paid_space=get_paid_storage_spacecctxt~chain:cctxt#chain~block:cctxt#blockcontractincheck_smart_contractcctxtpaid_space@@funpaid_space->let*!()=cctxt#answer"%a"Z.pp_printpaid_spaceinreturn_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"@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()keykey_typecontract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*v=get_contract_big_map_valuecctxt~chain:cctxt#chain~block:cctxt#blockcontract(key.expanded,key_type.expanded)inmatchvwith|None->cctxt#error"No value associated to this key."|Somevalue->let*!()=cctxt#answer"%a"Michelson_v1_printer.print_expr_unwrappedvalueinreturn_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->Lwt_result_syntax.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)->letopenLwt_result_syntaxinlet*value=get_big_map_valuecctxt~chain:cctxt#chain~block:cctxt#block~unparsing_mode(Big_map.Id.parse_z(Z.of_intid))keyinlet*!()=cctxt#answer"%a"Michelson_v1_printer.print_expr_unwrappedvalueinreturn_unit);command~group~desc:"Get the code of a contract."(args2(unparsing_mode_arg~default:"Readable")normalize_types_switch)(prefixes["get";"contract";"code";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun(unparsing_mode,normalize_types)contract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*v=get_scriptcctxt~chain:cctxt#chain~block:cctxt#block~unparsing_mode~normalize_typescontractincheck_smart_contractcctxtv@@fun{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_toplevelcodeinlet*!()=cctxt#answer"%s"sourceinreturn_unit);command~group~desc:"Get the `BLAKE2B` script hash of a contract."no_options(prefixes["get";"contract";"script";"hash";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()contract(cctxt:Protocol_client_context.full)->letopenLwt_syntaxinlet*r=get_script_hashcctxt~chain:cctxt#chain~block:cctxt#blockcontractinmatchrwith|Errorerrs->cctxt#error"%a"pp_print_traceerrs|Okhash->check_smart_contractcctxthash@@funhash->let*()=cctxt#answer"%a"Script_expr_hash.pphashinreturn_ok_unit);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"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(funnormalize_typesentrypointcontract(cctxt:Protocol_client_context.full)->letopenLwt_syntaxinlet*t=Michelson_v1_entrypoints.contract_entrypoint_typecctxt~chain:cctxt#chain~block:cctxt#block~contract~entrypoint~normalize_typesinMichelson_v1_entrypoints.print_entrypoint_typecctxt~emacs:false~contract~entrypointt);command~group~desc:"Get the entrypoint list of a contract."(args1normalize_types_switch)(prefixes["get";"contract";"entrypoints";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(funnormalize_typescontract(cctxt:Protocol_client_context.full)->letopenLwt_syntaxinlet*es=Michelson_v1_entrypoints.list_contract_entrypointscctxt~chain:cctxt#chain~block:cctxt#block~contract~normalize_typesinMichelson_v1_entrypoints.print_entrypoints_listcctxt~emacs:false~contractes);command~group~desc:"Get the list of unreachable paths in a contract's parameter type."no_options(prefixes["get";"contract";"unreachable";"paths";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()contract(cctxt:Protocol_client_context.full)->letopenLwt_syntaxinlet*u=Michelson_v1_entrypoints.list_contract_unreachablescctxt~chain:cctxt#chain~block:cctxt#block~contractinMichelson_v1_entrypoints.print_unreachablescctxt~emacs:false~contractu);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)->letopenLwt_result_syntaxinlet*v=Client_proto_contracts.get_delegatecctxt~chain:cctxt#chain~block:cctxt#blockcontractinmatchvwith|None->let*!()=cctxt#message"none"inreturn_unit|Somedelegate->let*mn=Public_key_hash.rev_findcctxtdelegateinlet*m=Public_key_hash.to_sourcedelegateinlet*!()=cctxt#message"%s (%s)"m(matchmnwithNone->"unknown"|Somen->"known as "^n)inreturn_unit);command~group~desc:"Get contract's balance of ticket with specified ticketer, content \
type, and content."no_options(prefixes["get";"ticket";"balance";"for"]@@Contract_alias.destination_param~name:"src"~desc:"Source contract."@@prefixes["with";"ticketer"]@@Contract_alias.destination_param~name:"ticketer"~desc:"Ticketer contract of the ticket."@@prefixes["and";"type"]@@Tezos_clic.param~name:"ticket content type"~desc:"Type of the content of the ticket."data_parameter@@prefixes["and";"content"]@@Tezos_clic.param~name:"ticket content"~desc:"Content of the ticket."data_parameter@@stop)(fun()contractticketercontent_typecontentcctxt->letopenLwt_result_syntaxinlet*balance=get_contract_ticket_balancecctxt~chain:cctxt#chain~block:cctxt#blockcontractTicket_token.{ticketer;contents_type=content_type.expanded;contents=content.expanded;}inlet*!()=cctxt#answer"%a"Z.pp_printbalanceinreturn_unit);command~group~desc:"Get the complete list of tickets owned by a given contract."no_options(prefixes["get";"all";"ticket";"balances";"for"]@@Originated_contract_alias.destination_param~name:"src"~desc:"Source contract."@@stop)(fun()contract(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*ticket_balances=get_contract_all_ticket_balancescctxt~chain:cctxt#chain~block:cctxt#blockcontractinletpp_ticket_balanceppf(Ticket_token.{ticketer;contents_type;contents},amount)=Format.fprintfppf"@[<v 0>Ticketer: %a@,Content type: %a@,Content: %a@,Amount: %a@]"Contract.ppticketerMichelson_v1_printer.print_exprcontents_typeMichelson_v1_printer.print_exprcontentsZ.pp_printamountinlet*!()=cctxt#answer"%a"(Format.pp_print_list~pp_sep:(funfmt()->Format.fprintffmt"@.@.")pp_ticket_balance)ticket_balancesinreturn_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_parameter())))(prefixes["get";"receipt";"for"]@@param~name:"operation"~desc:"Operation to be looked up"(parameter(fun(cctxt:#Client_context.full)x->matchOperation_hash.of_b58check_optxwith|None->cctxt#error"Invalid operation hash: '%s'"x|Somehash->Lwt_result_syntax.returnhash))@@stop)(funpredecessorsoperation_hash(ctxt:Protocol_client_context.full)->display_receipt_for_operationctxt~chain:ctxt#chain~predecessorsoperation_hash);command~group~desc:"Summarize the current voting period"no_options(fixed["show";"voting";"period"])(fun()(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*info=get_period_info~chain:cctxt#chain~block:cctxt#blockcctxtinlet*!()=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.remaininginlet*known_protos=Shell_services.Protocol.listcctxtinlet*props=get_proposals~chain:cctxt#chain~block:cctxt#blockcctxtinletranks=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 *)let*!()=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)Operation_result.tez_sym(ifList.mem~equal:Protocol_hash.equalpknown_protosthen""else"not "))ranks;pp_close_boxppf())elsecctxt#message"The proposals have already been cleared."inreturn_unit|Exploration|Promotion->let*!()=print_proposalinfo.current_proposalin(* the ballots are cleared on the last block of these periods *)ifinfo.remaining<>0lthenlet*ballots_info=get_ballots_info~chain:cctxt#chain~block:cctxt#blockcctxtinlet*!()=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)Operation_result.tez_symTez.pp(Tez.of_mutez_exnballots_info.ballots.nay)Operation_result.tez_symTez.pp(Tez.of_mutez_exnballots_info.ballots.pass)Operation_result.tez_sym(Int32.to_floatballots_info.participation/.100.)(Int32.to_floatballots_info.current_quorum/.100.)Tez.pp(Tez.of_mutez_exnballots_info.ballots.yay)Operation_result.tez_symTez.pp(Tez.of_mutez_exnballots_info.supermajority)Operation_result.tez_syminreturn_unitelselet*!()=cctxt#message"The ballots have already been cleared."inreturn_unit|Cooldown->let*!()=print_proposalinfo.current_proposalinreturn_unit|Adoption->let*!()=print_proposalinfo.current_proposalinreturn_unit);command~group:binary_description~desc:"Describe unsigned block header"no_options(fixed["describe";"unsigned";"block";"header"])(fun()(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*!()=cctxt#message"%a"Data_encoding.Binary_schema.pp(Data_encoding.Binary.describeAlpha_context.Block_header.unsigned_encoding)inreturn_unit);command~group:binary_description~desc:"Describe unsigned operation"no_options(fixed["describe";"unsigned";"operation"])(fun()(cctxt:Protocol_client_context.full)->letopenLwt_result_syntaxinlet*!()=cctxt#message"%a"Data_encoding.Binary_schema.pp(Data_encoding.Binary.describeAlpha_context.Operation.unsigned_encoding)inreturn_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)->letopenLwt_result_syntaxinmatchcontractwith|Originated_->cctxt#error"Cannot change deposits limit on contract %a. This operation is \
invalid on originated contracts."Contract.ppcontract|Implicitdelegate->let*o=get_frozen_deposits_limitcctxt~chain:cctxt#chain~block:cctxt#blockdelegateinlet*!()=matchowith|None->cctxt#answer"unlimited"|Somelimit->cctxt#answer"%a %s"Tez.pplimitOperation_result.tez_syminreturn_unit);]letdry_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"()letcommands_network()=commands_ro()