Skip to content

Commit d113332

Browse files
authored
Merge pull request #2373 from IntersectMBO/feat/1597-rendering-motion-of-no-confidence-governance-action
feat: add support for the rest of the Governance Actions
2 parents 628b78a + 44c2d9d commit d113332

27 files changed

+918
-179
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ changes.
1313
### Added
1414

1515
- Handle displaying votes based on bootstrap phase, full governance and security groups [Issue 2316](https://github.com/IntersectMBO/govtool/issues/2316)
16+
- Add support for displaying Motion of No Confidence Governance Action [Issue 1597](https://github.com/IntersectMBO/govtool/issues/1597)
17+
- Add support for displaying Update committee/threshold Governance Action [Issue 1598](https://github.com/IntersectMBO/govtool/issues/1598)
18+
- Add support for displaying New Constitution and/or Guardrails Script Governance Action [Issue 1599](https://github.com/IntersectMBO/govtool/issues/1598)
1619

1720
### Fixed
1821

govtool/backend/app/Main.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ startApp vvaConfig = do
8282
settings =
8383
setPort vvaPort
8484
$ setHost vvaHost
85-
$ setTimeout 60 -- 60 seconds timeout
85+
$ setTimeout 120 -- 120 seconds timeout
8686
$ setBeforeMainLoop
8787
( Text.hPutStrLn stderr $
8888
Text.pack
@@ -117,7 +117,7 @@ startApp vvaConfig = do
117117
, dRepListCache
118118
, networkMetricsCache
119119
}
120-
connectionPool <- createPool (connectPostgreSQL (encodeUtf8 (dbSyncConnectionString $ getter vvaConfig))) close 1 1 60
120+
connectionPool <- createPool (connectPostgreSQL (encodeUtf8 (dbSyncConnectionString $ getter vvaConfig))) close 10 10 120
121121
let appEnv = AppEnv {vvaConfig=vvaConfig, vvaCache=cacheEnv, vvaConnectionPool=connectionPool }
122122
server' <- mkVVAServer appEnv
123123
runSettings settings server'
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"dbsyncconfig" : {
3-
"host" : "localhost",
4-
"dbname" : "cexplorer",
5-
"user" : "postgres",
6-
"password" : "postgres",
7-
"port" : 5432
8-
},
9-
"port" : 9999,
10-
"host" : "localhost",
11-
"cachedurationseconds": 20,
12-
"sentrydsn": "https://username:[email protected]/id",
13-
"sentryenv": "dev"
2+
"dbsyncconfig" : {
3+
"host" : "localhost",
4+
"dbname" : "cexplorer",
5+
"user" : "postgres",
6+
"password" : "postgres",
7+
"port" : 5432
8+
},
9+
"port" : 9999,
10+
"host" : "localhost",
11+
"cachedurationseconds": 20,
12+
"sentrydsn": "https://username:[email protected]/id",
13+
"sentryenv": "dev"
1414
}

govtool/backend/sql/list-proposals.sql

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,74 @@ always_abstain_voting_power AS (
3131
LEFT JOIN drep_distr ON drep_hash.id = drep_distr.hash_id
3232
WHERE
3333
drep_hash.view = 'drep_always_abstain' ORDER BY epoch_no DESC LIMIT 1), 0) AS amount
34+
),
35+
committee_data AS (
36+
SELECT DISTINCT ON (ch.raw)
37+
encode(ch.raw, 'hex') AS hash,
38+
cm.expiration_epoch,
39+
ch.has_script
40+
FROM
41+
committee_member cm
42+
JOIN
43+
committee_hash ch ON cm.committee_hash_id = ch.id
44+
ORDER BY ch.raw, cm.expiration_epoch DESC
45+
),
46+
parsed_description AS (
47+
SELECT
48+
gov_action_proposal.id,
49+
description->'tag' AS tag,
50+
description->'contents'->1 AS members_to_be_removed,
51+
description->'contents'->2 AS members,
52+
description->'contents'->3 AS threshold
53+
FROM
54+
gov_action_proposal
55+
WHERE
56+
gov_action_proposal.type = 'NewCommittee'
57+
),
58+
members_to_be_removed AS (
59+
SELECT
60+
id,
61+
json_agg(value->>'keyHash') AS members_to_be_removed
62+
FROM
63+
parsed_description,
64+
json_array_elements(members_to_be_removed::json) AS value
65+
GROUP BY
66+
id
67+
),
68+
processed_current_members AS (
69+
SELECT
70+
pd.id,
71+
json_agg(
72+
json_build_object(
73+
'hash', regexp_replace(kv.key, '^keyHash-', ''),
74+
'newExpirationEpoch', kv.value::int
75+
)
76+
) AS current_members
77+
FROM
78+
parsed_description pd,
79+
jsonb_each_text(pd.members) AS kv(key, value)
80+
GROUP BY
81+
pd.id
82+
),
83+
enriched_current_members AS (
84+
SELECT
85+
pcm.id,
86+
json_agg(
87+
json_build_object(
88+
'hash', cm.hash,
89+
'expirationEpoch', cm.expiration_epoch,
90+
'hasScript', cm.has_script,
91+
'newExpirationEpoch', (member->>'newExpirationEpoch')::int
92+
)
93+
) AS enriched_members
94+
FROM
95+
processed_current_members pcm
96+
LEFT JOIN
97+
json_array_elements(pcm.current_members) AS member ON true
98+
LEFT JOIN
99+
committee_data cm ON cm.hash = encode(decode(member->>'hash', 'hex'), 'hex')
100+
GROUP BY
101+
pcm.id
34102
)
35103
SELECT
36104
gov_action_proposal.id,
@@ -42,13 +110,42 @@ SELECT
42110
json_build_object('Reward Address', stake_address.view, 'Amount', treasury_withdrawal.amount)
43111

44112
when gov_action_proposal.type::text = 'InfoAction' then
45-
json_build_object()
113+
json_build_object('data', gov_action_proposal.description)
46114

47115
when gov_action_proposal.type::text = 'HardForkInitiation' then
48116
json_build_object(
49117
'major', (gov_action_proposal.description->'contents'->1->>'major')::int,
50118
'minor', (gov_action_proposal.description->'contents'->1->>'minor')::int
51119
)
120+
121+
when gov_action_proposal.type::text = 'NoConfidence' then
122+
json_build_object('data', gov_action_proposal.description->'contents')
123+
124+
when gov_action_proposal.type::text = 'ParameterChange' then
125+
json_build_object('data', gov_action_proposal.description->'contents')
126+
127+
when gov_action_proposal.type::text = 'NewConstitution' then
128+
json_build_object(
129+
'anchor', gov_action_proposal.description->'contents'->1->'anchor'
130+
)
131+
when gov_action_proposal.type::text = 'NewCommittee' then
132+
(
133+
SELECT
134+
json_build_object(
135+
'tag', pd.tag,
136+
'members', em.enriched_members,
137+
'membersToBeRemoved', mtr.members_to_be_removed,
138+
'threshold', pd.threshold::float
139+
)
140+
FROM
141+
parsed_description pd
142+
JOIN
143+
members_to_be_removed mtr ON pd.id = mtr.id
144+
JOIN
145+
enriched_current_members em ON pd.id = em.id
146+
WHERE
147+
pd.id = gov_action_proposal.id
148+
)
52149
else
53150
null
54151
end

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
import { Box, SxProps } from "@mui/material";
22

33
import { Typography } from "@atoms";
4-
import { Share } from "@molecules";
54
import { MetadataValidationStatus } from "@models";
65
import { getMetadataDataMissingStatusTranslation } from "@/utils";
76

87
type DataMissingHeaderProps = {
98
isDataMissing: MetadataValidationStatus | null;
10-
shareLink?: string;
119
title?: string;
1210
titleStyle?: SxProps;
1311
};
1412

1513
export const DataMissingHeader = ({
1614
title,
1715
isDataMissing,
18-
shareLink,
1916
titleStyle,
2017
}: DataMissingHeaderProps) => (
2118
<Box
@@ -50,6 +47,5 @@ export const DataMissingHeader = ({
5047
title}
5148
</Typography>
5249
</Box>
53-
{shareLink && <Share link={shareLink} />}
5450
</Box>
5551
);

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ export const GovernanceActionCard: FC<ActionTypeProps> = ({ ...props }) => {
5454
const { t } = useTranslation();
5555

5656
const govActionId = getFullGovActionId(txHash, index);
57-
const cip129GovernanceActionId = encodeCIP129Identifier(
58-
txHash,
59-
index.toString(16).padStart(2, "0"),
60-
"gov_action",
61-
);
57+
const cip129GovernanceActionId = encodeCIP129Identifier({
58+
txID: txHash,
59+
index: index.toString(16).padStart(2, "0"),
60+
bech32Prefix: "gov_action",
61+
});
6262

6363
return (
6464
<Box

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

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Typography } from "@atoms";
44
import { ICONS } from "@consts";
55
import { useModal } from "@context";
66
import { useScreenDimension, useTranslation } from "@hooks";
7-
import { LinkWithIcon } from "@molecules";
87

98
export const GovernanceActionDetailsCardLinks = ({
109
links,
@@ -42,29 +41,56 @@ export const GovernanceActionDetailsCardLinks = ({
4241
}}
4342
>
4443
{links.map(({ uri, label }) => (
45-
<Box flexDirection="column">
44+
<Box flexDirection={isMobile ? "column" : "row"} display="flex">
4645
{label && (
4746
<Typography
4847
data-testid={`${label}-${uri}-label`}
49-
sx={{ fontWeight: "500" }}
48+
sx={{
49+
fontWeight: 400,
50+
flex: 1,
51+
fontSize: 16,
52+
lineHeight: "24px",
53+
mr: 8,
54+
overflow: "hidden",
55+
width: "auto",
56+
whiteSpace: "nowrap",
57+
}}
5058
>
5159
{label}
5260
</Typography>
5361
)}
54-
<LinkWithIcon
55-
key={uri}
56-
label={uri}
57-
onClick={() => {
58-
openModal({
59-
type: "externalLink",
60-
state: {
61-
externalLink: uri,
62-
},
63-
});
62+
<Typography
63+
sx={{
64+
fontSize: 16,
65+
fontWeight: 400,
66+
maxWidth: "283px",
67+
lineHeight: "24px",
68+
whiteSpace: "nowrap",
69+
overflow: "hidden",
70+
textOverflow: "ellipsis",
71+
color: "primaryBlue",
6472
}}
65-
icon={<img alt="link" src={ICONS.link} />}
66-
cutWithEllipsis
67-
/>
73+
>
74+
{uri}
75+
</Typography>
76+
{label && (
77+
<Box ml={1}>
78+
<img
79+
data-testid="link-button"
80+
alt="link"
81+
src={ICONS.externalLinkIcon}
82+
style={{ cursor: "pointer" }}
83+
onClick={() => {
84+
openModal({
85+
type: "externalLink",
86+
state: {
87+
externalLink: uri,
88+
},
89+
});
90+
}}
91+
/>
92+
</Box>
93+
)}
6894
</Box>
6995
))}
7096
</Box>

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { ReactNode } from "react";
12
import { Box } from "@mui/material";
23

34
import { Typography } from "@atoms";
@@ -65,7 +66,7 @@ export const GovernanceActionDetailsCardOnChainData = ({
6566
ml: 0.5,
6667
}}
6768
>
68-
{content}
69+
{content as ReactNode}
6970
</Typography>
7071
</Box>
7172
))}

0 commit comments

Comments
 (0)