@@ -7,7 +7,11 @@ use crate::error::NftVoterError;
7
7
8
8
/// Casts NFT vote. The NFTs used for voting are tracked using NftVoteRecord accounts
9
9
/// This instruction updates VoterWeightRecord which is valid for the current Slot and the target Proposal only
10
- /// and hance the instruction has to be executed inside the same transaction as spl-gov CastVote
10
+ /// and hance the instruction has to be executed inside the same transaction as spl-gov.CastVote
11
+ ///
12
+ /// CastNftVote instruction and NftVoteRecord are not directional. They don't record vote choice (ex Yes/No)
13
+ /// VoteChoice is recorded by spl-gov in VoteRecord and this CastNftVote only tracks voting NFTs
14
+ ///
11
15
#[ derive( Accounts ) ]
12
16
#[ instruction( proposal: Pubkey ) ]
13
17
pub struct CastNftVote < ' info > {
@@ -21,14 +25,13 @@ pub struct CastNftVote<'info> {
21
25
22
26
constraint = voter_weight_record. governing_token_mint == registrar. governing_token_mint
23
27
@ NftVoterError :: InvalidVoterWeightRecordMint ,
24
-
25
- constraint = voter_weight_record. governing_token_owner == governing_token_owner. key( )
26
- @ NftVoterError :: InvalidVoterWeightRecordOwner ,
27
28
) ]
28
29
pub voter_weight_record : Account < ' info , VoterWeightRecord > ,
29
30
30
31
/// The token owner who casts the vote
31
- #[ account( mut ) ]
32
+ #[ account(
33
+ address = voter_weight_record. governing_token_owner @ NftVoterError :: InvalidTokenOwnerForVoterWeightRecord
34
+ ) ]
32
35
pub governing_token_owner : Signer < ' info > ,
33
36
34
37
/// The account which pays for the transaction
@@ -64,6 +67,8 @@ pub fn cast_nft_vote<'a,'b,'c,'info>(ctx: Context<'a,'b,'c,'info,CastNftVote<'in
64
67
voter_weight = voter_weight. checked_add ( nft_vote_weight as u64 ) . unwrap ( ) ;
65
68
66
69
// Create NFT vote record to ensure the same NFT hasn't been already used for voting
70
+ // Note: The correct PDA of the NftVoteRecord is validated in create_and_serialize_account_signed
71
+ // It ensures the NftVoteRecord is for ('nft-vote-record',proposal,nft_mint) seeds
67
72
require ! (
68
73
nft_vote_record_info. data_is_empty( ) ,
69
74
NftVoterError :: NftAlreadyVoted
0 commit comments