123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2023 Marigold <contact@marigold.dev> *)(* *)(* 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. *)(* *)(*****************************************************************************)letmake?data?query_string=RPC_core.make?data?query_string(** [encode_bytes_for_json raw] encodes arbitrary byte sequence as hex string for JSON *)letencode_bytes_to_hex_stringraw="\""^matchHex.of_stringrawwith`Hexs->s^"\""moduleV0=structletapi_prefix="v0"letget_preimagepage_hash=makeGET[api_prefix;"preimage";page_hash]JSON.as_stringletmake_put_dac_member_signature_request_body~dac_member_pkh~root_hashsignature=let(`Hexroot_hash)=root_hashin`O[("root_hash",`Stringroot_hash);("signer_pkh",`Stringdac_member_pkh);("signature",`String(Tezos_crypto.Aggregate_signature.to_b58checksignature));]letput_dac_member_signature~hex_root_hash~dac_member_pkh~signature=letpayload=make_put_dac_member_signature_request_body~dac_member_pkh~root_hash:hex_root_hashsignatureinletdata:RPC_core.data=Datapayloadinmake~dataPUT[api_prefix;"dac_member_signature"]@@fun_resp->()letget_missing_page~hex_root_hash=makeGET[api_prefix;"missing_page";Hex.showhex_root_hash]JSON.as_stringletget_certificate~hex_root_hash=let(`Hexpage_hash)=hex_root_hashinmakeGET[api_prefix;"certificates";page_hash]@@funjson->JSON.(json|->"witnesses"|>as_int,json|->"aggregate_signature"|>as_string,json|->"root_hash"|>as_string,json|->"version"|>as_int)letget_serialized_certificate~hex_root_hash=let(`Hexpage_hash)=hex_root_hashinmakeGET[api_prefix;"serialized_certificates";page_hash]JSON.as_stringmoduleCoordinator=structletpost_preimage~payload=letpreimage=JSON.parse~origin:"Rollup.DAC.RPC.coordinator_post_preimage"(encode_bytes_to_hex_stringpayload)inletdata:RPC_core.data=Data(JSON.unannotatepreimage)inmake~dataPOST[api_prefix;"preimage"]JSON.as_stringendendletget_health_live=makeGET["health";"live"]JSON.as_boolletget_health_ready=makeGET["health";"ready"]JSON.as_boolmoduleV1=structletapi_prefix="v1"letget_pagespage_hash=makeGET[api_prefix;"pages";page_hash]JSON.as_stringend