Skip to content

Commit e563e24

Browse files
authored
Merge pull request #3202 from IntersectMBO/develop
fix(#3191): fix re-voting with a different rationale
2 parents 3033a1e + 67dcf21 commit e563e24

File tree

8 files changed

+35
-25
lines changed

8 files changed

+35
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ changes.
1818

1919
- hotfix for ada handle and payment address validation order [Issue 3155](https://github.com/IntersectMBO/govtool/issues/3155)
2020
- fix proposal list performance by pre-filtering active proposals [Issue 3190](https://github.com/IntersectMBO/govtool/issues/3190)
21+
- Fix wrong prefix of script based dreps in CIP-129 standard [Issue 3203](https://github.com/IntersectMBO/govtool/issues/3203)
2122

2223
### Changed
2324

2425
- Exclude network total stake and info from network metrics [Issue 3189](https://github.com/IntersectMBO/govtool/issues/3189)
26+
- Change restriction level for re-voting on governance actions [Issue 3191](https://github.com/IntersectMBO/govtool/issues/3191)
2527

2628
### Removed
2729

govtool/backend/sql/get-votes.sql

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
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
2-
from voting_procedure
3-
join gov_action_proposal
4-
on gov_action_proposal.id = voting_procedure.gov_action_proposal_id
5-
join drep_hash
6-
on drep_hash.id = voting_procedure.drep_voter
7-
left join voting_anchor
8-
on voting_anchor.id = voting_procedure.voting_anchor_id
9-
join tx as gov_action_tx
10-
on gov_action_tx.id = gov_action_proposal.tx_id
11-
join tx as vote_tx
12-
on vote_tx.id = voting_procedure.tx_id
13-
join block
14-
on block.id = vote_tx.block_id
15-
where drep_hash.raw = decode(?, 'hex')
16-
order by voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id desc
1+
SELECT DISTINCT ON (voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter)
2+
voting_procedure.gov_action_proposal_id,
3+
CONCAT(encode(gov_action_tx.hash,'hex'),'#',gov_action_proposal.index),
4+
encode(drep_hash.raw, 'hex'),
5+
LOWER(voting_procedure.vote::text),
6+
voting_anchor.url,
7+
encode(voting_anchor.data_hash, 'hex'),
8+
block.epoch_no AS epoch_no,
9+
block.time AS time,
10+
encode(vote_tx.hash, 'hex') AS vote_tx_hash
11+
FROM voting_procedure
12+
JOIN gov_action_proposal
13+
ON gov_action_proposal.id = voting_procedure.gov_action_proposal_id
14+
JOIN drep_hash
15+
ON drep_hash.id = voting_procedure.drep_voter
16+
LEFT JOIN voting_anchor ON voting_anchor.id = voting_procedure.voting_anchor_id
17+
JOIN tx AS gov_action_tx ON gov_action_tx.id = gov_action_proposal.tx_id
18+
JOIN tx AS vote_tx ON vote_tx.id = voting_procedure.tx_id
19+
JOIN block ON block.id = vote_tx.block_id
20+
WHERE drep_hash.raw = decode(?, 'hex')
21+
ORDER BY voting_procedure.gov_action_proposal_id, voting_procedure.drep_voter, voting_procedure.id DESC

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ export const VoteActionForm = ({
4545
const {
4646
areFormErrors,
4747
confirmVote,
48-
isDirty,
4948
isVoteLoading,
5049
registerInput,
5150
setValue,
@@ -350,7 +349,11 @@ export const VoteActionForm = ({
350349
data-testid="vote-button"
351350
variant="contained"
352351
disabled={
353-
!vote || previousVote?.vote === vote || (areFormErrors && isDirty)
352+
!vote ||
353+
areFormErrors ||
354+
(previousVote?.vote === vote &&
355+
(previousVote.metadataHash === voteContextHash ||
356+
!voteContextHash))
354357
}
355358
isLoading={isVoteLoading}
356359
onClick={confirmVote}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const DRepCard = ({
6262

6363
const cip129Identifier = encodeCIP129Identifier({
6464
txID: `${isScriptBased ? "23" : "22"}${drepId}`,
65-
bech32Prefix: isScriptBased ? "drep_script" : "drep",
65+
bech32Prefix: "drep",
6666
});
6767

6868
const base64Image = getBase64ImageDetails(image ?? "");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ export const DRepDetailsCard = ({
117117
<CopyableText
118118
value={encodeCIP129Identifier({
119119
txID: `${isScriptBased ? "23" : "22"}${drepId}`,
120-
bech32Prefix: isScriptBased ? "drep_script" : "drep",
120+
bech32Prefix: "drep",
121121
})}
122122
dataTestId="copy-cip-129-drep-id-button"
123123
/>

govtool/frontend/src/components/organisms/VoteContext/VoteContextText.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const VoteContextText = ({
2222
const isContinueDisabled = !watch("voteContextText");
2323

2424
const fieldProps = {
25-
key: "voteContextText",
2625
layoutStyles: { mb: 3 },
2726
name: "voteContextText",
2827
placeholder: t("govActions.provideContext"),
@@ -70,6 +69,7 @@ export const VoteContextText = ({
7069
<ControlledField.TextArea
7170
{...{ control, errors }}
7271
{...fieldProps}
72+
key="voteContextText"
7373
isModifiedLayout
7474
maxLength={MAX_LENGTH}
7575
data-testid="provide-context-input"

govtool/frontend/src/pages/ProposalDiscussion.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useCardano, useGovernanceActions } from "@/context";
55
import { useValidateMutation } from "@/hooks/mutations";
66
import { useScreenDimension } from "@/hooks/useScreenDimension";
77
import { Footer, TopNav } from "@/components/organisms";
8+
import { useGetVoterInfo } from "@/hooks";
89

910
const ProposalDiscussion = React.lazy(
1011
() => import("@intersect.mbo/pdf-ui/cjs"),
@@ -14,6 +15,7 @@ export const ProposalDiscussionPillar = () => {
1415
const { pagePadding } = useScreenDimension();
1516
const { validateMetadata } = useValidateMutation();
1617
const { walletApi, ...context } = useCardano();
18+
const { voter } = useGetVoterInfo();
1719
const { createGovernanceActionJsonLD, createHash } = useGovernanceActions();
1820

1921
return (
@@ -55,6 +57,7 @@ export const ProposalDiscussionPillar = () => {
5557
...walletApi,
5658
createGovernanceActionJsonLD,
5759
createHash,
60+
voter,
5861
}}
5962
pathname={window.location.pathname}
6063
validateMetadata={

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@ export const getVoteContextTextFromFile = async (url: string | undefined) => {
77

88
const response = await axios.get(url);
99

10-
const voteContextText =
11-
response.data.body["CIP108:voteContextText"]["@value"];
12-
13-
return voteContextText;
10+
return response.data.body?.body?.comment ?? "";
1411
};

0 commit comments

Comments
 (0)