Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
get all validators, not just those in the active set
Browse files Browse the repository at this point in the history
  • Loading branch information
bitcoinwarrior1 committed Dec 17, 2022
1 parent de7b820 commit af1afe4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion util/ValidatorSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ class ValidatorSelector {
await this.setEraToCurrentIfZero();
const validatorDisplays = {}; // used to prevent adding in validators run by the same entity
const validatorsMeetingCriteria = [];
const validators = ValidatorSelector.shuffleArray((await this.api.query.session.validators()));
// https://substrate.stackexchange.com/questions/6356/get-all-validators-on-the-network-not-just-the-active-ones
const validatorData = await this.api.query.staking.validators.entries();
const allValidators = validatorData.map(([key]) => {
return key.args.map((k) => k.toHuman());
}).join(",").split(",").filter((e) => { return e !== undefined });
const validators = ValidatorSelector.shuffleArray(allValidators);
for(const validator of validators) {
if(validatorsMeetingCriteria.length === amount) {
return validatorsMeetingCriteria;
Expand Down
4 changes: 2 additions & 2 deletions web-sample/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -81221,12 +81221,12 @@ document.addEventListener("DOMContentLoaded", async () => {

function addRecommendedPool(pools) {
try {
const poolId = JSON.parse(pools.text).results[0].poolId;
const { poolId } = JSON.parse(pools.text).results[0];
document.getElementById("pools").innerHTML = `<div class="card">
<div class="container">
<p>Nomination pool of the day</p>
<p>click <a href="https://github.com/TalismanSociety/dot-pool-selector#criteria">here</a> for more info</p>
<p><a href="">Pool ${poolId}</a></p>
<p><a href="https://polkadot.js.org/apps/#/staking/pools">Pool ${poolId}</a></p>
</div>
</div>`;
} catch (e) {
Expand Down

0 comments on commit af1afe4

Please sign in to comment.