Skip to content

Commit

Permalink
multiple delegation handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
SrikanthSoparla committed Dec 4, 2024
1 parent 1b28792 commit 8c6aaff
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
8 changes: 3 additions & 5 deletions src/containers/Stake/DelegateDialog/ToValidatorSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ const ToValidatorSelectField = (props) => {
item.operator_address}
value={item.value || item.name || item.address || item.type ||
(item.operator_address)}>
{image && image.length && image[0] && image[0].them && image[0].them.length &&
image[0].them[0] && image[0].them[0].pictures && image[0].them[0].pictures.primary &&
image[0].them[0].pictures.primary.url
{item && item.avatar
? <img
alt={item.description && item.description.moniker}
alt={item.name || item.address}
className="image"
src={image[0].them[0].pictures.primary.url}/>
src={item.avatar}/>
: item.description && item.description.moniker
? <span
className="image"
Expand Down
10 changes: 7 additions & 3 deletions src/containers/Stake/DelegateDialog/TokensTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ const TokensTextField = (props) => {
// if (filterList && filterList.length && filterList[2]) {
// stakedTokens = Number(filterList[2]);
// }
const filterList = props.delegatedValidatorList.find((value) => value && value.validator && value.validator.address &&
const filterList = props.delegatedValidatorList.filter((value) => value && value.validator && value.validator.address &&
(props.selectedValidator === value.validator.address));
if (filterList && filterList.minDenomAmount && filterList.minDenomAmount) {
stakedTokens = filterList.minDenomAmount && Number(filterList.minDenomAmount) / 10 ** config.COIN_DECIMALS;
if (filterList && filterList.length) {
stakedTokens = 0;
filterList.map((value) => {
stakedTokens = stakedTokens + Number(value.minDenomAmount);
})
stakedTokens = stakedTokens && Number(stakedTokens) / 10 ** config.COIN_DECIMALS;
}
}

Expand Down
29 changes: 24 additions & 5 deletions src/containers/Stake/DelegateDialog/ValidatorSelectField.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,27 @@ const ValidatorSelectField = (props) => {
});
}
});
} else {
let newData = [];
if (validatorList && validatorList.length) {
validatorList.map((val) => {
if (val && val.name && val.name.toLowerCase() === 'cosmic validator') {
newData.splice(0, 0, val);
} else if (val && val.name && val.name.toLowerCase() === 'mandragora') {
const find = newData.find((val1) => val1 && val1.name && val1.name.toLowerCase() === 'cosmic validator');
if (!find) {
newData.splice(0, 0, val);
} else {
newData.splice(1, 0, val);
}
} else {
newData.push(val);
}
});
} else {
newData = dataToMap;
}
validatorList = newData;
}

return (
Expand Down Expand Up @@ -65,13 +86,11 @@ const ValidatorSelectField = (props) => {
item.address || item.operator_address}
value={item.address || item.name || item.type ||
(item.operator_address)}>
{image && image.length && image[0] && image[0].them && image[0].them.length &&
image[0].them[0] && image[0].them[0].pictures && image[0].them[0].pictures.primary &&
image[0].them[0].pictures.primary.url
{item && item.avatar
? <img
alt={item.description && item.description.moniker}
alt={item.name || item.address}
className="image"
src={image[0].them[0].pictures.primary.url}/>
src={item.avatar}/>
: item.description && item.description.moniker
? <span
className="image"
Expand Down
10 changes: 8 additions & 2 deletions src/containers/Stake/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ class Table extends Component {
if (value && value.validator && value.validator.address && item &&
(item.address === value.validator.address)) {
address = value.validator.address;
newValue = value.minDenomAmount && value.minDenomAmount / 10 ** config.COIN_DECIMALS;
if (newValue) {
newValue = (value.minDenomAmount && value.minDenomAmount / 10 ** config.COIN_DECIMALS) + newValue;
} else {
newValue = value.minDenomAmount && value.minDenomAmount / 10 ** config.COIN_DECIMALS;
}
}
});
// address && this.props.delegations && this.props.delegations.length &&
Expand Down Expand Up @@ -184,10 +188,12 @@ class Table extends Component {
// if (this.props.genesisValidatorList && this.props.genesisValidatorList[val.address]) {
// address = this.props.genesisValidatorList[val.address];
// }
let valid = true;
this.props.delegatedValidatorList && this.props.delegatedValidatorList.length &&
this.props.delegatedValidatorList.map((value) => {
if (value && value.validator && value.validator.address &&
(val.address === value.validator.address)) {
(val.address === value.validator.address) && valid) {
valid = false;
dataToMap.push(val);
}
});
Expand Down

0 comments on commit 8c6aaff

Please sign in to comment.