sui_jsonrpc/api/
governance.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4use jsonrpsee::proc_macros::rpc;
5use sui_sdk_types::Address;
6
7use crate::msgs::{DelegatedStake, SuiCommittee, SuiSystemStateSummary, ValidatorApys};
8use crate::serde::BigInt;
9
10#[rpc(client, namespace = "suix")]
11pub trait GovernanceReadApi {
12    /// Return one or more [DelegatedStake]. If a Stake was withdrawn its status will be Unstaked.
13    #[method(name = "getStakesByIds")]
14    async fn get_stakes_by_ids(
15        &self,
16        staked_sui_ids: Vec<Address>,
17    ) -> RpcResult<Vec<DelegatedStake>>;
18
19    /// Return all [DelegatedStake].
20    #[method(name = "getStakes")]
21    async fn get_stakes(&self, owner: Address) -> RpcResult<Vec<DelegatedStake>>;
22
23    /// Return the committee information for the asked `epoch`.
24    #[method(name = "getCommitteeInfo")]
25    async fn get_committee_info(&self, epoch: Option<BigInt<u64>>) -> RpcResult<SuiCommittee>;
26
27    /// Return the latest SUI system state object on-chain.
28    #[method(name = "getLatestSuiSystemState")]
29    async fn get_latest_sui_system_state(&self) -> RpcResult<SuiSystemStateSummary>;
30
31    /// Return the reference gas price for the network
32    #[method(name = "getReferenceGasPrice")]
33    async fn get_reference_gas_price(&self) -> RpcResult<BigInt<u64>>;
34
35    /// Return the validator APY
36    #[method(name = "getValidatorsApy")]
37    async fn get_validators_apy(&self) -> RpcResult<ValidatorApys>;
38}