Skip to content

Commit

Permalink
active validator set updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Dec 7, 2024
1 parent eec42b6 commit 4553f5b
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 119 deletions.
17 changes: 10 additions & 7 deletions src/actions/stake.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/constants/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 1 addition & 9 deletions src/containers/Home/ClaimDialog/ValidatorsSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 5 additions & 5 deletions src/containers/NavBar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
// // }
// });
// }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 1 addition & 9 deletions src/containers/Stake/DelegateDialog/SuccessDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 1 addition & 9 deletions src/containers/Stake/DelegateDialog/ToValidatorSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
10 changes: 1 addition & 9 deletions src/containers/Stake/DelegateDialog/ValidatorSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
65 changes: 24 additions & 41 deletions src/containers/Stake/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down Expand Up @@ -59,23 +60,23 @@ class Table extends Component {
),
},
},
// {
// {
// name: 'status',
// label: 'Status',
// options: {
// sort: false,
// customBodyRender: (value) => (
// <div
// className={classNames('status', (value.jailed || value.status === 'BOND_STATUS_UNBONDED') ? 'red_status' : '')}
// title={value.status === 'BOND_STATUS_UNBONDED' ? 'jailed'
// : value.status === 'BOND_STATUS_UNBONDING' ? 'unbonding'
// : value.status === 'BOND_STATUS_BONDED' ? 'active'
// : value.status === 'BOND_STATUS_UNSPECIFIED' ? 'invalid'
// className={classNames('status', (value.status === 'inactive' || value.status === 'jailed') ? 'red_status' : '')}
// title={value.status === 'jailed' ? 'jailed'
// // : value.status === 'BOND_STATUS_UNBONDING' ? 'unbonding'
// : value.status === 'consensus' ? 'active'
// : value.status === 'inactive' ? 'invalid'
// : ''}>
// {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'
// : ''}
// </div>
// ),
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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,
])
Expand Down Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Stake/ValidatorName.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
16 changes: 8 additions & 8 deletions src/containers/Stake/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ const Stake = (props) => {
: null}
</p>
<span/>
{/* <p className={active === 3 ? 'active' : ''} onClick={() => handleChange(3)}> */}
{/* {variables[props.lang]['inactive_validators']} */}
{/* {props.inActiveValidators && */}
{/* props.inActiveValidators.length */}
{/* ? ' (' + props.inActiveValidators.length + ')' */}
{/* : null} */}
{/* </p> */}
{/* <span/> */}
{/* <p className={active === 3 ? 'active' : ''} onClick={() => handleChange(3)}>
{variables[props.lang]['inactive_validators']}
{props.inActiveValidators &&
props.inActiveValidators.length
? ' (' + props.inActiveValidators.length + ')'
: null}
</p>
<span/> */}
<p className={active === 2 ? 'active' : ''} onClick={() => handleChange(2)}>
{variables[props.lang]['staked_validators']}
{props.delegatedValidatorList &&
Expand Down
1 change: 0 additions & 1 deletion src/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 4553f5b

Please sign in to comment.