12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Marigold <contact@marigold.dev> *)(* Copyright (c) 2021 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_root/"context"/"tx_rollup"):RPC_context.tRPC_path.context)moduleS=structletstate=RPC_service.get_service~description:"Access the state of a rollup."~query:RPC_query.empty~output:Tx_rollup_state.encodingRPC_path.(custom_root/:Tx_rollup.rpc_arg/"state")letinbox=RPC_service.get_service~description:"Get the inbox of a transaction rollup"~query:RPC_query.empty~output:Data_encoding.(optionTx_rollup_inbox.encoding)RPC_path.(custom_root/:Tx_rollup.rpc_arg/"inbox"/:Tx_rollup_level.rpc_arg)letcommitment=RPC_service.get_service~description:"Return the commitment for a level, if any"~query:RPC_query.empty~output:Data_encoding.(optionTx_rollup_commitment.Submitted_commitment.encoding)RPC_path.(custom_root/:Tx_rollup.rpc_arg/"commitment"/:Tx_rollup_level.rpc_arg)letpending_bonded_commitments=RPC_service.get_service~description:"Get the number of pending bonded commitments for a pkh on a rollup"~query:RPC_query.empty~output:Data_encoding.int32RPC_path.(custom_root/:Tx_rollup.rpc_arg/"pending_bonded_commitments"/:Signature.Public_key_hash.rpc_arg)endletregister()=letopenServices_registrationinopt_register1~chunked:falseS.state(functxttx_rollup()()->Tx_rollup_state.findctxttx_rollup>|=?snd);register2~chunked:falseS.inbox(functxttx_rolluplevel()()->Tx_rollup_inbox.findctxtleveltx_rollup>|=?snd);register2~chunked:falseS.commitment(functxttx_rolluplevel()()->Tx_rollup_state.getctxttx_rollup>>=?fun(ctxt,state)->Tx_rollup_commitment.findctxttx_rollupstatelevel>|=?fun(_,commitment)->commitment);register2~chunked:falseS.pending_bonded_commitments(functxttx_rolluppkh()()->Tx_rollup_commitment.pending_bonded_commitmentsctxttx_rolluppkh>|=?fun(_,count)->Int32.of_intcount)letstatectxtblocktx_rollup=RPC_context.make_call1S.statectxtblocktx_rollup()()letinboxctxtblocktx_rolluplevel=RPC_context.make_call2S.inboxctxtblocktx_rolluplevel()()letcommitmentctxtblocktx_rolluplevel=RPC_context.make_call2S.commitmentctxtblocktx_rolluplevel()()