sui_json_rpc_api/
extended.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::{
8    CheckpointedObjectID, EpochInfo, EpochPage, QueryObjectsPage, SuiObjectResponseQuery,
9};
10use sui_open_rpc_macros::open_rpc;
11use sui_types::sui_serde::BigInt;
12
13#[open_rpc(namespace = "suix", tag = "Extended API")]
14#[rpc(server, client, namespace = "suix")]
15pub trait ExtendedApi {
16    /// Return a list of epoch info
17    #[method(name = "getEpochs")]
18    async fn get_epochs(
19        &self,
20        /// optional paging cursor
21        cursor: Option<BigInt<u64>>,
22        /// maximum number of items per page
23        limit: Option<usize>,
24        /// flag to return results in descending order
25        descending_order: Option<bool>,
26    ) -> RpcResult<EpochPage>;
27
28    /// Return current epoch info
29    #[method(name = "getCurrentEpoch")]
30    async fn get_current_epoch(&self) -> RpcResult<EpochInfo>;
31
32    /// Return the list of queried objects. Note that this is an enhanced full node only api.
33    #[method(name = "queryObjects")]
34    async fn query_objects(
35        &self,
36        /// the objects query criteria.
37        query: SuiObjectResponseQuery,
38        /// An optional paging cursor. If provided, the query will start from the next item after the specified cursor. Default to start from the first item if not specified.
39        cursor: Option<CheckpointedObjectID>,
40        /// Max number of items returned per page, default to [QUERY_MAX_RESULT_LIMIT] if not specified.
41        limit: Option<usize>,
42    ) -> RpcResult<QueryObjectsPage>;
43
44    #[method(name = "getTotalTransactions")]
45    async fn get_total_transactions(&self) -> RpcResult<BigInt<u64>>;
46}