From bf3484d9555382665e837d0867a0c418da703ec0 Mon Sep 17 00:00:00 2001 From: Gianmarco Fraccaroli Date: Fri, 30 Aug 2024 12:19:46 +0200 Subject: [PATCH 1/3] 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, From 08739d9dec4423984c1e4178e03097f117347714 Mon Sep 17 00:00:00 2001 From: brentstone Date: Fri, 6 Sep 2024 17:43:50 +0200 Subject: [PATCH 2/3] changelog: add #3734 --- .../unreleased/improvements/3734-query-active-validators.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/3734-query-active-validators.md 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 From c18b6cb113819002271b0b5c128b00f1fdcbddeb Mon Sep 17 00:00:00 2001 From: brentstone Date: Fri, 6 Sep 2024 18:23:01 +0200 Subject: [PATCH 3/3] fix import --- crates/sdk/src/rpc.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/sdk/src/rpc.rs b/crates/sdk/src/rpc.rs index 6ccfb8a69d..fe143e4757 100644 --- a/crates/sdk/src/rpc.rs +++ b/crates/sdk/src/rpc.rs @@ -742,7 +742,7 @@ pub async fn get_all_validators( } /// Get all consensus validators in the given epoch -pub async fn get_all_consensus_validators( +pub async fn get_all_consensus_validators( client: &C, epoch: Epoch, ) -> Result, error::Error> {