123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 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. *)(* *)(*****************************************************************************)openProtocolopenAlpha_contextmoduleHash=Tezos_crypto.Blake2B.Make(Tezos_crypto.Base58)(structletname="tx_rollup_l2_block_hash"lettitle="An tx_rollup L2 block identifier"letb58check_prefix="\016\006\254"(* BTx(53) *)letsize=Noneend)let()=Tezos_crypto.Base58.check_encoded_prefixHash.b58check_encoding"BTx"53typehash=Hash.ttypelevel=Tx_rollup_level.ttypeheader={level:level;tezos_block:Block_hash.t;predecessor:hashoption;context:Tx_rollup_l2_context_hash.t;commitment:Tx_rollup_commitment_hash.t;}type'inboxblock={hash:hash;header:header;inbox:'inbox;commitment:Tx_rollup_commitment.Full.t;}typet=Inbox.tblocktypecommitment_included_info={block:Block_hash.t;operation:Operation_hash.t;}typemetadata={commitment_included:commitment_included_infooption;finalized:bool;}letlevel_encoding=Tx_rollup_level.encodingletlevel_to_stringl=Int32.to_string(Tx_rollup_level.to_int32l)letheader_encoding=letopenData_encodinginconv(fun{level;tezos_block;predecessor;context;commitment}->(level,tezos_block,predecessor,context,commitment))(fun(level,tezos_block,predecessor,context,commitment)->{level;tezos_block;predecessor;context;commitment})(obj5(req"level"Tx_rollup_level.encoding)(req"tezos_block"Block_hash.encoding)(opt"predecessor"Hash.encoding)(req"context"Tx_rollup_l2_context_hash.encoding)(req"commitment"Tx_rollup_commitment_hash.encoding))letblock_encodinginbox_encoding:'inboxblockData_encoding.t=letopenData_encodinginconv(fun{hash;header;inbox;commitment}->(hash,header,inbox,commitment))(fun(hash,header,inbox,commitment)->{hash;header;inbox;commitment})(obj4(req"hash"Hash.encoding)(req"header"header_encoding)(req"inbox"inbox_encoding)(req"commitment"Tx_rollup_commitment.Full.encoding))letencoding:tData_encoding.t=block_encodingInbox.encodingletcommitment_included_info_encoding=letopenData_encodinginconv(fun{block;operation}->(block,operation))(fun(block,operation)->{block;operation})(obj2(req"block"Block_hash.encoding)(req"operation"Operation_hash.encoding))letmetadata_encoding=letopenData_encodinginconv(fun{commitment_included;finalized}->(commitment_included,finalized))(fun(commitment_included,finalized)->{commitment_included;finalized})(obj2(opt"commitment_included"commitment_included_info_encoding)(req"finalized"bool))lethash_headerh=Hash.hash_bytes[Data_encoding.Binary.to_bytes_exnheader_encodingh]