Skip to content

Commit 628b78a

Browse files
authored
Merge pull request #2363 from IntersectMBO/feat/2316-hide-vote-totals-for-the-groups-that-cant-vote-on-a-particular-governance-action-type
feat(#2316): hide vote totals for the particular governance actions
2 parents f7f222b + e17701d commit 628b78a

File tree

8 files changed

+415
-25
lines changed

8 files changed

+415
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ changes.
1212

1313
### Added
1414

15-
-
15+
- Handle displaying votes based on bootstrap phase, full governance and security groups [Issue 2316](https://github.com/IntersectMBO/govtool/issues/2316)
1616

1717
### Fixed
1818

govtool/frontend/src/components/molecules/GovernanceActionDetailsCardVotes.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Dispatch, SetStateAction } from "react";
1+
import { Dispatch, SetStateAction, useCallback } from "react";
22
import { Box } from "@mui/material";
33

44
import { useScreenDimension } from "@hooks";
55
import { VoteActionForm, VotesSubmitted } from "@molecules";
66
import { useFeatureFlag } from "@/context";
77
import { ProposalData, ProposalVote } from "@/models";
8+
import { SECURITY_RELEVANT_PARAMS_MAP } from "@/consts";
89

910
type GovernanceActionCardVotesProps = {
1011
setIsVoteSubmitted: Dispatch<SetStateAction<boolean>>;
@@ -25,9 +26,18 @@ export const GovernanceActionDetailsCardVotes = ({
2526
isInProgress,
2627
proposal,
2728
}: GovernanceActionCardVotesProps) => {
28-
const { isVotingOnGovernanceActionEnabled } = useFeatureFlag();
29+
const { areDRepVoteTotalsDisplayed } = useFeatureFlag();
2930
const { screenWidth } = useScreenDimension();
30-
31+
const isSecurityGroup = useCallback(
32+
() =>
33+
Object.values(SECURITY_RELEVANT_PARAMS_MAP).some(
34+
(paramKey) =>
35+
proposal.protocolParams?.[
36+
paramKey as keyof typeof proposal.protocolParams
37+
] !== null,
38+
),
39+
[proposal.protocolParams],
40+
);
3141
const isModifiedPadding =
3242
(isDashboard && screenWidth < 1368) ?? screenWidth < 1100;
3343

@@ -39,7 +49,8 @@ export const GovernanceActionDetailsCardVotes = ({
3949
p: `40px ${isModifiedPadding ? "24px" : "80px"}`,
4050
}}
4151
>
42-
{isVoter && isVotingOnGovernanceActionEnabled(proposal.type) ? (
52+
{isVoter &&
53+
areDRepVoteTotalsDisplayed(proposal.type, isSecurityGroup()) ? (
4354
<VoteActionForm
4455
setIsVoteSubmitted={setIsVoteSubmitted}
4556
proposal={proposal}

govtool/frontend/src/components/molecules/VotesSubmitted.tsx

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { useCallback } from "react";
12
import { Box } from "@mui/material";
23

3-
import { IMAGES } from "@consts";
4+
import { IMAGES, SECURITY_RELEVANT_PARAMS_MAP } from "@consts";
45
import { Typography, VotePill } from "@atoms";
56
import { useTranslation } from "@hooks";
67
import { correctVoteAdaFormat } from "@utils";
78
import { SubmittedVotesData } from "@models";
9+
import { useFeatureFlag } from "@/context";
810

911
type Props = {
1012
votes: SubmittedVotesData;
@@ -21,8 +23,24 @@ export const VotesSubmitted = ({
2123
ccYesVotes,
2224
ccAbstainVotes,
2325
ccNoVotes,
26+
type,
27+
protocolParams,
2428
},
2529
}: Props) => {
30+
const isSecurityGroup = useCallback(
31+
() =>
32+
Object.values(SECURITY_RELEVANT_PARAMS_MAP).some(
33+
(paramKey) =>
34+
protocolParams?.[paramKey as keyof typeof protocolParams] !== null,
35+
),
36+
[protocolParams],
37+
);
38+
39+
const {
40+
areDRepVoteTotalsDisplayed,
41+
areSPOVoteTotalsDisplayed,
42+
areCCVoteTotalsDisplayed,
43+
} = useFeatureFlag();
2644
const { t } = useTranslation();
2745

2846
return (
@@ -65,24 +83,30 @@ export const VotesSubmitted = ({
6583
gap: 4.5,
6684
}}
6785
>
68-
<VotesGroup
69-
type="dReps"
70-
yesVotes={dRepYesVotes}
71-
noVotes={dRepNoVotes}
72-
abstainVotes={dRepAbstainVotes}
73-
/>
74-
<VotesGroup
75-
type="sPos"
76-
yesVotes={poolYesVotes}
77-
noVotes={poolNoVotes}
78-
abstainVotes={poolAbstainVotes}
79-
/>
80-
<VotesGroup
81-
type="ccCommittee"
82-
yesVotes={ccYesVotes}
83-
noVotes={ccNoVotes}
84-
abstainVotes={ccAbstainVotes}
85-
/>
86+
{areDRepVoteTotalsDisplayed(type, isSecurityGroup()) && (
87+
<VotesGroup
88+
type="dReps"
89+
yesVotes={dRepYesVotes}
90+
noVotes={dRepNoVotes}
91+
abstainVotes={dRepAbstainVotes}
92+
/>
93+
)}
94+
{areSPOVoteTotalsDisplayed(type, isSecurityGroup()) && (
95+
<VotesGroup
96+
type="sPos"
97+
yesVotes={poolYesVotes}
98+
noVotes={poolNoVotes}
99+
abstainVotes={poolAbstainVotes}
100+
/>
101+
)}
102+
{areCCVoteTotalsDisplayed(type) && (
103+
<VotesGroup
104+
type="ccCommittee"
105+
yesVotes={ccYesVotes}
106+
noVotes={ccNoVotes}
107+
abstainVotes={ccAbstainVotes}
108+
/>
109+
)}
86110
</Box>
87111
</Box>
88112
);
@@ -111,6 +135,7 @@ const VotesGroup = ({
111135
flexDirection: "column",
112136
gap: "12px",
113137
}}
138+
data-testid={`submitted-votes-${type}`}
114139
>
115140
<Typography
116141
sx={{

govtool/frontend/src/consts/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,16 @@ export const COMPILED_GUARDRAIL_SCRIPTS = {
3333
mainnet:
3434
"5908545908510101003232323232323232323232323232323232323232323232323232323232323232323232323232323232259323255333573466e1d20000011180098111bab357426ae88d55cf00104554ccd5cd19b87480100044600422c6aae74004dd51aba1357446ae88d55cf1baa3255333573466e1d200a35573a002226ae84d5d11aab9e00111637546ae84d5d11aba235573c6ea800642b26006003149a2c8a4c301f801c0052000c00e0070018016006901e4070c00e003000c00d20d00fc000c0003003800a4005801c00e003002c00d20c09a0c80e1801c006001801a4101b5881380018000600700148013003801c006005801a410100078001801c006001801a4101001f8001800060070014801b0038018096007001800600690404002600060001801c0052008c00e006025801c006001801a41209d8001800060070014802b003801c006005801a410112f501c3003800c00300348202b7881300030000c00e00290066007003800c00b003482032ad7b806038403060070014803b00380180960003003800a4021801c00e003002c00d20f40380e1801c006001801a41403f800100a0c00e0029009600f0030078040c00e002900a600f003800c00b003301a483403e01a600700180060066034904801e00060001801c0052016c01e00600f801c006001801980c2402900e30000c00e002901060070030128060c00e00290116007003800c00b003483c0ba03860070018006006906432e00040283003800a40498003003800a404d802c00e00f003800c00b003301a480cb0003003800c003003301a4802b00030001801c01e0070018016006603490605c0160006007001800600660349048276000600030000c00e0029014600b003801c00c04b003800c00300348203a2489b00030001801c00e006025801c006001801a4101b11dc2df80018000c0003003800a4055802c00e007003012c00e003000c00d2080b8b872c000c0006007003801809600700180060069040607e4155016000600030000c00e00290166007003012c00e003000c00d2080c001c000c0003003800a405d801c00e003002c00d20c80180e1801c006001801a412007800100a0c00e00290186007003013c0006007001480cb005801801e006003801800e00600500403003800a4069802c00c00f003001c00c007003803c00e003002c00c05300333023480692028c0004014c00c00b003003c00c00f003003c00e00f003800c00b00301480590052008003003800a406d801c00e003002c00d2000c00d2006c00060070018006006900a600060001801c0052038c00e007001801600690006006901260003003800c003003483281300020141801c005203ac00e006027801c006001801a403d800180006007001480f3003801804e00700180060069040404af3c4e302600060001801c005203ec00e006013801c006001801a4101416f0fd20b80018000600700148103003801c006005801a403501c3003800c0030034812b00030000c00e0029021600f003800c00a01ac00e003000c00ccc08d20d00f4800b00030000c0000000000803c00c016008401e006009801c006001801807e0060298000c000401e006007801c0060018018074020c000400e00f003800c00b003010c000802180020070018006006019801805e0003000400600580180760060138000800c00b00330134805200c400e00300080330004006005801a4001801a410112f58000801c00600901260008019806a40118002007001800600690404a75ee01e00060008018046000801801e000300c4832004c025201430094800a0030028052003002c00d2002c000300648010c0092002300748028c0312000300b48018c0292012300948008c0212066801a40018000c0192008300a2233335573e00250002801994004d55ce800cd55cf0008d5d08014c00cd5d10011263009222532900389800a4d2219002912c80344c01526910c80148964cc04cdd68010034564cc03801400626601800e0071801226601800e01518010096400a3000910c008600444002600244004a664600200244246466004460044460040064600444600200646a660080080066a00600224446600644b20051800484ccc02600244666ae68cdc3801000c00200500a91199ab9a33710004003000801488ccd5cd19b89002001800400a44666ae68cdc4801000c00a00122333573466e20008006005000912a999ab9a3371200400222002220052255333573466e2400800444008440040026eb400a42660080026eb000a4264666015001229002914801c8954ccd5cd19b8700400211333573466e1c00c006001002118011229002914801c88cc044cdc100200099b82002003245200522900391199ab9a3371066e08010004cdc1001001c002004403245200522900391199ab9a3371266e08010004cdc1001001c00a00048a400a45200722333573466e20cdc100200099b820020038014000912c99807001000c40062004912c99807001000c400a2002001199919ab9a357466ae880048cc028dd69aba1003375a6ae84008d5d1000934000dd60010a40064666ae68d5d1800c0020052225933006003357420031330050023574400318010600a444aa666ae68cdc3a400000222c22aa666ae68cdc4000a4000226600666e05200000233702900000088994004cdc2001800ccdc20010008cc010008004c01088954ccd5cd19b87480000044400844cc00c004cdc300100091119803112c800c60012219002911919806912c800c4c02401a442b26600a004019130040018c008002590028c804c8888888800d1900991111111002a244b267201722222222008001000c600518000001112a999ab9a3370e004002230001155333573466e240080044600823002229002914801c88ccd5cd19b893370400800266e0800800e00100208c8c0040048c0088cc008008005",
3535
};
36+
37+
export const SECURITY_RELEVANT_PARAMS_MAP: Record<string, string> = {
38+
maxBlockBodySize: "max_block_size",
39+
maxTxSize: "max_tx_size",
40+
maxBlockHeaderSize: "max_bh_size",
41+
maxValueSize: "max_val_size",
42+
maxBlockExecutionUnits: "max_block_ex_mem",
43+
txFeePerByte: "min_fee_a",
44+
txFeeFixed: "min_fee_b",
45+
utxoCostPerByte: "coins_per_utxo_size",
46+
govActionDeposit: "gov_action_deposit",
47+
minFeeRefScriptCostPerByte: "min_fee_ref_script_cost_per_byte",
48+
};

govtool/frontend/src/context/appContext.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ type AppContextType = {
2323
isAppInitializing: boolean;
2424
isMainnet: boolean;
2525
isInBootstrapPhase: boolean;
26+
isFullGovernance: boolean;
2627
networkName: string;
2728
network: string;
2829
cExplorerBaseUrl: string;
@@ -74,6 +75,7 @@ const AppContextProvider = ({ children }: PropsWithChildren) => {
7475
isMainnet: networkMetrics?.networkName === "mainnet",
7576
isInBootstrapPhase:
7677
epochParams?.protocol_major === BOOTSTRAPPING_PHASE_MAJOR,
78+
isFullGovernance: Number(epochParams?.protocol_major) >= 10,
7779
networkName:
7880
NETWORK_NAMES[
7981
(networkMetrics?.networkName as keyof typeof NETWORK_NAMES) ||

0 commit comments

Comments
 (0)