1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2022 Trili Tech, <contact@trili.tech> *)(* *)(* 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_contextletmake_big_mapblock~source~key_type~value_typekey_values=letopenLwt_result_wrap_syntaxinletkey_type=Expr.from_stringkey_typeinletvalue_type=Expr.from_stringvalue_typeinlet*operation,originated=Op.contract_origination_hash(Bblock)source~script:Op.dummy_scriptinlet*block=Block.bake~operationblockinlet*incr=Incremental.begin_constructionblockinletctxt=Incremental.alpha_ctxtincrinlet*@ctxt,big_map_id=Big_map.fresh~temporary:falsectxtinlet*updates,ctxt=List.fold_left_es(fun(kvs,ctxt)(key,value)->letkey_hash=matchData_encoding.Binary.to_bytes_optScript_repr.expr_encodingkeywith|Somebytes->Script_expr_hash.hash_bytes[bytes]|None->assertfalseinreturn({Big_map.key;key_hash;value=Somevalue}::kvs,ctxt))([],ctxt)key_valuesinlet*@ctxt=Contract.update_script_storagectxtoriginatedkey_type(Some[Lazy_storage.makeLazy_storage.Kind.Big_mapbig_map_id(Update{init=Lazy_storage.AllocBig_map.{key_type;value_type};updates;});])inreturn(big_map_id,ctxt)