iota_json_rpc_api/
extended.rs

1// Copyright (c) Mysten Labs, Inc.
2// Modifications Copyright (c) 2024 IOTA Stiftung
3// SPDX-License-Identifier: Apache-2.0
4
5use iota_json_rpc_types::{
6    AddressMetrics, EpochInfo, EpochMetricsPage, EpochPage, MoveCallMetrics, NetworkMetrics,
7    ParticipationMetrics,
8};
9use iota_open_rpc_macros::open_rpc;
10use iota_types::iota_serde::BigInt;
11use jsonrpsee::{core::RpcResult, proc_macros::rpc};
12
13/// Methods served exclusively by the indexer, supporting queries using refined
14/// filters and providing access to system info and metrics.
15#[open_rpc(namespace = "iotax", tag = "Extended API")]
16#[rpc(server, client, namespace = "iotax")]
17pub trait ExtendedApi {
18    /// Return a list of epoch info. Exclusively served by the indexer.
19    #[rustfmt::skip]
20    #[method(name = "getEpochs")]
21    async fn get_epochs(
22        &self,
23        /// Optional paging cursor
24        cursor: Option<BigInt<u64>>,
25        /// Maximum number of items per page
26        limit: Option<usize>,
27        /// Flag to return results in descending order
28        descending_order: Option<bool>,
29    ) -> RpcResult<EpochPage>;
30
31    /// Return a list of epoch metrics, which is a subset of epoch info.
32    /// Exclusively served by the indexer.
33    #[method(name = "getEpochMetrics")]
34    async fn get_epoch_metrics(
35        &self,
36        /// Optional paging cursor
37        cursor: Option<BigInt<u64>>,
38        /// Maximum number of items per page
39        limit: Option<usize>,
40        /// Flag to return results in descending order
41        descending_order: Option<bool>,
42    ) -> RpcResult<EpochMetricsPage>;
43
44    /// Return current epoch info. Exclusively served by the indexer.
45    #[method(name = "getCurrentEpoch")]
46    async fn get_current_epoch(&self) -> RpcResult<EpochInfo>;
47
48    /// Return Network metrics. Exclusively served by the indexer.
49    #[method(name = "getNetworkMetrics")]
50    async fn get_network_metrics(&self) -> RpcResult<NetworkMetrics>;
51
52    /// Return move call metrics. Exclusively served by the indexer.
53    #[method(name = "getMoveCallMetrics")]
54    async fn get_move_call_metrics(&self) -> RpcResult<MoveCallMetrics>;
55
56    /// Address related metrics. Exclusively served by the indexer.
57    #[method(name = "getLatestAddressMetrics")]
58    async fn get_latest_address_metrics(&self) -> RpcResult<AddressMetrics>;
59
60    /// Address related metrics. Exclusively served by the indexer.
61    #[method(name = "getCheckpointAddressMetrics")]
62    async fn get_checkpoint_address_metrics(&self, checkpoint: u64) -> RpcResult<AddressMetrics>;
63
64    /// Address related metrics. Exclusively served by the indexer.
65    #[method(name = "getAllEpochAddressMetrics")]
66    async fn get_all_epoch_address_metrics(
67        &self,
68        descending_order: Option<bool>,
69    ) -> RpcResult<Vec<AddressMetrics>>;
70
71    /// Return the total number of transactions. Exclusively served by the
72    /// indexer.
73    #[method(name = "getTotalTransactions")]
74    async fn get_total_transactions(&self) -> RpcResult<BigInt<u64>>;
75
76    /// Returns the participation metrics. Participation is defined as the total
77    /// number of unique addresses that have delegated stake in the current
78    /// epoch. Includes both staked and timelocked staked IOTA.
79    /// Exclusively served by the indexer.
80    #[method(name = "getParticipationMetrics")]
81    async fn get_participation_metrics(&self) -> RpcResult<ParticipationMetrics>;
82}