Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rpc: add query consensus validators #3734

Merged
merged 3 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Add an RPC endpoint for the consensus validator set in the SDK.
([\#3734](https://github.com/anoma/namada/pull/3734))
14 changes: 14 additions & 0 deletions crates/sdk/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -740,6 +741,19 @@ pub async fn get_all_validators<C: namada_io::Client + Sync>(
)
}

/// Get all consensus validators in the given epoch
pub async fn get_all_consensus_validators<C: namada_io::Client + Sync>(
client: &C,
epoch: Epoch,
) -> Result<BTreeSet<WeightedValidator>, error::Error> {
convert_response::<C, _>(
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<C: namada_io::Client + Sync>(
client: &C,
Expand Down
Loading