Skip to content

Commit 215bd0e

Browse files
committed
done
1 parent 8712e7a commit 215bd0e

File tree

9 files changed

+74
-44
lines changed

9 files changed

+74
-44
lines changed

govtool/backend/src/VVA/API.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,7 @@ proposalToResponse timeZone Types.Proposal {..} =
245245
proposalResponseCcAbstainVotes = proposalCcAbstainVotes,
246246
proposalResponsePrevGovActionIndex = proposalPrevGovActionIndex,
247247
proposalResponsePrevGovActionTxHash = HexText <$> proposalPrevGovActionTxHash,
248-
proposalResponseAuthors = proposalAuthors
249-
-- proposalResponseAuthors = ProposalAuthors <$> proposalAuthors
248+
proposalResponseAuthors = ProposalAuthors <$> proposalAuthors
250249
}
251250

252251
voteToResponse :: Types.Vote -> VoteParams

govtool/backend/src/VVA/API/Types.hs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -401,38 +401,38 @@ data ProposalResponse
401401
, proposalResponseCcAbstainVotes :: Integer
402402
, proposalResponsePrevGovActionIndex :: Maybe Integer
403403
, proposalResponsePrevGovActionTxHash :: Maybe HexText
404-
, proposalResponseAuthors :: Maybe Value
404+
, proposalResponseAuthors :: Maybe ProposalAuthors
405405
}
406406
deriving (Generic, Show)
407407

408-
-- newtype ProposalAuthors = ProposalAuthors { getProposalAuthors :: Value }
409-
-- deriving newtype (Show)
410-
411-
-- instance FromJSON ProposalAuthors where
412-
-- parseJSON v@(Array _) = pure $ ProposalAuthors v
413-
-- parseJSON _ = fail "ProposalAuthors must be a JSON array"
414-
415-
-- instance ToJSON ProposalAuthors where
416-
-- toJSON (ProposalAuthors v) = v
417-
418-
-- instance ToSchema ProposalAuthors where
419-
-- declareNamedSchema _ = pure $ NamedSchema (Just "ProposalAuthors") $ mempty
420-
-- & type_ ?~ OpenApiArray
421-
-- & description ?~ "A JSON array of proposal authors"
422-
-- & example ?~ toJSON
423-
-- [ object
424-
-- [ "name" .= ("Alice" :: Text)
425-
-- , "witness_algorithm" .= ("algo" :: Text)
426-
-- , "public_key" .= ("key" :: Text)
427-
-- , "signature" .= ("sig" :: Text)
428-
-- ]
429-
-- , object
430-
-- [ "name" .= ("Bob" :: Text)
431-
-- , "witness_algorithm" .= ("algo2" :: Text)
432-
-- , "public_key" .= ("key2" :: Text)
433-
-- , "signature" .= ("sig2" :: Text)
434-
-- ]
435-
-- ]
408+
newtype ProposalAuthors = ProposalAuthors { getProposalAuthors :: Value }
409+
deriving newtype (Show)
410+
411+
instance FromJSON ProposalAuthors where
412+
parseJSON v@(Array _) = pure $ ProposalAuthors v
413+
parseJSON _ = fail "ProposalAuthors must be a JSON array"
414+
415+
instance ToJSON ProposalAuthors where
416+
toJSON (ProposalAuthors v) = v
417+
418+
instance ToSchema ProposalAuthors where
419+
declareNamedSchema _ = pure $ NamedSchema (Just "ProposalAuthors") $ mempty
420+
& type_ ?~ OpenApiArray
421+
& description ?~ "A JSON array of proposal authors"
422+
& example ?~ toJSON
423+
[ object
424+
[ "name" .= ("Alice" :: Text)
425+
, "witness_algorithm" .= ("algo" :: Text)
426+
, "public_key" .= ("key" :: Text)
427+
, "signature" .= ("sig" :: Text)
428+
]
429+
, object
430+
[ "name" .= ("Bob" :: Text)
431+
, "witness_algorithm" .= ("algo2" :: Text)
432+
, "public_key" .= ("key2" :: Text)
433+
, "signature" .= ("sig2" :: Text)
434+
]
435+
]
436436

437437
deriveJSON (jsonOptions "proposalResponse") ''ProposalResponse
438438

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export const GovernanceActionCardElement = ({
108108
...(isSemiTransparent && { opacity: 0.75 }),
109109
}}
110110
>
111-
{isMarkdown ? removeMarkdown(text) : text}
111+
{typeof text === "string" && isMarkdown ? removeMarkdown(text) : text}
112112
</Typography>
113113
);
114114

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useMemo, useState } from "react";
22
import { Box, Tabs, Tab, styled, Skeleton } from "@mui/material";
33
import { useLocation } from "react-router-dom";
44

5-
import { CopyButton, ExternalModalButton, Typography } from "@atoms";
5+
import { CopyButton, ExternalModalButton, Tooltip, Typography } from "@atoms";
66
import {
77
GovernanceActionCardElement,
88
GovernanceActionDetailsCardLinks,
@@ -76,6 +76,7 @@ export const GovernanceActionDetailsCardData = ({
7676
isValidating,
7777
proposal: {
7878
abstract,
79+
authors,
7980
createdDate,
8081
createdEpochNo,
8182
details,
@@ -365,6 +366,29 @@ export const GovernanceActionDetailsCardData = ({
365366
/>
366367
</>
367368
)}
369+
<GovernanceActionCardElement
370+
label={t("govActions.authors.title")}
371+
text={
372+
(authors ?? []).length <= 0
373+
? t("govActions.authors.noDataAvailable")
374+
: (authors ?? []).map((author, idx, arr) => (
375+
<>
376+
<Tooltip
377+
heading={`${t("govActions.authors.witnessAlgorithm")}: ${author.witnessAlgorithm}`}
378+
paragraphOne={`${t("govActions.authors.publicKey")}: ${author.publicKey}`}
379+
paragraphTwo={`${t("govActions.authors.signature")}: ${author.signature}`}
380+
placement="bottom-end"
381+
arrow
382+
>
383+
<span>{author.name}</span>
384+
</Tooltip>
385+
{idx < arr.length - 1 && <span>,&nbsp;</span>}
386+
</>
387+
))
388+
}
389+
textVariant="longText"
390+
dataTestId="authors"
391+
/>
368392

369393
<GovernanceActionDetailsCardLinks links={references} />
370394
</Box>

govtool/frontend/src/hooks/queries/useGetProposalQuery.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ export const useGetProposalQuery = (proposalId: string, enabled?: boolean) => {
1616
},
1717
);
1818

19-
console.log('useGetProposalQuery', { proposalId, dRepID, data, isLoading, isRefetching, error });
20-
2119
return {
2220
data,
2321
isLoading,

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,13 @@
421421
"amount": "Amount:",
422422
"anchorURL": "Metadata anchor link",
423423
"anchorHash": "Metadata anchor hash",
424+
"authors": {
425+
"noDataAvailable": "No data available",
426+
"title": "Authors",
427+
"publicKey": "Public Key",
428+
"signature": "Signature",
429+
"witnessAlgorithm": "Witness Algorithm"
430+
},
424431
"backToGovActions": "Back to Governance Actions",
425432
"castVote": "<0>You voted {{vote}} on this proposal</0>\non {{date}} (Epoch {{epoch}})",
426433
"castVoteDeadline": "You can change your vote up to {{date}} (Epoch {{epoch}})",

govtool/frontend/src/models/api.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,12 @@ export type ProposalData = {
234234
references?: Reference[];
235235
title?: string;
236236
protocolParams: EpochParams | null;
237+
authors?: {
238+
name?: string;
239+
witnessAlgorithm?: string;
240+
publicKey?: string;
241+
signature?: string;
242+
}[];
237243
} & SubmittedVotesData;
238244

239245
export type NewConstitutionAnchor = {
@@ -270,8 +276,8 @@ type DRepVotingPower = {
270276
export type DRepVotingPowerListResponse = DRepVotingPower[];
271277

272278
export type Account = {
273-
id: number,
274-
view: string,
275-
isRegistered: boolean,
276-
isScriptBased: boolean
277-
}
279+
id: number;
280+
view: string;
281+
isRegistered: boolean;
282+
isScriptBased: boolean;
283+
};

govtool/frontend/src/pages/GovernanceActionDetails.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ export const GovernanceActionDetails = () => {
5757
(data ?? state)?.proposal as ProposalData,
5858
);
5959

60-
console.log('GovernanceActionDetails', { extendedProposal, data, state, untypedState });
61-
6260
useEffect(() => {
6361
if (data?.proposal) {
6462
setExtendedProposal(data.proposal);

govtool/frontend/src/services/requests/getProposal.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,5 @@ export const getProposal = async (
1919
`/proposal/get/${encodedHash}?drepId=${drepId}`,
2020
);
2121

22-
console.log('-------------------getProposal', { proposalId, drepId, data });
23-
2422
return data;
2523
};

0 commit comments

Comments
 (0)