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/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) 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) 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/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..555db8ad1 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(); @@ -56,7 +58,7 @@ export const DelegateDashboardCard = ({ const cardProps: Partial = (() => { // transaction in progress - if (delegateTx) { + if (delegateTx && !voter.isRegisteredAsSoleVoter) { return { buttons: [learnMoreButton], description: getProgressDescription(delegateTx?.resourceId, ada), @@ -66,7 +68,7 @@ export const DelegateDashboardCard = ({ } // current delegation - if (currentDelegation) { + if (currentDelegation && !voter.isRegisteredAsSoleVoter) { return { buttons: currentDelegation?.dRepView ? [ @@ -116,11 +118,17 @@ export const DelegateDashboardCard = ({ return ( - {displayedDelegationId && ( + {displayedDelegationId && !voter.isRegisteredAsSoleVoter && ( - {details && Object.keys(details).length !== 0 && ( - - )} + {details && + Object.keys(details).length !== 0 && + Object.entries(details).map(([label, content]) => ( + + ))} ); diff --git a/govtool/frontend/src/i18n/locales/en.ts b/govtool/frontend/src/i18n/locales/en.ts index 56d199455..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", @@ -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],