123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)openTezos_client_baseletlogger=letlog_channelmsg=Lwt_fmt.printf"%s@."msginnewClient_context.simple_printerlogclassdummy_prompter:Client_context.prompter=objectmethodprompt:typea.(a,stringtzresult)Client_context.lwt_format->a=fun_msg->assertfalsemethodprompt_password:typea.(a,Bytes.ttzresult)Client_context.lwt_format->a=fun_msg->assertfalsemethodmultiple_password_retries=falseendletlog_channelmsg=print_endlinemsg;Lwt.return_unitclassfaked_ctxt(hooks:Faked_services.hooks)(chain_id:Chain_id.t):Tezos_rpc.Context.generic=letlocal_ctxt=letmoduleServices=Faked_services.Make((valhooks))inTezos_mockup_proxy.RPC_client.local_ctxt(Services.directorychain_id)inobjectmethodbase=local_ctxt#basemethodgeneric_media_type_callmeth?bodyuri=local_ctxt#generic_media_type_callmeth?bodyurimethodcall_service:'m'p'q'i'o.(([<Resto.meth]as'm),unit,'p,'q,'i,'o)Tezos_rpc.Service.t->'p->'q->'i->'otzresultLwt.t=funserviceparamsquerybody->local_ctxt#call_serviceserviceparamsquerybodymethodcall_streamed_service:'m'p'q'i'o.(([<Resto.meth]as'm),unit,'p,'q,'i,'o)Tezos_rpc.Service.t->on_chunk:('o->unit)->on_close:(unit->unit)->'p->'q->'i->(unit->unit)tzresultLwt.t=funservice~on_chunk~on_closeparamsquerybody->local_ctxt#call_streamed_serviceservice~on_chunk~on_closeparamsquerybodyendclassfaked_wallet~base_dir~filesystem:Client_context.wallet=object(self)methodload_passwords=Nonemethodread_filefname=letopenLwt_result_syntaxinmatchString.Hashtbl.findfilesystemfnamewith|None->failwith"faked_wallet: cannot read file (%s)"fname|Some(content,_mtime)->returncontentmethodprivatefilenamealias_name=Filename.concatbase_dir(String.map(function' '->'_'|c->c)alias_name^"s")vallock_mutex=Lwt_mutex.create()methodwith_lock:typea.(unit->aLwt.t)->aLwt.t=funf->Lwt_mutex.with_locklock_mutexfmethodget_base_dir=base_dirmethodload:typea.string->default:a->aData_encoding.encoding->atzresultLwt.t=letopenLwt_result_syntaxinfunalias_name~defaultencoding->letfilename=self#filenamealias_nameinifnot(String.Hashtbl.memfilesystemfilename)thenreturndefaultelselet*content=self#read_filefilenameinletjson=(Ezjsonm.from_stringcontent:>Data_encoding.json)inmatchData_encoding.Json.destructencodingjsonwith|exceptione->failwith"did not understand the %s alias file %s : %s"alias_namefilename(Printexc.to_stringe)|data->returndatamethodwrite:typea.string->a->aData_encoding.encoding->unittzresultLwt.t=letopenLwt_result_syntaxinfunalias_namelistencoding->letfilename=self#filenamealias_nameinletjson=Data_encoding.Json.constructencodinglistinletstr=Ezjsonm.value_to_string(json:>Ezjsonm.value)inString.Hashtbl.replacefilesystemfilename(str,Some(Ptime.to_float_s(Ptime_clock.now())));return_unitmethodlast_modification_time:string->floatoptiontzresultLwt.t=letopenLwt_result_syntaxinfunalias_name->letfilename=self#filenamealias_nameinletfile=String.Hashtbl.find_optfilesystemfilenameinmatchfilewith|None->return_none|Some(_content,mtime)->returnmtimeendclassfaked_io_wallet~base_dir~filesystem:Client_context.io_wallet=objectinheritClient_context.simple_printerloginheritdummy_prompterinheritfaked_wallet~base_dir~filesystemendclassunix_faked~base_dir~filesystem~chain_id~hooks:Client_context.full=objectinheritfaked_io_wallet~base_dir~filesysteminheritfaked_ctxthookschain_idinheritClient_context_unix.unix_uimethodchain=`Hashchain_idmethodblock=`Head0methodconfirmations=Nonemethodverbose_rpc_error_diagnostics=falseend