Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Governance: voter-weight-addin cleanup #2512

Merged
merged 9 commits into from
Oct 19, 2021
Prev Previous commit
chore: move program_id to first position
  • Loading branch information
SebastianBor committed Oct 18, 2021
commit 3e88f142a17b0bad4fcf9fc06cec8deda839957a
2 changes: 1 addition & 1 deletion governance/program/src/addins/voter_weight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn get_voter_weight_record_data(
program_id: &Pubkey,
voter_weight_record_info: &AccountInfo,
) -> Result<VoterWeightRecord, ProgramError> {
get_account_data::<VoterWeightRecord>(voter_weight_record_info, program_id)
get_account_data::<VoterWeightRecord>(program_id, voter_weight_record_info)
}

/// Deserializes VoterWeightRecord account, checks owner program and asserts it's for the same realm, mint and token owner as the provided TokenOwnerRecord
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub fn get_governance_data(
program_id: &Pubkey,
governance_info: &AccountInfo,
) -> Result<Governance, ProgramError> {
get_account_data::<Governance>(governance_info, program_id)
get_account_data::<Governance>(program_id, governance_info)
}

/// Deserializes Governance account, checks owner program and asserts governance belongs to the given ream
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ pub fn get_proposal_data(
program_id: &Pubkey,
proposal_info: &AccountInfo,
) -> Result<Proposal, ProgramError> {
get_account_data::<Proposal>(proposal_info, program_id)
get_account_data::<Proposal>(program_id, proposal_info)
}

/// Deserializes Proposal and validates it belongs to the given Governance and Governing Mint
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/proposal_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pub fn get_proposal_instruction_data(
program_id: &Pubkey,
proposal_instruction_info: &AccountInfo,
) -> Result<ProposalInstruction, ProgramError> {
get_account_data::<ProposalInstruction>(proposal_instruction_info, program_id)
get_account_data::<ProposalInstruction>(program_id, proposal_instruction_info)
}

/// Deserializes and returns ProposalInstruction account and checks it belongs to the given Proposal
Expand Down
4 changes: 2 additions & 2 deletions governance/program/src/state/realm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub fn get_realm_data(
program_id: &Pubkey,
realm_info: &AccountInfo,
) -> Result<Realm, ProgramError> {
get_account_data::<Realm>(realm_info, program_id)
get_account_data::<Realm>(program_id, realm_info)
}

/// Deserializes account and checks the given authority is Realm's authority
Expand All @@ -164,7 +164,7 @@ pub fn get_realm_data_for_authority(
realm_info: &AccountInfo,
realm_authority: &Pubkey,
) -> Result<Realm, ProgramError> {
let realm_data = get_account_data::<Realm>(realm_info, program_id)?;
let realm_data = get_account_data::<Realm>(program_id, realm_info)?;

if realm_data.authority.is_none() {
return Err(GovernanceError::RealmHasNoAuthority.into());
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/realm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn get_realm_config_data(
program_id: &Pubkey,
realm_config_info: &AccountInfo,
) -> Result<RealmConfigAccount, ProgramError> {
get_account_data::<RealmConfigAccount>(realm_config_info, program_id)
get_account_data::<RealmConfigAccount>(program_id, realm_config_info)
}

/// Deserializes RealmConfig account and checks the owner program and the Realm it belongs to
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/signatory_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn get_signatory_record_data(
program_id: &Pubkey,
signatory_record_info: &AccountInfo,
) -> Result<SignatoryRecord, ProgramError> {
get_account_data::<SignatoryRecord>(signatory_record_info, program_id)
get_account_data::<SignatoryRecord>(program_id, signatory_record_info)
}

/// Deserializes SignatoryRecord and validates its PDA
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/token_owner_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub fn get_token_owner_record_data(
program_id: &Pubkey,
token_owner_record_info: &AccountInfo,
) -> Result<TokenOwnerRecord, ProgramError> {
get_account_data::<TokenOwnerRecord>(token_owner_record_info, program_id)
get_account_data::<TokenOwnerRecord>(program_id, token_owner_record_info)
}

/// Deserializes TokenOwnerRecord account and checks its PDA against the provided seeds
Expand Down
2 changes: 1 addition & 1 deletion governance/program/src/state/vote_record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub fn get_vote_record_data(
program_id: &Pubkey,
vote_record_info: &AccountInfo,
) -> Result<VoteRecord, ProgramError> {
get_account_data::<VoteRecord>(vote_record_info, program_id)
get_account_data::<VoteRecord>(program_id, vote_record_info)
}

/// Deserializes VoteRecord and checks it belongs to the provided Proposal and Governing Token Owner
Expand Down
2 changes: 1 addition & 1 deletion governance/tools/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ pub fn create_and_serialize_account_signed<'a, T: BorshSerialize + AccountMaxSiz

/// Deserializes account and checks it's initialized and owned by the specified program
pub fn get_account_data<T: BorshDeserialize + IsInitialized>(
account_info: &AccountInfo,
owner_program_id: &Pubkey,
account_info: &AccountInfo,
) -> Result<T, ProgramError> {
if account_info.data_is_empty() {
return Err(GovernanceToolsError::AccountDoesNotExist.into());
Expand Down