Skip to content

Commit

Permalink
fix veto vote release (#2435)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xShuk authored Sep 2, 2024
1 parent f409a65 commit e44944d
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions pages/dao/[symbol]/proposal/components/MyProposalsBtn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import useRealm from '@hooks/useRealm'
import { useCallback, useEffect, useMemo, useState } from 'react'
import {
getProposalDepositsByDepositPayer,
getVoteRecord,
getVoteRecordAddress,
ProgramAccount,
Proposal,
Expand Down Expand Up @@ -236,7 +237,7 @@ const MyProposalsBn = () => {
instructions,
proposal: ProgramAccount<Proposal>
) => {
const voterTokenRecord =
let voterTokenRecord =
proposal.account.governingTokenMint.toBase58() ===
realm?.account.communityMint.toBase58()
? ownTokenRecord
Expand All @@ -248,12 +249,32 @@ const MyProposalsBn = () => {
const governanceAuthority = wallet!.publicKey!
const beneficiary = wallet!.publicKey!

const voteRecordPk = await getVoteRecordAddress(
let voteRecordPk = await getVoteRecordAddress(
realm!.owner,
proposal.pubkey,
voterTokenRecord!.pubkey
)

let governingTokenMint = proposal.account.governingTokenMint

try {
await getVoteRecord(connection, voteRecordPk)
} catch {
voterTokenRecord = role === "community" ?
ownCouncilTokenRecord :
ownTokenRecord

voteRecordPk = await getVoteRecordAddress(
realm!.owner,
proposal.pubkey,
voterTokenRecord!.pubkey
)

governingTokenMint = role === "community" && realm?.account.config.councilMint ?
realm.account.config.councilMint :
realm?.account.communityMint!
}

const inst = await withRelinquishVote(
instructions,
realm!.owner,
Expand All @@ -262,7 +283,7 @@ const MyProposalsBn = () => {
proposal.account.governance,
proposal.pubkey,
voterTokenRecord!.pubkey,
proposal.account.governingTokenMint,
governingTokenMint,
voteRecordPk,
governanceAuthority,
beneficiary
Expand Down

0 comments on commit e44944d

Please sign in to comment.