123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)(* Copyright (c) 2018-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_contexttype_t=|Manager_info:{source:Alpha_context.public_key_hashoption;fee:Tez.tLimit.t;gas_limit:Gas.Arith.integralLimit.t;storage_limit:Z.tLimit.t;counter:Manager_counter.toption;operation:'kindmanager_operation;}->'kindttypepacked=Annotated_manager_operation:'kindt->packedtype_annotated_list=|Single_manager:'kindt->'kindannotated_list|Cons_manager:'kindt*'restannotated_list->('kind*'rest)annotated_listtypepacked_annotated_list=|Manager_list:'kindannotated_list->packed_annotated_listletrecmanager_to_list=function|Manager_list(Single_managero)->[Annotated_manager_operationo]|Manager_list(Cons_manager(o,os))->Annotated_manager_operationo::manager_to_list(Manager_listos)letrecmanager_of_list=function|[]->assertfalse|[Annotated_manager_operationo]->Manager_list(Single_managero)|Annotated_manager_operationo::os->let(Manager_listos)=manager_of_listosinManager_list(Cons_manager(o,os))letjoin_feefeeoperation=letopenResult_syntaxinlet(Manager_infoc)=operationinlet*fee=Limit.join~where:__LOC__Tez.equalfeec.feeinreturn(Manager_info{cwithfee})letset_feefee(Manager_infoc)=Manager_info{cwithfee}letjoin_gas_limitgas_limitoperation=letopenResult_syntaxinlet(Manager_infoc)=operationinlet*gas_limit=Limit.join~where:__LOC__Gas.Arith.equalgas_limitc.gas_limitinreturn(Manager_info{cwithgas_limit})letset_gas_limitgas_limit(Manager_infoc)=Manager_info{cwithgas_limit}letjoin_storage_limitstorage_limit(Manager_infoc)=letopenResult_syntaxinlet*storage_limit=Limit.join~where:__LOC__Z.equalstorage_limitc.storage_limitinreturn(Manager_info{cwithstorage_limit})letset_storage_limitstorage_limit(Manager_infoc)=Manager_info{cwithstorage_limit}letset_countercounter(Manager_infoc)=matchc.counterwith|Some_->error_with"set_counter_annot: already set"|None->Ok(Manager_info{cwithcounter=Somecounter})letset_sourcesource(Manager_infoc)=matchc.sourcewith|Some_->error_with"set_source_annot: already set"|None->Ok(Manager_info{cwithsource=Somesource})letmanager_from_annotatedoperation=letopenResult_syntaxinlet(Manager_info{source;fee;gas_limit;storage_limit;counter;operation})=operationinlet*fee=Limit.get~when_unknown:"unknown fee"feeinlet*gas_limit=Limit.get~when_unknown:"unknown gas limit"gas_limitinlet*storage_limit=Limit.get~when_unknown:"unknown storage limit"storage_limitinlet*source=Option.fold~some:return~none:(error_with"manager_from_annotated: source not set")sourceinlet*counter=Option.fold~some:return~none:(error_with"manager_from_annotated: counter not set")counterinreturn@@Manager_operation{source;fee;counter;gas_limit;storage_limit;operation}letrecmanager_list_from_annotated:typekind.kindannotated_list->kindKind.managercontents_listtzresult=letopenResult_syntaxinfunction|Single_manageroperation->let*op=manager_from_annotatedoperationinreturn(Singleop)|Cons_manager(operation,rest)->let*rest=manager_list_from_annotatedrestinlet*op=manager_from_annotatedoperationinreturn(Cons(op,rest))