Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

voter weight wrapper for the new Governance addin API #1402

Merged
merged 1 commit into from Feb 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions spl/src/governance.rs
Expand Up @@ -4,15 +4,15 @@ macro_rules! vote_weight_record {
($id:expr) => {
/// Anchor wrapper for the SPL governance program's VoterWeightRecord type.
#[derive(Clone)]
pub struct VoterWeightRecord(spl_governance::addins::voter_weight::VoterWeightRecord);
pub struct VoterWeightRecord(spl_governance_addin_api::voter_weight::VoterWeightRecord);

impl anchor_lang::AccountDeserialize for VoterWeightRecord {
fn try_deserialize(buf: &mut &[u8]) -> std::result::Result<Self, ProgramError> {
let mut data = buf;
let vwr: spl_governance::addins::voter_weight::VoterWeightRecord =
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
anchor_lang::AnchorDeserialize::deserialize(&mut data)
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotDeserialize)?;
if vwr.account_type != spl_governance::addins::voter_weight::VoterWeightAccountType::VoterWeightRecord {
if !solana_program::program_pack::IsInitialized::is_initialized(&vwr) {
return Err(anchor_lang::__private::ErrorCode::AccountDidNotSerialize.into());
}
Ok(VoterWeightRecord(vwr))
Expand All @@ -22,7 +22,7 @@ macro_rules! vote_weight_record {
buf: &mut &[u8],
) -> std::result::Result<Self, ProgramError> {
let mut data = buf;
let vwr: spl_governance::addins::voter_weight::VoterWeightRecord =
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
anchor_lang::AnchorDeserialize::deserialize(&mut data)
.map_err(|_| anchor_lang::__private::ErrorCode::AccountDidNotDeserialize)?;
Ok(VoterWeightRecord(vwr))
Expand All @@ -47,7 +47,7 @@ macro_rules! vote_weight_record {
}

impl std::ops::Deref for VoterWeightRecord {
type Target = spl_governance::addins::voter_weight::VoterWeightRecord;
type Target = spl_governance_addin_api::voter_weight::VoterWeightRecord;

fn deref(&self) -> &Self::Target {
&self.0
Expand Down