From d9cbd2a58d43123dc4baaa419ffed6d1acdf6c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Wed, 9 Apr 2025 08:51:08 +0200 Subject: [PATCH] feat(#2243): add epochParams and ada holder balance to Proposal pillar --- CHANGELOG.md | 1 + .../frontend/src/pages/ProposalDiscussion.tsx | 11 +++- .../frontend/src/types/@intersect.mbo.d.ts | 65 ++++++++++--------- 3 files changed, 45 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3abe3b590..82cddf042 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ changes. ### Added - Add Proposal discussion context that manages username [Issue 3341](https://github.com/IntersectMBO/govtool/issues/3341) +- Add epochParams and ada holder balance to Proposal Discussion Pillar [Issue 2243](https://github.com/IntersectMBO/govtool/issues/2243) ### Fixed diff --git a/govtool/frontend/src/pages/ProposalDiscussion.tsx b/govtool/frontend/src/pages/ProposalDiscussion.tsx index e0efe26d1..b69836df9 100644 --- a/govtool/frontend/src/pages/ProposalDiscussion.tsx +++ b/govtool/frontend/src/pages/ProposalDiscussion.tsx @@ -2,6 +2,7 @@ import React, { ComponentProps, Suspense } from "react"; import { Box, CircularProgress } from "@mui/material"; import "@intersect.mbo/pdf-ui/style"; import { + useAppContext, useCardano, useGovernanceActions, useProposalDiscussion, @@ -9,13 +10,18 @@ import { import { useValidateMutation } from "@/hooks/mutations"; import { useScreenDimension } from "@/hooks/useScreenDimension"; import { Footer, TopNav } from "@/components/organisms"; -import { useGetDRepVotingPowerList, useGetVoterInfo } from "@/hooks"; +import { + useGetAdaHolderVotingPowerQuery, + useGetDRepVotingPowerList, + useGetVoterInfo, +} from "@/hooks"; const ProposalDiscussion = React.lazy( () => import("@intersect.mbo/pdf-ui/cjs"), ); export const ProposalDiscussionPillar = () => { + const { epochParams } = useAppContext(); const { pagePadding } = useScreenDimension(); const { validateMetadata } = useValidateMutation(); const { walletApi, ...context } = useCardano(); @@ -23,6 +29,7 @@ export const ProposalDiscussionPillar = () => { const { createGovernanceActionJsonLD, createHash } = useGovernanceActions(); const { fetchDRepVotingPowerList } = useGetDRepVotingPowerList(); const { username, setUsername } = useProposalDiscussion(); + const { votingPower } = useGetAdaHolderVotingPowerQuery(context.stakeKey); return ( { fetchDRepVotingPowerList={fetchDRepVotingPowerList} username={username} setUsername={setUsername} + epochParams={epochParams} + votingPower={votingPower} /> diff --git a/govtool/frontend/src/types/@intersect.mbo.d.ts b/govtool/frontend/src/types/@intersect.mbo.d.ts index bef6e3b07..4981c67fa 100644 --- a/govtool/frontend/src/types/@intersect.mbo.d.ts +++ b/govtool/frontend/src/types/@intersect.mbo.d.ts @@ -4,41 +4,44 @@ enum MetadataValidationStatus { INVALID_HASH = "INVALID_HASH", INCORRECT_FORMAT = "INCORRECT_FORMAT", } +declare module "@intersect.mbo/pdf-ui/cjs" { + import { EpochParams } from "@/models"; -type ProposalDiscussionProps = { - pdfApiUrl: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - walletAPI: any; - pathname: string; - locale?: string; - validateMetadata: ({ - url, - hash, - standard, - }: { - url: string; - hash: string; - standard: "CIP108"; - }) => Promise< + type ProposalDiscussionProps = { + pdfApiUrl: string; // eslint-disable-next-line @typescript-eslint/no-explicit-any - | { status?: MetadataValidationStatus; metadata?: any; valid: boolean } - | undefined - >; - fetchDRepVotingPowerList: ( - identifiers: string[], - ) => Promise; - username: string; - setUsername: (username: string) => void; -}; + walletAPI: any; + pathname: string; + locale?: string; + validateMetadata: ({ + url, + hash, + standard, + }: { + url: string; + hash: string; + standard: "CIP108"; + }) => Promise< + // eslint-disable-next-line @typescript-eslint/no-explicit-any + | { status?: MetadataValidationStatus; metadata?: any; valid: boolean } + | undefined + >; + fetchDRepVotingPowerList: ( + identifiers: string[], + ) => Promise; + epochParams?: EpochParams; + votingPower: number; + username: string; + setUsername: (username: string) => void; + }; -type GovernanceActionsOutcomesProps = { - apiUrl?: string; - ipfsGateway?: string; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - walletAPI?: any; -}; + type GovernanceActionsOutcomesProps = { + apiUrl?: string; + ipfsGateway?: string; + // eslint-disable-next-line @typescript-eslint/no-explicit-any + walletAPI?: any; + }; -declare module "@intersect.mbo/pdf-ui/cjs" { export default function ProposalDiscussion( props: ProposalDiscussionProps, ): JSX.Element;