diff --git a/.changelog/unreleased/improvements/3734-query-active-validators.md b/.changelog/unreleased/improvements/3734-query-active-validators.md new file mode 100644 index 0000000000..e8e6e790fc --- /dev/null +++ b/.changelog/unreleased/improvements/3734-query-active-validators.md @@ -0,0 +1,2 @@ +- Add an RPC endpoint for the consensus validator set in the SDK. + ([\#3734](https://github.com/anoma/namada/pull/3734)) \ No newline at end of file diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index 55be2a7e65..fe143e4757 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -40,6 +40,7 @@ use namada_parameters::{storage as params_storage, EpochDuration}; use namada_proof_of_stake::parameters::PosParams; use namada_proof_of_stake::types::{ BondsAndUnbondsDetails, CommissionPair, ValidatorMetaData, + WeightedValidator, }; use namada_state::LastBlock; use namada_token::masp::MaspTokenRewardData; @@ -740,6 +741,19 @@ pub async fn get_all_validators( ) } +/// Get all consensus validators in the given epoch +pub async fn get_all_consensus_validators( + client: &C, + epoch: Epoch, +) -> Result, error::Error> { + convert_response::( + RPC.vp() + .pos() + .consensus_validator_set(client, &Some(epoch)) + .await, + ) +} + /// Get the total staked tokens in the given epoch pub async fn get_total_staked_tokens( client: &C,