From aac1823f4ba02ec60e3ddc8dad357ad90cde3f9d Mon Sep 17 00:00:00 2001 From: fabriziovigevani Date: Mon, 15 Mar 2021 19:26:56 -0300 Subject: [PATCH 1/3] Dispute actions info box: Consider cases where the round is appealed --- src/components/Disputes/DisputeActions.js | 136 ++++++++++++++-------- 1 file changed, 87 insertions(+), 49 deletions(-) diff --git a/src/components/Disputes/DisputeActions.js b/src/components/Disputes/DisputeActions.js index 8f0742d1..27f16620 100644 --- a/src/components/Disputes/DisputeActions.js +++ b/src/components/Disputes/DisputeActions.js @@ -165,7 +165,11 @@ function InformationSection({ `} /> -
+
{ if (!jurorDraft) return {} - // If the dispute is in the execute ruling phase it means that the final ruling can already be ensured. - // If the dispute is closed it means that the final ruling was already ensured. - const finalRulingConfirmed = - status === DisputeStatus.Closed || phase === DisputePhase.ExecuteRuling - // Note that we can assume that the evidence submission and drafting phases have already passed since we do an early return above const votingPeriodEnded = phase !== DisputePhase.VotingPeriod && phase !== DisputePhase.RevealVote @@ -239,46 +238,18 @@ const useInfoAttributes = ({ } } - // Juror has revealed - // Check if has voted in consensus with the plurality for the last round - const hasVotedInConsensus = - lastRound.vote && jurorDraft.outcome === lastRound.vote.winningOutcome - - // We must check if the penalties were already settled so we can tell the jurors - // wether their HNY locked balance has been discounted or they can claim rewards - // Note that if the penalties for the round are settled it means that the dispute has already ended - const settledPenalties = lastRound.settledPenalties - - const title = hasVotedInConsensus - ? 'You have voted in consensus with the plurality' - : 'You have not voted in consensus with the plurality' - const background = hasVotedInConsensus - ? positiveBackground - : negativeBackground - - // If penalties settled then the locked HNY has been redistributed - if (settledPenalties) { - return { - title, - paragraph: hasVotedInConsensus ? ( - - ) : ( - - ), - background, - icon: hasVotedInConsensus ? IconRewardsGreen : IconVotingFailed, - } - } + // If the dispute is in the execute ruling phase it means that the final ruling can already be ensured. + // If the dispute is closed it means that the final ruling was already ensured. + const finalRulingConfirmed = + status === DisputeStatus.Closed || phase === DisputePhase.ExecuteRuling - // Includes the cases where penalties weren't settled or the last round hasn't ended - return { - title, - paragraph: ( - - ), - background, - icon: hasVotedInConsensus ? IconVotingSuccess : IconVotingFailed, - } + // Juror has revealed + return getAttributesWhenRevealed( + lastRound, + jurorDraft, + finalRulingConfirmed, + { positive: positiveBackground, negative: negativeBackground } + ) } // Juror has voted and reveal period hasn't ended @@ -299,8 +270,7 @@ const useInfoAttributes = ({ }, [ hasJurorVoted, jurorDraft, - lastRound.settledPenalties, - lastRound.vote, + lastRound, negativeBackground, phase, positiveBackground, @@ -320,8 +290,8 @@ const HNYLockedMessage = ({ finalRulingConfirmed }) => { ) } -const HNYSlashMessage = () => { - return +const HNYSlashMessage = ({ extra = '' }) => { + return } const HNYSlashedMessage = () => { @@ -406,4 +376,72 @@ const VoteInfo = ({ commitmentDate, outcome, revealDate }) => { ) } +// Assumes juror revealed vote +function getAttributesWhenRevealed( + lastRound, + jurorDraft, + finalRulingConfirmed, + backgroundColor +) { + const { appeal, vote } = lastRound + // Check if has voted in consensus with the plurality for the last round + + const hasVotedInConsensus = vote && jurorDraft.outcome === vote.winningOutcome + // We must check if the penalties were already settled so we can tell the jurors + // wether their HNY locked balance has been discounted or they can claim rewards + // Note that if the penalties for the round are settled it means that the dispute has already ended + const settledPenalties = lastRound.settledPenalties + + let background, icon, paragraph, title + + // Juror voted in consensus during voting phase + if (hasVotedInConsensus) { + background = backgroundColor[appeal ? 'negative' : 'positive'] + icon = appeal ? IconVotingFailed : IconRewardsGreen + paragraph = appeal ? ( + finalRulingConfirmed ? ( + + ) : ( + + ) + ) : settledPenalties ? ( + + ) : ( + + ) + title = appeal + ? 'Although you voted in consensus with the plurality during the voting phase, the dispute was appealed with a different outcome' + : 'You have voted in consensus with the plurality' + } else { + // Juror didn't vote in consenus during voting pahse + // Check if juror voted in favor of the appealed outcome + const inConsensusWithAppealer = + appeal && jurorDraft.outcome === appeal.appealedRuling + background = + backgroundColor[inConsensusWithAppealer ? 'positive' : 'negative'] + icon = inConsensusWithAppealer ? IconRewardsGreen : IconVotingFailed + paragraph = inConsensusWithAppealer ? ( + settledPenalties ? ( + + ) : ( + + ) + ) : finalRulingConfirmed ? ( + + ) : ( + + ) + title = inConsensusWithAppealer + ? "Altough you didn't vote in consensus with the plurality during the voting phase, the dispute was appealed with the outcome you voted for" + : 'You have not voted in consensus with the plurality' + } + + return { + background, + icon, + paragraph, + title, + } +} + export default DisputeActions From 7e86e5fbec3d4fb78d12e397c9e73bf51f90f3fd Mon Sep 17 00:00:00 2001 From: fabriziovigevani Date: Mon, 15 Mar 2021 19:28:04 -0300 Subject: [PATCH 2/3] Remove sapcing --- src/components/Disputes/DisputeActions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Disputes/DisputeActions.js b/src/components/Disputes/DisputeActions.js index 27f16620..8892fca9 100644 --- a/src/components/Disputes/DisputeActions.js +++ b/src/components/Disputes/DisputeActions.js @@ -402,7 +402,7 @@ function getAttributesWhenRevealed( finalRulingConfirmed ? ( ) : ( - + ) ) : settledPenalties ? ( From 99a2026fe5d3b983eb06520d2982880a66a56dec Mon Sep 17 00:00:00 2001 From: fabriziovigevani Date: Mon, 15 Mar 2021 19:33:34 -0300 Subject: [PATCH 3/3] Fix bug --- src/components/Disputes/DisputeActions.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Disputes/DisputeActions.js b/src/components/Disputes/DisputeActions.js index 8892fca9..81e51cc2 100644 --- a/src/components/Disputes/DisputeActions.js +++ b/src/components/Disputes/DisputeActions.js @@ -384,8 +384,8 @@ function getAttributesWhenRevealed( backgroundColor ) { const { appeal, vote } = lastRound - // Check if has voted in consensus with the plurality for the last round + // Check if has voted in consensus with the plurality for the last round const hasVotedInConsensus = vote && jurorDraft.outcome === vote.winningOutcome // We must check if the penalties were already settled so we can tell the jurors // wether their HNY locked balance has been discounted or they can claim rewards @@ -399,7 +399,7 @@ function getAttributesWhenRevealed( background = backgroundColor[appeal ? 'negative' : 'positive'] icon = appeal ? IconVotingFailed : IconRewardsGreen paragraph = appeal ? ( - finalRulingConfirmed ? ( + settledPenalties ? ( ) : ( @@ -426,7 +426,7 @@ function getAttributesWhenRevealed( ) : ( ) - ) : finalRulingConfirmed ? ( + ) : settledPenalties ? ( ) : (