Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add DRep voting power handling, metadata validator, Sentry config; Fix CSP, navigation, modal, vote issues; Update proposal-id, DRep navigation, yarn; Improve tests. #1424

Merged
merged 44 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
11a8d87
Test-infra: Expose storybook deployment publicly
mesudip Jun 19, 2024
2611b68
Test-infra: Add USERSNAP_SPACE_API_KEY build-arg
mesudip Jun 19, 2024
a2f1f09
Merge pull request #1356 from IntersectMBO/fix/storybook-deployment
NabinKawan Jun 20, 2024
8a91ce2
Merge pull request #1359 from IntersectMBO/infra/test-chores
mesudip Jun 20, 2024
c235dd9
chore: Update proposal-id for frontend validation in sorting
NabinKawan Jun 20, 2024
b18c87d
Fix CSP issue blocking Sentry requests in Traefik configuration
placek Jun 20, 2024
bfa66c6
Merge pull request #1362 from IntersectMBO/bug/1218-resolve-csp-issue…
placek Jun 20, 2024
248c6b8
Merge pull request #1360 from IntersectMBO/bugfix/test-4C_2
NabinKawan Jun 21, 2024
179d4e7
chore: Update matadata-anchor incorrect test ids
kneerose Jun 20, 2024
a792eb4
fix: Metadata error modal
kneerose Jun 20, 2024
340554a
chore: Add email and bio data on update dRep test
kneerose Jun 20, 2024
3b73afe
chore: Change navigation of dRep details page
kneerose Jun 21, 2024
97e8f28
chore: Add "add link" button click event on edit dRep
kneerose Jun 21, 2024
f1297b8
chore: Add missing testids on dRepDirectory page
kneerose Jun 20, 2024
4f4dbf0
chore: Add missing testids on dRep Registration page
kneerose Jun 20, 2024
e6940d4
chore: Add missing test ids on GA page
kneerose Jun 20, 2024
8ff03fa
Merge pull request #1395 from IntersectMBO/fix/metadata-validation
NabinKawan Jun 21, 2024
c76b129
Merge pull request #1394 from IntersectMBO/fix/dRep-GA-missing-test-ids
NabinKawan Jun 21, 2024
0b29322
Merge pull request #1396 from IntersectMBO/bugfix/test-2N-3M
NabinKawan Jun 21, 2024
dfd6094
fix edit drep form
Sworzen1 Jun 21, 2024
013e0ab
fix Modal ref error
Sworzen1 Jun 19, 2024
3e74a2d
fix tab index Modal
Sworzen1 Jun 19, 2024
2181a36
fix nested p error
Sworzen1 Jun 19, 2024
781914d
fix cannot get value from undefined and improve sanchonet info modal
Sworzen1 Jun 19, 2024
f185f8b
fix navigation
Sworzen1 Jun 19, 2024
46c2d1d
fix: Dashboard and homepage learn more navigation link
kneerose Jun 17, 2024
2c96724
fix: Abstain and signal-no-confidence info navigation url
kneerose Jun 17, 2024
bd439fa
chore: Replace hardcoded docs url with constant
kneerose Jun 21, 2024
f4e24da
Merge pull request #1337 from IntersectMBO/fix/console-errors
Sworzen1 Jun 21, 2024
4852a48
Merge pull request #1392 from IntersectMBO/refactor/test-docs-url-link
NabinKawan Jun 21, 2024
be00b50
chore: fix flaky tests
MSzalowski Jun 20, 2024
5dc08a4
Merge pull request #1373 from IntersectMBO/chore/1334-fix-sonarqube-a…
MSzalowski Jun 21, 2024
dbb00ed
feat: pass govtool metadata validator to pdf pillar
MSzalowski Jun 20, 2024
b90e1d4
Merge pull request #1374 from IntersectMBO/feat/pass-govtool-metadata…
MSzalowski Jun 21, 2024
0052547
fix vote
Sworzen1 Jun 21, 2024
b48108d
Merge pull request #1402 from IntersectMBO/fix/vote
Sworzen1 Jun 21, 2024
f5507e8
chore: provide tags to sentry events
MSzalowski Jun 21, 2024
17d782e
Merge pull request #1399 from IntersectMBO/chore/1326-group-the-same-…
MSzalowski Jun 21, 2024
fb643d0
[#1093] return 0 drep voting power instead of throwing 500
jankun4 Jun 23, 2024
911483e
Merge pull request #1397 from IntersectMBO/fix/1389-bug-clearing-name…
Sworzen1 Jun 24, 2024
d447847
fix(#1355): fix the navigation to Home from Proposal pillar on discon…
MSzalowski Jun 24, 2024
518acd2
fix(#1349): Change label of Proposal Discussion nav item
MSzalowski Jun 24, 2024
15382c9
Merge pull request #1411 from IntersectMBO/fix/1349-change-proposal-d…
MSzalowski Jun 24, 2024
fa202ec
Merge pull request #1412 from IntersectMBO/fix/1355-user-get-stack
MSzalowski Jun 24, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install Playwright
run: npx playwright install --with-deps
- name: Build Storybook
run: NODE_OPTIONS="--max-old-space-size=8046" npm run build-storybook --quiet
run: NODE_OPTIONS="--max-old-space-size=8046" npm run build:storybook --quiet
- name: Serve Storybook and run tests
run: |
npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ changes.

### Fixed

- drep/get-voting-power no longer throws 500 for non-existing dreps. Instead it returns 0 [Issue 1093](https://github.com/IntersectMBO/govtool/issues/1093)
- proposal/list no longer throws 500 error when proposal's url is incorrect [Issue 1073](https://github.com/IntersectMBO/govtool/issues/1073)
- drep/list sql fix (now the drep type is correct) [Issue 957](https://github.com/IntersectMBO/govtool/issues/957)
- drep/list sql fix (now the latest tx date is correct) [Issue 826](https://github.com/IntersectMBO/govtool/issues/826)
Expand Down Expand Up @@ -99,6 +100,7 @@ changes.
- Fix validation of the GAs with missing references [Issue 1282](https://github.com/IntersectMBO/govtool/issues/1282)
- Fix displaying the GA Markdowns [Issue 1244](https://github.com/IntersectMBO/govtool/issues/1244)
- Fix app crash on voting on the GA without the connected wallet before [Issue 1313](https://github.com/IntersectMBO/govtool/issues/1313)
- Fix the navigation to Home from Proposal pillar on disconnected wallet [Issue 1355](https://github.com/IntersectMBO/govtool/issues/1355)

### Changed

Expand Down Expand Up @@ -131,6 +133,7 @@ changes.
- Changed documents to prepare for open source [Issue 737](https://github.com/IntersectMBO/govtool/issues/737)
- Changed copy on maintenance page [Issue 753](https://github.com/IntersectMBO/govtool/issues/753)
- Update link to docs [Issue 1246](https://github.com/IntersectMBO/govtool/issues/1246)
- Change label of Proposal Discussion nav item [Issue 1349](https://github.com/IntersectMBO/govtool/issues/1349)

### Removed

Expand Down
43 changes: 43 additions & 0 deletions docs/GOVERNANCE_ACTION_SUBMISSION.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,46 @@ await buildSignSubmitConwayCertTx({
### Step 6: Verify the Governance Action

`buildSignSubmitConwayCertTx` logs the transaction CBOR making it able to be tracked on the transactions tools such as cexplorer.

## Additional steps for using the GovTool metadata validation on the imported Pillar component

```tsx
enum MetadataValidationStatus {
URL_NOT_FOUND = "URL_NOT_FOUND",
INVALID_JSONLD = "INVALID_JSONLD",
INVALID_HASH = "INVALID_HASH",
INCORRECT_FORMAT = "INCORRECT_FORMAT",
}
// Using the props passed to the component
type Props = {
validateMetadata: ({
url,
hash,
standard,
}: {
url: string;
hash: string;
standard: "CIP108";
}) => Promise<{
metadata?: any;
status?: MetadataValidationStatus;
valid: boolean;
}>;
};

import React, { Suspense } from "react";

const SomeImportedPillar: React.FC<Props> = React.lazy(
() => import("path/to/SomeImportedPillar")
);

const SomeWrapperComponent = () => {
const { validateMetadata } = useValidateMutation();

return (
<Suspense fallback={<div>I am lazy loading...</div>}>
<SomeImportedPillar validateMetadata={validateMetadata} />
</Suspense>
);
};
```
6 changes: 4 additions & 2 deletions govtool/backend/src/VVA/DRep.hs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ getVotingPower ::
Text ->
m Integer
getVotingPower drepId = withPool $ \conn -> do
[SQL.Only votingPower] <-
result <-
liftIO
(SQL.query @_ @(SQL.Only Scientific) conn getVotingPowerSql $ SQL.Only drepId)
return $ floor votingPower
case result of
[SQL.Only votingPower] -> return $ floor votingPower
[] -> return 0

listDRepsSql :: SQL.Query
listDRepsSql = sqlFrom $(embedFile "sql/list-dreps.sql")
Expand Down
16 changes: 8 additions & 8 deletions govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions govtool/frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "voltaire-voting-app",
"name": "govtool",
"private": true,
"version": "0.0.0",
"version": "1.0.6",
"type": "module",
"scripts": {
"build": "vite build",
"build-storybook": "storybook build",
"build:storybook": "storybook build",
"chromatic": "chromatic",
"dev": "vite",
"format": "prettier --write src",
Expand Down Expand Up @@ -34,9 +34,6 @@
"@rollup/plugin-babel": "^6.0.4",
"@rollup/pluginutils": "^5.1.0",
"@sentry/react": "^7.77.0",
"@types/jsonld": "^1.5.13",
"@types/react": "^18.2.12",
"@types/react-gtm-module": "^2.0.2",
"@usersnap/browser": "^0.0.5",
"axios": "^1.4.0",
"bech32": "^2.0.0",
Expand Down Expand Up @@ -78,7 +75,9 @@
"@testing-library/user-event": "^14.5.2",
"@types/jsonld": "^1.5.13",
"@types/node": "^20.4.8",
"@types/react": "^18.2.12",
"@types/react-dom": "^18.0.11",
"@types/react-gtm-module": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
"@vitejs/plugin-react": "^4.3.0",
Expand Down Expand Up @@ -107,5 +106,5 @@
"typescript": "^5.0.2"
},
"readme": "ERROR: No README data found!",
"_id": "voltaire-voting-app@0.0.0"
"_id": "govtool@1.0.6"
}
15 changes: 3 additions & 12 deletions govtool/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { PDFWrapper } from "./components/organisms/PDFWrapper";

export default () => {
const { isProposalDiscussionForumEnabled } = useFeatureFlag();
const { enable, isEnabled } = useCardano();
const { enable } = useCardano();
const navigate = useNavigate();
const { modal, openModal, modals } = useModal();

Expand Down Expand Up @@ -87,10 +87,7 @@ export default () => {
!window.location.pathname.includes(PATHS.proposalPillar.replace("/*", ""))
) {
navigate(
`${(isEnabled
? PATHS.connectedProposalPillar
: PATHS.proposalPillar
).replace("/*", "")}${window.location.pathname}`,
`${PATHS.proposalPillar.replace("/*", "")}${window.location.pathname}`,
);
}
}, [window.location.pathname]);
Expand All @@ -101,9 +98,6 @@ export default () => {
<Routes>
<Route path={PATHS.home} element={<Home />} />
<Route path={PATHS.governanceActions} element={<GovernanceActions />} />
{isProposalDiscussionForumEnabled && !isEnabled && (
<Route path={PATHS.proposalPillar} element={<PDFWrapper />} />
)}
<Route
path={PATHS.governanceActionsCategory}
element={<GovernanceActionsCategory />}
Expand All @@ -115,10 +109,7 @@ export default () => {
<Route element={<Dashboard />}>
<Route path={PATHS.dashboard} element={<DashboardCards />} />
{isProposalDiscussionForumEnabled && (
<Route
path={PATHS.connectedProposalPillar}
element={<PDFWrapper />}
/>
<Route path={PATHS.proposalPillar} element={<PDFWrapper />} />
)}
<Route
path={PATHS.dashboardGovernanceActions}
Expand Down
9 changes: 6 additions & 3 deletions govtool/frontend/src/components/atoms/CopyButton.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { render, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { SnackbarProvider } from "@context";
import { CopyButton } from "@atoms";
import { act } from "react";

Object.defineProperty(global.navigator, "clipboard", {
value: {
Expand Down Expand Up @@ -61,9 +62,11 @@ describe("CopyButton", () => {
);

const copyButton = screen.getByTestId("copy-button");
await userEvent.click(copyButton);
expect(navigator.clipboard.writeText).toHaveBeenCalledWith("Example Text");

expect(screen.getByText("alerts.copiedToClipboard")).toBeInTheDocument();
await act(async () => {
await userEvent.click(copyButton);
});

expect(navigator.clipboard.writeText).toHaveBeenCalledWith("Example Text");
});
});
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/atoms/DrawerLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type LinkProps = {
const isRouteActive = (isActive: boolean, route: string) =>
isActive ||
(route ===
`${PATHS.connectedProposalPillar.replace("/*", "")}${
`${PATHS.proposalPillar.replace("/*", "")}${
PDF_PATHS.proposalDiscussion
}` &&
Object.values(PDF_PATHS).some((pdfPath) =>
Expand Down
3 changes: 2 additions & 1 deletion govtool/frontend/src/components/atoms/modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { DialogContent } from "@mui/material";
import MuiModal from "@mui/material/Modal";
import type { ComponentProps } from "react";

Expand All @@ -11,6 +12,6 @@ interface Props {

export const Modal = ({ open, children, handleClose }: Props) => (
<MuiModal open={open} onClose={handleClose} disableAutoFocus>
{children}
<DialogContent>{children}</DialogContent>
</MuiModal>
);
52 changes: 29 additions & 23 deletions govtool/frontend/src/components/atoms/modal/ModalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SxProps, styled } from "@mui/material/styles";
import { ICONS } from "@consts";
import { useModal } from "@context";
import { callAll } from "@utils";
import { forwardRef } from "react";

interface Props {
variant?: "modal" | "popup";
Expand Down Expand Up @@ -49,27 +50,32 @@ export const CloseButton = styled("img")`
right: 24px;
`;

export const ModalWrapper = ({
children,
onClose,
variant = "modal",
hideCloseButton = false,
dataTestId = "modal",
sx,
}: Props) => {
const { closeModal } = useModal();
export const ModalWrapper = forwardRef<HTMLDivElement, Props>(
(
{
children,
onClose,
variant = "modal",
hideCloseButton = false,
dataTestId = "modal",
sx,
},
ref,
) => {
const { closeModal } = useModal();

return (
<BaseWrapper variant={variant} data-testid={dataTestId} sx={sx}>
{variant !== "popup" && !hideCloseButton && (
<CloseButton
data-testid="close-modal-button"
alt="close"
onClick={callAll(closeModal, onClose)}
src={ICONS.closeIcon}
/>
)}
{children}
</BaseWrapper>
);
};
return (
<BaseWrapper variant={variant} data-testid={dataTestId} sx={sx} ref={ref}>
{variant !== "popup" && !hideCloseButton && (
<CloseButton
data-testid="close-modal-button"
alt="close"
onClick={callAll(closeModal, onClose)}
src={ICONS.closeIcon}
/>
)}
{children}
</BaseWrapper>
);
},
);
2 changes: 1 addition & 1 deletion govtool/frontend/src/components/atoms/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type LoadingButtonProps = ButtonProps & {

export type TypographyProps = Pick<
MUITypographyProps,
"color" | "lineHeight" | "sx"
"color" | "lineHeight" | "sx" | "component"
> & {
children?: React.ReactNode;
fontSize?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const DashboardActionCard: FC<DashboardActionCardProps> = ({
variant="title2"
fontWeight={600}
sx={{ display: "inline" }}
component="span"
>
{` ${t("inProgress")}`}
</Typography>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const WalletInfoCard = () => {
await disconnectWallet();
navigate(
pathname.includes("/connected")
? `${pathname.replace("/connected", "")}${hash}`
? `${pathname.replace("/connected", "")}${hash ?? ""}`
: PATHS.home,
);
window.location.reload();
Expand Down
7 changes: 5 additions & 2 deletions govtool/frontend/src/components/molecules/WalletOption.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ export const WalletOptionButton: FC<WalletOption> = ({
const result = await enable(name);
if (result?.stakeKey) {
navigate(
pathToNavigate ?? pathname === "/"
// eslint-disable-next-line no-unneeded-ternary
pathToNavigate
? pathToNavigate
: pathname === "/"
? "/dashboard"
: `connected${pathname}${hash}`,
: `connected${pathname}${hash ?? ""}`,
{ state },
);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const ProposeGovActionDashboardCard = ({

navigate(
isProposalDiscussionForumEnabled
? `${PATHS.connectedProposalPillar.replace("/*", "")}${
? `${PATHS.proposalPillar.replace("/*", "")}${
PDF_PATHS.proposalDiscussion
}`
: PATHS.createGovernanceAction,
Expand Down
Loading
Loading