From 546fb2f455f9b5a5ccd610fac27ed012d6985600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Fri, 14 Mar 2025 13:59:45 +0100 Subject: [PATCH 1/3] fix(#3191): fix re-voting with a different rationale --- CHANGELOG.md | 1 + govtool/backend/sql/get-votes.sql | 37 +++++++++++-------- .../components/molecules/VoteActionForm.tsx | 7 +++- .../organisms/VoteContext/VoteContextText.tsx | 2 +- .../requests/getVoteContextTextFromFile.ts | 5 +-- 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ce80483c..afaf92bdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ changes. ### Changed - Exclude network total stake and info from network metrics [Issue 3189](https://github.com/IntersectMBO/govtool/issues/3189) +- Change restriction level for re-voting on governance actions [Issue 3191](https://github.com/IntersectMBO/govtool/issues/3191) ### Removed diff --git a/govtool/backend/sql/get-votes.sql b/govtool/backend/sql/get-votes.sql index 31aaba85f..132a8fe66 100644 --- a/govtool/backend/sql/get-votes.sql +++ b/govtool/backend/sql/get-votes.sql @@ -1,16 +1,21 @@ -select DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) voting_procedure.gov_action_proposal_id, concat(encode(gov_action_tx.hash,'hex'),'#',gov_action_proposal.index), encode(drep_hash.raw, 'hex'), voting_procedure.vote::text, voting_anchor.url, encode(voting_anchor.data_hash, 'hex'), block.epoch_no as epoch_no, block.time as time, encode(vote_tx.hash, 'hex') as vote_tx_hash -from voting_procedure -join gov_action_proposal -on gov_action_proposal.id = voting_procedure.gov_action_proposal_id -join drep_hash -on drep_hash.id = voting_procedure.drep_voter -left join voting_anchor -on voting_anchor.id = voting_procedure.voting_anchor_id -join tx as gov_action_tx -on gov_action_tx.id = gov_action_proposal.tx_id -join tx as vote_tx -on vote_tx.id = voting_procedure.tx_id -join block -on block.id = vote_tx.block_id -where drep_hash.raw = decode(?, 'hex') -order by voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id desc +SELECT DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter) + voting_procedure.gov_action_proposal_id, + CONCAT(encode(gov_action_tx.hash,'hex'),'#',gov_action_proposal.index), + encode(drep_hash.raw, 'hex'), + LOWER(voting_procedure.vote::text), + voting_anchor.url, + encode(voting_anchor.data_hash, 'hex'), + block.epoch_no AS epoch_no, + block.time AS time, + encode(vote_tx.hash, 'hex') AS vote_tx_hash +FROM voting_procedure +JOIN gov_action_proposal +ON gov_action_proposal.id = voting_procedure.gov_action_proposal_id +JOIN drep_hash +ON drep_hash.id = voting_procedure.drep_voter +LEFT JOIN voting_anchor ON voting_anchor.id = voting_procedure.voting_anchor_id +JOIN tx AS gov_action_tx ON gov_action_tx.id = gov_action_proposal.tx_id +JOIN tx AS vote_tx ON vote_tx.id = voting_procedure.tx_id +JOIN block ON block.id = vote_tx.block_id +WHERE drep_hash.raw = decode(?, 'hex') +ORDER BY voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id DESC diff --git a/govtool/frontend/src/components/molecules/VoteActionForm.tsx b/govtool/frontend/src/components/molecules/VoteActionForm.tsx index 93f433a6c..ca72961a5 100644 --- a/govtool/frontend/src/components/molecules/VoteActionForm.tsx +++ b/govtool/frontend/src/components/molecules/VoteActionForm.tsx @@ -45,7 +45,6 @@ export const VoteActionForm = ({ const { areFormErrors, confirmVote, - isDirty, isVoteLoading, registerInput, setValue, @@ -350,7 +349,11 @@ export const VoteActionForm = ({ data-testid="vote-button" variant="contained" disabled={ - !vote || previousVote?.vote === vote || (areFormErrors && isDirty) + !vote || + areFormErrors || + (previousVote?.vote === vote && + (previousVote.metadataHash === voteContextHash || + !voteContextHash)) } isLoading={isVoteLoading} onClick={confirmVote} diff --git a/govtool/frontend/src/components/organisms/VoteContext/VoteContextText.tsx b/govtool/frontend/src/components/organisms/VoteContext/VoteContextText.tsx index 066e9a5ad..3f40d7622 100644 --- a/govtool/frontend/src/components/organisms/VoteContext/VoteContextText.tsx +++ b/govtool/frontend/src/components/organisms/VoteContext/VoteContextText.tsx @@ -22,7 +22,6 @@ export const VoteContextText = ({ const isContinueDisabled = !watch("voteContextText"); const fieldProps = { - key: "voteContextText", layoutStyles: { mb: 3 }, name: "voteContextText", placeholder: t("govActions.provideContext"), @@ -70,6 +69,7 @@ export const VoteContextText = ({ { const response = await axios.get(url); - const voteContextText = - response.data.body["CIP108:voteContextText"]["@value"]; - - return voteContextText; + return response.data.body?.body?.comment ?? ""; }; From 7174e63f3fba52b041157b465bb9e07ad74ab5eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Mon, 17 Mar 2025 11:10:49 +0100 Subject: [PATCH 2/3] fix(#3203): Fix wrong CIP-129 script based DRep prefix --- CHANGELOG.md | 1 + govtool/frontend/src/components/organisms/DRepCard.tsx | 2 +- govtool/frontend/src/components/organisms/DRepDetailsCard.tsx | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afaf92bdb..ce6a54583 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ changes. - hotfix for ada handle and payment address validation order [Issue 3155](https://github.com/IntersectMBO/govtool/issues/3155) - fix proposal list performance by pre-filtering active proposals [Issue 3190](https://github.com/IntersectMBO/govtool/issues/3190) +- Fix wrong prefix of script based dreps in CIP-129 standard [Issue 3203](https://github.com/IntersectMBO/govtool/issues/3203) ### Changed diff --git a/govtool/frontend/src/components/organisms/DRepCard.tsx b/govtool/frontend/src/components/organisms/DRepCard.tsx index c3c4c6a23..bd74a5b11 100644 --- a/govtool/frontend/src/components/organisms/DRepCard.tsx +++ b/govtool/frontend/src/components/organisms/DRepCard.tsx @@ -62,7 +62,7 @@ export const DRepCard = ({ const cip129Identifier = encodeCIP129Identifier({ txID: `${isScriptBased ? "23" : "22"}${drepId}`, - bech32Prefix: isScriptBased ? "drep_script" : "drep", + bech32Prefix: "drep", }); const base64Image = getBase64ImageDetails(image ?? ""); diff --git a/govtool/frontend/src/components/organisms/DRepDetailsCard.tsx b/govtool/frontend/src/components/organisms/DRepDetailsCard.tsx index 98a830623..0a0798d60 100644 --- a/govtool/frontend/src/components/organisms/DRepDetailsCard.tsx +++ b/govtool/frontend/src/components/organisms/DRepDetailsCard.tsx @@ -117,7 +117,7 @@ export const DRepDetailsCard = ({ From e88b8bd77a125a05e2cb73d6482282c920c562c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Mon, 17 Mar 2025 11:35:35 +0100 Subject: [PATCH 3/3] feat: add voter info to pdf pillar --- govtool/frontend/src/pages/ProposalDiscussion.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/govtool/frontend/src/pages/ProposalDiscussion.tsx b/govtool/frontend/src/pages/ProposalDiscussion.tsx index 67ed9b667..bc98f170d 100644 --- a/govtool/frontend/src/pages/ProposalDiscussion.tsx +++ b/govtool/frontend/src/pages/ProposalDiscussion.tsx @@ -5,6 +5,7 @@ import { useCardano, useGovernanceActions } from "@/context"; import { useValidateMutation } from "@/hooks/mutations"; import { useScreenDimension } from "@/hooks/useScreenDimension"; import { Footer, TopNav } from "@/components/organisms"; +import { useGetVoterInfo } from "@/hooks"; const ProposalDiscussion = React.lazy( () => import("@intersect.mbo/pdf-ui/cjs"), @@ -14,6 +15,7 @@ export const ProposalDiscussionPillar = () => { const { pagePadding } = useScreenDimension(); const { validateMetadata } = useValidateMutation(); const { walletApi, ...context } = useCardano(); + const { voter } = useGetVoterInfo(); const { createGovernanceActionJsonLD, createHash } = useGovernanceActions(); return ( @@ -55,6 +57,7 @@ export const ProposalDiscussionPillar = () => { ...walletApi, createGovernanceActionJsonLD, createHash, + voter, }} pathname={window.location.pathname} validateMetadata={