From 80c5ea31c0615eef6aa190b484bd022b9d703c1f Mon Sep 17 00:00:00 2001 From: Hemanth Sai Date: Mon, 3 Jun 2024 21:46:15 +0530 Subject: [PATCH] chore: update validator profile for vitwit validator (#1260) * chore: update validator profile for vitwit validator * chore: review changes --- .../staking/components/StakingCard.tsx | 2 +- .../[validator]/ValidatorProfile.tsx | 50 +++++++++++-------- .../(routes)/validator/[validator]/page.tsx | 13 +++-- .../src/custom-hooks/useGetValidatorInfo.ts | 26 ++++++---- frontend/src/utils/constants.ts | 7 +++ 5 files changed, 60 insertions(+), 38 deletions(-) diff --git a/frontend/src/app/(routes)/staking/components/StakingCard.tsx b/frontend/src/app/(routes)/staking/components/StakingCard.tsx index d1886b39d..1df1db667 100644 --- a/frontend/src/app/(routes)/staking/components/StakingCard.tsx +++ b/frontend/src/app/(routes)/staking/components/StakingCard.tsx @@ -121,7 +121,7 @@ export const StakingCardHeader = ({ networkLogo, }: StakingCardHeaderProps) => { const validatorProfileURL = validator - ? `/staking/validator/${encodeURIComponent(validator?.toLowerCase())}` + ? `/validator/${encodeURIComponent(validator?.toLowerCase())}` : ''; return (
diff --git a/frontend/src/app/(routes)/validator/[validator]/ValidatorProfile.tsx b/frontend/src/app/(routes)/validator/[validator]/ValidatorProfile.tsx index 35205179b..11e7b4521 100644 --- a/frontend/src/app/(routes)/validator/[validator]/ValidatorProfile.tsx +++ b/frontend/src/app/(routes)/validator/[validator]/ValidatorProfile.tsx @@ -10,17 +10,18 @@ import useGetValidatorInfo from '@/custom-hooks/useGetValidatorInfo'; import { capitalizeFirstLetter, formatValidatorStatsValue } from '@/utils/util'; import ValidatorLogo from '../../staking/components/ValidatorLogo'; import { Tooltip } from '@mui/material'; -import { WITVAL } from '@/utils/constants'; +import { VITWIT_VALIDATOR_NAMES, WITVAL } from '@/utils/constants'; const ValidatorProfile = ({ moniker }: { moniker: string }) => { const tabs = ['Profile', 'Announcements', 'Inbox', 'Notices']; const selectedTab = 'profile'; useInitAllValidator(); - const { getChainwiseValidatorInfo, + const { + getChainwiseValidatorInfo, getOasisValidatorInfo, getPolygonValidatorInfo, - getValidatorStats } = - useGetValidatorInfo(); + getValidatorStats, + } = useGetValidatorInfo(); const { chainWiseValidatorData, validatorDescription, @@ -33,20 +34,23 @@ const ValidatorProfile = ({ moniker }: { moniker: string }) => { moniker: moniker, }); - const { avgCommission, - activeNetworks, - totalNetworks } = validatorStatsResult; + const { avgCommission, activeNetworks, totalNetworks } = validatorStatsResult; - let { totalDelegators, - totalStaked, } = validatorStatsResult + let { totalDelegators, totalStaked } = validatorStatsResult; - const { totalStakedInUSD: totalPolygonStaked, totalDelegators: totalPolygonDelegators } = getPolygonValidatorInfo() - const { totalStakedInUSD: totalOasisStaked, totalDelegators: totalOasisDelegator } = getOasisValidatorInfo() + const { + totalStakedInUSD: totalPolygonStaked, + totalDelegators: totalPolygonDelegators, + } = getPolygonValidatorInfo(); + const { + totalStakedInUSD: totalOasisStaked, + totalDelegators: totalOasisDelegator, + } = getOasisValidatorInfo(); - totalStaked += totalPolygonStaked || 0 - totalStaked += totalOasisStaked || 0 - totalDelegators += totalPolygonDelegators - totalDelegators += totalOasisDelegator + totalStaked += totalPolygonStaked || 0; + totalStaked += totalOasisStaked || 0; + totalDelegators += totalPolygonDelegators; + totalDelegators += totalOasisDelegator; return (
@@ -100,7 +104,7 @@ const ValidatorProfile = ({ moniker }: { moniker: string }) => {
@@ -120,22 +124,24 @@ const ValidatorMetadataCard = ({ website: string; moniker: string; }) => { + const isWitval = moniker.toLowerCase() === WITVAL; + return (
- { - moniker.toLowerCase() === WITVAL ? 'VITWIT' : capitalizeFirstLetter(moniker) - } + {isWitval ? 'VITWIT' : capitalizeFirstLetter(moniker)}
Description
-
{ - moniker.toLowerCase() === WITVAL ? - 'Vitwit excels in providing top-notch infrastructure services for the Cosmos blockchain ecosystem. We specialize in setting up and managing validators, relayers, and offering expert advisory services.' : description || '-'}
+
+ {isWitval + ? 'Vitwit excels in providing top-notch infrastructure services for the Cosmos blockchain ecosystem. We specialize in setting up and managing validators, relayers, and offering expert advisory services.' + : description || '-'} +
{website ? (
diff --git a/frontend/src/app/(routes)/validator/[validator]/page.tsx b/frontend/src/app/(routes)/validator/[validator]/page.tsx index 3232dbe01..e310238ca 100644 --- a/frontend/src/app/(routes)/validator/[validator]/page.tsx +++ b/frontend/src/app/(routes)/validator/[validator]/page.tsx @@ -2,14 +2,17 @@ import React from 'react'; import ValidatorProfile from './ValidatorProfile'; import '../validator-profile.css'; import '../../staking/staking.css'; -import { VITWIT, WITVAL } from '@/utils/constants'; +import { VITWIT_NEW_MONIKER, VITWIT_VALIDATOR_NAMES } from '@/utils/constants'; const page = ({ params }: { params: { validator: string } }) => { const decodedMonikerName = decodeURIComponent(params.validator); - const monikerName = - decodedMonikerName.toLowerCase() === VITWIT - ? WITVAL - : decodedMonikerName.toLocaleLowerCase(); + // If the moniker name is vitwit or vitwit (previously witval) or witval use new moniker name + const isVitwitValidator = VITWIT_VALIDATOR_NAMES.includes( + decodedMonikerName.toLowerCase() + ); + const monikerName = isVitwitValidator + ? decodeURIComponent(VITWIT_NEW_MONIKER) + : decodedMonikerName.toLocaleLowerCase(); return ; }; diff --git a/frontend/src/custom-hooks/useGetValidatorInfo.ts b/frontend/src/custom-hooks/useGetValidatorInfo.ts index b64948f90..4392127cb 100644 --- a/frontend/src/custom-hooks/useGetValidatorInfo.ts +++ b/frontend/src/custom-hooks/useGetValidatorInfo.ts @@ -4,9 +4,14 @@ import { ValidatorProfileInfo } from '@/types/staking'; import { getValidatorRank } from '@/utils/util'; import { parseBalance } from '@/utils/denom'; import useGetAllChainsInfo from './useGetAllChainsInfo'; -import { COIN_GECKO_IDS, OASIS_CONFIG, POLYGON_CONFIG, WITVAL } from '@/utils/constants'; +import { + COIN_GECKO_IDS, + OASIS_CONFIG, + POLYGON_CONFIG, + WITVAL, +} from '@/utils/constants'; -const removedChains = ['crescent-1', 'archway-1', 'celestia'] +const removedChains = ['crescent-1', 'archway-1', 'celestia']; const useGetValidatorInfo = () => { const stakingData = useAppSelector( @@ -16,10 +21,9 @@ const useGetValidatorInfo = () => { (state: RootState) => state.common.allNetworksInfo ); - const allChainIds = Object.keys(allNetworksInfo); - const chainIDs = allChainIds.filter(c => !removedChains.includes(c)) + const chainIDs = allChainIds.filter((c) => !removedChains.includes(c)); const tokensPriceInfo = useAppSelector( (state) => state.common.allTokensInfoState.info @@ -43,10 +47,12 @@ const useGetValidatorInfo = () => { const validator = Object.values( stakingData?.[chainID]?.validators.active ).find((v) => { - return ( + // For few networks supported by Vitwit Validator, Moniker name is still Witval, so considering that validator also + const isMatchingMoniker = v.description.moniker.trim().toLowerCase() === - moniker.trim().toLowerCase() - ); + moniker.trim().toLowerCase(); + const isWitval = v.description.moniker.trim().toLowerCase() === WITVAL; + return isMatchingMoniker || isWitval; }); if (validator) { @@ -173,7 +179,7 @@ const useGetValidatorInfo = () => { } const delegatorsCount = stakingData[validator.chainID].validatorProfiles?.[ - validator.operatorAddress + validator.operatorAddress ]; totalDelegators += Number(delegatorsCount?.totalDelegators || 0); @@ -284,8 +290,8 @@ const useGetValidatorInfo = () => { totalDelegators = oasisDelegations?.data?.totalSize; operatorAddress = OASIS_CONFIG.witval.operatorAddress; } else { - totalDelegators = 8 - totalStakedTokens = 11641594 + totalDelegators = 8; + totalStakedTokens = 11641594; commission = OASIS_CONFIG.witval.commission.toString(); totalStakedInUSD = usdPriceInfo diff --git a/frontend/src/utils/constants.ts b/frontend/src/utils/constants.ts index d1bc5c0ba..c92291f63 100644 --- a/frontend/src/utils/constants.ts +++ b/frontend/src/utils/constants.ts @@ -269,6 +269,13 @@ export const ALERT_TYPE_MAP: Record = { }; export const WITVAL = 'witval'; export const VITWIT = 'vitwit'; +export const VITWIT_NEW_MONIKER = 'vitwit%20(previously%20witval)'; +export const VITWIT_VALIDATOR_NAMES = [ + 'vitwit', + 'witval', + 'validator/vitwit%20(previously%20witval)', + 'vitwit (previously witval)', +]; export const POLYGON_API = 'https://staking-api.polygon.technology/api/v2'; export const POLYGON_CONFIG = {