123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2019-2020 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. *)(* *)(*****************************************************************************)openAlpha_contextletcustom_root=RPC_path.open_rootmoduleSeed=structmoduleS=structopenData_encodingletseed=RPC_service.post_service~description:"Seed of the cycle to which the block belongs."~query:RPC_query.empty~input:empty~output:Seed.seed_encodingRPC_path.(custom_root/"context"/"seed")endlet()=letopenServices_registrationinregister0~chunked:falseS.seed(functxt()()->letl=Level.currentctxtinSeed.for_cyclectxtl.cycle)letgetctxtblock=RPC_context.make_call0S.seedctxtblock()()endmoduleNonce=structtypeinfo=RevealedofNonce.t|MissingofNonce_hash.t|Forgottenletinfo_encoding=letopenData_encodinginunion[case(Tag0)~title:"Revealed"(obj1(req"nonce"Nonce.encoding))(functionRevealednonce->Somenonce|_->None)(funnonce->Revealednonce);case(Tag1)~title:"Missing"(obj1(req"hash"Nonce_hash.encoding))(functionMissingnonce->Somenonce|_->None)(funnonce->Missingnonce);case(Tag2)~title:"Forgotten"empty(functionForgotten->Some()|_->None)(fun()->Forgotten);]moduleS=structletget=RPC_service.get_service~description:"Info about the nonce of a previous block."~query:RPC_query.empty~output:info_encodingRPC_path.(custom_root/"context"/"nonces"/:Raw_level.rpc_arg)endletregister()=letopenServices_registrationinregister1~chunked:falseS.get(functxtraw_level()()->letlevel=Level.from_rawctxtraw_levelinNonce.getctxtlevel>|=function|Ok(Revealednonce)->ok(Revealednonce)|Ok(Unrevealed{nonce_hash;_})->ok(Missingnonce_hash)|Error_->okForgotten)letgetctxtblocklevel=RPC_context.make_call1S.getctxtblocklevel()()endmoduleContract=Contract_servicesmoduleConstants=Constants_servicesmoduleDelegate=Delegate_servicesmoduleVoting=Voting_servicesmoduleSapling=Sapling_servicesmoduleLiquidity_baking=structmoduleS=structletget_cpmm_address=RPC_service.get_service~description:"Liquidity baking CPMM address"~query:RPC_query.empty~output:Alpha_context.Contract.encodingRPC_path.(custom_root/"context"/"liquidity_baking"/"cpmm_address")endletregister()=letopenServices_registrationinregister0~chunked:falseS.get_cpmm_address(functxt()()->Alpha_context.Liquidity_baking.get_cpmm_addressctxt)letget_cpmm_addressctxtblock=RPC_context.make_call0S.get_cpmm_addressctxtblock()()endmoduleCache=structmoduleS=structletcached_contracts=RPC_service.get_service~description:"Return the list of cached contracts"~query:RPC_query.empty~output:Data_encoding.(list@@tup2Alpha_context.Contract.encodingint31)RPC_path.(custom_root/"context"/"cache"/"contracts"/"all")letcontract_cache_size=RPC_service.get_service~description:"Return the size of the contract cache"~query:RPC_query.empty~output:Data_encoding.int31RPC_path.(custom_root/"context"/"cache"/"contracts"/"size")letcontract_cache_size_limit=RPC_service.get_service~description:"Return the size limit of the contract cache"~query:RPC_query.empty~output:Data_encoding.int31RPC_path.(custom_root/"context"/"cache"/"contracts"/"size_limit")letcontract_rank=RPC_service.post_service~description:"Return the number of cached contracts older than the provided \
contract"~query:RPC_query.empty~input:Alpha_context.Contract.encoding~output:Data_encoding.(optionint31)RPC_path.(custom_root/"context"/"cache"/"contracts"/"rank")endletregister()=letopenServices_registrationinregister0~chunked:trueS.cached_contracts(functxt()()->Script_cache.entriesctxt|>Lwt.return);register0~chunked:falseS.contract_cache_size(functxt()()->Script_cache.sizectxt|>return);register0~chunked:falseS.contract_cache_size_limit(functxt()()->Script_cache.size_limitctxt|>return);register0~chunked:falseS.contract_rank(functxt()contract->Script_cache.contract_rankctxtcontract|>return)letcached_contractsctxtblock=RPC_context.make_call0S.cached_contractsctxtblock()()letcontract_cache_sizectxtblock=RPC_context.make_call0S.contract_cache_sizectxtblock()()letcontract_cache_size_limitctxtblock=RPC_context.make_call0S.contract_cache_size_limitctxtblock()()letcontract_rankctxtblockcontract=RPC_context.make_call0S.contract_rankctxtblock()contractendletregister()=Contract.register();Constants.register();Delegate.register();Nonce.register();Voting.register();Sapling.register();Liquidity_baking.register();Cache.register()