Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit d6d0b92

Browse files
authored
Governance: Voter-weight-addin cleanup (#2512)
* chore: Ensure voter-weight-addin is built for tests fix: build addin during test run fix: build voter weight addin for tests using the addin only chore: use mutex to build addin only once chore: move build guard to separate file chore: update governance version for chat * chore: create tools crate for common utility functions in governance ecosystem * chore: add test-sdk and tools readme * chore: rename reserved addins to specific names * chore: remove todo comment * chore: remove unnecessary var drop * chore: move all account tools to shared crate * chore: fix chat compilation * chore: move program_id to first position
1 parent f95e390 commit d6d0b92

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+317
-236
lines changed

Cargo.lock

Lines changed: 23 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ members = [
1313
"governance/voter-weight-addin/program",
1414
"governance/program",
1515
"governance/test-sdk",
16+
"governance/tools",
1617
"governance/chat/program",
1718
"libraries/math",
1819
"memo/program",

governance/chat/program/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ serde = "1.0.127"
2121
serde_derive = "1.0.103"
2222
solana-program = "1.8.0"
2323
spl-token = { version = "3.2", path = "../../../token/program", features = [ "no-entrypoint" ] }
24-
spl-governance= { version = "2.1.0", path ="../../program", features = [ "no-entrypoint" ]}
24+
spl-governance= { version = "2.1.2", path ="../../program", features = [ "no-entrypoint" ]}
25+
spl-governance-tools= { version = "0.1.0", path ="../../tools"}
2526
thiserror = "1.0"
2627

2728

governance/chat/program/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ pub mod error;
66
pub mod instruction;
77
pub mod processor;
88
pub mod state;
9-
pub mod tools;
109

1110
// Export current sdk types for downstream users building with a different sdk version
1211
pub use solana_program;

governance/chat/program/src/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::{
44
error::GovernanceChatError,
55
instruction::GovernanceChatInstruction,
66
state::{assert_is_valid_chat_message, ChatMessage, GovernanceChatAccountType, MessageBody},
7-
tools::account::create_and_serialize_account,
87
};
98
use borsh::BorshDeserialize;
109

@@ -21,6 +20,7 @@ use spl_governance::state::{
2120
governance::get_governance_data, proposal::get_proposal_data_for_governance,
2221
token_owner_record::get_token_owner_record_data_for_realm,
2322
};
23+
use spl_governance_tools::account::create_and_serialize_account;
2424

2525
/// Processes an instruction
2626
pub fn process_instruction(

governance/chat/program/src/state.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
44
use solana_program::{
55
account_info::AccountInfo, clock::UnixTimestamp, program_error::ProgramError, pubkey::Pubkey,
66
};
7-
use spl_governance::tools::account::{assert_is_valid_account, AccountMaxSize};
7+
8+
use spl_governance_tools::account::{assert_is_valid_account, AccountMaxSize};
89

910
/// Defines all GovernanceChat accounts types
1011
#[repr(C)]

governance/chat/program/src/tools/account.rs

Lines changed: 0 additions & 62 deletions
This file was deleted.

governance/chat/program/src/tools/mod.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

governance/program/Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "spl-governance"
3-
version = "2.1.1"
3+
version = "2.1.2"
44
description = "Solana Program Library Governance Program"
55
authors = ["Solana Maintainers <[email protected]>"]
66
repository = "https://github.com/solana-labs/solana-program-library"
@@ -21,17 +21,18 @@ serde = "1.0.130"
2121
serde_derive = "1.0.103"
2222
solana-program = "1.8.0"
2323
spl-token = { version = "3.2", path = "../../token/program", features = [ "no-entrypoint" ] }
24+
spl-governance-tools= { version = "0.1.0", path ="../tools"}
2425
thiserror = "1.0"
2526

2627
[dev-dependencies]
2728
assert_matches = "1.5.0"
2829
base64 = "0.13"
30+
lazy_static = "1.4.0"
2931
proptest = "1.0"
3032
solana-program-test = "1.8.0"
3133
solana-sdk = "1.8.0"
3234
spl-governance-test-sdk = { version = "0.1.0", path ="../test-sdk"}
3335
spl-governance-v1 = {package="spl-governance", version = "1.1.1", features = [ "no-entrypoint" ] }
3436

35-
3637
[lib]
3738
crate-type = ["cdylib", "lib"]

governance/program/src/addins/voter_weight.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@ use solana_program::{
99
pubkey::Pubkey,
1010
sysvar::Sysvar,
1111
};
12+
use spl_governance_tools::account::{get_account_data, AccountMaxSize};
1213

13-
use crate::{
14-
error::GovernanceError,
15-
state::token_owner_record::TokenOwnerRecord,
16-
tools::account::{get_account_data, AccountMaxSize},
17-
};
14+
use crate::{error::GovernanceError, state::token_owner_record::TokenOwnerRecord};
1815

1916
/// VoterWeight account type
2017
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
@@ -82,7 +79,7 @@ pub fn get_voter_weight_record_data(
8279
program_id: &Pubkey,
8380
voter_weight_record_info: &AccountInfo,
8481
) -> Result<VoterWeightRecord, ProgramError> {
85-
get_account_data::<VoterWeightRecord>(voter_weight_record_info, program_id)
82+
get_account_data::<VoterWeightRecord>(program_id, voter_weight_record_info)
8683
}
8784

8885
/// Deserializes VoterWeightRecord account, checks owner program and asserts it's for the same realm, mint and token owner as the provided TokenOwnerRecord

0 commit comments

Comments
 (0)