feat(governance): show multisig penalty in tooltip (#4140)

This commit is contained in:
Sam Keen 2023-06-22 09:43:46 +01:00 committed by GitHub
parent da66b7b20d
commit bb1b236cdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 9 deletions

View File

@ -30,7 +30,6 @@ const normalisedVotingPowerToolTip =
'[data-testid="normalised-voting-power-tooltip"]'; '[data-testid="normalised-voting-power-tooltip"]';
const performancePenaltyToolTip = '[data-testid="performance-penalty-tooltip"]'; const performancePenaltyToolTip = '[data-testid="performance-penalty-tooltip"]';
const overstakedPenaltyToolTip = '[data-testid="overstaked-penalty-tooltip"]'; const overstakedPenaltyToolTip = '[data-testid="overstaked-penalty-tooltip"]';
const totalPenaltyToolTip = '[data-testid="total-penalty-tooltip"]';
const epochCountDown = '[data-testid="epoch-countdown"]'; const epochCountDown = '[data-testid="epoch-countdown"]';
const stakeNumberRegex = /^\d{1,3}(,\d{3})*(\.\d+)?$/; const stakeNumberRegex = /^\d{1,3}(,\d{3})*(\.\d+)?$/;
@ -143,9 +142,6 @@ context('Validators Page - verify elements on page', function () {
cy.get(overstakedPenaltyToolTip) cy.get(overstakedPenaltyToolTip)
.invoke('text') .invoke('text')
.should('contain', 'Overstaked penalty: 60.00%'); // value not asserted due to #2886 .should('contain', 'Overstaked penalty: 60.00%'); // value not asserted due to #2886
cy.get(totalPenaltyToolTip)
.invoke('text')
.should('contain', 'Total penalties: 60.00%');
}); });
it('Should be able to see validator pending stake', function () { it('Should be able to see validator pending stake', function () {

View File

@ -786,6 +786,7 @@
"performancePenalty": "Performance penalty", "performancePenalty": "Performance penalty",
"overstaked": "Overstaked", "overstaked": "Overstaked",
"overstakedPenalty": "Overstaked penalty", "overstakedPenalty": "Overstaked penalty",
"multisigPenalty": "Multisig penalty",
"homeProposalsIntro": "Decisions on the Vega network are on-chain, with tokenholders creating proposals that other tokenholders vote to approve or reject. Network upgrades are proposed and approved by validators.", "homeProposalsIntro": "Decisions on the Vega network are on-chain, with tokenholders creating proposals that other tokenholders vote to approve or reject. Network upgrades are proposed and approved by validators.",
"homeProposalsButtonText": "Browse, vote, and propose", "homeProposalsButtonText": "Browse, vote, and propose",
"homeValidatorsIntro": "Vega runs on a delegated proof of stake blockchain, where validators earn fees for validating block transactions. Tokenholders can nominate validators by staking tokens to them.", "homeValidatorsIntro": "Vega runs on a delegated proof of stake blockchain, where validators earn fees for validating block transactions. Tokenholders can nominate validators by staking tokens to them.",

View File

@ -36,6 +36,7 @@ import {
toBigNum, toBigNum,
} from '@vegaprotocol/utils'; } from '@vegaprotocol/utils';
import { VALIDATOR_LOGO_MAP } from './logo-map'; import { VALIDATOR_LOGO_MAP } from './logo-map';
import { getMultisigStatusInfo } from '../../../../lib/get-multisig-status-info';
interface CanonisedConsensusNodeProps { interface CanonisedConsensusNodeProps {
id: string; id: string;
@ -137,6 +138,10 @@ export const ConsensusValidatorsTable = ({
[totalStake] [totalStake]
); );
const multisigStatus = previousEpochData
? getMultisigStatusInfo(previousEpochData)
: undefined;
const allNodesInPreviousEpoch = removePaginationWrapper( const allNodesInPreviousEpoch = removePaginationWrapper(
previousEpochData?.epoch.validatorsConnection?.edges previousEpochData?.epoch.validatorsConnection?.edges
); );
@ -223,6 +228,8 @@ export const ConsensusValidatorsTable = ({
[ValidatorFields.USER_STAKE_SHARE]: userStakeShare [ValidatorFields.USER_STAKE_SHARE]: userStakeShare
? formatNumberPercentage(new BigNumber(userStakeShare), 2) ? formatNumberPercentage(new BigNumber(userStakeShare), 2)
: undefined, : undefined,
[ValidatorFields.MULTISIG_ERROR]:
multisigStatus?.showMultisigStatusError,
}; };
} }
); );
@ -332,6 +339,7 @@ export const ConsensusValidatorsTable = ({
data, data,
decimals, decimals,
hideTopThird, hideTopThird,
multisigStatus?.showMultisigStatusError,
previousEpochData, previousEpochData,
thirdOfTotalStake, thirdOfTotalStake,
validatorsView, validatorsView,

View File

@ -39,6 +39,7 @@ export enum ValidatorFields {
STAKED_BY_USER = 'stakedByUser', STAKED_BY_USER = 'stakedByUser',
PENDING_USER_STAKE = 'pendingUserStake', PENDING_USER_STAKE = 'pendingUserStake',
USER_STAKE_SHARE = 'userStakeShare', USER_STAKE_SHARE = 'userStakeShare',
MULTISIG_ERROR = 'multisigError',
} }
export const addUserDataToValidator = ( export const addUserDataToValidator = (
@ -326,6 +327,7 @@ interface TotalPenaltiesRendererProps {
overstakedAmount: string; overstakedAmount: string;
overstakingPenalty: string; overstakingPenalty: string;
totalPenalties: string; totalPenalties: string;
multisigError?: boolean;
}; };
} }
@ -344,10 +346,11 @@ export const TotalPenaltiesRenderer = ({
<div data-testid="overstaked-penalty-tooltip"> <div data-testid="overstaked-penalty-tooltip">
{t('overstakedPenalty')}: {data.overstakingPenalty} {t('overstakedPenalty')}: {data.overstakingPenalty}
</div> </div>
<div data-testid="total-penalty-tooltip"> {data.multisigError && (
{t('totalPenalties')}:{' '} <div data-testid="multisig-error-tooltip">
<span className="font-bold">{data.totalPenalties}</span> {t('multisigPenalty')}: 100%
</div> </div>
)}
</> </>
} }
> >

View File

@ -10,7 +10,7 @@ import {
import type { ITooltipParams } from 'ag-grid-community'; import type { ITooltipParams } from 'ag-grid-community';
const tooltipContentClasses = const tooltipContentClasses =
'max-w-sm bg-vega-light-100 dark:bg-vega-dark-100 border border-vega-light-200 dark:border-vega-dark-200 px-2 py-1 z-20 rounded text-xs break-word'; 'max-w-sm bg-vega-light-100 dark:bg-vega-dark-100 border border-vega-light-200 dark:border-vega-dark-200 px-2 py-1 z-20 rounded text-xs text-black dark:text-white break-word';
export interface TooltipProps { export interface TooltipProps {
children: React.ReactElement; children: React.ReactElement;
description?: string | ReactNode; description?: string | ReactNode;