sui_json_rpc_api/
governance.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use jsonrpsee::core::RpcResult;
5use jsonrpsee::proc_macros::rpc;
6
7use sui_json_rpc_types::{DelegatedStake, SuiCommittee, ValidatorApys};
8use sui_open_rpc_macros::open_rpc;
9use sui_types::base_types::{ObjectID, SuiAddress};
10use sui_types::sui_serde::BigInt;
11use sui_types::sui_system_state::sui_system_state_summary::SuiSystemStateSummary;
12
13#[open_rpc(namespace = "suix", tag = "Governance Read API")]
14#[rpc(server, client, namespace = "suix")]
15pub trait GovernanceReadApi {
16    /// Return one or more [DelegatedStake]. If a Stake was withdrawn its status will be Unstaked.
17    #[method(name = "getStakesByIds")]
18    async fn get_stakes_by_ids(
19        &self,
20        staked_sui_ids: Vec<ObjectID>,
21    ) -> RpcResult<Vec<DelegatedStake>>;
22
23    /// Return all [DelegatedStake].
24    #[method(name = "getStakes")]
25    async fn get_stakes(&self, owner: SuiAddress) -> RpcResult<Vec<DelegatedStake>>;
26
27    /// Return the committee information for the asked `epoch`.
28    #[method(name = "getCommitteeInfo")]
29    async fn get_committee_info(
30        &self,
31        /// The epoch of interest. If None, default to the latest epoch
32        epoch: Option<BigInt<u64>>,
33    ) -> RpcResult<SuiCommittee>;
34
35    /// Return the latest SUI system state object on-chain.
36    #[method(name = "getLatestSuiSystemState")]
37    async fn get_latest_sui_system_state(&self) -> RpcResult<SuiSystemStateSummary>;
38
39    /// Return the reference gas price for the network
40    #[method(name = "getReferenceGasPrice")]
41    async fn get_reference_gas_price(&self) -> RpcResult<BigInt<u64>>;
42
43    /// Return the validator APY
44    #[method(name = "getValidatorsApy")]
45    async fn get_validators_apy(&self) -> RpcResult<ValidatorApys>;
46}