Skip to content

Commit 7914baa

Browse files
committed
feat(#2745): add script hash to new constitution governance action
1 parent c4eb77b commit 7914baa

File tree

7 files changed

+37
-34
lines changed

7 files changed

+37
-34
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ changes.
1313
### Added
1414

1515
- Add exception handler on stake key voting power query execution [Issue 2757](https://github.com/IntersectMBO/govtool/issues/2757)
16+
- Add script hash to new consitution governance action [Issue 2745](https://github.com/IntersectMBO/govtool/issues/2745)
1617

1718
### Fixed
1819

govtool/backend/sql/list-proposals.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ SELECT
175175

176176
WHEN gov_action_proposal.type::text = 'NewConstitution' THEN
177177
json_build_object(
178-
'anchor', gov_action_proposal.description->'contents'->1->'anchor'
178+
'anchor', gov_action_proposal.description->'contents'->1->'anchor',
179+
'script', gov_action_proposal.description->'contents'->1->'script'
179180
)
180181
WHEN gov_action_proposal.type::text = 'NewCommittee' THEN
181182
(

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type DataMissingHeaderProps = {
1616
titleStyle?: SxProps;
1717
isDRep?: boolean;
1818
image?: string | null;
19+
shareLink?: string;
1920
};
2021

2122
export const DataMissingHeader = ({
@@ -24,6 +25,7 @@ export const DataMissingHeader = ({
2425
titleStyle,
2526
isDRep,
2627
image,
28+
shareLink,
2729
}: DataMissingHeaderProps) => {
2830
const base64Image = getBase64ImageDetails(image ?? "");
2931
const { screenWidth } = useScreenDimension();
@@ -81,7 +83,9 @@ export const DataMissingHeader = ({
8183
title}
8284
</Typography>
8385
</Box>
84-
{screenWidth >= 1020 && <Share link={window.location.href} />}
86+
{screenWidth >= 1020 && (
87+
<Share link={shareLink || window.location.href} />
88+
)}
8589
</Box>
8690
);
8791
};
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,38 @@
11
import { Box } from "@mui/material";
22

33
import { NewConstitutionAnchor, ProposalData } from "@/models";
4-
import { useScreenDimension } from "@/hooks";
4+
import { useScreenDimension, useTranslation } from "@/hooks";
55

66
import { GovernanceActionCardElement } from "./GovernanceActionCardElement";
77

88
export const GovernanceActionNewConstitutionDetailsTabContent = ({
99
details,
1010
}: Pick<ProposalData, "details">) => {
1111
const { screenWidth } = useScreenDimension();
12+
const { t } = useTranslation();
1213
return (
1314
<Box>
1415
<GovernanceActionCardElement
1516
isLinkButton
16-
label="New constitution link"
17+
label={t("govActions.newConstitution.url")}
1718
text={(details?.anchor as NewConstitutionAnchor)?.url as string}
1819
dataTestId="new-constitution-url"
1920
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
2021
/>
2122
<GovernanceActionCardElement
2223
isCopyButton
23-
label="New constitution hash"
24+
label={t("govActions.newConstitution.hash")}
2425
text={(details?.anchor as NewConstitutionAnchor)?.dataHash as string}
2526
dataTestId="new-constitution-data-hash"
2627
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
2728
/>
29+
<GovernanceActionCardElement
30+
isCopyButton
31+
label={t("govActions.newConstitution.scriptHash")}
32+
text={details?.script as string}
33+
dataTestId="new-constitution-script-hash"
34+
textVariant={screenWidth > 1600 ? "longText" : "oneLine"}
35+
/>
2836
</Box>
2937
);
3038
};

govtool/frontend/src/components/organisms/GovernanceActionDetailsCard.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import { useScreenDimension } from "@hooks";
55
import {
66
GovernanceActionCardStatePill,
77
GovernanceActionDetailsCardVotes,
8-
Share,
98
} from "@molecules";
109
import { GovernanceActionDetailsCardData } from "@organisms";
1110
import { MetadataValidationStatus, ProposalData, ProposalVote } from "@models";
12-
import { useLocation } from "react-router-dom";
1311

1412
type GovernanceActionDetailsCardProps = {
1513
isDashboard?: boolean;
@@ -32,13 +30,6 @@ export const GovernanceActionDetailsCard = ({
3230
const { screenWidth, isMobile } = useScreenDimension();
3331

3432
const isOneColumn = (isDashboard && screenWidth < 1036) ?? isMobile;
35-
const { pathname, hash } = useLocation();
36-
37-
const govActionLinkToShare = `${window.location.protocol}//${
38-
window.location.hostname
39-
}${window.location.port ? `:${window.location.port}` : ""}${pathname}${
40-
hash ?? ""
41-
}`;
4233

4334
return (
4435
<Box
@@ -82,9 +73,6 @@ export const GovernanceActionDetailsCard = ({
8273
isInProgress={isInProgress}
8374
proposal={proposal}
8475
/>
85-
<Box position="absolute" right={40} top={40}>
86-
<Share link={govActionLinkToShare} />
87-
</Box>
8876
</Box>
8977
);
9078
};

govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useMemo, useState } from "react";
22
import { Box, Tabs, Tab, styled } from "@mui/material";
3+
import { useLocation } from "react-router-dom";
34

45
import { CopyButton, ExternalModalButton, Typography } from "@atoms";
56
import {
@@ -88,13 +89,13 @@ export const GovernanceActionDetailsCardData = ({
8889
url,
8990
type,
9091
protocolParams,
91-
metadataHash,
9292
},
9393
}: GovernanceActionDetailsCardDataProps) => {
9494
const { epochParams } = useAppContext();
9595
const { t } = useTranslation();
9696
const { screenWidth } = useScreenDimension();
9797
const { isMobile } = useScreenDimension();
98+
const { pathname, hash } = useLocation();
9899

99100
const mappedArraysToObjectsProtocolParams = useMemo(
100101
() =>
@@ -147,6 +148,12 @@ export const GovernanceActionDetailsCardData = ({
147148
? getFullGovActionId(prevGovActionTxHash, prevGovActionIndex)
148149
: null;
149150

151+
const govActionLinkToShare = `${window.location.protocol}//${
152+
window.location.hostname
153+
}${window.location.port ? `:${window.location.port}` : ""}${pathname}${
154+
hash ?? ""
155+
}`;
156+
150157
const tabs = useMemo(
151158
() =>
152159
[
@@ -232,7 +239,11 @@ export const GovernanceActionDetailsCardData = ({
232239
overflow: "hidden",
233240
}}
234241
>
235-
<DataMissingHeader isDataMissing={isDataMissing} title={title} />
242+
<DataMissingHeader
243+
isDataMissing={isDataMissing}
244+
title={title}
245+
shareLink={govActionLinkToShare}
246+
/>
236247
<DataMissingInfoBox
237248
isDataMissing={isDataMissing}
238249
isInProgress={isInProgress}
@@ -319,21 +330,6 @@ export const GovernanceActionDetailsCardData = ({
319330
amount={withdrawal.amount}
320331
/>
321332
))}
322-
<GovernanceActionCardElement
323-
label={t("govActions.anchorURL")}
324-
text={url}
325-
textVariant="longText"
326-
dataTestId="anchor-url"
327-
isLinkButton
328-
/>
329-
<GovernanceActionCardElement
330-
label={t("govActions.anchorHash")}
331-
text={metadataHash}
332-
textVariant="longText"
333-
dataTestId="anchor-hash"
334-
isCopyButton
335-
/>
336-
337333
<GovernanceActionDetailsCardLinks links={references} />
338334
</Box>
339335
);

govtool/frontend/src/i18n/locales/en.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@
382382
"proposedVersion": "Proposed version",
383383
"previousGAId": "Previous Governance Action ID"
384384
},
385+
"newConstitution": {
386+
"url": "New constitution link",
387+
"hash": "New constitution hash",
388+
"scriptHash": "New constitution script hash"
389+
},
385390
"motivation": "Motivation",
386391
"myVote": "My Vote:",
387392
"noResultsForTheSearch": "No results for the search.",

0 commit comments

Comments
 (0)