From b9de80ea2e1e2c6101ea026df37ff47284884e88 Mon Sep 17 00:00:00 2001 From: Sudip Bhattarai Date: Wed, 22 May 2024 10:34:27 +0545 Subject: [PATCH 1/9] Update Readme add SonarCloud metrics --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 44189428f..90e9993a1 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,8 @@ [![npm](https://img.shields.io/npm/v/npm.svg?style=flat-square)](https://www.npmjs.com/package/npm) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0) -![Statements](https://img.shields.io/badge/statements-29.28%25-red.svg?style=flat) ![Branches](https://img.shields.io/badge/branches-86.39%25-yellow.svg?style=flat) ![Functions](https://img.shields.io/badge/functions-14.28%25-red.svg?style=flat) ![Lines](https://img.shields.io/badge/lines-29.28%25-red.svg?style=flat) + +[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=intersect-govtool&metric=ncloc)](https://sonarcloud.io/summary/overall?id=intersect-govtool) [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=intersect-govtool&metric=coverage)](https://sonarcloud.io/summary/overall?id=intersect-govtool) [![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=intersect-govtool&metric=sqale_index)](https://sonarcloud.io/summary/overall?id=intersect-govtool) From 364741741371d1c7e65f3621b0df389c272b4cad Mon Sep 17 00:00:00 2001 From: jankun4 Date: Sun, 26 May 2024 23:48:27 +0200 Subject: [PATCH 2/9] [#1073] fix proposal/list 500 error on HardFork proposal --- CHANGELOG.md | 1 + govtool/backend/src/VVA/API.hs | 6 ++++-- govtool/backend/src/VVA/API/Types.hs | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f439bb23..c78020868 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ changes. ### Fixed +- 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) - drep/info no longer returns null values [Issue 720](https://github.com/IntersectMBO/govtool/issues/720) diff --git a/govtool/backend/src/VVA/API.hs b/govtool/backend/src/VVA/API.hs index d860fd391..6067000cc 100644 --- a/govtool/backend/src/VVA/API.hs +++ b/govtool/backend/src/VVA/API.hs @@ -407,5 +407,7 @@ validateMetadata MetadataValidationParams {..} = do $ Metadata.validateMetadata metadataValidationParamsUrl (unHexText metadataValidationParamsHash) case fromJSON result of - Error e -> throwError $ InternalError $ pack $ show e - Success a -> return a + Error e -> return $ MetadataValidationResponse Nothing False (AnyValue $ Just result) + Success (InternalMetadataValidationResponse {..}) -> return $ MetadataValidationResponse {metadataValidationResponseStatus=internalMetadataValidationResponseStatus, metadataValidationResponseValid=internalMmetadataValidationResponseValid, metadataValidationResponseRaw=AnyValue $ Just result} + + diff --git a/govtool/backend/src/VVA/API/Types.hs b/govtool/backend/src/VVA/API/Types.hs index 6eebd5d7c..760b24857 100644 --- a/govtool/backend/src/VVA/API/Types.hs +++ b/govtool/backend/src/VVA/API/Types.hs @@ -140,10 +140,36 @@ instance ToSchema MetadataValidationStatus where & description ?~ "Metadata Validation Status" & enum_ ?~ map toJSON [IncorrectFormat, IncorrectJSONLD, IncorrectHash, UrlNotFound] + + +data InternalMetadataValidationResponse + = InternalMetadataValidationResponse + { internalMetadataValidationResponseStatus :: Maybe MetadataValidationStatus + , internalMmetadataValidationResponseValid :: Bool + } + deriving (Generic, Show) + +deriveJSON (jsonOptions "internalMetadataValidationResponse") ''InternalMetadataValidationResponse + +instance ToSchema InternalMetadataValidationResponse where + declareNamedSchema _ = do + NamedSchema name_ schema_ <- + genericDeclareNamedSchema + ( fromAesonOptions $ jsonOptions "internalMetadataValidationResponse" ) + (Proxy :: Proxy InternalMetadataValidationResponse) + return $ + NamedSchema name_ $ + schema_ + & description ?~ "Metadata Validation Response" + & example + ?~ toJSON ("{\"status\": \"INCORRECT_FORMTAT\", \"valid\":false, \"raw\":{\"some\":\"key\"}}" :: Text) + + data MetadataValidationResponse = MetadataValidationResponse { metadataValidationResponseStatus :: Maybe MetadataValidationStatus , metadataValidationResponseValid :: Bool + , metadataValidationResponseRaw :: AnyValue } deriving (Generic, Show) From 3b7c2b1dab1e6caef333c49157350f03a9cb9a30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 27 May 2024 11:29:02 +0200 Subject: [PATCH 3/9] add posibility to copy address from Treasury GA --- .../molecules/GovernanceActionCardElement.tsx | 5 +++-- .../organisms/GovernanceActionDetailsCardData.tsx | 15 +++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx b/govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx index 83aa5f585..e8481fcce 100644 --- a/govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx +++ b/govtool/frontend/src/components/molecules/GovernanceActionCardElement.tsx @@ -5,7 +5,7 @@ import { Typography, Tooltip, CopyButton, TooltipProps } from "@atoms"; type BaseProps = { label: string; - text?: string; + text?: string | number; dataTestId?: string; isSliderCard?: boolean; tooltipProps?: Omit; @@ -109,6 +109,7 @@ export const GovernanceActionCardElement = ({ sx={{ fontSize: isSliderCard ? 14 : 16, fontWeight: 400, + maxWidth: textVariant === "oneLine" ? "283px" : "auto", lineHeight: isSliderCard ? "20px" : "24px", ...(textVariant === "oneLine" && { whiteSpace: "nowrap" }), ...((textVariant === "oneLine" || @@ -131,7 +132,7 @@ export const GovernanceActionCardElement = ({ {isCopyButton && ( - + )} diff --git a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx index 51f6e087d..a77ec844c 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx @@ -10,7 +10,7 @@ import { GovernanceActionDetailsCardOnChainData, } from "@molecules"; import { useScreenDimension, useTranslation } from "@hooks"; -import { getProposalTypeNoEmptySpaces } from "@utils"; +import { getProposalTypeNoEmptySpaces, testIdFromLabel } from "@utils"; import { MetadataValidationStatus } from "@models"; type GovernanceActionDetailsCardDataProps = { @@ -120,9 +120,16 @@ export const GovernanceActionDetailsCardData = ({ textVariant="longText" dataTestId="rationale" /> - {details && Object.keys(details).length !== 0 && ( - - )} + {details && + Object.keys(details).length !== 0 && + Object.entries(details).map(([label, content]) => ( + + ))} ); From 2fd2bf0f385dc7445def498e6022ba13f018e2bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 27 May 2024 11:31:45 +0200 Subject: [PATCH 4/9] fix lint --- .../src/components/organisms/GovernanceActionDetailsCardData.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx index a77ec844c..61d37d1fa 100644 --- a/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx +++ b/govtool/frontend/src/components/organisms/GovernanceActionDetailsCardData.tsx @@ -7,7 +7,6 @@ import { DataMissingInfoBox, GovernanceActionDetailsCardHeader, GovernanceActionsDatesBox, - GovernanceActionDetailsCardOnChainData, } from "@molecules"; import { useScreenDimension, useTranslation } from "@hooks"; import { getProposalTypeNoEmptySpaces, testIdFromLabel } from "@utils"; From 549450c12dc0e1c6460571884438a4dbc171c996 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 27 May 2024 13:09:13 +0200 Subject: [PATCH 5/9] change myDrep chips description --- govtool/frontend/src/i18n/locales/en.ts | 2 +- govtool/frontend/src/pages/DRepDetails.tsx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 56d199455..dfe06e6e6 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -265,7 +265,7 @@ export const en = { myDelegation: "You have delegated ₳ {{ada}} to:", myDelegationToYourself: "You have delegated ₳ {{ada}} to yourself:", - myDRep: "This is your DRep profile", + myDRep: "You have delegated ₳{{ada}} to this DRep.", listTitle: "Find a DRep", noConfidenceDefaultDescription: "Select this to signal no confidence in the current constitutional committee by voting NO on every proposal and voting YES to no confidence proposals", diff --git a/govtool/frontend/src/pages/DRepDetails.tsx b/govtool/frontend/src/pages/DRepDetails.tsx index d844f63ca..616d0de56 100644 --- a/govtool/frontend/src/pages/DRepDetails.tsx +++ b/govtool/frontend/src/pages/DRepDetails.tsx @@ -8,6 +8,7 @@ import { useCardano, useModal } from "@context"; import { useDelegateTodRep, useGetAdaHolderCurrentDelegationQuery, + useGetAdaHolderVotingPowerQuery, useGetDRepListInfiniteQuery, useScreenDimension, useTranslation, @@ -15,6 +16,7 @@ import { import { Card, EmptyStateDrepDirectory, LinkWithIcon, Share } from "@molecules"; import { correctAdaFormat, + correctDRepDirectoryFormat, isSameDRep, openInNewTab, testIdFromLabel, @@ -42,6 +44,8 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { const { dRepId: dRepParam } = useParams(); const { delegate, isDelegating } = useDelegateTodRep(); const { currentDelegation } = useGetAdaHolderCurrentDelegationQuery(stakeKey); + const { votingPower: myVotingPower } = + useGetAdaHolderVotingPowerQuery(stakeKey); const displayBackButton = location.state?.enteredFromWithinApp || false; @@ -141,7 +145,11 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => { theme.shadows[2], From 777be80f5c32688cec472fa800b7a44dfd4eba1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 27 May 2024 13:26:21 +0200 Subject: [PATCH 6/9] change register as direct voter card description --- govtool/frontend/src/i18n/locales/en.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index dfe06e6e6..9c00bd3f0 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -104,7 +104,7 @@ export const en = { "Your Voting Power of ₳{{votingPower}} can be used to vote.", register: "Register", registerDescription: - "Vote on Governance Actions using your own voting power of ₳{{votingPower}}.", + "Register to Vote on Governance Actions using your own voting power of ₳{{votingPower}}.", registerTitle: "Become a Direct Voter", reRegister: "Re-register", registration: "Direct Voter Registration", From 7c74c3a6757d4d063b1acdbc01a485cafd940170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 27 May 2024 13:28:33 +0200 Subject: [PATCH 7/9] change direct voter card description --- govtool/frontend/src/i18n/locales/en.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 56d199455..e707844c3 100644 --- a/govtool/frontend/src/i18n/locales/en.ts +++ b/govtool/frontend/src/i18n/locales/en.ts @@ -104,7 +104,7 @@ export const en = { "Your Voting Power of ₳{{votingPower}} can be used to vote.", register: "Register", registerDescription: - "Vote on Governance Actions using your own voting power of ₳{{votingPower}}.", + "Register to Vote on Governance Actions using your own voting power of ₳{{votingPower}}.", registerTitle: "Become a Direct Voter", reRegister: "Re-register", registration: "Direct Voter Registration", From bd2fd63f4a632e73cd3434e7cb02b1a14d710f71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Sworze=C5=84?= Date: Mon, 27 May 2024 13:59:42 +0200 Subject: [PATCH 8/9] block delegation card when iam direct voter --- .../components/organisms/DashboardCards.tsx | 1 + .../DashboardCards/DelegateDashboardCard.tsx | 22 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/govtool/frontend/src/components/organisms/DashboardCards.tsx b/govtool/frontend/src/components/organisms/DashboardCards.tsx index 0b651e5ff..869faf2a7 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards.tsx @@ -63,6 +63,7 @@ export const DashboardCards = () => { currentDelegation={currentDelegation} delegateTx={pendingTransaction.delegate} dRepID={dRepID} + voter={voter} votingPower={votingPower} /> diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx index 6d59122d9..c22566d49 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx @@ -5,7 +5,7 @@ import { Trans } from "react-i18next"; import { IMAGES, PATHS } from "@consts"; import { PendingTransaction } from "@context"; import { useTranslation } from "@hooks"; -import { CurrentDelegation } from "@models"; +import { CurrentDelegation, VoterInfo } from "@models"; import { DashboardActionCard, DashboardActionCardProps, @@ -21,6 +21,7 @@ type DelegateDashboardCardProps = { currentDelegation: CurrentDelegation; delegateTx: PendingTransaction["delegate"]; dRepID: string; + voter: VoterInfo; votingPower: number; }; @@ -28,6 +29,7 @@ export const DelegateDashboardCard = ({ currentDelegation, delegateTx, dRepID, + voter, votingPower, }: DelegateDashboardCardProps) => { const navigate = useNavigate(); @@ -54,9 +56,11 @@ export const DelegateDashboardCard = ({ const ada = correctAdaFormat(votingPower); + console.log(voter.isRegisteredAsSoleVoter); + const cardProps: Partial = (() => { // transaction in progress - if (delegateTx) { + if (delegateTx && !voter.isRegisteredAsSoleVoter) { return { buttons: [learnMoreButton], description: getProgressDescription(delegateTx?.resourceId, ada), @@ -66,7 +70,7 @@ export const DelegateDashboardCard = ({ } // current delegation - if (currentDelegation) { + if (currentDelegation && !voter.isRegisteredAsSoleVoter) { return { buttons: currentDelegation?.dRepView ? [ @@ -116,11 +120,17 @@ export const DelegateDashboardCard = ({ return ( - {displayedDelegationId && ( + {displayedDelegationId && !voter.isRegisteredAsSoleVoter && ( Date: Mon, 27 May 2024 14:02:57 +0200 Subject: [PATCH 9/9] delete consolelog --- .../organisms/DashboardCards/DelegateDashboardCard.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx index c22566d49..555db8ad1 100644 --- a/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx +++ b/govtool/frontend/src/components/organisms/DashboardCards/DelegateDashboardCard.tsx @@ -56,8 +56,6 @@ export const DelegateDashboardCard = ({ const ada = correctAdaFormat(votingPower); - console.log(voter.isRegisteredAsSoleVoter); - const cardProps: Partial = (() => { // transaction in progress if (delegateTx && !voter.isRegisteredAsSoleVoter) {