Skip to content

Commit 546fb2f

Browse files
committed
fix(#3191): fix re-voting with a different rationale
1 parent 4cef738 commit 546fb2f

File tree

5 files changed

+29
-23
lines changed

5 files changed

+29
-23
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ changes.
2222
### Changed
2323

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

2627
### Removed
2728

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/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/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)