123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.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_contextmoduleS=structletpath=RPC_path.(open_root/"votes")letballots=RPC_service.get_service~description:"Sum of ballots casted so far during a voting period."~query:RPC_query.empty~output:Vote.ballots_encodingRPC_path.(path/"ballots")letballot_list=RPC_service.get_service~description:"Ballots casted so far during a voting period."~query:RPC_query.empty~output:Data_encoding.(list(obj2(req"pkh"Signature.Public_key_hash.encoding)(req"ballot"Vote.ballot_encoding)))RPC_path.(path/"ballot_list")letcurrent_period_kind=RPC_service.get_service~description:"Current period kind."~query:RPC_query.empty~output:Voting_period.kind_encodingRPC_path.(path/"current_period_kind")letcurrent_quorum=RPC_service.get_service~description:"Current expected quorum."~query:RPC_query.empty~output:Data_encoding.int32RPC_path.(path/"current_quorum")letlistings=RPC_service.get_service~description:"List of delegates with their voting weight, in number of rolls."~query:RPC_query.empty~output:Vote.listings_encodingRPC_path.(path/"listings")letproposals=RPC_service.get_service~description:"List of proposals with number of supporters."~query:RPC_query.empty~output:(Protocol_hash.Map.encodingData_encoding.int32)RPC_path.(path/"proposals")letcurrent_proposal=RPC_service.get_service~description:"Current proposal under evaluation."~query:RPC_query.empty~output:(Data_encoding.optionProtocol_hash.encoding)RPC_path.(path/"current_proposal")endletregister()=letopenServices_registrationinregister0S.ballotsbeginfunctxt()()->Vote.get_ballotsctxtend;register0S.ballot_listbeginfunctxt()()->Vote.get_ballot_listctxt>|=okend;register0S.current_period_kindbeginfunctxt()()->Vote.get_current_period_kindctxtend;register0S.current_quorumbeginfunctxt()()->Vote.get_current_quorumctxtend;register0S.proposalsbeginfunctxt()()->Vote.get_proposalsctxtend;register0S.listingsbeginfunctxt()()->Vote.get_listingsctxt>|=okend;register0S.current_proposalbeginfunctxt()()->(* this would be better implemented using get_option in get_current_proposal *)Vote.get_current_proposalctxt>>=function|Okp->return_somep|Error(Raw_context.Storage_error(Missing_key_)::_)->return_none|Error_ase->Lwt.returneendletballotsctxtblock=RPC_context.make_call0S.ballotsctxtblock()()letballot_listctxtblock=RPC_context.make_call0S.ballot_listctxtblock()()letcurrent_period_kindctxtblock=RPC_context.make_call0S.current_period_kindctxtblock()()letcurrent_quorumctxtblock=RPC_context.make_call0S.current_quorumctxtblock()()letlistingsctxtblock=RPC_context.make_call0S.listingsctxtblock()()letproposalsctxtblock=RPC_context.make_call0S.proposalsctxtblock()()letcurrent_proposalctxtblock=RPC_context.make_call0S.current_proposalctxtblock()()