1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(*****************************************************************************)(* *)(* Open Source License *)(* 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. *)(* *)(*****************************************************************************)openProtocolopenAlpha_context(* From OCaml values to Micheline expressions *)letseq?(loc=0)l=Tezos_micheline.Micheline.Seq(loc,l)letpair?(loc=0)ab=Tezos_micheline.Micheline.Prim(loc,Script.D_Pair,[a;b],[])letpair_n?(loc=0)els=Tezos_micheline.Micheline.Prim(loc,Script.D_Pair,els,[])letcomb?(loc=0)es=Tezos_micheline.Micheline.Prim(loc,Script.D_Pair,es,[])letnone?(loc=0)()=Tezos_micheline.Micheline.Prim(loc,Script.D_None,[],[])letsome?(loc=0)a=Tezos_micheline.Micheline.Prim(loc,Script.D_Some,[a],[])letleft?(loc=0)a=Tezos_micheline.Micheline.Prim(loc,Script.D_Left,[a],[])letright?(loc=0)b=Tezos_micheline.Micheline.Prim(loc,Script.D_Right,[b],[])letunit?(loc=0)()=Tezos_micheline.Micheline.Prim(loc,Script.D_Unit,[],[])letint?(loc=0)i=Tezos_micheline.Micheline.Int(loc,i)letbytes?(loc=0)s=Tezos_micheline.Micheline.Bytes(loc,s)letstring?(loc=0)s=Tezos_micheline.Micheline.String(loc,s)letmutez?(loc=0)m=int~loc(Z.of_int64(Tez.to_mutezm))(* Translate a timestamp to a Micheline expression in optimized
form *)lettimestamp?(loc=0)ts=int~loc(Script_timestamp.to_zintts)letaddress?(loc=0)adr=bytes~loc@@Data_encoding.Binary.to_bytes_exnContract.encodingadrletaddress_string?(loc=0)adr=string~loc@@Contract.to_b58checkadrletbig_map_id?(loc=0)id=int~loc@@Big_map.Id.unparse_to_zid(* From Micheline expressions to OCaml values *)lettimestamp_of_zintzint=Script_timestamp.of_zintzintletpublic_key_of_bytes_exnb=Data_encoding.Binary.of_bytes_exnSignature.Public_key.encodingbletaddress_of_bytes_exnb=Data_encoding.Binary.of_bytes_exnContract.encodingbtypeexn+=Invalid_address_exprofstringletaddress_of_string_exns=matchContract.of_b58checkswith|Okc->c|Error_->raise@@Invalid_address_exprsletoriginated_of_string_exns=matchaddress_of_string_exnswith|Contract.Originatedaddr->addr|Contract.Implicit_->invalid_arg"Expected originated contract address, got implicit contract address"