Skip to content

Commit

Permalink
Chary/validator p fix (#1200)
Browse files Browse the repository at this point in the history
* fix witval validator issue

* fix validator issues
  • Loading branch information
charymalloju authored Mar 18, 2024
1 parent df5f692 commit e32ab66
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const ValidatorProfile = ({ moniker }: { moniker: string }) => {
useInitAllValidator();
const { getChainwiseValidatorInfo,
getOasisValidatorInfo,
getPolygonValidatorInfo, getValidatorStats } =
getPolygonValidatorInfo,
getValidatorStats } =
useGetValidatorInfo();
const {
chainWiseValidatorData,
Expand Down Expand Up @@ -48,7 +49,7 @@ const ValidatorProfile = ({ moniker }: { moniker: string }) => {
totalDelegators += totalOasisDelegator

return (
<div className="py-6 px-10 space-y-10 h-screen flex flex-col">
<div className="py-6 px-10 space-y-10 h-screen flex flex-col text-[#E1E1E1]">
<div className="space-y-10">
<div className="flex justify-between">
<h2 className="text-[20px] leading-normal font-normal">
Expand Down Expand Up @@ -215,11 +216,11 @@ const StatsCard = ({ name, value }: { name: string; value: string }) => {
draggable={false}
/>
</div>
<div className="text-sm text-white font-extralight leading-normal">
<div className="text-sm text-[#E1E1E1] font-extralight leading-normal">
{name}
</div>
</div>
<div className="px-2 pl-[10px] text-lg font-bold leading-normal text-white">
<div className="px-2 pl-[10px] text-lg font-bold leading-normal text-[#E1E1E1]">
{value}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';
const TableHeader = ({ title }: { title: string }) => {
return (
<th>
<div className="min-h-[17px] flex items-center text-sm not-italic font-normal leading-[normal]">
<div className="min-h-[17px] flex items-center text-sm not-italic font-normal leading-[normal] text-[#E1E1E1]">
{title}
</div>
</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const ValidatorItem = ({
};

return (
<tr>
<tr className='text-[#E1E1E1]'>
<td>
<NetworkItem
logo={chainLogo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,17 @@ const ValidatorsTable = ({
'Actions',
];

const sortedKeys = Object.keys(data).sort((a, b) => {
return parseInt(data[b].totalStakedInUSD) - parseInt(data[a].totalStakedInUSD);
});

const sortedObject: Record<string, ValidatorProfileInfo> = {};
sortedKeys.forEach(key => {
sortedObject[key] = data[key];
});

return (
<div className="flex flex-col flex-1 overflow-y-scroll">
<div className="flex flex-col flex-1 overflow-y-scroll text-[#E1E1E1]">
<div className="validators-table bg-[#1a1a1b] px-8 py-8">
<div className="flex flex-col flex-1">
<div className="flex-1">
Expand All @@ -41,20 +50,21 @@ const ValidatorsTable = ({
</tr>
</thead>
<tbody className="flex-1">
{Object.keys(data).map((chainID) => {
{isWitval ? (
<>
<NonCosmosValidators networkName={'polygon'} />
<NonCosmosValidators networkName={'oasis'} />
</>
) : null}
{Object.keys(sortedObject).map((chainID) => {
return (
<ValidatorItem
validatorInfo={data[chainID]}
key={chainID}
/>
);
})}
{isWitval ? (
<>
<NonCosmosValidators networkName={'polygon'} />
<NonCosmosValidators networkName={'oasis'} />
</>
) : null}

</tbody>
</table>
</div>
Expand Down Expand Up @@ -89,7 +99,7 @@ const NonCosmosValidators = ({ networkName }: { networkName: string }) => {
const connected = useAppSelector((state) => state.wallet.connected);

return (
<tr>
<tr className='text-[#E1E1E1]'>
<td>
<NetworkItem
logo={logo}
Expand Down
10 changes: 6 additions & 4 deletions frontend/src/custom-hooks/useGetValidatorInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ const useGetValidatorInfo = () => {
stakingData[validator.chainID].validatorProfiles?.[
validator.operatorAddress
];

totalDelegators += Number(delegatorsCount?.totalDelegators || 0);
totalCommission += Number(validator?.commission) || 0;
if (validator.validatorStatus === 'BOND_STATUS_BONDED') {
Expand All @@ -186,10 +187,11 @@ const useGetValidatorInfo = () => {
const {
commission,
totalDelegators: delegators,
totalStakedInUSD: totalStaked,
// totalStakedInUSD: totalStaked,
} = getPolygonValidatorInfo();
totalCommission += Number(commission || 0);
totalDelegators += totalStaked;
// totalDelegators += totalStaked;
// totalStaked+=totalS
totalDelegators += delegators;
activeNetworks += 1;
totalNetworks += 1;
Expand All @@ -199,10 +201,10 @@ const useGetValidatorInfo = () => {
const {
commission,
totalDelegators: delegators,
totalStakedInUSD: totalStaked,
// totalStakedInUSD: totalStaked,
} = getOasisValidatorInfo();
totalCommission += Number(commission || 0);
totalDelegators += totalStaked;
// totalDelegators += totalStaked;
totalDelegators += delegators;
activeNetworks += 1;
totalNetworks += 1;
Expand Down

0 comments on commit e32ab66

Please sign in to comment.