123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123(*****************************************************************************)(* *)(* 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:Z.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=let(Manager_infoc)=operationinLimit.join~where:__LOC__Tez.equalfeec.fee>|?funfee->Manager_info{cwithfee}letset_feefee(Manager_infoc)=Manager_info{cwithfee}letjoin_gas_limitgas_limitoperation=let(Manager_infoc)=operationinLimit.join~where:__LOC__Gas.Arith.equalgas_limitc.gas_limit>|?fungas_limit->Manager_info{cwithgas_limit}letset_gas_limitgas_limit(Manager_infoc)=Manager_info{cwithgas_limit}letjoin_storage_limitstorage_limit(Manager_infoc)=Limit.join~where:__LOC__Z.equalstorage_limitc.storage_limit>|?funstorage_limit->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=let(Manager_info{source;fee;gas_limit;storage_limit;counter;operation})=operationinLimit.get~when_unknown:"unknown fee"fee>>?funfee->Limit.get~when_unknown:"unknown gas limit"gas_limit>>?fungas_limit->Limit.get~when_unknown:"unknown storage limit"storage_limit>>?funstorage_limit->Option.fold~some:ok~none:(error_with"manager_from_annotated: source not set")source>>?funsource->Option.fold~some:ok~none:(error_with"manager_from_annotated: counter not set")counter>|?funcounter->Manager_operation{source;fee;counter;gas_limit;storage_limit;operation}letrecmanager_list_from_annotated:typekind.kindannotated_list->kindKind.managercontents_listtzresult=function|Single_manageroperation->manager_from_annotatedoperation>|?funop->Singleop|Cons_manager(operation,rest)->manager_list_from_annotatedrest>>?funrest->manager_from_annotatedoperation>|?funop->Cons(op,rest)