diff --git a/programs/nft_voter/src/instructions/initialize_nft_voter_v0.rs b/programs/nft_voter/src/instructions/initialize_nft_voter_v0.rs index eaf913f..21dba3b 100644 --- a/programs/nft_voter/src/instructions/initialize_nft_voter_v0.rs +++ b/programs/nft_voter/src/instructions/initialize_nft_voter_v0.rs @@ -1,8 +1,9 @@ -use crate::state::*; use anchor_lang::prelude::*; use anchor_spl::token::Mint; use nft_proxy::state::ProxyConfigV0; +use crate::state::*; + #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct InitializeNftVoterArgsV0 { pub name: String, @@ -19,7 +20,7 @@ pub struct InitializeNftVoterV0<'info> { #[account( init, payer = payer, - space = 8 + 60 + std::mem::size_of::(), + space = 8 + 60 + std::mem::size_of::() + 4 + args.name.len(), seeds = [b"nft_voter", args.name.as_bytes()], bump )] diff --git a/programs/nft_voter/src/instructions/proxied_relinquish_vote_v0.rs b/programs/nft_voter/src/instructions/proxied_relinquish_vote_v0.rs index 3d3d90d..b92eea3 100644 --- a/programs/nft_voter/src/instructions/proxied_relinquish_vote_v0.rs +++ b/programs/nft_voter/src/instructions/proxied_relinquish_vote_v0.rs @@ -1,10 +1,11 @@ -use crate::{error::ErrorCode, metaplex::MetadataAccount, RelinquishVoteArgsV0}; use anchor_lang::prelude::*; use anchor_spl::token::Mint; use nft_proxy::state::ProxyAssignmentV0; use proposal::{ProposalConfigV0, ProposalV0}; -use crate::{nft_voter_seeds, state::*}; +use crate::{ + error::ErrorCode, metaplex::MetadataAccount, nft_voter_seeds, state::*, RelinquishVoteArgsV0, +}; #[derive(Accounts)] pub struct ProxiedRelinquishVoteV0<'info> { @@ -35,6 +36,7 @@ pub struct ProxiedRelinquishVoteV0<'info> { constraint = proxy_assignment.proxy_config == nft_voter.proxy_config, constraint = proxy_assignment.index <= marker.proxy_index, constraint = proxy_assignment.expiration_time > Clock::get().unwrap().unix_timestamp, + constraint = proxy_assignment.asset == mint.key(), )] pub proxy_assignment: Box>, #[account( diff --git a/programs/nft_voter/src/instructions/proxied_vote_v0.rs b/programs/nft_voter/src/instructions/proxied_vote_v0.rs index eda361b..0a60f38 100644 --- a/programs/nft_voter/src/instructions/proxied_vote_v0.rs +++ b/programs/nft_voter/src/instructions/proxied_vote_v0.rs @@ -1,10 +1,9 @@ -use crate::{error::ErrorCode, metaplex::MetadataAccount, VoteArgsV0}; use anchor_lang::prelude::*; use anchor_spl::token::Mint; use nft_proxy::state::ProxyAssignmentV0; use proposal::{ProposalConfigV0, ProposalV0}; -use crate::{nft_voter_seeds, state::*}; +use crate::{error::ErrorCode, metaplex::MetadataAccount, nft_voter_seeds, state::*, VoteArgsV0}; #[derive(Accounts)] pub struct ProxyVoteV0<'info> { @@ -13,7 +12,7 @@ pub struct ProxyVoteV0<'info> { #[account( init_if_needed, payer = payer, - space = 8 + 60 + std::mem::size_of::(), + space = 8 + 60 + std::mem::size_of::() + 2 * proposal.choices.len(), seeds = [b"marker", nft_voter.key().as_ref(), mint.key().as_ref(), proposal.key().as_ref()], bump )] @@ -24,6 +23,7 @@ pub struct ProxyVoteV0<'info> { // only the current or earlier delegates can change vote. Or if proposal not set, this was an `init` for the marker constraint = proxy_assignment.index <= marker.proxy_index || marker.proposal == Pubkey::default(), constraint = proxy_assignment.expiration_time > Clock::get().unwrap().unix_timestamp, + constraint = proxy_assignment.asset == mint.key(), )] pub proxy_assignment: Box>, pub nft_voter: Box>, diff --git a/programs/nft_voter/src/instructions/vote_v0.rs b/programs/nft_voter/src/instructions/vote_v0.rs index 13b5133..eb619c5 100644 --- a/programs/nft_voter/src/instructions/vote_v0.rs +++ b/programs/nft_voter/src/instructions/vote_v0.rs @@ -1,9 +1,8 @@ -use crate::{error::ErrorCode, metaplex::MetadataAccount}; use anchor_lang::prelude::*; use anchor_spl::token::{Mint, TokenAccount}; use proposal::{ProposalConfigV0, ProposalV0}; -use crate::{nft_voter_seeds, state::*}; +use crate::{error::ErrorCode, metaplex::MetadataAccount, nft_voter_seeds, state::*}; #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct VoteArgsV0 { @@ -17,7 +16,7 @@ pub struct VoteV0<'info> { #[account( init_if_needed, payer = payer, - space = 8 + 60 + std::mem::size_of::(), + space = 8 + 60 + std::mem::size_of::() + 2 * proposal.choices.len(), seeds = [b"marker", nft_voter.key().as_ref(), mint.key().as_ref(), proposal.key().as_ref()], bump )] diff --git a/programs/token_voter/src/instructions/initialize_token_voter_v0.rs b/programs/token_voter/src/instructions/initialize_token_voter_v0.rs index 0d752e9..7159cf6 100644 --- a/programs/token_voter/src/instructions/initialize_token_voter_v0.rs +++ b/programs/token_voter/src/instructions/initialize_token_voter_v0.rs @@ -1,11 +1,17 @@ -use crate::metaplex::{ - create_master_edition_v3, create_metadata_accounts_v3, CollectionDetails, CreateMasterEditionV3, - CreateMetadataAccountsV3, DataV2, Metadata, -}; -use crate::{state::*, token_voter_seeds}; use anchor_lang::prelude::*; -use anchor_spl::associated_token::AssociatedToken; -use anchor_spl::token::{self, Mint, MintTo, Token, TokenAccount}; +use anchor_spl::{ + associated_token::AssociatedToken, + token::{self, Mint, MintTo, Token, TokenAccount}, +}; + +use crate::{ + metaplex::{ + create_master_edition_v3, create_metadata_accounts_v3, CollectionDetails, + CreateMasterEditionV3, CreateMetadataAccountsV3, DataV2, Metadata, + }, + state::*, + token_voter_seeds, +}; #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct InitializeTokenVoterArgsV0 { @@ -23,7 +29,7 @@ pub struct InitializeTokenVoterV0<'info> { #[account( init, payer = payer, - space = 8 + 60 + std::mem::size_of::(), + space = 8 + 60 + std::mem::size_of::() + 4 + args.name.len(), seeds = [b"token_voter", args.name.as_bytes()], bump )] diff --git a/programs/token_voter/src/instructions/vote_v0.rs b/programs/token_voter/src/instructions/vote_v0.rs index c3ac8d9..b9c2b22 100644 --- a/programs/token_voter/src/instructions/vote_v0.rs +++ b/programs/token_voter/src/instructions/vote_v0.rs @@ -1,9 +1,8 @@ -use crate::error::ErrorCode; use anchor_lang::prelude::*; use anchor_spl::token::{Mint, TokenAccount}; use proposal::{ProposalConfigV0, ProposalV0}; -use crate::{state::*, token_voter_seeds}; +use crate::{error::ErrorCode, state::*, token_voter_seeds}; #[derive(AnchorSerialize, AnchorDeserialize, Clone, Default)] pub struct VoteArgsV0 { @@ -17,7 +16,7 @@ pub struct VoteV0<'info> { #[account( init_if_needed, payer = payer, - space = 8 + 60 + std::mem::size_of::(), + space = 8 + 60 + std::mem::size_of::() + 2 * proposal.choices.len(), seeds = [b"marker", token_voter.key().as_ref(), mint.key().as_ref(), proposal.key().as_ref()], bump )] diff --git a/programs/token_voter/src/instructions/withdraw_v0.rs b/programs/token_voter/src/instructions/withdraw_v0.rs index 1dc5cb3..f23d170 100644 --- a/programs/token_voter/src/instructions/withdraw_v0.rs +++ b/programs/token_voter/src/instructions/withdraw_v0.rs @@ -1,10 +1,14 @@ -use crate::metaplex::{burn, Burn, Metadata}; -use crate::receipt_seeds; -use crate::state::*; use anchor_lang::prelude::*; -use anchor_spl::associated_token::AssociatedToken; -use anchor_spl::token::{self, CloseAccount, Transfer}; -use anchor_spl::token::{Mint, Token, TokenAccount}; +use anchor_spl::{ + associated_token::AssociatedToken, + token::{self, CloseAccount, Mint, Token, TokenAccount, Transfer}, +}; + +use crate::{ + metaplex::{burn, Burn, Metadata}, + receipt_seeds, + state::*, +}; #[derive(Accounts)] pub struct WithdrawV0<'info> { @@ -62,7 +66,6 @@ pub struct WithdrawV0<'info> { #[account( mut, - close = refund, associated_token::authority = receipt, associated_token::mint = deposit_mint, )]