From 4553f5be08d0246c461040ca03e7de6ed9a36c01 Mon Sep 17 00:00:00 2001
From: SrikanthSoparla
Date: Sat, 7 Dec 2024 16:38:31 +0530
Subject: [PATCH] active validator set updates.
---
src/actions/stake.js | 17 +++--
src/constants/url.js | 4 +-
.../ClaimDelegateValidatorSelectField.js | 10 +--
.../Home/ClaimDialog/ValidatorsSelectField.js | 10 +--
src/containers/NavBar/index.js | 10 +--
.../MultiValidatorSelectField.js | 10 +--
.../Stake/DelegateDialog/SuccessDialog.js | 10 +--
.../DelegateDialog/ToValidatorSelectField.js | 10 +--
.../DelegateDialog/ValidatorSelectField.js | 10 +--
src/containers/Stake/Table.js | 65 +++++++------------
src/containers/Stake/ValidatorName.js | 2 +-
src/containers/Stake/index.js | 16 ++---
src/helper.js | 1 -
13 files changed, 56 insertions(+), 119 deletions(-)
diff --git a/src/actions/stake.js b/src/actions/stake.js
index b5dfe09..ff721f7 100644
--- a/src/actions/stake.js
+++ b/src/actions/stake.js
@@ -430,13 +430,16 @@ export const getInActiveValidators = (cb) => (dispatch) => {
Connection: 'keep-alive',
},
});
- const unBondingResult = await Axios.get(INACTIVE_VALIDATORS_UNBONDING_URL, {
- headers: {
- Accept: 'application/json, text/plain, */*',
- Connection: 'keep-alive',
- },
- });
- const updatedResult = [...result.data && result.data.result, ...unBondingResult.data && unBondingResult.data.result];
+ // const unBondingResult = await Axios.get(INACTIVE_VALIDATORS_UNBONDING_URL, {
+ // headers: {
+ // Accept: 'application/json, text/plain, */*',
+ // Connection: 'keep-alive',
+ // },
+ // });
+ const updatedResult = [
+ ...result.data,
+ // ...unBondingResult.data && unBondingResult.data.result
+ ];
dispatch(fetchInActiveValidatorsSuccess(updatedResult));
cb(updatedResult);
} catch (error) {
diff --git a/src/constants/url.js b/src/constants/url.js
index d3da034..50f47c8 100644
--- a/src/constants/url.js
+++ b/src/constants/url.js
@@ -12,9 +12,9 @@ export const urlFetchRewards = (address) => `${REST_URL}/api/v1/pos/reward/${add
export const urlFetchVoteDetails = (proposalId, address) => `${REST_URL}/cosmos/gov/v1beta1/proposals/${proposalId}/votes/${address}`;
export const urlFetchRevealedPubkey = (address) => `${REST_URL}/api/v1/revealed-public-key/${address}`;
-export const VALIDATORS_LIST_URL = () => `${REST_URL}/api/v1/pos/validator/all`;
+export const VALIDATORS_LIST_URL = () => `${REST_URL}/api/v1/pos/validator/all?state=consensus`;
export const GENESIS_VALIDATORS_LIST_URL = 'https://namada.info/shielded-expedition.88f17d1d14/output/genesis_tm_address_to_alias.json';
-export const INACTIVE_VALIDATORS_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000&status=BOND_STATUS_UNBONDED`;
+export const INACTIVE_VALIDATORS_URL = `${REST_URL}/api/v1/pos/validator/all?state=belowCapacity&state=belowThreshold&state=inactive&state=jailed&state=unknown`;
export const INACTIVE_VALIDATORS_UNBONDING_URL = `${REST_URL}/cosmos/staking/v1beta1/validators?pagination.limit=1000&status=BOND_STATUS_UNBONDING`;
export const getValidatorURL = (address) => `${REST_URL}/cosmos/staking/v1beta1/validators/${address}`;
export const PROPOSALS_LIST_URL = `${REST_URL}/cosmos/gov/v1/proposals?pagination.limit=1000`;
diff --git a/src/containers/Home/ClaimDialog/ClaimDelegateValidatorSelectField.js b/src/containers/Home/ClaimDialog/ClaimDelegateValidatorSelectField.js
index bbc0a31..c239e6e 100644
--- a/src/containers/Home/ClaimDialog/ClaimDelegateValidatorSelectField.js
+++ b/src/containers/Home/ClaimDialog/ClaimDelegateValidatorSelectField.js
@@ -108,15 +108,7 @@ ClaimDelegateValidatorSelectField.propTypes = {
onChange: PropTypes.func.isRequired,
inProgress: PropTypes.bool,
items: PropTypes.array,
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/Home/ClaimDialog/ValidatorsSelectField.js b/src/containers/Home/ClaimDialog/ValidatorsSelectField.js
index ccbd610..ebb5fa1 100644
--- a/src/containers/Home/ClaimDialog/ValidatorsSelectField.js
+++ b/src/containers/Home/ClaimDialog/ValidatorsSelectField.js
@@ -90,15 +90,7 @@ ValidatorSelectField.propTypes = {
onChange: PropTypes.func.isRequired,
inProgress: PropTypes.bool,
items: PropTypes.array,
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/NavBar/index.js b/src/containers/NavBar/index.js
index 0db6bc1..bbfb991 100644
--- a/src/containers/NavBar/index.js
+++ b/src/containers/NavBar/index.js
@@ -139,12 +139,12 @@ class NavBar extends Component {
// this.props.fetchAPR();
// }
- // if (!this.props.inActiveValidatorsList.length && !this.props.inActiveValidatorsInProgress && !this.props.proposalTab) {
+ // if (this.props.inActiveValidatorsList && !this.props.inActiveValidatorsList.length && !this.props.inActiveValidatorsInProgress && !this.props.proposalTab) {
// this.props.getInActiveValidators((data) => {
- // if (data && data.length) {
- // const array = data.filter((val) => val && val.description && val.description.identity);
- // this.getValidatorImage(0, array);
- // }
+ // // if (data && data.length) {
+ // // const array = data.filter((val) => val && val.description && val.description.identity);
+ // // this.getValidatorImage(0, array);
+ // // }
// });
// }
diff --git a/src/containers/Stake/DelegateDialog/MultiValidatorSelectField.js b/src/containers/Stake/DelegateDialog/MultiValidatorSelectField.js
index b65cb65..e26179f 100644
--- a/src/containers/Stake/DelegateDialog/MultiValidatorSelectField.js
+++ b/src/containers/Stake/DelegateDialog/MultiValidatorSelectField.js
@@ -107,15 +107,7 @@ MultiValidatorSelectField.propTypes = {
validatorImages: PropTypes.array.isRequired,
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/Stake/DelegateDialog/SuccessDialog.js b/src/containers/Stake/DelegateDialog/SuccessDialog.js
index 6306b45..aab3bda 100644
--- a/src/containers/Stake/DelegateDialog/SuccessDialog.js
+++ b/src/containers/Stake/DelegateDialog/SuccessDialog.js
@@ -264,15 +264,7 @@ SuccessDialog.propTypes = {
}).isRequired,
}),
tokens: PropTypes.any,
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js b/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js
index 5f8c361..4b1c5ef 100644
--- a/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js
+++ b/src/containers/Stake/DelegateDialog/ToValidatorSelectField.js
@@ -81,15 +81,7 @@ ToValidatorSelectField.propTypes = {
value: PropTypes.string.isRequired,
onChange: PropTypes.func.isRequired,
inProgress: PropTypes.bool,
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/Stake/DelegateDialog/ValidatorSelectField.js b/src/containers/Stake/DelegateDialog/ValidatorSelectField.js
index 5085ec6..76dccb7 100644
--- a/src/containers/Stake/DelegateDialog/ValidatorSelectField.js
+++ b/src/containers/Stake/DelegateDialog/ValidatorSelectField.js
@@ -139,15 +139,7 @@ ValidatorSelectField.propTypes = {
delegations: PropTypes.array,
dialogValidatorAddress: PropTypes.string,
inProgress: PropTypes.bool,
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/Stake/Table.js b/src/containers/Stake/Table.js
index 7ffd47c..1caf1ce 100644
--- a/src/containers/Stake/Table.js
+++ b/src/containers/Stake/Table.js
@@ -13,6 +13,7 @@ import { config } from '../../config';
import { Button } from '@material-ui/core';
import { showConnectDialog } from '../../actions/navBar';
import { randomNoRepeats } from 'utils/array';
+import classNames from 'classnames';
class Table extends Component {
render () {
@@ -59,23 +60,23 @@ class Table extends Component {
),
},
},
- // {
+ // {
// name: 'status',
// label: 'Status',
// options: {
// sort: false,
// customBodyRender: (value) => (
//
- // {value.status === 'BOND_STATUS_UNBONDED' ? 'jailed'
- // : value.status === 'BOND_STATUS_UNBONDING' ? 'unbonding'
- // : value.status === 'BOND_STATUS_BONDED' ? 'active'
- // : value.status === 'BOND_STATUS_UNSPECIFIED' ? 'invalid'
+ // {value.status === 'jailed' ? 'jailed'
+ // // : value.status === 'BOND_STATUS_UNBONDING' ? 'unbonding'
+ // : value.status === 'consensus' ? 'active'
+ // : value.status === 'inactive' ? 'invalid'
// : ''}
//
// ),
@@ -105,16 +106,16 @@ class Table extends Component {
// },
// },
// },
- // {
- // name: 'commission',
- // label: 'Commission',
- // options: {
- // sort: true,
- // customBodyRender: (value) => (
- // value ? value + '%' : '0%'
- // ),
- // },
- // },
+ {
+ name: 'commission',
+ label: 'Commission',
+ options: {
+ sort: true,
+ customBodyRender: (value) => (
+ value ? value + '%' : '0%'
+ ),
+ },
+ },
{
name: 'tokens_staked',
label: 'Tokens Staked',
@@ -229,11 +230,8 @@ class Table extends Component {
// item,
// parseFloat((Number(item.tokens) / (10 ** config.COIN_DECIMALS)).toFixed(1)),
parseFloat((Number(item.votingPower)).toFixed(1)),
- // item.commission && item.commission.commission_rates &&
- // item.commission.commission_rates.rate,
- // item.commission && item.commission.commission_rates &&
- // item.commission.commission_rates.rate
- // ? parseFloat((Number(item.commission.commission_rates.rate) * 100).toFixed(2)) : null,
+ item.commission
+ ? parseFloat((Number(item.commission) * 100).toFixed(2)) : null,
item,
item,
])
@@ -301,22 +299,7 @@ Table.propTypes = {
}),
}),
),
- validatorList: PropTypes.arrayOf(
- PropTypes.shape({
- operator_address: PropTypes.string,
- status: PropTypes.number,
- tokens: PropTypes.string,
- commission: PropTypes.shape({
- commission_rates: PropTypes.shape({
- rate: PropTypes.string,
- }),
- }),
- delegator_shares: PropTypes.string,
- description: PropTypes.shape({
- moniker: PropTypes.string,
- }),
- }),
- ),
+ validatorList: PropTypes.array,
};
const stateToProps = (state) => {
diff --git a/src/containers/Stake/ValidatorName.js b/src/containers/Stake/ValidatorName.js
index 80ed303..4c43caa 100644
--- a/src/containers/Stake/ValidatorName.js
+++ b/src/containers/Stake/ValidatorName.js
@@ -46,10 +46,10 @@ const ValidatorName = (props) => {
ValidatorName.propTypes = {
genesisValidatorList: PropTypes.object.isRequired,
- name: PropTypes.string.isRequired,
validatorImages: PropTypes.array.isRequired,
value: PropTypes.object.isRequired,
index: PropTypes.number,
+ name: PropTypes.string,
};
const stateToProps = (state) => {
diff --git a/src/containers/Stake/index.js b/src/containers/Stake/index.js
index a9bf806..391d059 100644
--- a/src/containers/Stake/index.js
+++ b/src/containers/Stake/index.js
@@ -36,14 +36,14 @@ const Stake = (props) => {
: null}
- {/* handleChange(3)}> */}
- {/* {variables[props.lang]['inactive_validators']} */}
- {/* {props.inActiveValidators && */}
- {/* props.inActiveValidators.length */}
- {/* ? ' (' + props.inActiveValidators.length + ')' */}
- {/* : null} */}
- {/*
*/}
- {/* */}
+ {/* handleChange(3)}>
+ {variables[props.lang]['inactive_validators']}
+ {props.inActiveValidators &&
+ props.inActiveValidators.length
+ ? ' (' + props.inActiveValidators.length + ')'
+ : null}
+
+ */}
handleChange(2)}>
{variables[props.lang]['staked_validators']}
{props.delegatedValidatorList &&
diff --git a/src/helper.js b/src/helper.js
index fb01ca7..cfc6bac 100644
--- a/src/helper.js
+++ b/src/helper.js
@@ -367,7 +367,6 @@ export const delegateTransaction = (Tx, txs, revealPublicKey, type, cb) => {
client.sign(updateDate, Tx.source, checksums).then((signedBondTxBytes) => {
rpc.broadcastTx(signedBondTxBytes && signedBondTxBytes.length && signedBondTxBytes[0], wrapperProps).then((result) => {
- console.log('result', result);
if (result && result.code !== undefined && result.code !== 0 && result.code !== '0') {
cb(result.info || result.log || result.rawLog);
} else {