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

Cardano Stack: Address Copying Added, HardFork Proposal Error Fixed, UI Enhancements, and Merged Pull Requests #1104

Merged
merged 15 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

</div>

Expand Down
6 changes: 4 additions & 2 deletions govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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}


26 changes: 26 additions & 0 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TooltipProps, "children">;
Expand Down Expand Up @@ -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" ||
Expand All @@ -131,7 +132,7 @@ export const GovernanceActionCardElement = ({
</Typography>
{isCopyButton && (
<Box ml={1}>
<CopyButton text={text} variant="blueThin" />
<CopyButton text={text.toString()} variant="blueThin" />
</Box>
)}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const DashboardCards = () => {
currentDelegation={currentDelegation}
delegateTx={pendingTransaction.delegate}
dRepID={dRepID}
voter={voter}
votingPower={votingPower}
/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -21,13 +21,15 @@ type DelegateDashboardCardProps = {
currentDelegation: CurrentDelegation;
delegateTx: PendingTransaction["delegate"];
dRepID: string;
voter: VoterInfo;
votingPower: number;
};

export const DelegateDashboardCard = ({
currentDelegation,
delegateTx,
dRepID,
voter,
votingPower,
}: DelegateDashboardCardProps) => {
const navigate = useNavigate();
Expand Down Expand Up @@ -56,7 +58,7 @@ export const DelegateDashboardCard = ({

const cardProps: Partial<DashboardActionCardProps> = (() => {
// transaction in progress
if (delegateTx) {
if (delegateTx && !voter.isRegisteredAsSoleVoter) {
return {
buttons: [learnMoreButton],
description: getProgressDescription(delegateTx?.resourceId, ada),
Expand All @@ -66,7 +68,7 @@ export const DelegateDashboardCard = ({
}

// current delegation
if (currentDelegation) {
if (currentDelegation && !voter.isRegisteredAsSoleVoter) {
return {
buttons: currentDelegation?.dRepView
? [
Expand Down Expand Up @@ -116,11 +118,17 @@ export const DelegateDashboardCard = ({
return (
<DashboardActionCard
imageURL={IMAGES.govActionDelegateImage}
isSpaceBetweenButtons={!!currentDelegation?.dRepView}
transactionId={delegateTx?.transactionHash || currentDelegation?.txHash}
isSpaceBetweenButtons={
!!currentDelegation?.dRepView && !voter.isRegisteredAsSoleVoter
}
transactionId={
!voter.isRegisteredAsSoleVoter
? delegateTx?.transactionHash ?? currentDelegation?.txHash
: undefined
}
{...cardProps}
>
{displayedDelegationId && (
{displayedDelegationId && !voter.isRegisteredAsSoleVoter && (
<DelegationAction
dRepId={displayedDelegationId}
onCardClick={navigateToDRepDetails}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import {
DataMissingInfoBox,
GovernanceActionDetailsCardHeader,
GovernanceActionsDatesBox,
GovernanceActionDetailsCardOnChainData,
} from "@molecules";
import { useScreenDimension, useTranslation } from "@hooks";
import { getProposalTypeNoEmptySpaces } from "@utils";
import { getProposalTypeNoEmptySpaces, testIdFromLabel } from "@utils";
import { MetadataValidationStatus } from "@models";

type GovernanceActionDetailsCardDataProps = {
Expand Down Expand Up @@ -120,9 +119,16 @@ export const GovernanceActionDetailsCardData = ({
textVariant="longText"
dataTestId="rationale"
/>
{details && Object.keys(details).length !== 0 && (
<GovernanceActionDetailsCardOnChainData data={details} />
)}
{details &&
Object.keys(details).length !== 0 &&
Object.entries(details).map(([label, content]) => (
<GovernanceActionCardElement
isCopyButton={label.toLowerCase().includes("address")}
label={label}
text={content}
dataTestId={testIdFromLabel(label)}
/>
))}
<GovernanceActionDetailsCardLinks links={links} />
</Box>
);
Expand Down
4 changes: 2 additions & 2 deletions govtool/frontend/src/i18n/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const en = {
"Your Voting Power of ₳<strong>{{votingPower}}</strong> can be used to vote.",
register: "Register",
registerDescription:
"Vote on Governance Actions using your own voting power of ₳<strong>{{votingPower}}</strong>.",
"Register to Vote on Governance Actions using your own voting power of ₳<strong>{{votingPower}}</strong>.",
registerTitle: "Become a Direct Voter",
reRegister: "Re-register",
registration: "Direct Voter Registration",
Expand Down Expand Up @@ -265,7 +265,7 @@ export const en = {
myDelegation: "You have delegated <strong>₳ {{ada}}</strong> to:",
myDelegationToYourself:
"You have delegated <strong>₳ {{ada}}</strong> 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",
Expand Down
10 changes: 9 additions & 1 deletion govtool/frontend/src/pages/DRepDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import { useCardano, useModal } from "@context";
import {
useDelegateTodRep,
useGetAdaHolderCurrentDelegationQuery,
useGetAdaHolderVotingPowerQuery,
useGetDRepListInfiniteQuery,
useScreenDimension,
useTranslation,
} from "@hooks";
import { Card, EmptyStateDrepDirectory, LinkWithIcon, Share } from "@molecules";
import {
correctAdaFormat,
correctDRepDirectoryFormat,
isSameDRep,
openInNewTab,
testIdFromLabel,
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -141,7 +145,11 @@ export const DRepDetails = ({ isConnected }: DRepDetailsProps) => {
<Chip
color="primary"
label={
isMe ? t("dRepDirectory.meAsDRep") : t("dRepDirectory.myDRep")
isMe
? t("dRepDirectory.meAsDRep")
: t("dRepDirectory.myDRep", {
ada: correctDRepDirectoryFormat(myVotingPower),
})
}
sx={{
boxShadow: (theme) => theme.shadows[2],
Expand Down
Loading