Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file client_proto_context_commands.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.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. *)(* *)(*****************************************************************************)openProtocolopenAlpha_contextopenTezos_michelineopenClient_proto_contextopenClient_proto_contractsopenClient_keys_v0letreport_michelson_errors?(no_print_source=false)~msg(cctxt:#Client_context.printer)=function|Errorerrs->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_somedataletdata_parameter=Tezos_clic.parameter(fun_data->Lwt.return(Micheline_parser.no_parsing_error@@Michelson_v1_parser.parse_expressiondata))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)";}letbinary_description={Tezos_clic.name="description";title="Binary Description"}letcommands()=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:Alpha_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:Alpha_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:"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:Alpha_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."no_options(prefixes["get";"script";"storage";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Alpha_client_context.full)->get_storagecctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=?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."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:Alpha_client_context.full)->get_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 the storage of a contract."no_options(prefixes["get";"script";"code";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Alpha_client_context.full)->get_scriptcctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=?function|None->cctxt#error"This is not a smart contract."|Some{code;storage=_}->(matchScript_repr.force_decodecodewith|Errorerrs->cctxt#error"%a"(Format.pp_print_list~pp_sep:Format.pp_print_newlineEnvironment.Error_monad.pp)errs|Ok(code,_)->let{Michelson_v1_parser.source;_}=Michelson_v1_printer.unparse_toplevelcodeincctxt#answer"%s"source>>=return));command~group~desc:"Get the manager of a contract."no_options(prefixes["get";"manager";"for"]@@Contract_alias.destination_param~name:"src"~desc:"source contract"@@stop)(fun()(_,contract)(cctxt:Alpha_client_context.full)->Client_proto_contracts.get_managercctxt~chain:cctxt#chain~block:cctxt#blockcontract>>=?funmanager->Public_key_hash.rev_findcctxtmanager>>=?funmn->Public_key_hash.to_sourcemanager>>=?funm->cctxt#message"%s (%s)"m(matchmnwithNone->"unknown"|Somen->"known as "^n)>>=fun()->return_unit);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:Alpha_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:Alpha_client_context.full)->display_receipt_for_operationctxt~chain:ctxt#chain~predecessorsoperation_hash>>=?fun_->return_unit);command~group:binary_description~desc:"Describe unsigned block header"no_options(fixed["describe";"unsigned";"block";"header"])(fun()(cctxt:Alpha_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:Alpha_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:"Summarize the current voting period"no_options(fixed["show";"voting";"period"])(fun()(cctxt:Alpha_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)->Int32.(comparev2v1))inletprint_proposal=function|None->assertfalse(* not called during proposal phase *)|Someproposal->cctxt#message"Current proposal: %a"Protocol_hash.ppproposalinmatchinfo.current_period_kindwith|Proposal->cctxt#answer"Current proposals:%t"Format.(funppf->pp_print_cutppf();pp_open_vboxppf0;List.iter(fun(p,w)->fprintfppf"* %a %ld (%sknown by the node)@."Protocol_hash.pppw(ifList.mem~equal:Protocol_hash.equalpknown_protosthen""else"not "))ranks;pp_close_boxppf())>>=fun()->return_unit|Testing_vote|Promotion_vote->print_proposalinfo.current_proposal>>=fun()->get_ballots_info~chain:cctxt#chain~block:cctxt#blockcctxt>>=?funballots_info->cctxt#answer"Ballots: %a@,\
Current participation %.2f%%, necessary quorum %.2f%%@,\
Current in favor %ld, needed supermajority %ld"Data_encoding.Json.pp(Data_encoding.Json.constructVote.ballots_encodingballots_info.ballots)(Int32.to_floatballots_info.participation/.100.)(Int32.to_floatballots_info.current_quorum/.100.)ballots_info.ballots.yayballots_info.supermajority>>=fun()->return_unit|Testing->print_proposalinfo.current_proposal>>=fun()->return_unit);]