@@ -50,9 +50,9 @@ import {
5050} from '@hooks/queries/proposal'
5151import queryClient from '@hooks/queries/queryClient'
5252import { getFeeEstimate } from '@tools/feeEstimate'
53- import { createComputeBudgetIx } from '@blockworks-foundation/mango-v4 '
54- import { useVotingClients } from "@hooks/useVotingClients" ;
55- import { useNftClient } from "../../../../../VoterWeightPlugins/useNftClient" ;
53+ import { useVotingClients } from '@hooks/useVotingClients '
54+ import { useNftClient } from '../../../../../VoterWeightPlugins/useNftClient'
55+ import { useSelectedDelegatorStore } from 'stores/useSelectedDelegatorStore'
5656
5757const MyProposalsBn = ( ) => {
5858 const [ modalIsOpen , setModalIsOpen ] = useState ( false )
@@ -61,10 +61,16 @@ const MyProposalsBn = () => {
6161 const [ isLoading , setIsLoading ] = useState ( false )
6262 const { governancesArray } = useGovernanceAssets ( )
6363 const { connection } = useConnection ( )
64- const myVoteRecords = useVoteRecordsByOwnerQuery (
65- wallet ?. publicKey ?? undefined
66- ) . data
6764
65+ const { communityDelegator } = useSelectedDelegatorStore ( )
66+
67+ const user = communityDelegator ?? wallet ?. publicKey ?? undefined
68+
69+ const myVoteRecords = useVoteRecordsByOwnerQuery ( user ) . data
70+
71+ console . log ( 'myVoteRecords' , myVoteRecords )
72+
73+ const realm = useRealmQuery ( ) . data ?. result
6874 const ownVoteRecordsByProposal = useMemo ( ( ) => {
6975 return myVoteRecords !== undefined
7076 ? ( Object . fromEntries (
@@ -79,14 +85,13 @@ const MyProposalsBn = () => {
7985 const { data : tokenOwnerRecord } = useAddressQuery_CommunityTokenOwner ( )
8086
8187 const maxVoterWeight = useMaxVoteRecord ( ) ?. pubkey || undefined
82- const realm = useRealmQuery ( ) . data ?. result
8388 const programId = realm ?. owner
8489
8590 const programVersion =
8691 useProgramVersion ( ) ?? DEFAULT_GOVERNANCE_PROGRAM_VERSION
8792
88- const votingClients = useVotingClients ( ) ;
89- const { nftClient } = useNftClient ( ) ;
93+ const votingClients = useVotingClients ( )
94+ const { nftClient } = useNftClient ( )
9095
9196 const [
9297 proposalsWithDepositedTokens ,
@@ -97,6 +102,7 @@ const MyProposalsBn = () => {
97102
98103 const { realmInfo, isNftMode } = useRealm ( )
99104 const { data : proposals } = useRealmProposalsQuery ( )
105+
100106 const myProposals = useMemo (
101107 ( ) =>
102108 connected
@@ -115,9 +121,11 @@ const MyProposalsBn = () => {
115121 ownCouncilTokenRecord ?. pubkey ,
116122 ]
117123 )
124+
118125 const drafts = myProposals ?. filter ( ( x ) => {
119126 return x . account . state === ProposalState . Draft
120127 } )
128+
121129 const notfinalized = myProposals ?. filter ( ( x ) => {
122130 const governance = governancesArray ?. find (
123131 ( gov ) => gov . pubkey . toBase58 ( ) === x . account . governance . toBase58 ( )
@@ -138,6 +146,7 @@ const MyProposalsBn = () => {
138146 now > timestamp
139147 )
140148 } )
149+
141150 const unReleased = proposals ?. filter (
142151 ( x ) =>
143152 ( x . account . state === ProposalState . Completed ||
@@ -183,14 +192,16 @@ const MyProposalsBn = () => {
183192 recentBlockhash,
184193 feePayer : wallet . publicKey ! ,
185194 } )
186- transaction . add ( ...[ createComputeBudgetIx ( fee ) , ...chunk ] )
187195 transaction . recentBlockhash = recentBlockhash
188196 transaction . setSigners (
189197 // fee payed by the wallet owner
190198 wallet . publicKey !
191199 )
192200 transactions . push ( transaction )
193201 }
202+
203+ console . log ( 'transactions' , transactions )
204+
194205 const signedTXs = await wallet . signAllTransactions ( transactions )
195206 await Promise . all (
196207 signedTXs . map ( ( transaction ) =>
@@ -242,10 +253,11 @@ const MyProposalsBn = () => {
242253 realm ?. account . communityMint . toBase58 ( )
243254 ? ownTokenRecord
244255 : ownCouncilTokenRecord
245- const role = proposal . account . governingTokenMint . toBase58 ( ) ===
256+ const role =
257+ proposal . account . governingTokenMint . toBase58 ( ) ===
246258 realm ?. account . communityMint . toBase58 ( )
247- ? 'community'
248- : 'council'
259+ ? 'community'
260+ : 'council'
249261 const governanceAuthority = wallet ! . publicKey !
250262 const beneficiary = wallet ! . publicKey !
251263
@@ -254,27 +266,29 @@ const MyProposalsBn = () => {
254266 proposal . pubkey ,
255267 voterTokenRecord ! . pubkey
256268 )
257-
269+
258270 let governingTokenMint = proposal . account . governingTokenMint
259271
260272 try {
261273 await getVoteRecord ( connection , voteRecordPk )
262274 } catch {
263- voterTokenRecord = role === "community" ?
264- ownCouncilTokenRecord :
265- ownTokenRecord
275+ voterTokenRecord =
276+ role === 'community' ? ownCouncilTokenRecord : ownTokenRecord
266277
267278 voteRecordPk = await getVoteRecordAddress (
268279 realm ! . owner ,
269280 proposal . pubkey ,
270281 voterTokenRecord ! . pubkey
271282 )
272283
273- governingTokenMint = role === "community" && realm ?. account . config . councilMint ?
274- realm . account . config . councilMint :
275- realm ?. account . communityMint !
284+ governingTokenMint =
285+ role === 'community' && realm ?. account . config . councilMint
286+ ? realm . account . config . councilMint
287+ : realm ?. account . communityMint !
276288 }
277-
289+
290+ console . log ( 'THE INSTRUCTIONS' , instructions )
291+
278292 const inst = await withRelinquishVote (
279293 instructions ,
280294 realm ! . owner ,
@@ -333,8 +347,15 @@ const MyProposalsBn = () => {
333347
334348 setIsLoading ( true )
335349 const instructions : TransactionInstruction [ ] = [ ]
336- const { registrar } = nftClient . getRegistrarPDA ( realm . pubkey , realm . account . communityMint ) ;
337- const { voterWeightPk } = await nftClient . getVoterWeightRecordPDA ( realm . pubkey , realm . account . communityMint , wallet . publicKey ) ;
350+ const { registrar } = nftClient . getRegistrarPDA (
351+ realm . pubkey ,
352+ realm . account . communityMint
353+ )
354+ const { voterWeightPk } = await nftClient . getVoterWeightRecordPDA (
355+ realm . pubkey ,
356+ realm . account . communityMint ,
357+ wallet . publicKey
358+ )
338359
339360 const nfts = ownNftVoteRecordsFilterd . slice (
340361 0 ,
@@ -387,7 +408,7 @@ const MyProposalsBn = () => {
387408 }
388409
389410 const getNftsVoteRecord = useCallback ( async ( ) => {
390- if ( ! nftClient ) throw new Error ( 'no nft client' ) ;
411+ if ( ! nftClient ) throw new Error ( 'no nft client' )
391412 const nftVoteRecords = await nftClient . program . account . nftVoteRecord . all ( [
392413 {
393414 memcmp : {
@@ -473,13 +494,7 @@ const MyProposalsBn = () => {
473494 if ( wallet ?. publicKey && isNftMode && nftClient && modalIsOpen ) {
474495 getNftsVoteRecord ( )
475496 }
476- } , [
477- nftClient ,
478- getNftsVoteRecord ,
479- isNftMode ,
480- modalIsOpen ,
481- wallet ?. publicKey ,
482- ] )
497+ } , [ nftClient , getNftsVoteRecord , isNftMode , modalIsOpen , wallet ?. publicKey ] )
483498
484499 return (
485500 < >
0 commit comments