123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 Nomadic Labs <contact@nomadic-labs.com> *)(* Copyright (c) 2022 Trili Tech, <contact@trili.tech> *)(* Copyright (c) 2022 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. *)(* *)(*****************************************************************************)moduleAddress=structincludeSmart_rollup.Addressletprefix="sr1"let()=Base58.check_encoded_prefixb58check_encodingprefix36letof_b58data=functionSmart_rollup.Address.Datah->Someh|_->NoneendmoduleInternal_for_tests=structletoriginated_sc_rollupnonce=letdata=Data_encoding.Binary.to_bytes_exnOrigination_nonce.encodingnonceinAddress.hash_bytes[data]endmoduleState_hash=Smart_rollup.State_hash(* TODO: https://gitlab.com/tezos/tezos/-/issues/5506
Remove type and module aliases for Smart_rollup.Address. *)typet=Address.tletpp=Address.ppletencoding=Address.encodingletrpc_arg=Address.rpc_argletin_memory_size(_:t)=letopenCache_memory_helpersinh1w+!string_size_genAddress.sizemoduleStaker=structincludeSignature.Public_key_hashletrpc_arg_staker1=RPC_arg.likerpc_arg?descr:(RPC_arg.descrrpc_arg).descr"staker1_pkh"letrpc_arg_staker2=RPC_arg.likerpc_arg?descr:(RPC_arg.descrrpc_arg).descr"staker2_pkh"endmoduleIndex=structtypet=Address.tletpath_length=1letto_pathcl=letraw_key=Data_encoding.Binary.to_bytes_exnencodingcinlet(`Hexkey)=Hex.of_bytesraw_keyinkey::lletof_path=function|[key]->Option.bind(Hex.to_bytes(`Hexkey))(Data_encoding.Binary.of_bytes_optencoding)|_->Noneletrpc_arg=rpc_argletencoding=encodingletcompare=Address.compareendmoduleNumber_of_ticks=structincludeBounded.Int64(structletmin_value=0Lletmax_value=Int64.max_intend)letzero=matchof_value0Lwith|Somezero->zero|None->assertfalse(* unreachable case, since [min_int = 0l] *)end