diff --git a/programs/voter-stake-registry/src/governance.rs b/programs/voter-stake-registry/src/governance.rs index a70922b..ef3c5ed 100644 --- a/programs/voter-stake-registry/src/governance.rs +++ b/programs/voter-stake-registry/src/governance.rs @@ -58,11 +58,11 @@ macro_rules! vote_weight_record { #[cfg(feature = "idl-build")] impl anchor_lang::IdlBuild for VoterWeightRecord {} - #[cfg(feature = "idl-build")] impl anchor_lang::Discriminator for VoterWeightRecord { const DISCRIMINATOR: [u8; 8] = [0; 8]; fn discriminator() -> [u8; 8] { - spl_governance_addin_api::voter_weight::VoterWeightRecord::ACCOUNT_DISCRIMINATOR + // legacy discriminator which is not compatible with Anchor but is used by older plugins + *b"2ef99b4b" } } }; diff --git a/programs/voter-stake-registry/src/instructions/create_voter.rs b/programs/voter-stake-registry/src/instructions/create_voter.rs index e586432..650b8ea 100644 --- a/programs/voter-stake-registry/src/instructions/create_voter.rs +++ b/programs/voter-stake-registry/src/instructions/create_voter.rs @@ -2,6 +2,7 @@ use crate::error::*; use crate::state::*; use anchor_lang::prelude::*; use anchor_lang::solana_program::sysvar::instructions as tx_instructions; +use anchor_lang::Discriminator; use std::mem::size_of; #[derive(Accounts)] @@ -82,8 +83,7 @@ pub fn create_voter( voter.registrar = ctx.accounts.registrar.key(); let voter_weight_record = &mut ctx.accounts.voter_weight_record; - voter_weight_record.account_discriminator = - spl_governance_addin_api::voter_weight::VoterWeightRecord::ACCOUNT_DISCRIMINATOR; + voter_weight_record.account_discriminator = VoterWeightRecord::discriminator(); voter_weight_record.realm = registrar.realm; voter_weight_record.governing_token_mint = registrar.realm_governing_token_mint; voter_weight_record.governing_token_owner = voter_authority; diff --git a/programs/voter-stake-registry/src/instructions/grant.rs b/programs/voter-stake-registry/src/instructions/grant.rs index d3fa4b8..3bae496 100644 --- a/programs/voter-stake-registry/src/instructions/grant.rs +++ b/programs/voter-stake-registry/src/instructions/grant.rs @@ -1,6 +1,7 @@ use crate::error::*; use crate::state::*; use anchor_lang::prelude::*; +use anchor_lang::Discriminator; use anchor_spl::associated_token::AssociatedToken; use anchor_spl::token::{self, Mint, Token, TokenAccount}; use std::convert::TryFrom; @@ -145,8 +146,7 @@ pub fn grant( // Note that vote_weight_record is not an Anchor account, is_freshly_initialized() // would not work. let voter_weight_record = &mut ctx.accounts.voter_weight_record; - voter_weight_record.account_discriminator = - spl_governance_addin_api::voter_weight::VoterWeightRecord::ACCOUNT_DISCRIMINATOR; + voter_weight_record.account_discriminator = VoterWeightRecord::discriminator(); voter_weight_record.realm = registrar.realm; voter_weight_record.governing_token_mint = registrar.realm_governing_token_mint; voter_weight_record.governing_token_owner = voter_authority; diff --git a/programs/voter-stake-registry/tests/test_grants.rs b/programs/voter-stake-registry/tests/test_grants.rs index 7085547..ebb5de1 100644 --- a/programs/voter-stake-registry/tests/test_grants.rs +++ b/programs/voter-stake-registry/tests/test_grants.rs @@ -126,12 +126,12 @@ async fn test_grants() -> Result<(), TransportError> { .get_account::(voter.address) .await; let deposit = &voter_data.deposits[1]; - assert_eq!(deposit.is_used, true.into()); + assert_eq!(deposit.is_used, true); let amount_deposited_native = deposit.amount_deposited_native; let amount_initially_locked_native = deposit.amount_initially_locked_native; assert_eq!(amount_deposited_native, 12000); assert_eq!(amount_initially_locked_native, 12000); - assert_eq!(deposit.allow_clawback, true.into()); + assert_eq!(deposit.allow_clawback, true); assert_eq!(deposit.lockup.kind, LockupKind::Monthly); assert_eq!(deposit.lockup.periods_total().unwrap(), 12);