From bf3484d9555382665e837d0867a0c418da703ec0 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Fri, 30 Aug 2024 12:19:46 +0200 Subject: [PATCH] rpc: add query consensus validators --- crates/sdk/src/rpc.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index 55be2a7e65..6ccfb8a69d 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,