sui_graphql_client/query_types/epoch.rs
1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3//
4use super::PageInfo;
5use crate::query_types::schema;
6use crate::query_types::Address;
7use crate::query_types::BigInt;
8use crate::query_types::DateTime;
9use crate::query_types::ProtocolConfigs;
10
11// ===========================================================================
12// Epoch Queries
13// ===========================================================================
14#[derive(cynic::QueryFragment, Debug)]
15#[cynic(schema = "rpc", graphql_type = "Query", variables = "EpochArgs")]
16pub struct EpochQuery {
17 #[arguments(id: $id)]
18 pub epoch: Option<Epoch>,
19}
20
21#[derive(cynic::QueryFragment, Debug)]
22#[cynic(schema = "rpc", graphql_type = "Query", variables = "EpochsArgs")]
23pub struct EpochsQuery {
24 #[arguments(first: $first, after: $after, last: $last, before: $before)]
25 pub epochs: EpochConnection,
26}
27
28#[derive(cynic::QueryFragment, Debug)]
29#[cynic(schema = "rpc", graphql_type = "Query", variables = "EpochArgs")]
30pub struct EpochSummaryQuery {
31 #[arguments(id: $id)]
32 pub epoch: Option<EpochSummary>,
33}
34
35#[derive(cynic::QueryFragment, Debug)]
36#[cynic(schema = "rpc", graphql_type = "EpochConnection")]
37pub struct EpochConnection {
38 pub nodes: Vec<Epoch>,
39 pub page_info: PageInfo,
40}
41// ===========================================================================
42// Epoch Summary Args
43// ===========================================================================
44
45#[derive(cynic::QueryVariables, Debug)]
46pub struct EpochArgs {
47 pub id: Option<u64>,
48}
49
50#[derive(cynic::QueryVariables, Debug)]
51pub struct EpochsArgs<'a> {
52 pub first: Option<i32>,
53 pub after: Option<&'a str>,
54 pub last: Option<i32>,
55 pub before: Option<&'a str>,
56}
57
58/// A summary of the epoch.
59#[derive(cynic::QueryFragment, Debug)]
60#[cynic(schema = "rpc", graphql_type = "Epoch")]
61pub struct EpochSummary {
62 /// The epoch number.
63 pub epoch_id: u64,
64 /// The reference gas price throughout this epoch.
65 pub reference_gas_price: Option<BigInt>,
66 /// The total number of checkpoints in this epoch.
67 pub total_checkpoints: Option<u64>,
68 /// The total number of transactions in this epoch.
69 pub total_transactions: Option<u64>,
70}
71
72// ===========================================================================
73// Epoch Types
74// ===========================================================================
75
76#[derive(cynic::QueryFragment, Debug, Clone)]
77#[cynic(schema = "rpc", graphql_type = "Epoch")]
78pub struct Epoch {
79 /// The epoch's id as a sequence number that starts at 0 and is incremented by one at every epoch change.
80 pub epoch_id: u64,
81 /// The storage fees paid for transactions executed during the epoch.
82 pub fund_inflow: Option<BigInt>,
83 /// The storage fee rebates paid to users who deleted the data associated with past
84 /// transactions.
85 pub fund_outflow: Option<BigInt>,
86 /// The storage fund available in this epoch.
87 /// This fund is used to redistribute storage fees from past transactions
88 /// to future validators.
89 pub fund_size: Option<BigInt>,
90 /// A commitment by the committee at the end of epoch on the contents of the live object set at
91 /// that time. This can be used to verify state snapshots.
92 pub live_object_set_digest: Option<String>,
93 /// The difference between the fund inflow and outflow, representing
94 /// the net amount of storage fees accumulated in this epoch.
95 pub net_inflow: Option<BigInt>,
96 /// The epoch's corresponding protocol configuration, including the feature flags and the
97 /// configuration options.
98 pub protocol_configs: Option<ProtocolConfigs>,
99 /// The minimum gas price that a quorum of validators are guaranteed to sign a transaction for.
100 pub reference_gas_price: Option<BigInt>,
101 /// The epoch's starting timestamp.
102 pub start_timestamp: DateTime,
103 /// The epoch's ending timestamp. Note that this is available only on epochs that have ended.
104 pub end_timestamp: Option<DateTime>,
105 /// The value of the `version` field of `0x5`, the `0x3::sui::SuiSystemState` object. This
106 /// version changes whenever the fields contained in the system state object (held in a dynamic
107 /// field attached to `0x5`) change.
108 pub system_state_version: Option<u64>,
109 /// The total number of checkpoints in this epoch.
110 pub total_checkpoints: Option<u64>,
111 /// The total amount of gas fees (in MIST) that were paid in this epoch.
112 pub total_gas_fees: Option<BigInt>,
113 /// The total MIST rewarded as stake.
114 pub total_stake_rewards: Option<BigInt>,
115 /// The amount added to total gas fees to make up the total stake rewards.
116 pub total_stake_subsidies: Option<BigInt>,
117 /// The total number of transaction in this epoch.
118 pub total_transactions: Option<u64>,
119 /// Validator related properties. For active validators, see `active_validators` API.
120 pub validator_set: Option<ValidatorSet>,
121}
122
123#[derive(cynic::QueryFragment, Debug, Clone)]
124#[cynic(schema = "rpc", graphql_type = "ValidatorSet")]
125pub struct ValidatorSet {
126 /// Object ID of the `Table` storing the inactive staking pools.
127 pub inactive_pools_id: Option<Address>,
128 /// Size of the inactive pools `Table`.
129 pub inactive_pools_size: Option<i32>,
130 /// Object ID of the wrapped object `TableVec` storing the pending active validators.
131 pub pending_active_validators_id: Option<Address>,
132 /// Size of the pending active validators table.
133 pub pending_active_validators_size: Option<i32>,
134 /// Validators that are pending removal from the active validator set, expressed as indices in
135 /// to `activeValidators`.
136 pub pending_removals: Option<Vec<i32>>,
137 /// Object ID of the `Table` storing the mapping from staking pool ids to the addresses
138 /// of the corresponding validators. This is needed because a validator's address
139 /// can potentially change but the object ID of its pool will not.
140 pub staking_pool_mappings_id: Option<Address>,
141 /// Size of the stake pool mappings `Table`.
142 pub staking_pool_mappings_size: Option<i32>,
143 /// Total amount of stake for all active validators at the beginning of the epoch.
144 pub total_stake: Option<BigInt>,
145 /// Size of the validator candidates `Table`.
146 pub validator_candidates_size: Option<i32>,
147 /// Object ID of the `Table` storing the validator candidates.
148 pub validator_candidates_id: Option<Address>,
149}