diff --git a/crates/sui-graphql-rpc/schema/current_progress_schema.graphql b/crates/sui-graphql-rpc/schema/current_progress_schema.graphql index 53231289fb429..6224a32e3be5c 100644 --- a/crates/sui-graphql-rpc/schema/current_progress_schema.graphql +++ b/crates/sui-graphql-rpc/schema/current_progress_schema.graphql @@ -3979,12 +3979,22 @@ type Validator { The validator's current staking pool object, used to track the amount of stake and to compound staking rewards. """ - stakingPool: MoveObject + stakingPool: MoveObject @deprecated(reason: "The staking pool is a wrapped object. Access its fields directly on the `Validator` type.") + """ + The ID of this validator's `0x3::staking_pool::StakingPool`. + """ + stakingPoolId: SuiAddress! """ The validator's current exchange object. The exchange rate is used to determine the amount of SUI tokens that each past SUI staker can withdraw in the future. """ - exchangeRates: MoveObject + exchangeRates: MoveObject @deprecated(reason: "The exchange object is a wrapped object. Access its dynamic fields through the `exchangeRatesTable` query.") + """ + A wrapped object containing the validator's exchange rates. This is a table from epoch + number to `PoolTokenExchangeRate` value. The exchange rate is used to determine the amount + of SUI tokens that each past SUI staker can withdraw in the future. + """ + exchangeRatesTable: Owner """ Number of exchange rates in the table. """ diff --git a/crates/sui-graphql-rpc/src/types/validator.rs b/crates/sui-graphql-rpc/src/types/validator.rs index de01a9bb10bf2..d3b7584ae23c6 100644 --- a/crates/sui-graphql-rpc/src/types/validator.rs +++ b/crates/sui-graphql-rpc/src/types/validator.rs @@ -9,6 +9,7 @@ use async_graphql::connection::{Connection, CursorType, Edge}; use super::big_int::BigInt; use super::move_object::MoveObject; use super::object::Object; +use super::owner::Owner; use super::sui_address::SuiAddress; use super::validator_credentials::ValidatorCredentials; use super::{address::Address, base64::Base64}; @@ -106,26 +107,37 @@ impl Validator { /// The validator's current staking pool object, used to track the amount of stake /// and to compound staking rewards. - async fn staking_pool(&self, ctx: &Context<'_>) -> Result> { - MoveObject::query( - ctx, - self.staking_pool_id(), - Object::latest_at(self.checkpoint_viewed_at), - ) - .await - .extend() + #[graphql( + deprecation = "The staking pool is a wrapped object. Access its fields directly on the \ + `Validator` type." + )] + async fn staking_pool(&self) -> Result> { + Ok(None) + } + + /// The ID of this validator's `0x3::staking_pool::StakingPool`. + async fn staking_pool_id(&self) -> SuiAddress { + self.validator_summary.staking_pool_id.into() } /// The validator's current exchange object. The exchange rate is used to determine /// the amount of SUI tokens that each past SUI staker can withdraw in the future. - async fn exchange_rates(&self, ctx: &Context<'_>) -> Result> { - MoveObject::query( - ctx, - self.exchange_rates_id(), - Object::latest_at(self.checkpoint_viewed_at), - ) - .await - .extend() + #[graphql( + deprecation = "The exchange object is a wrapped object. Access its dynamic fields through \ + the `exchangeRatesTable` query." + )] + async fn exchange_rates(&self) -> Result> { + Ok(None) + } + + /// A wrapped object containing the validator's exchange rates. This is a table from epoch + /// number to `PoolTokenExchangeRate` value. The exchange rate is used to determine the amount + /// of SUI tokens that each past SUI staker can withdraw in the future. + async fn exchange_rates_table(&self) -> Result> { + Ok(Some(Owner { + address: self.validator_summary.exchange_rates_id.into(), + checkpoint_viewed_at: self.checkpoint_viewed_at, + })) } /// Number of exchange rates in the table. @@ -266,10 +278,4 @@ impl Validator { pub fn operation_cap_id(&self) -> SuiAddress { SuiAddress::from_array(**self.validator_summary.operation_cap_id) } - pub fn staking_pool_id(&self) -> SuiAddress { - SuiAddress::from_array(**self.validator_summary.staking_pool_id) - } - pub fn exchange_rates_id(&self) -> SuiAddress { - SuiAddress::from_array(**self.validator_summary.exchange_rates_id) - } } diff --git a/crates/sui-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap b/crates/sui-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap index 754aca78c4968..a799576a36a86 100644 --- a/crates/sui-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap +++ b/crates/sui-graphql-rpc/tests/snapshots/snapshot_tests__schema_sdl_export.snap @@ -3983,12 +3983,22 @@ type Validator { The validator's current staking pool object, used to track the amount of stake and to compound staking rewards. """ - stakingPool: MoveObject + stakingPool: MoveObject @deprecated(reason: "The staking pool is a wrapped object. Access its fields directly on the `Validator` type.") + """ + The ID of this validator's `0x3::staking_pool::StakingPool`. + """ + stakingPoolId: SuiAddress! """ The validator's current exchange object. The exchange rate is used to determine the amount of SUI tokens that each past SUI staker can withdraw in the future. """ - exchangeRates: MoveObject + exchangeRates: MoveObject @deprecated(reason: "The exchange object is a wrapped object. Access its dynamic fields through the `exchangeRatesTable` query.") + """ + A wrapped object containing the validator's exchange rates. This is a table from epoch + number to `PoolTokenExchangeRate` value. The exchange rate is used to determine the amount + of SUI tokens that each past SUI staker can withdraw in the future. + """ + exchangeRatesTable: Owner """ Number of exchange rates in the table. """