123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100(* The MIT License (MIT)
*
* Copyright (c) 2019-2020 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. *)openAlpha_contextletcustom_root=(RPC_path.(open_root/"context"/"sapling"):RPC_context.tRPC_path.context)typediff_query={offset_commitment:Int64.toption;offset_nullifier:Int64.toption;}moduleS=structmoduleArgs=structtype('query,'output)t={name:string;description:string;query:'queryRPC_query.t;output:'outputData_encoding.t;f:context->Sapling.Id.t->'query->'outputtzresultLwt.t;}letget_diff_query:diff_queryRPC_query.t=letopenRPC_queryinquery(funoffset_commitmentoffset_nullifier->{offset_commitment;offset_nullifier})|+opt_field~descr:"Commitments and ciphertexts are returned from the specified \
offset up to the most recent.""offset_commitment"RPC_arg.int64(fun{offset_commitment;_}->offset_commitment)|+opt_field~descr:"Nullifiers are returned from the specified offset up to the \
most recent.""offset_nullifier"RPC_arg.int64(fun{offset_nullifier;_}->offset_nullifier)|>sealletencoding=letopenData_encodinginmerge_objs(obj1(req"root"Sapling.root_encoding))Sapling.diff_encodingletget_diff={name="get_diff";description="Returns the root and a diff of a state starting from an optional \
offset which is zero by default.";query=get_diff_query;output=encoding;f=(functxtid{offset_commitment;offset_nullifier}->Sapling.get_diffctxtid?offset_commitment?offset_nullifier());}endletmake_serviceArgs.{name;description;query;output;f}=letpath=RPC_path.(custom_root/:Sapling.rpc_arg/name)inletservice=RPC_service.get_service~description~query~outputpathin(service,functxtidq()->fctxtidq)letget_diff=make_serviceArgs.get_diffendletregister()=letreg(service,f)=Services_registration.register1servicefinregS.get_diffletmk_call1(service,_f)ctxtblockidq=RPC_context.make_call1servicectxtblockidq()letget_diffctxtblockid?offset_commitment?offset_nullifier()=mk_call1S.get_diffctxtblockid{offset_commitment;offset_nullifier}